aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--CODE_OWNERS.txt10
-rw-r--r--INSTALL.txt5
-rw-r--r--cmake/LLDBDependencies.cmake166
-rw-r--r--cmake/modules/AddLLDB.cmake58
-rw-r--r--cmake/modules/LLDBConfig.cmake53
-rw-r--r--cmake/modules/LLDBStandalone.cmake1
-rw-r--r--cmake/platforms/Android.cmake11
-rw-r--r--docs/lldb-gdb-remote.txt2
-rwxr-xr-xexamples/python/crashlog.py6
-rwxr-xr-xexamples/python/gdbremote.py53
-rw-r--r--include/lldb/API/SBAttachInfo.h4
-rw-r--r--include/lldb/API/SBBreakpoint.h12
-rw-r--r--include/lldb/API/SBBreakpointLocation.h3
-rw-r--r--include/lldb/API/SBFrame.h4
-rw-r--r--include/lldb/API/SBListener.h2
-rw-r--r--include/lldb/API/SBTarget.h8
-rw-r--r--include/lldb/API/SBWatchpoint.h2
-rw-r--r--include/lldb/Breakpoint/Breakpoint.h2
-rw-r--r--include/lldb/Breakpoint/BreakpointLocation.h2
-rw-r--r--include/lldb/Breakpoint/BreakpointOptions.h4
-rw-r--r--include/lldb/Breakpoint/BreakpointResolver.h7
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileLine.h2
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileRegex.h2
-rw-r--r--include/lldb/Breakpoint/BreakpointSite.h2
-rw-r--r--include/lldb/Breakpoint/Stoppoint.h2
-rw-r--r--include/lldb/Breakpoint/StoppointLocation.h2
-rw-r--r--include/lldb/Breakpoint/Watchpoint.h2
-rw-r--r--include/lldb/Breakpoint/WatchpointOptions.h4
-rw-r--r--include/lldb/Core/Address.h43
-rw-r--r--include/lldb/Core/AddressRange.h18
-rw-r--r--include/lldb/Core/AddressResolver.h20
-rw-r--r--include/lldb/Core/AddressResolverFileLine.h16
-rw-r--r--include/lldb/Core/AddressResolverName.h17
-rw-r--r--include/lldb/Core/ArchSpec.h26
-rw-r--r--include/lldb/Core/Broadcaster.h36
-rw-r--r--include/lldb/Core/Communication.h30
-rw-r--r--include/lldb/Core/Connection.h21
-rw-r--r--include/lldb/Core/DataBufferMemoryMap.h154
-rw-r--r--include/lldb/Core/Debugger.h64
-rw-r--r--include/lldb/Core/Disassembler.h64
-rw-r--r--include/lldb/Core/DumpDataExtractor.h95
-rw-r--r--include/lldb/Core/EmulateInstruction.h31
-rw-r--r--include/lldb/Core/Event.h27
-rw-r--r--include/lldb/Core/FileLineResolver.h14
-rw-r--r--include/lldb/Core/FileSpecList.h10
-rw-r--r--include/lldb/Core/FormatEntity.h35
-rw-r--r--include/lldb/Core/IOHandler.h29
-rw-r--r--include/lldb/Core/Listener.h28
-rw-r--r--include/lldb/Core/Log.h189
-rw-r--r--include/lldb/Core/Mangled.h15
-rw-r--r--include/lldb/Core/MappedHash.h6
-rw-r--r--include/lldb/Core/Module.h87
-rw-r--r--include/lldb/Core/ModuleChild.h2
-rw-r--r--include/lldb/Core/ModuleList.h63
-rw-r--r--include/lldb/Core/ModuleSpec.h6
-rw-r--r--include/lldb/Core/Opcode.h21
-rw-r--r--include/lldb/Core/PluginManager.h43
-rw-r--r--include/lldb/Core/RangeMap.h63
-rw-r--r--include/lldb/Core/RegisterValue.h26
-rw-r--r--include/lldb/Core/Scalar.h15
-rw-r--r--include/lldb/Core/SearchFilter.h41
-rw-r--r--include/lldb/Core/Section.h41
-rw-r--r--include/lldb/Core/SourceManager.h25
-rw-r--r--include/lldb/Core/State.h21
-rw-r--r--include/lldb/Core/StreamAsynchronousIO.h11
-rw-r--r--include/lldb/Core/StreamBuffer.h2
-rw-r--r--include/lldb/Core/StreamFile.h15
-rw-r--r--include/lldb/Core/StructuredData.h40
-rw-r--r--include/lldb/Core/Timer.h16
-rw-r--r--include/lldb/Core/UniqueCStringMap.h4
-rw-r--r--include/lldb/Core/UserSettingsController.h33
-rw-r--r--include/lldb/Core/Value.h40
-rw-r--r--include/lldb/Core/ValueObject.h84
-rw-r--r--include/lldb/Core/ValueObjectCast.h15
-rw-r--r--include/lldb/Core/ValueObjectChild.h14
-rw-r--r--include/lldb/Core/ValueObjectConstResult.h26
-rw-r--r--include/lldb/Core/ValueObjectConstResultCast.h22
-rw-r--r--include/lldb/Core/ValueObjectConstResultChild.h24
-rw-r--r--include/lldb/Core/ValueObjectConstResultImpl.h25
-rw-r--r--include/lldb/Core/ValueObjectDynamicValue.h25
-rw-r--r--include/lldb/Core/ValueObjectList.h15
-rw-r--r--include/lldb/Core/ValueObjectMemory.h17
-rw-r--r--include/lldb/Core/ValueObjectRegister.h30
-rw-r--r--include/lldb/Core/ValueObjectSyntheticFilter.h26
-rw-r--r--include/lldb/Core/ValueObjectVariable.h30
-rw-r--r--include/lldb/DataFormatters/DataVisualization.h2
-rw-r--r--include/lldb/DataFormatters/DumpValueObjectOptions.h5
-rw-r--r--include/lldb/DataFormatters/FormatCache.h2
-rw-r--r--include/lldb/DataFormatters/FormattersContainer.h2
-rw-r--r--include/lldb/DataFormatters/StringPrinter.h2
-rw-r--r--include/lldb/DataFormatters/TypeSummary.h2
-rw-r--r--include/lldb/DataFormatters/ValueObjectPrinter.h3
-rw-r--r--include/lldb/DataFormatters/VectorIterator.h2
-rw-r--r--include/lldb/Expression/DWARFExpression.h4
-rw-r--r--include/lldb/Expression/ExpressionParser.h2
-rw-r--r--include/lldb/Expression/ExpressionVariable.h2
-rw-r--r--include/lldb/Expression/IRExecutionUnit.h2
-rw-r--r--include/lldb/Expression/IRInterpreter.h4
-rw-r--r--include/lldb/Expression/IRMemoryMap.h4
-rw-r--r--include/lldb/Expression/Materializer.h2
-rw-r--r--include/lldb/Host/Config.h39
-rw-r--r--include/lldb/Host/Config.h.cmake19
-rw-r--r--include/lldb/Host/Editline.h5
-rw-r--r--include/lldb/Host/File.h13
-rw-r--r--include/lldb/Host/FileCache.h5
-rw-r--r--include/lldb/Host/FileSystem.h36
-rw-r--r--include/lldb/Host/Host.h18
-rw-r--r--include/lldb/Host/HostInfo.h3
-rw-r--r--include/lldb/Host/HostInfoBase.h35
-rw-r--r--include/lldb/Host/HostNativeProcessBase.h2
-rw-r--r--include/lldb/Host/HostNativeThread.h8
-rw-r--r--include/lldb/Host/HostNativeThreadBase.h2
-rw-r--r--include/lldb/Host/HostNativeThreadForward.h12
-rw-r--r--include/lldb/Host/HostThread.h2
-rw-r--r--include/lldb/Host/LockFileBase.h2
-rw-r--r--include/lldb/Host/MainLoopBase.h2
-rw-r--r--include/lldb/Host/PipeBase.h2
-rw-r--r--include/lldb/Host/PseudoTerminal.h (renamed from include/lldb/Utility/PseudoTerminal.h)6
-rw-r--r--include/lldb/Host/Socket.h5
-rw-r--r--include/lldb/Host/SocketAddress.h16
-rw-r--r--include/lldb/Host/Symbols.h6
-rw-r--r--include/lldb/Host/ThisThread.h37
-rw-r--r--include/lldb/Host/ThreadLauncher.h2
-rw-r--r--include/lldb/Host/XML.h2
-rw-r--r--include/lldb/Host/android/Config.h28
-rw-r--r--include/lldb/Host/common/NativeBreakpointList.h10
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h37
-rw-r--r--include/lldb/Host/common/NativeRegisterContext.h5
-rw-r--r--include/lldb/Host/common/NativeThreadProtocol.h7
-rw-r--r--include/lldb/Host/common/NativeWatchpointList.h2
-rw-r--r--include/lldb/Host/common/UDPSocket.h4
-rw-r--r--include/lldb/Host/freebsd/Config.h28
-rw-r--r--include/lldb/Host/freebsd/HostInfoFreeBSD.h3
-rw-r--r--include/lldb/Host/freebsd/HostThreadFreeBSD.h29
-rw-r--r--include/lldb/Host/linux/Config.h28
-rw-r--r--include/lldb/Host/linux/HostInfoLinux.h3
-rw-r--r--include/lldb/Host/linux/HostThreadLinux.h30
-rw-r--r--include/lldb/Host/linux/Support.h27
-rw-r--r--include/lldb/Host/macosx/Config.h28
-rw-r--r--include/lldb/Host/macosx/HostInfoMacOSX.h3
-rw-r--r--include/lldb/Host/mingw/Config.h30
-rw-r--r--include/lldb/Host/msvc/Config.h39
-rw-r--r--include/lldb/Host/netbsd/Config.h28
-rw-r--r--include/lldb/Host/netbsd/HostInfoNetBSD.h3
-rw-r--r--include/lldb/Host/netbsd/HostThreadNetBSD.h30
-rw-r--r--include/lldb/Host/openbsd/HostInfoOpenBSD.h27
-rw-r--r--include/lldb/Host/posix/HostInfoPosix.h2
-rw-r--r--include/lldb/Host/posix/HostProcessPosix.h2
-rw-r--r--include/lldb/Host/posix/ProcessLauncherPosixFork.h (renamed from include/lldb/Host/linux/ProcessLauncherLinux.h)12
-rw-r--r--include/lldb/Host/windows/HostInfoWindows.h2
-rw-r--r--include/lldb/Host/windows/PosixApi.h2
-rw-r--r--include/lldb/Interpreter/Args.h14
-rw-r--r--include/lldb/Interpreter/CommandCompletions.h12
-rw-r--r--include/lldb/Interpreter/CommandHistory.h2
-rw-r--r--include/lldb/Interpreter/CommandInterpreter.h4
-rw-r--r--include/lldb/Interpreter/CommandObject.h5
-rw-r--r--include/lldb/Interpreter/CommandObjectRegexCommand.h2
-rw-r--r--include/lldb/Interpreter/CommandReturnObject.h4
-rw-r--r--include/lldb/Interpreter/OptionGroupPlatform.h2
-rw-r--r--include/lldb/Interpreter/OptionValue.h6
-rw-r--r--include/lldb/Interpreter/OptionValueEnumeration.h13
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpec.h2
-rw-r--r--include/lldb/Interpreter/OptionValueProperties.h2
-rw-r--r--include/lldb/Interpreter/OptionValueRegex.h2
-rw-r--r--include/lldb/Interpreter/OptionValueString.h3
-rw-r--r--include/lldb/Interpreter/OptionValueUUID.h2
-rw-r--r--include/lldb/Interpreter/Property.h13
-rw-r--r--include/lldb/Interpreter/ScriptInterpreter.h4
-rw-r--r--include/lldb/Symbol/ArmUnwindInfo.h2
-rw-r--r--include/lldb/Symbol/Block.h5
-rw-r--r--include/lldb/Symbol/ClangASTContext.h2
-rw-r--r--include/lldb/Symbol/CompactUnwindInfo.h2
-rw-r--r--include/lldb/Symbol/CompileUnit.h4
-rw-r--r--include/lldb/Symbol/CompilerDecl.h2
-rw-r--r--include/lldb/Symbol/CompilerDeclContext.h2
-rw-r--r--include/lldb/Symbol/CompilerType.h2
-rw-r--r--include/lldb/Symbol/DWARFCallFrameInfo.h6
-rw-r--r--include/lldb/Symbol/DebugMacros.h2
-rw-r--r--include/lldb/Symbol/DeclVendor.h1
-rw-r--r--include/lldb/Symbol/Declaration.h2
-rw-r--r--include/lldb/Symbol/Function.h2
-rw-r--r--include/lldb/Symbol/GoASTContext.h2
-rw-r--r--include/lldb/Symbol/JavaASTContext.h2
-rw-r--r--include/lldb/Symbol/LineEntry.h2
-rw-r--r--include/lldb/Symbol/OCamlASTContext.h2
-rw-r--r--include/lldb/Symbol/ObjectContainer.h6
-rw-r--r--include/lldb/Symbol/ObjectFile.h60
-rw-r--r--include/lldb/Symbol/Symbol.h2
-rw-r--r--include/lldb/Symbol/Type.h5
-rw-r--r--include/lldb/Symbol/UnwindPlan.h4
-rw-r--r--include/lldb/Symbol/Variable.h2
-rw-r--r--include/lldb/Target/ABI.h2
-rw-r--r--include/lldb/Target/DynamicLoader.h38
-rw-r--r--include/lldb/Target/FileAction.h2
-rw-r--r--include/lldb/Target/Memory.h28
-rw-r--r--include/lldb/Target/MemoryRegionInfo.h23
-rw-r--r--include/lldb/Target/ModuleCache.h (renamed from source/Utility/ModuleCache.h)10
-rw-r--r--include/lldb/Target/PathMappingList.h4
-rw-r--r--include/lldb/Target/Platform.h4
-rw-r--r--include/lldb/Target/Process.h18
-rw-r--r--include/lldb/Target/ProcessInfo.h2
-rw-r--r--include/lldb/Target/ProcessLaunchInfo.h7
-rw-r--r--include/lldb/Target/ProcessStructReader.h (renamed from include/lldb/Utility/ProcessStructReader.h)13
-rw-r--r--include/lldb/Target/QueueItem.h2
-rw-r--r--include/lldb/Target/QueueList.h2
-rw-r--r--include/lldb/Target/RegisterCheckpoint.h2
-rw-r--r--include/lldb/Target/RegisterNumber.h (renamed from include/lldb/Utility/RegisterNumber.h)4
-rw-r--r--include/lldb/Target/StackFrame.h9
-rw-r--r--include/lldb/Target/SystemRuntime.h2
-rw-r--r--include/lldb/Target/Thread.h14
-rw-r--r--include/lldb/Target/ThreadList.h2
-rw-r--r--include/lldb/Target/ThreadPlan.h26
-rw-r--r--include/lldb/Target/ThreadPlanPython.h2
-rw-r--r--include/lldb/Target/UnixSignals.h23
-rw-r--r--include/lldb/Utility/Baton.h (renamed from include/lldb/Core/Baton.h)11
-rw-r--r--include/lldb/Utility/ConstString.h (renamed from include/lldb/Core/ConstString.h)23
-rw-r--r--include/lldb/Utility/ConvertEnum.h21
-rw-r--r--include/lldb/Utility/DataBuffer.h (renamed from include/lldb/Core/DataBuffer.h)0
-rw-r--r--include/lldb/Utility/DataBufferHeap.h (renamed from include/lldb/Core/DataBufferHeap.h)11
-rw-r--r--include/lldb/Utility/DataBufferLLVM.h52
-rw-r--r--include/lldb/Utility/DataEncoder.h (renamed from include/lldb/Core/DataEncoder.h)12
-rw-r--r--include/lldb/Utility/DataExtractor.h (renamed from include/lldb/Core/DataExtractor.h)141
-rw-r--r--include/lldb/Utility/Endian.h (renamed from include/lldb/Host/Endian.h)6
-rw-r--r--include/lldb/Utility/Error.h (renamed from include/lldb/Core/Error.h)66
-rw-r--r--include/lldb/Utility/FastDemangle.h (renamed from include/lldb/Core/FastDemangle.h)0
-rw-r--r--include/lldb/Utility/FileSpec.h (renamed from include/lldb/Host/FileSpec.h)231
-rw-r--r--include/lldb/Utility/Flags.h (renamed from include/lldb/Core/Flags.h)6
-rw-r--r--include/lldb/Utility/History.h (renamed from include/lldb/Core/History.h)12
-rw-r--r--include/lldb/Utility/JSON.h9
-rw-r--r--include/lldb/Utility/LLDBAssert.h5
-rw-r--r--include/lldb/Utility/Log.h218
-rw-r--r--include/lldb/Utility/Logging.h (renamed from include/lldb/Core/Logging.h)26
-rw-r--r--include/lldb/Utility/NameMatches.h14
-rw-r--r--include/lldb/Utility/PriorityPointerPair.h86
-rw-r--r--include/lldb/Utility/Range.h1
-rw-r--r--include/lldb/Utility/RegularExpression.h (renamed from include/lldb/Core/RegularExpression.h)7
-rw-r--r--include/lldb/Utility/SelectHelper.h9
-rw-r--r--include/lldb/Utility/SharingPtr.h3
-rw-r--r--include/lldb/Utility/Stream.h (renamed from include/lldb/Core/Stream.h)46
-rw-r--r--include/lldb/Utility/StreamCallback.h (renamed from include/lldb/Core/StreamCallback.h)23
-rw-r--r--include/lldb/Utility/StreamGDBRemote.h (renamed from include/lldb/Core/StreamGDBRemote.h)13
-rw-r--r--include/lldb/Utility/StreamString.h (renamed from include/lldb/Core/StreamString.h)9
-rw-r--r--include/lldb/Utility/StreamTee.h (renamed from include/lldb/Core/StreamTee.h)2
-rw-r--r--include/lldb/Utility/StringExtractor.h9
-rw-r--r--include/lldb/Utility/StringLexer.h6
-rw-r--r--include/lldb/Utility/StringList.h (renamed from include/lldb/Core/StringList.h)22
-rw-r--r--include/lldb/Utility/TaskPool.h29
-rw-r--r--include/lldb/Utility/TildeExpressionResolver.h65
-rw-r--r--include/lldb/Utility/Timeout.h18
-rw-r--r--include/lldb/Utility/UUID.h (renamed from include/lldb/Core/UUID.h)16
-rw-r--r--include/lldb/Utility/UriParser.h (renamed from source/Utility/UriParser.h)8
-rw-r--r--include/lldb/Utility/UserID.h (renamed from include/lldb/Core/UserID.h)6
-rw-r--r--include/lldb/Utility/Utils.h22
-rw-r--r--include/lldb/Utility/VASPrintf.h21
-rw-r--r--include/lldb/Utility/VMRange.h (renamed from include/lldb/Core/VMRange.h)9
-rw-r--r--include/lldb/lldb-forward.h2
-rw-r--r--include/lldb/lldb-private-enumerations.h37
-rw-r--r--include/lldb/lldb-private-interfaces.h3
-rw-r--r--lit/lit.cfg18
-rw-r--r--lit/lit.site.cfg.in2
-rw-r--r--lldb.xcodeproj/project.pbxproj472
-rw-r--r--packages/Python/lldbsuite/test/README-TestSuite7
-rw-r--r--packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py2
-rw-r--r--packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp6
-rw-r--r--packages/Python/lldbsuite/test/configuration.py10
-rw-r--r--packages/Python/lldbsuite/test/dosep.py2
-rw-r--r--packages/Python/lldbsuite/test/dotest.py270
-rw-r--r--packages/Python/lldbsuite/test/dotest_args.py9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py114
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp51
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py63
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py120
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/darwin_log/.categories1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py53
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py52
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py23
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py33
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py45
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py68
-rw-r--r--packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py87
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other.h7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py67
-rw-r--r--packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py22
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.corebin0 -> 24576 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.outbin0 -> 3576 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.corebin0 -> 28672 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.outbin0 -> 2792 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.corebin0 -> 28672 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.outbin0 -> 2872 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py16
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile3
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py67
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c25
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/Makefile2
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile4
-rw-r--r--packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py5
-rw-r--r--packages/Python/lldbsuite/test/lldbinline.py8
-rw-r--r--packages/Python/lldbsuite/test/lldbplatformutil.py12
-rw-r--r--packages/Python/lldbsuite/test/lldbtest.py65
-rw-r--r--packages/Python/lldbsuite/test/macosx/queues/TestQueues.py2
-rw-r--r--packages/Python/lldbsuite/test/make/Android.rules91
-rw-r--r--packages/Python/lldbsuite/test/make/Makefile.rules81
-rw-r--r--packages/Python/lldbsuite/test/make/pseudo_barrier.h20
-rw-r--r--packages/Python/lldbsuite/test/make/test_common.h39
-rw-r--r--packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py26
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py66
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp54
-rw-r--r--packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py20
-rw-r--r--packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py3
-rw-r--r--packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py16
-rw-r--r--packages/Python/lldbsuite/test/sample_test/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py10
-rw-r--r--packages/Python/lldbsuite/test/sample_test/TestSampleTest.py74
-rw-r--r--packages/Python/lldbsuite/test/sample_test/main.c13
-rw-r--r--packages/Python/lldbsuite/test/test_categories.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py9
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py44
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py14
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py68
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp33
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py6
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/.clang-format1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py (renamed from packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py)0
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py119
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py60
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp630
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp50
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/main.cpp639
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp7
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py115
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp37
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile (renamed from packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile)4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py41
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp22
-rw-r--r--packages/Python/lldbsuite/test_event/formatter/results_formatter.py31
-rw-r--r--packages/Python/lldbsuite/test_event/formatter/xunit.py2
-rw-r--r--scripts/Python/finishSwigPythonLLDB.py4
-rwxr-xr-xscripts/Xcode/build-llvm.py57
-rw-r--r--scripts/Xcode/repo.py42
-rw-r--r--scripts/Xcode/repos/FALLBACK19
-rw-r--r--scripts/Xcode/repos/svn-trunk.json19
-rw-r--r--scripts/analyze-project-deps.py206
-rw-r--r--scripts/finishSwigWrapperClasses.py9
-rw-r--r--scripts/interface/SBFrame.i8
-rw-r--r--scripts/interface/SBThread.i14
-rw-r--r--scripts/utilsArgsParse.py4
-rw-r--r--source/API/CMakeLists.txt18
-rw-r--r--source/API/SBAddress.cpp4
-rw-r--r--source/API/SBBlock.cpp2
-rw-r--r--source/API/SBBreakpoint.cpp450
-rw-r--r--source/API/SBBreakpointLocation.cpp206
-rw-r--r--source/API/SBBroadcaster.cpp22
-rw-r--r--source/API/SBCommandReturnObject.cpp5
-rw-r--r--source/API/SBCommunication.cpp2
-rw-r--r--source/API/SBCompileUnit.cpp2
-rw-r--r--source/API/SBData.cpp15
-rw-r--r--source/API/SBDebugger.cpp16
-rw-r--r--source/API/SBDeclaration.cpp8
-rw-r--r--source/API/SBError.cpp4
-rw-r--r--source/API/SBEvent.cpp14
-rw-r--r--source/API/SBFileSpec.cpp7
-rw-r--r--source/API/SBFileSpecList.cpp7
-rw-r--r--source/API/SBFrame.cpp25
-rw-r--r--source/API/SBFunction.cpp2
-rw-r--r--source/API/SBHostOS.cpp4
-rw-r--r--source/API/SBInstruction.cpp4
-rw-r--r--source/API/SBInstructionList.cpp2
-rw-r--r--source/API/SBLineEntry.cpp5
-rw-r--r--source/API/SBListener.cpp6
-rw-r--r--source/API/SBMemoryRegionInfo.cpp2
-rw-r--r--source/API/SBMemoryRegionInfoList.cpp4
-rw-r--r--source/API/SBModule.cpp4
-rw-r--r--source/API/SBModuleSpec.cpp2
-rw-r--r--source/API/SBPlatform.cpp6
-rw-r--r--source/API/SBProcess.cpp4
-rw-r--r--source/API/SBQueue.cpp2
-rw-r--r--source/API/SBQueueItem.cpp2
-rw-r--r--source/API/SBSection.cpp13
-rw-r--r--source/API/SBSourceManager.cpp2
-rw-r--r--source/API/SBStream.cpp6
-rw-r--r--source/API/SBStringList.cpp2
-rw-r--r--source/API/SBStructuredData.cpp4
-rw-r--r--source/API/SBSymbol.cpp2
-rw-r--r--source/API/SBSymbolContext.cpp2
-rw-r--r--source/API/SBTarget.cpp50
-rw-r--r--source/API/SBThread.cpp6
-rw-r--r--source/API/SBThreadPlan.cpp3
-rw-r--r--source/API/SBType.cpp6
-rw-r--r--source/API/SBTypeEnumMember.cpp6
-rw-r--r--source/API/SBUnixSignals.cpp2
-rw-r--r--source/API/SBValue.cpp6
-rw-r--r--source/API/SBValueList.cpp2
-rw-r--r--source/API/SBWatchpoint.cpp28
-rw-r--r--source/API/SystemInitializerFull.cpp3
-rw-r--r--source/Breakpoint/Breakpoint.cpp7
-rw-r--r--source/Breakpoint/BreakpointID.cpp4
-rw-r--r--source/Breakpoint/BreakpointLocation.cpp4
-rw-r--r--source/Breakpoint/BreakpointOptions.cpp4
-rw-r--r--source/Breakpoint/BreakpointResolver.cpp6
-rw-r--r--source/Breakpoint/BreakpointResolverAddress.cpp4
-rw-r--r--source/Breakpoint/BreakpointResolverFileLine.cpp97
-rw-r--r--source/Breakpoint/BreakpointResolverFileRegex.cpp4
-rw-r--r--source/Breakpoint/BreakpointResolverName.cpp4
-rw-r--r--source/Breakpoint/BreakpointSite.cpp2
-rw-r--r--source/Breakpoint/BreakpointSiteList.cpp2
-rw-r--r--source/Breakpoint/CMakeLists.txt13
-rw-r--r--source/Breakpoint/Watchpoint.cpp2
-rw-r--r--source/Breakpoint/WatchpointOptions.cpp4
-rw-r--r--source/CMakeLists.txt21
-rw-r--r--source/Commands/CMakeLists.txt16
-rw-r--r--source/Commands/CommandCompletions.cpp305
-rw-r--r--source/Commands/CommandObjectArgs.cpp7
-rw-r--r--source/Commands/CommandObjectBreakpoint.cpp6
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.cpp1
-rw-r--r--source/Commands/CommandObjectCommands.cpp3
-rw-r--r--source/Commands/CommandObjectDisassemble.cpp2
-rw-r--r--source/Commands/CommandObjectExpression.cpp2
-rw-r--r--source/Commands/CommandObjectFrame.cpp13
-rw-r--r--source/Commands/CommandObjectHelp.h1
-rw-r--r--source/Commands/CommandObjectLog.cpp80
-rw-r--r--source/Commands/CommandObjectMemory.cpp42
-rw-r--r--source/Commands/CommandObjectPlatform.cpp33
-rw-r--r--source/Commands/CommandObjectProcess.cpp3
-rw-r--r--source/Commands/CommandObjectRegister.cpp3
-rw-r--r--source/Commands/CommandObjectSettings.cpp1
-rw-r--r--source/Commands/CommandObjectSource.cpp4
-rw-r--r--source/Commands/CommandObjectTarget.cpp42
-rw-r--r--source/Commands/CommandObjectThread.cpp1
-rw-r--r--source/Commands/CommandObjectType.cpp14
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp4
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.cpp1
-rw-r--r--source/Core/Address.cpp78
-rw-r--r--source/Core/AddressRange.cpp17
-rw-r--r--source/Core/AddressResolver.cpp13
-rw-r--r--source/Core/AddressResolverFileLine.cpp16
-rw-r--r--source/Core/AddressResolverName.cpp21
-rw-r--r--source/Core/ArchSpec.cpp43
-rw-r--r--source/Core/Baton.cpp22
-rw-r--r--source/Core/Broadcaster.cpp29
-rw-r--r--source/Core/CMakeLists.txt43
-rw-r--r--source/Core/Communication.cpp52
-rw-r--r--source/Core/Connection.cpp6
-rw-r--r--source/Core/DataBufferMemoryMap.cpp307
-rw-r--r--source/Core/Debugger.cpp165
-rw-r--r--source/Core/Disassembler.cpp61
-rw-r--r--source/Core/DumpDataExtractor.cpp824
-rw-r--r--source/Core/DynamicLoader.cpp28
-rw-r--r--source/Core/EmulateInstruction.cpp32
-rw-r--r--source/Core/Event.cpp27
-rw-r--r--source/Core/FileLineResolver.cpp11
-rw-r--r--source/Core/FileSpecList.cpp54
-rw-r--r--source/Core/FormatEntity.cpp65
-rw-r--r--source/Core/IOHandler.cpp41
-rw-r--r--source/Core/Listener.cpp23
-rw-r--r--source/Core/Log.cpp399
-rw-r--r--source/Core/Logging.cpp322
-rw-r--r--source/Core/Mangled.cpp76
-rw-r--r--source/Core/Module.cpp130
-rw-r--r--source/Core/ModuleList.cpp59
-rw-r--r--source/Core/Opcode.cpp20
-rw-r--r--source/Core/PluginManager.cpp151
-rw-r--r--source/Core/RegisterValue.cpp47
-rw-r--r--source/Core/Scalar.cpp23
-rw-r--r--source/Core/SearchFilter.cpp140
-rw-r--r--source/Core/Section.cpp106
-rw-r--r--source/Core/SourceManager.cpp43
-rw-r--r--source/Core/State.cpp6
-rw-r--r--source/Core/StreamAsynchronousIO.cpp2
-rw-r--r--source/Core/StreamCallback.cpp50
-rw-r--r--source/Core/StreamFile.cpp5
-rw-r--r--source/Core/StructuredData.cpp45
-rw-r--r--source/Core/Timer.cpp10
-rw-r--r--source/Core/UserSettingsController.cpp30
-rw-r--r--source/Core/Value.cpp27
-rw-r--r--source/Core/ValueObject.cpp74
-rw-r--r--source/Core/ValueObjectCast.cpp23
-rw-r--r--source/Core/ValueObjectChild.cpp21
-rw-r--r--source/Core/ValueObjectConstResult.cpp21
-rw-r--r--source/Core/ValueObjectConstResultCast.cpp13
-rw-r--r--source/Core/ValueObjectConstResultChild.cpp17
-rw-r--r--source/Core/ValueObjectConstResultImpl.cpp31
-rw-r--r--source/Core/ValueObjectDynamicValue.cpp29
-rw-r--r--source/Core/ValueObjectList.cpp14
-rw-r--r--source/Core/ValueObjectMemory.cpp27
-rw-r--r--source/Core/ValueObjectRegister.cpp23
-rw-r--r--source/Core/ValueObjectSyntheticFilter.cpp19
-rw-r--r--source/Core/ValueObjectVariable.cpp32
-rw-r--r--source/DataFormatters/CMakeLists.txt10
-rw-r--r--source/DataFormatters/CXXFunctionPointer.cpp2
-rw-r--r--source/DataFormatters/FormatManager.cpp58
-rw-r--r--source/DataFormatters/FormattersHelpers.cpp4
-rw-r--r--source/DataFormatters/StringPrinter.cpp2
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp2
-rw-r--r--source/DataFormatters/TypeFormat.cpp10
-rw-r--r--source/DataFormatters/TypeSummary.cpp2
-rw-r--r--source/DataFormatters/TypeSynthetic.cpp2
-rw-r--r--source/DataFormatters/TypeValidator.cpp2
-rw-r--r--source/DataFormatters/ValueObjectPrinter.cpp35
-rw-r--r--source/DataFormatters/VectorType.cpp10
-rw-r--r--source/Expression/CMakeLists.txt14
-rw-r--r--source/Expression/DWARFExpression.cpp10
-rw-r--r--source/Expression/DiagnosticManager.cpp4
-rw-r--r--source/Expression/ExpressionSourceCode.cpp2
-rw-r--r--source/Expression/ExpressionVariable.cpp2
-rw-r--r--source/Expression/FunctionCaller.cpp4
-rw-r--r--source/Expression/IRDynamicChecks.cpp4
-rw-r--r--source/Expression/IRExecutionUnit.cpp6
-rw-r--r--source/Expression/IRInterpreter.cpp12
-rw-r--r--source/Expression/IRMemoryMap.cpp8
-rw-r--r--source/Expression/LLVMUserExpression.cpp11
-rw-r--r--source/Expression/Materializer.cpp53
-rw-r--r--source/Expression/UserExpression.cpp6
-rw-r--r--source/Expression/UtilityFunction.cpp6
-rw-r--r--source/Host/CMakeLists.txt63
-rw-r--r--source/Host/common/Editline.cpp21
-rw-r--r--source/Host/common/File.cpp27
-rw-r--r--source/Host/common/FileSystem.cpp74
-rw-r--r--source/Host/common/Host.cpp156
-rw-r--r--source/Host/common/HostInfoBase.cpp92
-rw-r--r--source/Host/common/HostNativeThreadBase.cpp7
-rw-r--r--source/Host/common/MonitoringProcessLauncher.cpp17
-rw-r--r--source/Host/common/NativeBreakpoint.cpp4
-rw-r--r--source/Host/common/NativeBreakpointList.cpp2
-rw-r--r--source/Host/common/NativeProcessProtocol.cpp118
-rw-r--r--source/Host/common/NativeRegisterContext.cpp12
-rw-r--r--source/Host/common/NativeWatchpointList.cpp2
-rw-r--r--source/Host/common/PseudoTerminal.cpp (renamed from source/Utility/PseudoTerminal.cpp)5
-rw-r--r--source/Host/common/Socket.cpp26
-rw-r--r--source/Host/common/SocketAddress.cpp48
-rw-r--r--source/Host/common/SoftwareBreakpoint.cpp4
-rw-r--r--source/Host/common/Symbols.cpp21
-rw-r--r--source/Host/common/TCPSocket.cpp2
-rw-r--r--source/Host/common/ThisThread.cpp50
-rw-r--r--source/Host/common/ThreadLauncher.cpp3
-rw-r--r--source/Host/common/UDPSocket.cpp58
-rw-r--r--source/Host/freebsd/Host.cpp48
-rw-r--r--source/Host/freebsd/HostInfoFreeBSD.cpp3
-rw-r--r--source/Host/freebsd/HostThreadFreeBSD.cpp70
-rw-r--r--source/Host/freebsd/ThisThread.cpp35
-rw-r--r--source/Host/linux/Host.cpp405
-rw-r--r--source/Host/linux/HostInfoLinux.cpp14
-rw-r--r--source/Host/linux/HostThreadLinux.cpp45
-rw-r--r--source/Host/linux/ProcessLauncherLinux.cpp216
-rw-r--r--source/Host/linux/Support.cpp34
-rw-r--r--source/Host/linux/ThisThread.cpp25
-rw-r--r--source/Host/macosx/Host.mm53
-rw-r--r--source/Host/macosx/HostInfoMacOSX.mm7
-rw-r--r--source/Host/macosx/Symbols.cpp42
-rw-r--r--source/Host/macosx/ThisThread.cpp25
-rw-r--r--source/Host/netbsd/Host.cpp37
-rw-r--r--source/Host/netbsd/HostInfoNetBSD.cpp22
-rw-r--r--source/Host/netbsd/HostThreadNetBSD.cpp43
-rw-r--r--source/Host/netbsd/ThisThread.cpp26
-rw-r--r--source/Host/openbsd/Host.cpp225
-rw-r--r--source/Host/openbsd/HostInfoOpenBSD.cpp65
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp21
-rw-r--r--source/Host/posix/DomainSocket.cpp4
-rw-r--r--source/Host/posix/FileSystem.cpp191
-rw-r--r--source/Host/posix/HostInfoPosix.cpp2
-rw-r--r--source/Host/posix/HostThreadPosix.cpp2
-rw-r--r--source/Host/posix/MainLoopPosix.cpp4
-rw-r--r--source/Host/posix/PipePosix.cpp3
-rw-r--r--source/Host/posix/ProcessLauncherPosixFork.cpp231
-rw-r--r--source/Host/windows/ConnectionGenericFileWindows.cpp5
-rw-r--r--source/Host/windows/FileSystem.cpp165
-rw-r--r--source/Host/windows/Host.cpp16
-rw-r--r--source/Host/windows/HostInfoWindows.cpp6
-rw-r--r--source/Host/windows/HostProcessWindows.cpp2
-rw-r--r--source/Host/windows/HostThreadWindows.cpp2
-rw-r--r--source/Host/windows/ThisThread.cpp63
-rw-r--r--source/Host/windows/Windows.cpp32
-rw-r--r--source/Initialization/CMakeLists.txt28
-rw-r--r--source/Initialization/SystemInitializerCommon.cpp13
-rw-r--r--source/Interpreter/Args.cpp23
-rw-r--r--source/Interpreter/CMakeLists.txt11
-rw-r--r--source/Interpreter/CommandAlias.cpp2
-rw-r--r--source/Interpreter/CommandHistory.cpp1
-rw-r--r--source/Interpreter/CommandInterpreter.cpp21
-rw-r--r--source/Interpreter/CommandObject.cpp8
-rw-r--r--source/Interpreter/CommandReturnObject.cpp4
-rw-r--r--source/Interpreter/OptionGroupArchitecture.cpp2
-rw-r--r--source/Interpreter/OptionGroupBoolean.cpp1
-rw-r--r--source/Interpreter/OptionGroupFile.cpp1
-rw-r--r--source/Interpreter/OptionGroupFormat.cpp40
-rw-r--r--source/Interpreter/OptionGroupOutputFile.cpp2
-rw-r--r--source/Interpreter/OptionGroupPlatform.cpp2
-rw-r--r--source/Interpreter/OptionGroupString.cpp1
-rw-r--r--source/Interpreter/OptionGroupUInt64.cpp1
-rw-r--r--source/Interpreter/OptionGroupUUID.cpp2
-rw-r--r--source/Interpreter/OptionGroupValueObjectDisplay.cpp3
-rw-r--r--source/Interpreter/OptionGroupVariable.cpp4
-rw-r--r--source/Interpreter/OptionGroupWatchpoint.cpp2
-rw-r--r--source/Interpreter/OptionValue.cpp2
-rw-r--r--source/Interpreter/OptionValueArray.cpp2
-rw-r--r--source/Interpreter/OptionValueBoolean.cpp4
-rw-r--r--source/Interpreter/OptionValueChar.cpp4
-rw-r--r--source/Interpreter/OptionValueEnumeration.cpp2
-rw-r--r--source/Interpreter/OptionValueFileSpec.cpp7
-rw-r--r--source/Interpreter/OptionValueFileSpecLIst.cpp2
-rw-r--r--source/Interpreter/OptionValueFormat.cpp2
-rw-r--r--source/Interpreter/OptionValueFormatEntity.cpp4
-rw-r--r--source/Interpreter/OptionValueLanguage.cpp2
-rw-r--r--source/Interpreter/OptionValuePathMappings.cpp4
-rw-r--r--source/Interpreter/OptionValueProperties.cpp7
-rw-r--r--source/Interpreter/OptionValueRegex.cpp2
-rw-r--r--source/Interpreter/OptionValueSInt64.cpp2
-rw-r--r--source/Interpreter/OptionValueString.cpp3
-rw-r--r--source/Interpreter/OptionValueUInt64.cpp2
-rw-r--r--source/Interpreter/OptionValueUUID.cpp4
-rw-r--r--source/Interpreter/Options.cpp3
-rw-r--r--source/Interpreter/ScriptInterpreter.cpp8
-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.cpp200
-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.cpp268
-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.cpp667
-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.cpp266
-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.cpp1061
-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.cpp121
-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.cpp130
-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.cpp201
-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.cpp (renamed from source/Host/common/NativeRegisterContextRegisterInfo.cpp)2
-rw-r--r--source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h (renamed from include/lldb/Host/common/NativeRegisterContextRegisterInfo.h)11
-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.cpp212
-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
-rw-r--r--source/Symbol/ArmUnwindInfo.cpp2
-rw-r--r--source/Symbol/Block.cpp2
-rw-r--r--source/Symbol/CMakeLists.txt20
-rw-r--r--source/Symbol/ClangASTContext.cpp56
-rw-r--r--source/Symbol/ClangASTImporter.cpp2
-rw-r--r--source/Symbol/ClangExternalASTSourceCallbacks.cpp89
-rw-r--r--source/Symbol/ClangExternalASTSourceCommon.cpp2
-rw-r--r--source/Symbol/CompactUnwindInfo.cpp6
-rw-r--r--source/Symbol/CompilerType.cpp17
-rw-r--r--source/Symbol/DWARFCallFrameInfo.cpp160
-rw-r--r--source/Symbol/Declaration.cpp4
-rw-r--r--source/Symbol/FuncUnwinders.cpp20
-rw-r--r--source/Symbol/Function.cpp15
-rw-r--r--source/Symbol/GoASTContext.cpp14
-rw-r--r--source/Symbol/JavaASTContext.cpp12
-rw-r--r--source/Symbol/LineTable.cpp11
-rw-r--r--source/Symbol/OCamlASTContext.cpp9
-rw-r--r--source/Symbol/ObjectFile.cpp58
-rw-r--r--source/Symbol/Symbol.cpp2
-rw-r--r--source/Symbol/SymbolContext.cpp2
-rw-r--r--source/Symbol/SymbolFile.cpp4
-rw-r--r--source/Symbol/SymbolVendor.cpp2
-rw-r--r--source/Symbol/Symtab.cpp10
-rw-r--r--source/Symbol/Type.cpp6
-rw-r--r--source/Symbol/UnwindPlan.cpp4
-rw-r--r--source/Symbol/Variable.cpp4
-rw-r--r--source/Symbol/VariableList.cpp2
-rw-r--r--source/Target/CMakeLists.txt17
-rw-r--r--source/Target/FileAction.cpp2
-rw-r--r--source/Target/InstrumentationRuntime.cpp2
-rw-r--r--source/Target/Language.cpp12
-rw-r--r--source/Target/LanguageRuntime.cpp1
-rw-r--r--source/Target/Memory.cpp182
-rw-r--r--source/Target/ModuleCache.cpp (renamed from source/Utility/ModuleCache.cpp)37
-rw-r--r--source/Target/ObjCLanguageRuntime.cpp2
-rw-r--r--source/Target/PathMappingList.cpp6
-rw-r--r--source/Target/Platform.cpp116
-rw-r--r--source/Target/Process.cpp123
-rw-r--r--source/Target/ProcessInfo.cpp2
-rw-r--r--source/Target/ProcessLaunchInfo.cpp10
-rw-r--r--source/Target/RegisterContext.cpp4
-rw-r--r--source/Target/RegisterNumber.cpp (renamed from source/Utility/RegisterNumber.cpp)2
-rw-r--r--source/Target/SectionLoadHistory.cpp2
-rw-r--r--source/Target/SectionLoadList.cpp30
-rw-r--r--source/Target/StackFrame.cpp67
-rw-r--r--source/Target/StackFrameList.cpp2
-rw-r--r--source/Target/StackID.cpp2
-rw-r--r--source/Target/StopInfo.cpp22
-rw-r--r--source/Target/Target.cpp10
-rw-r--r--source/Target/TargetList.cpp33
-rw-r--r--source/Target/Thread.cpp73
-rw-r--r--source/Target/ThreadList.cpp15
-rw-r--r--source/Target/ThreadPlan.cpp12
-rw-r--r--source/Target/ThreadPlanBase.cpp4
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp9
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp4
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp4
-rw-r--r--source/Target/ThreadPlanPython.cpp2
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp4
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp6
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp6
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp13
-rw-r--r--source/Target/ThreadPlanStepOut.cpp2
-rw-r--r--source/Target/ThreadPlanStepOverBreakpoint.cpp4
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp4
-rw-r--r--source/Target/ThreadPlanStepRange.cpp14
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp4
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp4
-rw-r--r--source/Target/ThreadPlanTracer.cpp6
-rw-r--r--source/Target/UnixSignals.cpp39
-rw-r--r--source/Utility/ARM64_DWARF_Registers.cpp212
-rw-r--r--source/Utility/ARM64_DWARF_Registers.h4
-rw-r--r--source/Utility/ARM_DWARF_Registers.cpp925
-rw-r--r--source/Utility/ARM_DWARF_Registers.h5
-rw-r--r--source/Utility/Baton.cpp (renamed from tools/debugserver/source/MacOSX/HasAVX.h)22
-rw-r--r--source/Utility/CMakeLists.txt35
-rw-r--r--source/Utility/ConstString.cpp (renamed from source/Core/ConstString.cpp)31
-rw-r--r--source/Utility/ConvertEnum.cpp118
-rw-r--r--source/Utility/DataBufferHeap.cpp (renamed from source/Core/DataBufferHeap.cpp)2
-rw-r--r--source/Utility/DataBufferLLVM.cpp70
-rw-r--r--source/Utility/DataEncoder.cpp (renamed from source/Core/DataEncoder.cpp)17
-rw-r--r--source/Utility/DataExtractor.cpp (renamed from source/Core/DataExtractor.cpp)948
-rw-r--r--source/Utility/Error.cpp (renamed from source/Core/Error.cpp)130
-rw-r--r--source/Utility/FastDemangle.cpp (renamed from source/Core/FastDemangle.cpp)11
-rw-r--r--source/Utility/FileSpec.cpp (renamed from source/Host/common/FileSpec.cpp)729
-rw-r--r--source/Utility/History.cpp (renamed from source/Core/History.cpp)4
-rw-r--r--source/Utility/JSON.cpp26
-rw-r--r--source/Utility/LLDBAssert.cpp3
-rw-r--r--source/Utility/Log.cpp323
-rw-r--r--source/Utility/Logging.cpp74
-rw-r--r--source/Utility/NameMatches.cpp27
-rw-r--r--source/Utility/Range.cpp6
-rw-r--r--source/Utility/RegularExpression.cpp (renamed from source/Core/RegularExpression.cpp)22
-rw-r--r--source/Utility/SelectHelper.cpp23
-rw-r--r--source/Utility/Stream.cpp (renamed from source/Core/Stream.cpp)132
-rw-r--r--source/Utility/StreamCallback.cpp23
-rw-r--r--source/Utility/StreamGDBRemote.cpp (renamed from source/Core/StreamGDBRemote.cpp)6
-rw-r--r--source/Utility/StreamString.cpp (renamed from source/Core/StreamString.cpp)3
-rw-r--r--source/Utility/StringExtractor.cpp10
-rw-r--r--source/Utility/StringExtractorGDBRemote.cpp13
-rw-r--r--source/Utility/StringExtractorGDBRemote.h12
-rw-r--r--source/Utility/StringLexer.cpp3
-rw-r--r--source/Utility/StringList.cpp (renamed from source/Core/StringList.cpp)23
-rw-r--r--source/Utility/TaskPool.cpp4
-rw-r--r--source/Utility/TildeExpressionResolver.cpp95
-rw-r--r--source/Utility/UUID.cpp (renamed from source/Core/UUID.cpp)15
-rw-r--r--source/Utility/UriParser.cpp12
-rw-r--r--source/Utility/UserID.cpp (renamed from source/Core/UserID.cpp)4
-rw-r--r--source/Utility/VASprintf.cpp56
-rw-r--r--source/Utility/VMRange.cpp (renamed from source/Core/VMRange.cpp)12
-rw-r--r--test/CMakeLists.txt19
-rw-r--r--tools/CMakeLists.txt1
-rw-r--r--tools/argdumper/CMakeLists.txt11
-rw-r--r--tools/argdumper/argdumper.cpp2
-rw-r--r--tools/debugserver/debugserver.xcodeproj/project.pbxproj36
-rw-r--r--tools/debugserver/source/CMakeLists.txt90
-rw-r--r--tools/debugserver/source/MacOSX/CMakeLists.txt72
-rw-r--r--tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp3
-rw-r--r--tools/debugserver/source/MacOSX/HasAVX.s50
-rw-r--r--tools/debugserver/source/MacOSX/MachProcess.mm31
-rw-r--r--tools/debugserver/source/MacOSX/MachThread.cpp2
-rw-r--r--tools/debugserver/source/MacOSX/OsLogger.cpp4
-rw-r--r--tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp1068
-rw-r--r--tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h1
-rw-r--r--tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp954
-rw-r--r--tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h4
-rw-r--r--tools/debugserver/source/RNBRemote.cpp7
-rw-r--r--tools/driver/CMakeLists.txt31
-rw-r--r--tools/driver/Driver.h2
-rw-r--r--tools/driver/Platform.h1
-rw-r--r--tools/intel-mpx/CMakeLists.txt15
-rw-r--r--tools/intel-mpx/IntelMPXTablePlugin.cpp427
-rw-r--r--tools/intel-mpx/test/Makefile7
-rw-r--r--tools/intel-mpx/test/README.txt6
-rw-r--r--tools/intel-mpx/test/TestMPXTable.py168
-rw-r--r--tools/intel-mpx/test/main.cpp48
-rw-r--r--tools/lldb-mi/CMakeLists.txt39
-rw-r--r--tools/lldb-mi/MICmdCmdStack.cpp8
-rw-r--r--tools/lldb-mi/MICmdCmdVar.cpp4
-rw-r--r--tools/lldb-mi/MICmnBase.cpp2
-rw-r--r--tools/lldb-mi/MICmnBase.h2
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp2
-rw-r--r--tools/lldb-mi/MIDriver.cpp2
-rw-r--r--tools/lldb-mi/MIUtilString.cpp2
-rw-r--r--tools/lldb-mi/MIUtilString.h2
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.h3
-rw-r--r--tools/lldb-mi/Platform.h1
-rw-r--r--tools/lldb-server/Acceptor.cpp5
-rw-r--r--tools/lldb-server/Acceptor.h2
-rw-r--r--tools/lldb-server/CMakeLists.txt140
-rw-r--r--tools/lldb-server/LLDBServerUtilities.cpp44
-rw-r--r--tools/lldb-server/lldb-gdbserver.cpp10
-rw-r--r--tools/lldb-server/lldb-platform.cpp24
-rw-r--r--unittests/Breakpoint/BreakpointIDTest.cpp2
-rw-r--r--unittests/Breakpoint/CMakeLists.txt6
-rw-r--r--unittests/CMakeLists.txt22
-rw-r--r--unittests/Core/BroadcasterTest.cpp1
-rw-r--r--unittests/Core/CMakeLists.txt9
-rw-r--r--unittests/Core/DataExtractorTest.cpp9
-rw-r--r--unittests/Core/ScalarTest.cpp15
-rw-r--r--unittests/Core/StateTest.cpp21
-rw-r--r--unittests/Core/StreamCallbackTest.cpp28
-rw-r--r--unittests/Core/StructuredDataTest.cpp2
-rw-r--r--unittests/Core/TimerTest.cpp8
-rw-r--r--unittests/Editline/CMakeLists.txt5
-rw-r--r--unittests/Editline/EditlineTest.cpp6
-rw-r--r--unittests/Expression/CMakeLists.txt4
-rw-r--r--unittests/Expression/GoParserTest.cpp9
-rw-r--r--unittests/Host/CMakeLists.txt16
-rw-r--r--unittests/Host/FileSpecTest.cpp28
-rw-r--r--unittests/Host/SocketTest.cpp18
-rw-r--r--unittests/Host/linux/HostTest.cpp48
-rw-r--r--unittests/Host/linux/SupportTest.cpp26
-rw-r--r--unittests/Interpreter/CMakeLists.txt5
-rw-r--r--unittests/Interpreter/TestArgs.cpp8
-rw-r--r--unittests/Interpreter/TestCompletion.cpp307
-rw-r--r--unittests/Language/CPlusPlus/CMakeLists.txt3
-rw-r--r--unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp138
-rw-r--r--unittests/ObjectFile/CMakeLists.txt1
-rw-r--r--unittests/ObjectFile/ELF/CMakeLists.txt7
-rw-r--r--unittests/ObjectFile/ELF/TestELFHeader.cpp62
-rw-r--r--unittests/Platform/CMakeLists.txt5
-rw-r--r--unittests/Process/gdb-remote/CMakeLists.txt9
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp9
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp73
-rw-r--r--unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp7
-rw-r--r--unittests/Process/minidump/CMakeLists.txt9
-rw-r--r--unittests/Process/minidump/MinidumpParserTest.cpp19
-rw-r--r--unittests/ScriptInterpreter/Python/CMakeLists.txt9
-rw-r--r--unittests/Signals/CMakeLists.txt6
-rw-r--r--unittests/Signals/UnixSignalsTest.cpp140
-rw-r--r--unittests/Symbol/CMakeLists.txt4
-rw-r--r--unittests/SymbolFile/DWARF/CMakeLists.txt11
-rw-r--r--unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp2
-rw-r--r--unittests/SymbolFile/PDB/CMakeLists.txt11
-rw-r--r--unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp14
-rw-r--r--unittests/Target/CMakeLists.txt15
-rw-r--r--unittests/Target/Inputs/TestModule.c (renamed from unittests/Utility/Inputs/TestModule.c)0
-rw-r--r--unittests/Target/Inputs/TestModule.so (renamed from unittests/Utility/Inputs/TestModule.so)bin5602 -> 5602 bytes
-rw-r--r--unittests/Target/MemoryRegionInfoTest.cpp20
-rw-r--r--unittests/Target/ModuleCacheTest.cpp (renamed from unittests/Utility/ModuleCacheTest.cpp)2
-rw-r--r--unittests/UnwindAssembly/InstEmulation/CMakeLists.txt14
-rw-r--r--unittests/UnwindAssembly/x86/CMakeLists.txt7
-rw-r--r--unittests/Utility/CMakeLists.txt17
-rw-r--r--unittests/Utility/ConstStringTest.cpp18
-rw-r--r--unittests/Utility/ErrorTest.cpp (renamed from unittests/Core/ErrorTest.cpp)2
-rw-r--r--unittests/Utility/LogTest.cpp280
-rw-r--r--unittests/Utility/Mocks/CMakeLists.txt9
-rw-r--r--unittests/Utility/Mocks/MockTildeExpressionResolver.cpp80
-rw-r--r--unittests/Utility/Mocks/MockTildeExpressionResolver.h37
-rw-r--r--unittests/Utility/NameMatchesTest.cpp58
-rw-r--r--unittests/Utility/TildeExpressionResolverTest.cpp36
-rw-r--r--unittests/Utility/TimeoutTest.cpp18
-rw-r--r--unittests/Utility/UriParserTest.cpp40
-rw-r--r--unittests/Utility/VASprintfTest.cpp59
-rw-r--r--unittests/debugserver/CMakeLists.txt19
-rw-r--r--unittests/debugserver/RNBSocketTest.cpp133
-rw-r--r--unittests/debugserver/debugserver_LogCallback.cpp20
-rw-r--r--unittests/gtest_common.h9
-rwxr-xr-xwww/build.html2
-rwxr-xr-xwww/index.html2
-rwxr-xr-xwww/projects.html433
-rw-r--r--www/sidebar.incl1
-rw-r--r--www/test.html2
-rwxr-xr-xwww/varformats.html1
1356 files changed, 26640 insertions, 21448 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32b4580a5873..fe640fedb038 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ include(cmake/modules/LLDBStandalone.cmake)
include(cmake/modules/LLDBConfig.cmake)
include(cmake/modules/AddLLDB.cmake)
-if (__ANDROID_NDK__ OR (CMAKE_SYSTEM_NAME MATCHES "Windows"))
+if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
else()
set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
@@ -20,6 +20,10 @@ endif()
# add_subdirectory(include)
add_subdirectory(docs)
if (NOT LLDB_DISABLE_PYTHON)
+ if(LLDB_USE_SYSTEM_SIX)
+ set(SIX_EXTRA_ARGS "--useSystemSix")
+ endif()
+
set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
if(LLDB_BUILD_FRAMEWORK)
set(LLDB_PYTHON_TARGET_DIR
@@ -50,6 +54,7 @@ if (NOT LLDB_DISABLE_PYTHON)
--prefix=${CMAKE_BINARY_DIR}
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
+ ${SIX_EXTRA_ARGS}
${FINISH_EXTRA_ARGS}
VERBATIM
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
diff --git a/CODE_OWNERS.txt b/CODE_OWNERS.txt
index 92d91a3f197c..8fe43284cf6c 100644
--- a/CODE_OWNERS.txt
+++ b/CODE_OWNERS.txt
@@ -13,8 +13,7 @@ E: scallanan@apple.com
D: Expression evaluator, IR interpreter, Clang integration
N: Greg Clayton
-E: clayborg@gmail.com (Phabricator)
-E: gclayton@apple.com (Direct)
+E: clayborg@gmail.com
D: Overall LLDB architecture, Host (common+macosx), Symbol, API, ABI, Mac-specific code,
D: DynamicLoader, ObjectFile, IOHandler, EditLine, Core/Value*, Watchpoints, debugserver
D: Build scripts, Test suite, Platform, gdb-remote, Anything not covered by this file
@@ -35,12 +34,17 @@ D: FreeBSD
N: Jason Molenda
E: jmolenda@apple.com
-D: ABI, Disassembler, Unwinding, iOS, debugserver, Platform
+D: ABI, Disassembler, Unwinding, iOS, debugserver, Platform, ObjectFile, SymbolFile,
+D: SymbolVendor, DWARF, gdb-remote
N: Hafiz Abid Qadeer
E: abidh.haq@gmail.com
D: lldb-mi
+N: Kamil Rytarowski
+E: kamil@netbsd.org
+D: NetBSD
+
N: Zachary Turner
E: zturner@google.com
D: CMake build, Host (common+windows), Plugins/Process/Windows, Anything Windows-specific
diff --git a/INSTALL.txt b/INSTALL.txt
index 0f05823b6e4c..ef7126994f4a 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -7,6 +7,11 @@ On Mac OS X, in addition to using Xcode you'll need to enable code signing
on your system to either build lldb or debug using lldb. Please see the code
signing documentation in docs/code-signing.txt for more detailed directions.
+If you are building on Mac OS X and LLVM is not present in llvm/, then LLDB
+will check it out automatically. The files in scripts/Xcode/repos determine
+which branches of LLVM/Clang are checked out, depending on the current
+LLDB branch, according to the algorithm in scripts/Xcode/repo.py.
+
For instructions to build LLDB on Linux, or more details about supported
compiler versions, other dependencies, and build flags, see:
diff --git a/cmake/LLDBDependencies.cmake b/cmake/LLDBDependencies.cmake
index e12a52268342..55ce37908563 100644
--- a/cmake/LLDBDependencies.cmake
+++ b/cmake/LLDBDependencies.cmake
@@ -1,152 +1,13 @@
-set( LLDB_USED_LIBS
- lldbBase
- lldbBreakpoint
- lldbCommands
- lldbDataFormatters
- lldbHost
- lldbCore
- lldbExpression
- lldbInitialization
- lldbInterpreter
- lldbSymbol
- lldbTarget
- lldbUtility
-
- # Plugins
- lldbPluginDisassemblerLLVM
- lldbPluginSymbolFileDWARF
- lldbPluginSymbolFilePDB
- lldbPluginSymbolFileSymtab
- lldbPluginDynamicLoaderStatic
- lldbPluginDynamicLoaderPosixDYLD
- lldbPluginDynamicLoaderHexagonDYLD
- lldbPluginDynamicLoaderWindowsDYLD
-
- lldbPluginCPlusPlusLanguage
- lldbPluginGoLanguage
- lldbPluginJavaLanguage
- lldbPluginObjCLanguage
- lldbPluginObjCPlusPlusLanguage
- lldbPluginOCamlLanguage
-
- lldbPluginObjectFileELF
- lldbPluginObjectFileJIT
- lldbPluginSymbolVendorELF
- lldbPluginObjectContainerBSDArchive
- lldbPluginObjectContainerMachOArchive
- lldbPluginProcessGDBRemote
- lldbPluginProcessUtility
- lldbPluginPlatformAndroid
- lldbPluginPlatformGDB
- lldbPluginPlatformFreeBSD
- lldbPluginPlatformKalimba
- lldbPluginPlatformLinux
- lldbPluginPlatformNetBSD
- lldbPluginPlatformPOSIX
- lldbPluginPlatformWindows
- lldbPluginObjectContainerMachOArchive
- lldbPluginObjectContainerBSDArchive
- lldbPluginPlatformMacOSX
- lldbPluginStructuredDataDarwinLog
- lldbPluginDynamicLoaderMacOSXDYLD
- lldbPluginUnwindAssemblyInstEmulation
- lldbPluginUnwindAssemblyX86
- lldbPluginAppleObjCRuntime
- lldbPluginRenderScriptRuntime
- lldbPluginLanguageRuntimeGo
- lldbPluginLanguageRuntimeJava
- lldbPluginCXXItaniumABI
- lldbPluginABIMacOSX_arm
- lldbPluginABIMacOSX_arm64
- lldbPluginABIMacOSX_i386
- lldbPluginABISysV_arm
- lldbPluginABISysV_arm64
- lldbPluginABISysV_i386
- lldbPluginABISysV_x86_64
- lldbPluginABISysV_hexagon
- lldbPluginABISysV_ppc
- lldbPluginABISysV_ppc64
- lldbPluginABISysV_mips
- lldbPluginABISysV_mips64
- lldbPluginABISysV_s390x
- lldbPluginInstructionARM
- lldbPluginInstructionARM64
- lldbPluginInstructionMIPS
- lldbPluginInstructionMIPS64
- lldbPluginObjectFilePECOFF
- lldbPluginOSGo
- lldbPluginOSPython
- lldbPluginMemoryHistoryASan
- lldbPluginInstrumentationRuntimeAddressSanitizer
- lldbPluginInstrumentationRuntimeThreadSanitizer
- lldbPluginSystemRuntimeMacOSX
- lldbPluginProcessElfCore
- lldbPluginProcessMinidump
- lldbPluginJITLoaderGDB
- lldbPluginExpressionParserClang
- lldbPluginExpressionParserGo
- )
+set(LLDB_SYSTEM_LIBS)
# Windows-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginProcessWindowsCommon
+ list(APPEND LLDB_SYSTEM_LIBS
ws2_32
rpcrt4
)
endif ()
-# Linux-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginProcessLinux
- lldbPluginProcessPOSIX
- )
-endif ()
-
-# FreeBSD-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginProcessFreeBSD
- lldbPluginProcessPOSIX
- )
-endif ()
-
-# NetBSD-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginProcessPOSIX
- )
-endif ()
-
-# Darwin-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginDynamicLoaderDarwinKernel
- lldbPluginObjectFileMachO
- lldbPluginProcessMachCore
- lldbPluginProcessMacOSXKernel
- lldbPluginSymbolVendorMacOSX
- )
-endif()
-
-set( CLANG_USED_LIBS
- clangAnalysis
- clangAST
- clangBasic
- clangCodeGen
- clangDriver
- clangEdit
- clangFrontend
- clangLex
- clangParse
- clangRewrite
- clangRewriteFrontend
- clangSema
- clangSerialization
- )
-
-set(LLDB_SYSTEM_LIBS)
if (NOT LLDB_DISABLE_LIBEDIT)
list(APPEND LLDB_SYSTEM_LIBS edit)
endif()
@@ -178,29 +39,6 @@ if (LLVM_BUILD_STATIC)
endif()
endif()
-set(LLVM_LINK_COMPONENTS
- ${LLVM_TARGETS_TO_BUILD}
- interpreter
- asmparser
- bitreader
- bitwriter
- codegen
- demangle
- ipo
- selectiondag
- bitreader
- mc
- mcjit
- core
- mcdisassembler
- executionengine
- runtimedyld
- option
- support
- coverage
- target
- )
-
if ( NOT LLDB_DISABLE_PYTHON )
set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
if (CLANG_CL)
diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake
index 47ee25da52b2..4c6f1efd673d 100644
--- a/cmake/modules/AddLLDB.cmake
+++ b/cmake/modules/AddLLDB.cmake
@@ -1,31 +1,17 @@
-function(lldb_link_common_libs name targetkind)
- if (NOT LLDB_USED_LIBS)
- return()
- endif()
-
- if(${targetkind} MATCHES "SHARED")
- set(LINK_KEYWORD PRIVATE)
- endif()
-
- if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
- if (LLDB_LINKER_SUPPORTS_GROUPS)
- target_link_libraries(${name} ${LINK_KEYWORD}
- -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
- else()
- target_link_libraries(${name} ${LINK_KEYWORD} ${LLDB_USED_LIBS})
- endif()
- endif()
-endfunction(lldb_link_common_libs)
-
function(add_lldb_library name)
# only supported parameters to this macro are the optional
# MODULE;SHARED;STATIC library type and source files
cmake_parse_arguments(PARAM
- "MODULE;SHARED;STATIC;OBJECT"
+ "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
""
- "DEPENDS"
+ "DEPENDS;LINK_LIBS;LINK_COMPONENTS"
${ARGN})
llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
+ list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
+
+ if(PARAM_PLUGIN)
+ set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
+ endif()
if (MSVC_IDE OR XCODE)
string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
@@ -56,22 +42,9 @@ function(add_lldb_library name)
if (PARAM_OBJECT)
add_library(${name} ${libkind} ${srcs})
else()
- if (PARAM_SHARED)
- if (LLDB_LINKER_SUPPORTS_GROUPS)
- llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
- -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group
- -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group
- DEPENDS ${PARAM_DEPENDS}
- )
- else()
- llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
- ${LLDB_USED_LIBS} ${CLANG_USED_LIBS}
- DEPENDS ${PARAM_DEPENDS}
- )
- endif()
- else()
- llvm_add_library(${name} ${libkind} ${srcs} DEPENDS ${PARAM_DEPENDS})
- endif()
+ llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
+ ${PARAM_LINK_LIBS}
+ DEPENDS ${PARAM_DEPENDS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
if (PARAM_SHARED)
@@ -112,8 +85,17 @@ function(add_lldb_library name)
endfunction(add_lldb_library)
function(add_lldb_executable name)
- cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL" "" "" ${ARGN})
+ cmake_parse_arguments(ARG
+ "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL"
+ ""
+ "LINK_LIBS;LINK_COMPONENTS"
+ ${ARGN}
+ )
+
+ list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+
+ target_link_libraries(${name} ${ARG_LINK_LIBS})
set_target_properties(${name} PROPERTIES
FOLDER "lldb executables")
diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake
index 74d6e74b0cfd..79e82fbb3fb1 100644
--- a/cmake/modules/LLDBConfig.cmake
+++ b/cmake/modules/LLDBConfig.cmake
@@ -13,14 +13,12 @@ endif()
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
set(LLDB_DEFAULT_DISABLE_CURSES 1)
+elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
+ set(LLDB_DEFAULT_DISABLE_PYTHON 1)
+ set(LLDB_DEFAULT_DISABLE_CURSES 1)
else()
- if ( __ANDROID_NDK__ )
- set(LLDB_DEFAULT_DISABLE_PYTHON 1)
- set(LLDB_DEFAULT_DISABLE_CURSES 1)
- else()
- set(LLDB_DEFAULT_DISABLE_PYTHON 0)
- set(LLDB_DEFAULT_DISABLE_CURSES 0)
- endif()
+ set(LLDB_DEFAULT_DISABLE_PYTHON 0)
+ set(LLDB_DEFAULT_DISABLE_CURSES 0)
endif()
set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
@@ -31,6 +29,9 @@ set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
"Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
+set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
+ "Use six.py shipped with system and do not install a copy of it")
+
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
"Causes lldb to export all symbols when building liblldb.")
@@ -269,8 +270,8 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION
message(STATUS "LLDB version: ${LLDB_VERSION}")
include_directories(BEFORE
- ${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/include
)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
@@ -280,6 +281,17 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
+ PATTERN ".cmake" EXCLUDE
+ PATTERN "Config.h" EXCLUDE
+ )
+
+ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
+ COMPONENT lldb_headers
+ DESTINATION include
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN ".svn" EXCLUDE
+ PATTERN ".cmake" EXCLUDE
)
endif()
@@ -354,10 +366,7 @@ endif()
# Figure out if lldb could use lldb-server. If so, then we'll
# ensure we build lldb-server when an lldb target is being built.
-if ((CMAKE_SYSTEM_NAME MATCHES "Darwin") OR
- (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") OR
- (CMAKE_SYSTEM_NAME MATCHES "Linux") OR
- (CMAKE_SYSTEM_NAME MATCHES "NetBSD"))
+if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD")
set(LLDB_CAN_USE_LLDB_SERVER 1)
else()
set(LLDB_CAN_USE_LLDB_SERVER 0)
@@ -417,4 +426,24 @@ if(LLDB_USE_BUILTIN_DEMANGLER)
add_definitions(-DLLDB_USE_BUILTIN_DEMANGLER)
endif()
+if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND
+ ((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips")))
+ add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND)
+endif()
+
find_package(Backtrace)
+
+check_include_file(termios.h HAVE_TERMIOS_H)
+
+# These checks exist in LLVM's configuration, so I want to match the LLVM names
+# so that the check isn't duplicated, but we translate them into the LLDB names
+# so that I don't have to change all the uses at the moment.
+set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H})
+if(NOT UNIX)
+ set(LLDB_DISABLE_POSIX 1)
+endif()
+
+# This should be done at the end
+configure_file(
+ ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/include/lldb/Host/Config.h)
diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake
index a142b757569c..67e207e59edb 100644
--- a/cmake/modules/LLDBStandalone.cmake
+++ b/cmake/modules/LLDBStandalone.cmake
@@ -69,6 +69,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
if(EXISTS ${LLVMCONFIG_FILE})
+ file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH}" LLVM_CMAKE_PATH)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
include(${LLVMCONFIG_FILE})
else()
diff --git a/cmake/platforms/Android.cmake b/cmake/platforms/Android.cmake
index b977b1ed364c..789322f4353c 100644
--- a/cmake/platforms/Android.cmake
+++ b/cmake/platforms/Android.cmake
@@ -29,13 +29,12 @@ if( IS_IN_TRY_COMPILE )
return()
endif()
-set( CMAKE_SYSTEM_NAME Linux )
+set( CMAKE_SYSTEM_NAME Android )
include( CMakeForceCompiler )
# flags and definitions
add_definitions( -DANDROID -DLLDB_DISABLE_LIBEDIT )
set( ANDROID True )
-set( __ANDROID_NDK__ True )
set( LLDB_DEFAULT_DISABLE_LIBEDIT True )
# linking lldb-server statically for Android avoids the need to ship two
@@ -103,10 +102,6 @@ elseif( ANDROID_ABI STREQUAL "armeabi" )
# 64 bit atomic operations used in c++ libraries require armv7-a instructions
# armv5te and armv6 were tried but do not work.
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mthumb" )
- if( LLVM_BUILD_STATIC )
- # Temporary workaround for static linking with the latest API.
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -DANDROID_ARM_BUILD_STATIC" )
- endif()
elseif( ANDROID_ABI STREQUAL "mips" )
# http://b.android.com/182094
list( FIND LLDB_SYSTEM_LIBS atomic index )
@@ -114,10 +109,6 @@ elseif( ANDROID_ABI STREQUAL "mips" )
list( APPEND LLDB_SYSTEM_LIBS atomic )
set( LLDB_SYSTEM_LIBS ${LLDB_SYSTEM_LIBS} CACHE INTERNAL "" FORCE )
endif()
- if( LLVM_BUILD_STATIC )
- # Temporary workaround for static linking with the latest API.
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -DANDROID_MIPS_BUILD_STATIC" )
- endif()
endif()
# Use gold linker and enable safe ICF in case of x86, x86_64 and arm
diff --git a/docs/lldb-gdb-remote.txt b/docs/lldb-gdb-remote.txt
index 450981894184..80a44e866cab 100644
--- a/docs/lldb-gdb-remote.txt
+++ b/docs/lldb-gdb-remote.txt
@@ -1029,7 +1029,7 @@ for this region.
// region what contains data mapped from the specified file.
//
// RESPONSE
-// <unsinged-hex64> - Load address of the file in big endian encoding
+// <unsigned-hex64> - Load address of the file in big endian encoding
// "E01" - the requested file isn't loaded
// "EXX" - for any other errors
//
diff --git a/examples/python/crashlog.py b/examples/python/crashlog.py
index abd6aaae7780..7270f60f4373 100755
--- a/examples/python/crashlog.py
+++ b/examples/python/crashlog.py
@@ -259,7 +259,11 @@ class CrashLog(symbolication.Symbolicator):
self.dsymForUUIDBinary, uuid_str)
s = commands.getoutput(dsym_for_uuid_command)
if s:
- plist_root = plistlib.readPlistFromString(s)
+ try:
+ plist_root = plistlib.readPlistFromString(s)
+ except:
+ print("Got exception: ", sys.exc_value, " handling dsymForUUID output: \n", s)
+ raise
if plist_root:
plist = plist_root[uuid_str]
if plist:
diff --git a/examples/python/gdbremote.py b/examples/python/gdbremote.py
index 7d5874e8b0c7..a6ff3f5978e4 100755
--- a/examples/python/gdbremote.py
+++ b/examples/python/gdbremote.py
@@ -322,6 +322,15 @@ def is_hex_byte(str):
return str[0] in string.hexdigits and str[1] in string.hexdigits
return False
+def get_hex_string_if_all_printable(str):
+ try:
+ s = binascii.unhexlify(str)
+ if all(c in string.printable for c in s):
+ return s
+ except TypeError:
+ pass
+ return None
+
# global register info list
g_register_infos = list()
g_max_register_info_name_len = 0
@@ -638,6 +647,14 @@ def cmd_qSymbol(options, cmd, args):
else:
print 'error: bad command format'
+def cmd_QSetWithHexString(options, cmd, args):
+ print '%s("%s")' % (cmd[:-1], binascii.unhexlify(args))
+
+def cmd_QSetWithString(options, cmd, args):
+ print '%s("%s")' % (cmd[:-1], args)
+
+def cmd_QSetWithUnsigned(options, cmd, args):
+ print '%s(%i)' % (cmd[:-1], int(args))
def rsp_qSymbol(options, cmd, cmd_args, rsp):
if len(rsp) == 0:
@@ -766,7 +783,11 @@ def dump_key_value_pairs(key_value_pairs):
for key_value_pair in key_value_pairs:
key = key_value_pair[0]
value = key_value_pair[1]
- print "%*s = %s" % (max_key_len, key, value)
+ unhex_value = get_hex_string_if_all_printable(value)
+ if unhex_value:
+ print "%*s = %s (%s)" % (max_key_len, key, value, unhex_value)
+ else:
+ print "%*s = %s" % (max_key_len, key, value)
def rsp_dump_key_value_pairs(options, cmd, cmd_args, rsp):
@@ -910,26 +931,29 @@ def rsp_qThreadInfo(options, cmd, cmd_args, rsp):
def rsp_hex_big_endian(options, cmd, cmd_args, rsp):
- packet = Packet(rsp)
- uval = packet.get_hex_uint('big')
- print '%s: 0x%x' % (cmd, uval)
+ if rsp == '':
+ print "%s%s is not supported" % (cmd, cmd_args)
+ else:
+ packet = Packet(rsp)
+ uval = packet.get_hex_uint('big')
+ print '%s: 0x%x' % (cmd, uval)
def cmd_read_mem_bin(options, cmd, args):
# x0x7fff5fc39200,0x200
packet = Packet(args)
- addr = packet.get_number()
+ addr = packet.get_hex_uint('big')
comma = packet.get_char()
- size = packet.get_number()
+ size = packet.get_hex_uint('big')
print 'binary_read_memory (addr = 0x%16.16x, size = %u)' % (addr, size)
return False
def rsp_mem_bin_bytes(options, cmd, cmd_args, rsp):
packet = Packet(cmd_args)
- addr = packet.get_number()
+ addr = packet.get_hex_uint('big')
comma = packet.get_char()
- size = packet.get_number()
+ size = packet.get_hex_uint('big')
print 'memory:'
if size > 0:
dump_hex_memory_buffer(addr, rsp)
@@ -1192,11 +1216,11 @@ gdb_remote_commands = {
'QStartNoAckMode': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if no ack mode is supported"},
'QThreadSuffixSupported': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if thread suffix is supported"},
'QListThreadsInStopReply': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if threads in stop reply packets are supported"},
- 'QSetDetachOnError': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "set if we should detach on error"},
- 'QSetDisableASLR': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "set if we should disable ASLR"},
+ 'QSetDetachOnError:': {'cmd': cmd_QSetWithUnsigned, 'rsp': rsp_ok_means_success, 'name': "set if we should detach on error"},
+ 'QSetDisableASLR:': {'cmd': cmd_QSetWithUnsigned, 'rsp': rsp_ok_means_success, 'name': "set if we should disable ASLR"},
'qLaunchSuccess': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "check on launch success for the A packet"},
'A': {'cmd': cmd_A, 'rsp': rsp_ok_means_success, 'name': "launch process"},
- 'QLaunchArch': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "set if we should disable ASLR"},
+ 'QLaunchArch:': {'cmd': cmd_QSetWithString, 'rsp': rsp_ok_means_supported, 'name': "set the arch to launch in case the file contains multiple architectures"},
'qVAttachOrWaitSupported': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "set the launch architecture"},
'qHostInfo': {'cmd': cmd_query_packet, 'rsp': rsp_dump_key_value_pairs, 'name': "get host information"},
'qC': {'cmd': cmd_qC, 'rsp': rsp_qC, 'name': "return the current thread ID"},
@@ -1213,6 +1237,11 @@ gdb_remote_commands = {
'qSupported': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query supported"},
'qXfer:': {'cmd': cmd_qXfer, 'rsp': rsp_qXfer, 'name': "qXfer"},
'qSymbol:': {'cmd': cmd_qSymbol, 'rsp': rsp_qSymbol, 'name': "qSymbol"},
+ 'QSetSTDIN:' : {'cmd' : cmd_QSetWithHexString, 'rsp' : rsp_ok_means_success, 'name': "set STDIN prior to launching with A packet"},
+ 'QSetSTDOUT:' : {'cmd' : cmd_QSetWithHexString, 'rsp' : rsp_ok_means_success, 'name': "set STDOUT prior to launching with A packet"},
+ 'QSetSTDERR:' : {'cmd' : cmd_QSetWithHexString, 'rsp' : rsp_ok_means_success, 'name': "set STDERR prior to launching with A packet"},
+ 'QEnvironment:' : {'cmd' : cmd_QSetWithString, 'rsp' : rsp_ok_means_success, 'name': "set an environment variable prior to launching with A packet"},
+ 'QEnvironmentHexEncoded:' : {'cmd' : cmd_QSetWithHexString, 'rsp' : rsp_ok_means_success, 'name': "set an environment variable prior to launching with A packet"},
'x': {'cmd': cmd_read_mem_bin, 'rsp': rsp_mem_bin_bytes, 'name': "read memory binary"},
'X': {'cmd': cmd_write_memory, 'rsp': rsp_ok_means_success, 'name': "write memory binary"},
'm': {'cmd': cmd_read_memory, 'rsp': rsp_memory_bytes, 'name': "read memory"},
@@ -1269,7 +1298,7 @@ def parse_gdb_log(file, options):
packet_name_regex = re.compile('([A-Za-z_]+)[^a-z]')
packet_transmit_name_regex = re.compile(
'(?P<direction>send|read) packet: (?P<packet>.*)')
- packet_contents_name_regex = re.compile('\$([^#]+)#[0-9a-fA-F]{2}')
+ packet_contents_name_regex = re.compile('\$([^#]*)#[0-9a-fA-F]{2}')
packet_checksum_regex = re.compile('.*#[0-9a-fA-F]{2}$')
packet_names_regex_str = '(' + \
'|'.join(gdb_remote_commands.keys()) + ')(.*)'
diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h
index 6c3561615990..0c52218f57cd 100644
--- a/include/lldb/API/SBAttachInfo.h
+++ b/include/lldb/API/SBAttachInfo.h
@@ -86,7 +86,7 @@ public:
/// This function implies that a call to SBTarget::Attach(...) will
/// be synchronous.
///
- /// @param[in] wait_for
+ /// @param[in] b
/// If \b false, attach to an existing process whose name matches.
/// If \b true, then wait for the next process whose name matches.
//------------------------------------------------------------------
@@ -99,7 +99,7 @@ public:
/// Future calls to SBTarget::Attach(...) will be synchronous or
/// asynchronous depending on the \a async argument.
///
- /// @param[in] wait_for
+ /// @param[in] b
/// If \b false, attach to an existing process whose name matches.
/// If \b true, then wait for the next process whose name matches.
///
diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h
index 56509c903c2d..d3f22f39ab00 100644
--- a/include/lldb/API/SBBreakpoint.h
+++ b/include/lldb/API/SBBreakpoint.h
@@ -133,19 +133,13 @@ private:
SBBreakpoint(const lldb::BreakpointSP &bp_sp);
- lldb_private::Breakpoint *operator->() const;
-
- lldb_private::Breakpoint *get() const;
-
- lldb::BreakpointSP &operator*();
-
- const lldb::BreakpointSP &operator*() const;
-
static bool PrivateBreakpointHitCallback(
void *baton, lldb_private::StoppointCallbackContext *context,
lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
- lldb::BreakpointSP m_opaque_sp;
+ lldb::BreakpointSP GetSP() const;
+
+ lldb::BreakpointWP m_opaque_wp;
};
class LLDB_API SBBreakpointList {
diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h
index 344c39c7bfd3..0b5ba79d784f 100644
--- a/include/lldb/API/SBBreakpointLocation.h
+++ b/include/lldb/API/SBBreakpointLocation.h
@@ -78,8 +78,9 @@ private:
friend class SBBreakpoint;
void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp);
+ BreakpointLocationSP GetSP() const;
- lldb::BreakpointLocationSP m_opaque_sp;
+ lldb::BreakpointLocationWP m_opaque_wp;
};
} // namespace lldb
diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h
index be5c0920aee5..58339750def6 100644
--- a/include/lldb/API/SBFrame.h
+++ b/include/lldb/API/SBFrame.h
@@ -78,6 +78,10 @@ public:
const char *GetDisplayFunctionName();
const char *GetFunctionName() const;
+
+ // Return the frame function's language. If there isn't a function, then
+ // guess the language type from the mangled name.
+ lldb::LanguageType GuessLanguage() const;
/// Return true if this frame represents an inlined function.
///
diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h
index 05282c215406..a2f82a83c3ed 100644
--- a/include/lldb/API/SBListener.h
+++ b/include/lldb/API/SBListener.h
@@ -89,7 +89,7 @@ protected:
SBListener(const lldb::ListenerSP &listener_sp);
- lldb::ListenerSP GetSP() { return m_opaque_sp; }
+ lldb::ListenerSP GetSP();
private:
lldb_private::Listener *operator->() const;
diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h
index 4e8db835ddc0..21341fbc27fa 100644
--- a/include/lldb/API/SBTarget.h
+++ b/include/lldb/API/SBTarget.h
@@ -124,9 +124,6 @@ public:
/// @param[in] envp
/// The environment array.
///
- /// @param[in] launch_flags
- /// Flags to modify the launch (@see lldb::LaunchFlags)
- ///
/// @param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
/// process. If all stdXX_path arguments are nullptr, a pseudo
@@ -480,6 +477,7 @@ public:
/// Resolve a current file address into a section offset address.
///
/// @param[in] file_addr
+ /// The file address to resolve.
///
/// @return
/// An SBAddress which will be valid if...
@@ -653,7 +651,7 @@ public:
/// @param[in] source_file
/// The file from which to read the breakpoints.
///
- /// @param[out] bkpt_list
+ /// @param[out] new_bps
/// A list of the newly created breakpoints.
///
/// @return
@@ -673,7 +671,7 @@ public:
/// Only read in breakpoints whose names match one of the names in this
/// list.
///
- /// @param[out] bkpt_list
+ /// @param[out] new_bps
/// A list of the newly created breakpoints.
///
/// @return
diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h
index 284ec12392a3..92d4851fc14d 100644
--- a/include/lldb/API/SBWatchpoint.h
+++ b/include/lldb/API/SBWatchpoint.h
@@ -72,7 +72,7 @@ private:
friend class SBTarget;
friend class SBValue;
- lldb::WatchpointSP m_opaque_sp;
+ std::weak_ptr<lldb_private::Watchpoint> m_opaque_wp;
};
} // namespace lldb
diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h
index 9af6e586de39..4a16df047ee3 100644
--- a/include/lldb/Breakpoint/Breakpoint.h
+++ b/include/lldb/Breakpoint/Breakpoint.h
@@ -26,8 +26,8 @@
#include "lldb/Breakpoint/Stoppoint.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/StringList.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h
index 43aef9fc6a27..d0567ccf2e04 100644
--- a/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/include/lldb/Breakpoint/BreakpointLocation.h
@@ -19,7 +19,7 @@
// Project includes
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/UserID.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h
index e053af352ff2..024e915908c0 100644
--- a/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/include/lldb/Breakpoint/BreakpointOptions.h
@@ -17,9 +17,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Baton.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/Baton.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h
index e19a2135fbd2..7a57250d632b 100644
--- a/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/include/lldb/Breakpoint/BreakpointResolver.h
@@ -15,12 +15,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index f1fdf60e74ec..50750b1fbdf5 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -63,6 +63,8 @@ public:
lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
+ void FilterContexts(SymbolContextList &sc_list);
+
friend class Breakpoint;
FileSpec m_file_spec; // This is the file spec we are looking for.
uint32_t m_line_number; // This is the line number that we are looking for.
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index 0429e264774e..6f00dac3f0a7 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -17,7 +17,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointResolver.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h
index b334c6e1a276..6e9875615fd9 100644
--- a/include/lldb/Breakpoint/BreakpointSite.h
+++ b/include/lldb/Breakpoint/BreakpointSite.h
@@ -21,7 +21,7 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/StoppointLocation.h"
-#include "lldb/Core/UserID.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-forward.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h
index 5d131a556ad1..3195ef942d9e 100644
--- a/include/lldb/Breakpoint/Stoppoint.h
+++ b/include/lldb/Breakpoint/Stoppoint.h
@@ -14,7 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UserID.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h
index ba03b4ea1f5b..f64035bbb941 100644
--- a/include/lldb/Breakpoint/StoppointLocation.h
+++ b/include/lldb/Breakpoint/StoppointLocation.h
@@ -14,7 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UserID.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
// #include "lldb/Breakpoint/BreakpointOptions.h"
diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h
index 97f2e282acc2..beb7bad1ee9d 100644
--- a/include/lldb/Breakpoint/Watchpoint.h
+++ b/include/lldb/Breakpoint/Watchpoint.h
@@ -19,9 +19,9 @@
// Project includes
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/WatchpointOptions.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h
index bfb814ecbd54..6ab1264a1c7f 100644
--- a/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/include/lldb/Breakpoint/WatchpointOptions.h
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Baton.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/Baton.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h
index 909a0605eae1..a800570ec8b1 100644
--- a/include/lldb/Core/Address.h
+++ b/include/lldb/Core/Address.h
@@ -10,13 +10,44 @@
#ifndef liblldb_Address_h_
#define liblldb_Address_h_
-// C Includes
-// C++ Includes
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-enumerations.h" // for AddressClass::eAddressClassInvalid
+#include "lldb/lldb-forward.h" // for SectionWP, SectionSP, ModuleSP
+#include "lldb/lldb-types.h" // for addr_t
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Symbol/SymbolContextScope.h"
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, UINT32_MAX, int64_t
+
+namespace lldb_private {
+class Block;
+}
+namespace lldb_private {
+class CompileUnit;
+}
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class Function;
+}
+namespace lldb_private {
+class SectionList;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Symbol;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+struct LineEntry;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h
index fa9fefbc0df1..e787d1d5740d 100644
--- a/include/lldb/Core/AddressRange.h
+++ b/include/lldb/Core/AddressRange.h
@@ -10,11 +10,21 @@
#ifndef liblldb_AddressRange_h_
#define liblldb_AddressRange_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Address.h"
+#include "lldb/lldb-forward.h" // for SectionSP
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class SectionList;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Target;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h
index 5fe2ec1eaec6..432268e497b4 100644
--- a/include/lldb/Core/AddressResolver.h
+++ b/include/lldb/Core/AddressResolver.h
@@ -10,20 +10,20 @@
#ifndef liblldb_AddressResolver_h_
#define liblldb_AddressResolver_h_
-#include <vector>
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+
+#include <stddef.h> // for size_t
+#include <vector>
namespace lldb_private {
+class ModuleList;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h"
diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h
index 950750e5bfa4..ec15cc76d887 100644
--- a/include/lldb/Core/AddressResolverFileLine.h
+++ b/include/lldb/Core/AddressResolverFileLine.h
@@ -10,8 +10,22 @@
#ifndef liblldb_AddressResolverFileLine_h_
#define liblldb_AddressResolverFileLine_h_
-// Project includes
#include "lldb/Core/AddressResolver.h"
+#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR...
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h
index e93d16fbc6aa..aadc05495999 100644
--- a/include/lldb/Core/AddressResolverName.h
+++ b/include/lldb/Core/AddressResolverName.h
@@ -10,10 +10,21 @@
#ifndef liblldb_AddressResolverName_h_
#define liblldb_AddressResolverName_h_
-// Project includes
-
#include "lldb/Core/AddressResolver.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::Call...
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h
index 7f663f7abd12..648815c21371 100644
--- a/include/lldb/Core/ArchSpec.h
+++ b/include/lldb/Core/ArchSpec.h
@@ -12,13 +12,31 @@
#if defined(__cplusplus)
-#include "lldb/Core/ConstString.h"
-#include "lldb/lldb-forward.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "llvm/ADT/StringRef.h" // for StringRef
#include "llvm/ADT/Triple.h"
+#include <string> // for string
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class Platform;
+}
namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class StringList;
+}
+namespace lldb_private {
+class Thread;
+}
-struct CoreDefinition;
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
@@ -307,7 +325,7 @@ public:
/// @return A string representing target CPU for the current
/// architecture.
//------------------------------------------------------------------
- std::string GetClangTargetCPU();
+ std::string GetClangTargetCPU() const;
//------------------------------------------------------------------
/// Return a string representing target application ABI.
diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h
index c23f12c30b9c..825287db5984 100644
--- a/include/lldb/Core/Broadcaster.h
+++ b/include/lldb/Core/Broadcaster.h
@@ -10,21 +10,33 @@
#ifndef liblldb_Broadcaster_h_
#define liblldb_Broadcaster_h_
-// C Includes
-// C++ Includes
-#include <functional>
-#include <list>
+#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-forward.h" // for ListenerSP, EventSP, Broadcast...
+
+#include "llvm/ADT/SmallVector.h"
+
+#include <cstdint> // for uint32_t, UINT32_MAX
#include <map>
+#include <memory> // for shared_ptr, operator==, enable...
#include <mutex>
+#include <set> // for set
#include <string>
+#include <utility> // for pair
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/lldb-private.h"
-
-#include "llvm/ADT/SmallVector.h"
+namespace lldb_private {
+class Broadcaster;
+}
+namespace lldb_private {
+class EventData;
+}
+namespace lldb_private {
+class Listener;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
@@ -82,8 +94,8 @@ protected:
public:
// Listeners hold onto weak pointers to their broadcaster managers. So they
- // must be
- // made into shared pointers, which you do with MakeBroadcasterManager.
+ // must be made into shared pointers, which you do with
+ // MakeBroadcasterManager.
static lldb::BroadcasterManagerSP MakeBroadcasterManager();
diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h
index 8a875ddad1f8..9459573ca90e 100644
--- a/include/lldb/Core/Communication.h
+++ b/include/lldb/Core/Communication.h
@@ -10,19 +10,31 @@
#ifndef liblldb_Communication_h_
#define liblldb_Communication_h_
-// C Includes
-// C++ Includes
+#include "lldb/Core/Broadcaster.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/Timeout.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ConnectionStatus, FLAGS_ANONYMOU...
+#include "lldb/lldb-forward.h" // for ConnectionSP
+#include "lldb/lldb-types.h" // for thread_arg_t, thread_result_t
+
#include <atomic>
#include <mutex>
+#include <ratio> // for micro
#include <string>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Host/HostThread.h"
-#include "lldb/Utility/Timeout.h"
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint8_t
+
+namespace lldb_private {
+class Connection;
+}
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class Error;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/Connection.h b/include/lldb/Core/Connection.h
index 6ff7b001a709..8d84377e3757 100644
--- a/include/lldb/Core/Connection.h
+++ b/include/lldb/Core/Connection.h
@@ -10,15 +10,24 @@
#ifndef liblldb_Connection_h_
#define liblldb_Connection_h_
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Utility/Timeout.h"
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ConnectionStatus
+#include "lldb/lldb-forward.h" // for IOObjectSP
-// C Includes
-// C++ Includes
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <ratio> // for micro
#include <string>
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+template <typename Ratio> class Timeout;
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Core/DataBufferMemoryMap.h b/include/lldb/Core/DataBufferMemoryMap.h
deleted file mode 100644
index 1b8277b50488..000000000000
--- a/include/lldb/Core/DataBufferMemoryMap.h
+++ /dev/null
@@ -1,154 +0,0 @@
-//===-- DataBufferMemoryMap.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_DataBufferMemoryMap_h_
-#define liblldb_DataBufferMemoryMap_h_
-
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/Error.h"
-#include "lldb/lldb-private.h"
-#include <string>
-
-namespace lldb_private {
-
-//----------------------------------------------------------------------
-/// @class DataBufferMemoryMap DataBufferMemoryMap.h
-/// "lldb/Core/DataBufferMemoryMap.h"
-/// @brief A subclass of DataBuffer that memory maps data.
-///
-/// This class memory maps data and stores any needed data for the
-/// memory mapping in its internal state. Memory map requests are not
-/// required to have any alignment or size constraints, this class will
-/// work around any host OS issues regarding such things.
-///
-/// This class is designed to allow pages to be faulted in as needed and
-/// works well data from large files that won't be accessed all at once.
-//----------------------------------------------------------------------
-class DataBufferMemoryMap : public DataBuffer {
-public:
- //------------------------------------------------------------------
- /// Default Constructor
- //------------------------------------------------------------------
- DataBufferMemoryMap();
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Virtual destructor since this class inherits from a pure virtual
- /// base class #DataBuffer.
- //------------------------------------------------------------------
- ~DataBufferMemoryMap() override;
-
- //------------------------------------------------------------------
- /// Reverts this object to an empty state by unmapping any memory
- /// that is currently owned.
- //------------------------------------------------------------------
- void Clear();
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes()
- //------------------------------------------------------------------
- uint8_t *GetBytes() override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
- const uint8_t *GetBytes() const override;
-
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
- lldb::offset_t GetByteSize() const override;
-
- //------------------------------------------------------------------
- /// Error get accessor.
- ///
- /// @return
- /// A const reference to Error object in case memory mapping
- /// fails.
- //------------------------------------------------------------------
- const Error &GetError() const;
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from \a file starting \a offset
- /// bytes into the file. If \a length is set to \c SIZE_MAX,
- /// then map as many bytes as possible.
- ///
- /// @param[in] file
- /// The file specification from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible. Even though it may be possible
- /// for a 32-bit host debugger to debug a 64-bit target, size_t
- /// still dictates the maximum possible size that can be mapped
- /// into this process. For this kind of cross-arch debugging
- /// scenario, mappings and views should be managed at a higher
- /// level.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t MemoryMapFromFileSpec(const FileSpec *file, lldb::offset_t offset = 0,
- size_t length = SIZE_MAX,
- bool writeable = false);
-
- //------------------------------------------------------------------
- /// Memory map all or part of a file.
- ///
- /// Memory map \a length bytes from an opened file descriptor \a fd
- /// starting \a offset bytes into the file. If \a length is set to
- /// \c SIZE_MAX, then map as many bytes as possible.
- ///
- /// @param[in] fd
- /// The posix file descriptor for an already opened file
- /// from which to map data.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// The number of bytes mapped starting from the \a offset.
- //------------------------------------------------------------------
- size_t MemoryMapFromFileDescriptor(int fd, lldb::offset_t offset,
- size_t length, bool write,
- bool fd_is_file);
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from DataBufferMemoryMap can see and modify these
- //------------------------------------------------------------------
- uint8_t *m_mmap_addr; ///< The actual pointer that was returned from \c mmap()
- size_t m_mmap_size; ///< The actual number of bytes that were mapped when \c
- ///mmap() was called
- uint8_t *m_data; ///< The data the user requested somewhere within the memory
- ///mapped data.
- lldb::offset_t
- m_size; ///< The size of the data the user got when data was requested
-
-private:
- DISALLOW_COPY_AND_ASSIGN(DataBufferMemoryMap);
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_DataBufferMemoryMap_h_
diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h
index ccc07b30f0c6..56201273fdd2 100644
--- a/include/lldb/Core/Debugger.h
+++ b/include/lldb/Core/Debugger.h
@@ -14,9 +14,7 @@
#include <stdint.h>
// C++ Includes
-#include <map>
#include <memory>
-#include <mutex>
#include <vector>
// Other libraries and framework includes
@@ -24,21 +22,55 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/Listener.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Terminal.h"
+#include "lldb/Target/ExecutionContext.h" // for ExecutionContext
#include "lldb/Target/Platform.h"
#include "lldb/Target/TargetList.h"
-#include "lldb/lldb-public.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/UserID.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ScriptLanguage, Langua...
+#include "lldb/lldb-forward.h" // for StreamFileSP, DebuggerSP
+#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType
+#include "lldb/lldb-private-types.h" // for LoadPluginCallbackType
+#include "lldb/lldb-types.h" // for LogOutputCallback, thr...
+
+#include "llvm/ADT/ArrayRef.h" // for ArrayRef
+#include "llvm/ADT/StringMap.h" // for StringMap
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/DynamicLibrary.h" // for DynamicLibrary
+#include "llvm/Support/Threading.h"
+
+#include <assert.h> // for assert
+#include <stddef.h> // for size_t
+#include <stdio.h>
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class CommandInterpreter;
+}
+namespace lldb_private {
+class Process;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class Target;
+}
namespace llvm {
-namespace sys {
-class DynamicLibrary;
-} // namespace sys
-} // namespace llvm
+class raw_ostream;
+}
namespace lldb_private {
@@ -190,9 +222,10 @@ public:
void SetCloseInputOnEOF(bool b);
- bool EnableLog(const char *channel, const char **categories,
- const char *log_file, uint32_t log_options,
- Stream &error_stream);
+ bool EnableLog(llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ llvm::StringRef log_file, uint32_t log_options,
+ llvm::raw_ostream &error_stream);
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
@@ -363,9 +396,8 @@ protected:
std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
IOHandlerStack m_input_reader_stack;
- typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
- LogStreamMap m_log_streams;
- lldb::StreamSP m_log_callback_stream_sp;
+ llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams;
+ std::shared_ptr<llvm::raw_ostream> m_log_callback_stream_sp;
ConstString m_instance_name;
static LoadPluginCallbackType g_load_plugin_callback;
typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
@@ -374,7 +406,7 @@ protected:
HostThread m_io_handler_thread;
Broadcaster m_sync_broadcaster;
lldb::ListenerSP m_forward_listener_sp;
- std::once_flag m_clear_once;
+ llvm::once_flag m_clear_once;
//----------------------------------------------------------------------
// Events for m_sync_broadcaster
diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h
index c42074719b1a..929b668c092b 100644
--- a/include/lldb/Core/Disassembler.h
+++ b/include/lldb/Core/Disassembler.h
@@ -10,22 +10,68 @@
#ifndef liblldb_Disassembler_h_
#define liblldb_Disassembler_h_
-// C Includes
-// C++ Includes
-#include <string>
-#include <vector>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/EmulateInstruction.h"
+#include "lldb/Core/FormatEntity.h" // for FormatEntity
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Symbol/LineEntry.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Target/ExecutionContext.h" // for ExecutionContext
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for AddressClass, AddressClass...
+#include "lldb/lldb-forward.h" // for InstructionSP, DisassemblerSP
+#include "lldb/lldb-types.h" // for addr_t, offset_t
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <functional> // for function
+#include <map>
+#include <memory> // for enable_shared_from_this
+#include <set>
+#include <string>
+#include <vector>
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, int64_t
+#include <stdio.h> // for FILE
+
+namespace lldb_private {
+class AddressRange;
+}
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Debugger;
+}
+namespace lldb_private {
+class Disassembler;
+}
+namespace lldb_private {
+class Module;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class SymbolContextList;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+struct RegisterInfo;
+}
+namespace llvm {
+template <typename T> class SmallVectorImpl;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/DumpDataExtractor.h b/include/lldb/Core/DumpDataExtractor.h
new file mode 100644
index 000000000000..46e676c239d1
--- /dev/null
+++ b/include/lldb/Core/DumpDataExtractor.h
@@ -0,0 +1,95 @@
+//===-- DumpDataExtractor.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_CORE_DUMPDATAEXTRACTOR_H
+#define LLDB_CORE_DUMPDATAEXTRACTOR_H
+
+#include "lldb/lldb-enumerations.h" // for Format
+#include "lldb/lldb-types.h"
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
+namespace lldb_private {
+class DataExtractor;
+class ExecutionContextScope;
+class Stream;
+
+//------------------------------------------------------------------
+/// Dumps \a item_count objects into the stream \a s.
+///
+/// Dumps \a item_count objects using \a item_format, each of which
+/// are \a item_byte_size bytes long starting at offset \a offset
+/// bytes into the contained data, into the stream \a s. \a
+/// num_per_line objects will be dumped on each line before a new
+/// line will be output. If \a base_addr is a valid address, then
+/// each new line of output will be preceded by the address value
+/// plus appropriate offset, and a colon and space. Bitfield values
+/// can be dumped by calling this function multiple times with the
+/// same start offset, format and size, yet differing \a
+/// item_bit_size and \a item_bit_offset values.
+///
+/// @param[in] s
+/// The stream to dump the output to. This value can not be nullptr.
+///
+/// @param[in] offset
+/// The offset into the data at which to start dumping.
+///
+/// @param[in] item_format
+/// The format to use when dumping each item.
+///
+/// @param[in] item_byte_size
+/// The byte size of each item.
+///
+/// @param[in] item_count
+/// The number of items to dump.
+///
+/// @param[in] num_per_line
+/// The number of items to display on each line.
+///
+/// @param[in] base_addr
+/// The base address that gets added to the offset displayed on
+/// each line if the value is valid. Is \a base_addr is
+/// LLDB_INVALID_ADDRESS then no address values will be prepended
+/// to any lines.
+///
+/// @param[in] item_bit_size
+/// If the value to display is a bitfield, this value should
+/// be the number of bits that the bitfield item has within the
+/// item's byte size value. This function will need to be called
+/// multiple times with identical \a offset and \a item_byte_size
+/// values in order to display multiple bitfield values that
+/// exist within the same integer value. If the items being
+/// displayed are not bitfields, this value should be zero.
+///
+/// @param[in] item_bit_offset
+/// If the value to display is a bitfield, this value should
+/// be the offset in bits, or shift right amount, that the
+/// bitfield item occupies within the item's byte size value.
+/// This function will need to be called multiple times with
+/// identical \a offset and \a item_byte_size values in order
+/// to display multiple bitfield values that exist within the
+/// same integer value. If the items being displayed are not
+/// bitfields, this value should be zero.
+///
+/// @return
+/// The offset at which dumping ended.
+//------------------------------------------------------------------
+lldb::offset_t
+DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset,
+ lldb::Format item_format, size_t item_byte_size,
+ size_t item_count, size_t num_per_line, uint64_t base_addr,
+ uint32_t item_bit_size, uint32_t item_bit_offset,
+ ExecutionContextScope *exe_scope = nullptr);
+
+void DumpHexBytes(Stream *s, const void *src, size_t src_len,
+ uint32_t bytes_per_line, lldb::addr_t base_addr);
+}
+
+#endif
diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h
index 90e66d668ca4..bfc9ef054d7a 100644
--- a/include/lldb/Core/EmulateInstruction.h
+++ b/include/lldb/Core/EmulateInstruction.h
@@ -15,9 +15,34 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-public.h"
+
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for RegisterKind, ByteOrder
+#include "lldb/lldb-private-enumerations.h" // for InstructionType
+#include "lldb/lldb-private-types.h" // for RegisterInfo
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t, int64_t
+namespace lldb_private {
+class OptionValueDictionary;
+}
+namespace lldb_private {
+class RegisterContext;
+}
+namespace lldb_private {
+class RegisterValue;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+class UnwindPlan;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h
index 049bb3cec224..5d297a719e73 100644
--- a/include/lldb/Core/Event.h
+++ b/include/lldb/Core/Event.h
@@ -10,19 +10,28 @@
#ifndef liblldb_Event_h_
#define liblldb_Event_h_
-// C Includes
-// C++ Includes
+#include "lldb/Core/Broadcaster.h"
+#include "lldb/Core/StructuredData.h"
+#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct...
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
#include <chrono>
#include <memory>
#include <string>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/StructuredData.h"
-#include "lldb/Host/Predicate.h"
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class Event;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h
index e9e20c59f93f..54bce4fd2f41 100644
--- a/include/lldb/Core/FileLineResolver.h
+++ b/include/lldb/Core/FileLineResolver.h
@@ -10,9 +10,19 @@
#ifndef liblldb_FileLineResolver_h_
#define liblldb_FileLineResolver_h_
-// Project includes
-#include "lldb/Core/AddressResolver.h"
+#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR...
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+
+#include <stdint.h> // for uint32_t, UINT32_MAX
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h
index 75995d1ca9fb..3cbffca44f69 100644
--- a/include/lldb/Core/FileSpecList.h
+++ b/include/lldb/Core/FileSpecList.h
@@ -11,10 +11,16 @@
#define liblldb_FileSpecList_h_
#if defined(__cplusplus)
-#include "lldb/Host/FileSpec.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/FileSpec.h"
+
#include <vector>
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class Stream;
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h
index b6fe9ea46bfc..6705c155cefc 100644
--- a/include/lldb/Core/FormatEntity.h
+++ b/include/lldb/Core/FormatEntity.h
@@ -10,19 +10,38 @@
#ifndef liblldb_FormatEntity_h_
#define liblldb_FormatEntity_h_
-// C Includes
-// C++ Includes
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format
+#include "lldb/lldb-types.h" // for addr_t
+#include <algorithm> // for min
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/lldb-private.h"
-
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class ExecutionContext;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class StringList;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class ValueObject;
+}
namespace llvm {
class StringRef;
-} // namespace llvm
+}
namespace lldb_private {
class FormatEntity {
diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h
index 2e6ff31ee687..ebf56d7908b4 100644
--- a/include/lldb/Core/IOHandler.h
+++ b/include/lldb/Core/IOHandler.h
@@ -10,26 +10,27 @@
#ifndef liblldb_IOHandler_h_
#define liblldb_IOHandler_h_
-// C Includes
-#include <string.h>
+#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-forward.h" // for IOHandlerSP, StreamFileSP
+#include "llvm/ADT/StringRef.h" // for StringRef
-// C++ Includes
#include <memory>
#include <mutex>
#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Host/Predicate.h"
-#include "lldb/lldb-enumerations.h"
-#include "lldb/lldb-public.h"
+#include <stdint.h> // for uint32_t
+#include <stdio.h> // for FILE
+
+namespace lldb_private {
+class Debugger;
+}
namespace curses {
class Application;
diff --git a/include/lldb/Core/Listener.h b/include/lldb/Core/Listener.h
index b82844eabbb8..3d12f8fb3391 100644
--- a/include/lldb/Core/Listener.h
+++ b/include/lldb/Core/Listener.h
@@ -10,20 +10,29 @@
#ifndef liblldb_Select_h_
#define liblldb_Select_h_
-// C Includes
-// C++ Includes
-#include <chrono>
+#include "lldb/Core/Broadcaster.h" // for Broadcaster::BroadcasterImplWP
+#include "lldb/Utility/Timeout.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-forward.h" // for BroadcasterManagerWP, EventSP
+
+#include <condition_variable>
#include <list>
#include <map>
+#include <memory> // for owner_less, enable_shared_from_this
#include <mutex>
+#include <ratio> // for micro
#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Event.h"
-#include "lldb/Utility/Timeout.h"
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class Event;
+}
namespace lldb_private {
@@ -39,8 +48,7 @@ public:
//------------------------------------------------------------------
//
// Listeners have to be constructed into shared pointers - at least if you
- // want them to listen to
- // Broadcasters,
+ // want them to listen to Broadcasters,
protected:
Listener(const char *name);
diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h
deleted file mode 100644
index d87c263a427c..000000000000
--- a/include/lldb/Core/Log.h
+++ /dev/null
@@ -1,189 +0,0 @@
-//===-- Log.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_Log_h_
-#define liblldb_Log_h_
-
-// C Includes
-#include <signal.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/Logging.h"
-#include "lldb/Core/PluginInterface.h"
-#include "lldb/lldb-private.h"
-
-#include "llvm/Support/FormatVariadic.h"
-
-//----------------------------------------------------------------------
-// Logging Options
-//----------------------------------------------------------------------
-#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
-#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
-#define LLDB_LOG_OPTION_DEBUG (1u << 2)
-#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
-#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
-#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
-#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
-#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
-#define LLDB_LOG_OPTION_APPEND (1U << 8)
-
-//----------------------------------------------------------------------
-// Logging Functions
-//----------------------------------------------------------------------
-namespace lldb_private {
-
-class Log final {
-public:
- //------------------------------------------------------------------
- // Callback definitions for abstracted plug-in log access.
- //------------------------------------------------------------------
- typedef void (*DisableCallback)(const char **categories,
- Stream *feedback_strm);
- typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp,
- uint32_t log_options, const char **categories,
- Stream *feedback_strm);
- typedef void (*ListCategoriesCallback)(Stream *strm);
-
- struct Callbacks {
- DisableCallback disable;
- EnableCallback enable;
- ListCategoriesCallback list_categories;
- };
-
- //------------------------------------------------------------------
- // Static accessors for logging channels
- //------------------------------------------------------------------
- static void RegisterLogChannel(const ConstString &channel,
- const Log::Callbacks &log_callbacks);
-
- static bool UnregisterLogChannel(const ConstString &channel);
-
- static bool GetLogChannelCallbacks(const ConstString &channel,
- Log::Callbacks &log_callbacks);
-
- static bool EnableLogChannel(lldb::StreamSP &log_stream_sp,
- uint32_t log_options, const char *channel,
- const char **categories, Stream &error_stream);
-
- static void EnableAllLogChannels(lldb::StreamSP &log_stream_sp,
- uint32_t log_options,
- const char **categories,
- Stream *feedback_strm);
-
- static void DisableAllLogChannels(Stream *feedback_strm);
-
- static void ListAllLogChannels(Stream *strm);
-
- static void Initialize();
-
- static void Terminate();
-
- //------------------------------------------------------------------
- // Auto completion
- //------------------------------------------------------------------
- static void AutoCompleteChannelName(const char *channel_name,
- StringList &matches);
-
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- Log();
-
- Log(const lldb::StreamSP &stream_sp);
-
- ~Log();
-
- void PutCString(const char *cstr);
- void PutString(llvm::StringRef str);
-
- template <typename... Args> void Format(const char *fmt, Args &&... args) {
- PutString(llvm::formatv(fmt, std::forward<Args>(args)...).str());
- }
-
- // CLEANUP: Add llvm::raw_ostream &Stream() function.
- void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
-
- void VAPrintf(const char *format, va_list args);
-
- void LogIf(uint32_t mask, const char *fmt, ...)
- __attribute__((format(printf, 3, 4)));
-
- void Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
- void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
- void VAError(const char *format, va_list args);
-
- void Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
- void Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
- Flags &GetOptions();
-
- const Flags &GetOptions() const;
-
- Flags &GetMask();
-
- const Flags &GetMask() const;
-
- bool GetVerbose() const;
-
- bool GetDebug() const;
-
- void SetStream(const lldb::StreamSP &stream_sp) { m_stream_sp = stream_sp; }
-
-protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::StreamSP m_stream_sp;
- Flags m_options;
- Flags m_mask_bits;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(Log);
-};
-
-class LogChannel : public PluginInterface {
-public:
- LogChannel();
-
- ~LogChannel() override;
-
- static lldb::LogChannelSP FindPlugin(const char *plugin_name);
-
- // categories is an array of chars that ends with a NULL element.
- virtual void Disable(const char **categories, Stream *feedback_strm) = 0;
-
- virtual bool
- Enable(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- Stream *feedback_strm, // Feedback stream for argument errors etc
- const char **categories) = 0; // The categories to enable within this
- // logging stream, if empty, enable
- // default set
-
- virtual void ListCategories(Stream *strm) = 0;
-
-protected:
- std::unique_ptr<Log> m_log_ap;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(LogChannel);
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_Log_h_
diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h
index 4170b708013e..22778fabe63d 100644
--- a/include/lldb/Core/Mangled.h
+++ b/include/lldb/Core/Mangled.h
@@ -11,9 +11,18 @@
#define liblldb_Mangled_h_
#if defined(__cplusplus)
-#include "lldb/Core/ConstString.h"
-#include "lldb/lldb-private.h"
-#include <vector>
+#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-enumerations.h" // for LanguageType
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class RegularExpression;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h
index 842a116d07a8..cab98ee5b302 100644
--- a/include/lldb/Core/MappedHash.h
+++ b/include/lldb/Core/MappedHash.h
@@ -22,8 +22,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
class MappedHash {
public:
@@ -353,7 +353,7 @@ public:
bool IsValid() const {
return m_header.version == 1 &&
m_header.hash_function == eHashFunctionDJB &&
- m_header.bucket_count > 0 && m_header.hashes_count > 0;
+ m_header.bucket_count > 0;
}
uint32_t GetHashIndex(uint32_t bucket_idx) const {
diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h
index 90d75b623732..ca47a38a2ef5 100644
--- a/include/lldb/Core/Module.h
+++ b/include/lldb/Core/Module.h
@@ -10,29 +10,86 @@
#ifndef liblldb_Module_h_
#define liblldb_Module_h_
-#include "lldb/Symbol/SymbolContextScope.h"
-
-// Project includes
+#include "lldb/Core/Address.h" // for Address
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Core/ModuleSpec.h" // for ModuleSpec
+#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for LanguageType, SymbolType
#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h" // for addr_t, offset_t
-// Other libraries and framework includes
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Chrono.h"
-// C Includes
-// C++ Includes
#include <atomic>
+#include <memory> // for enable_shared_from_this
#include <mutex>
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
#include <string>
#include <vector>
namespace lldb_private {
+class CompilerDeclContext;
+}
+namespace lldb_private {
+class Function;
+}
+namespace lldb_private {
+class Log;
+}
+namespace lldb_private {
+class ObjectFile;
+}
+namespace lldb_private {
+class RegularExpression;
+}
+namespace lldb_private {
+class SectionList;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Symbol;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class SymbolContextList;
+}
+namespace lldb_private {
+class SymbolFile;
+}
+namespace lldb_private {
+class SymbolVendor;
+}
+namespace lldb_private {
+class Symtab;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+class TypeList;
+}
+namespace lldb_private {
+class TypeMap;
+}
+namespace lldb_private {
+class VariableList;
+}
+
+namespace lldb_private {
//----------------------------------------------------------------------
/// @class Module Module.h "lldb/Core/Module.h"
@@ -962,6 +1019,20 @@ public:
bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
bool RemapSourceFile(const char *, std::string &) const = delete;
+ //------------------------------------------------------------------
+ /// Loads this module to memory.
+ ///
+ /// Loads the bits needed to create an executable image to the memory.
+ /// It is useful with bare-metal targets where target does not have the
+ /// ability to start a process itself.
+ ///
+ /// @param[in] target
+ /// Target where to load the module.
+ ///
+ /// @return
+ //------------------------------------------------------------------
+ Error LoadInMemory(Target &target, bool set_pc);
+
//----------------------------------------------------------------------
/// @class LookupInfo Module.h "lldb/Core/Module.h"
/// @brief A class that encapsulates name lookup information.
diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h
index f47c5ca135e6..8f2985c8185b 100644
--- a/include/lldb/Core/ModuleChild.h
+++ b/include/lldb/Core/ModuleChild.h
@@ -10,7 +10,7 @@
#ifndef liblldb_ModuleChild_h_
#define liblldb_ModuleChild_h_
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h
index 4aa16740bd74..d82d1c0d48d8 100644
--- a/include/lldb/Core/ModuleList.h
+++ b/include/lldb/Core/ModuleList.h
@@ -10,18 +10,67 @@
#ifndef liblldb_ModuleList_h_
#define liblldb_ModuleList_h_
-// C Includes
-// C++ Includes
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/ModuleSpec.h" // for ModuleSpec
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
+
+#include "llvm/ADT/DenseSet.h"
+
#include <functional>
#include <list>
#include <mutex>
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Utility/Iterable.h"
-#include "lldb/lldb-private.h"
-#include "llvm/ADT/DenseSet.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class FileSpecList;
+}
+namespace lldb_private {
+class Function;
+}
+namespace lldb_private {
+class Log;
+}
+namespace lldb_private {
+class Module;
+}
+namespace lldb_private {
+class RegularExpression;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class SymbolContextList;
+}
+namespace lldb_private {
+class SymbolFile;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+class TypeList;
+}
+namespace lldb_private {
+class UUID;
+}
+namespace lldb_private {
+class VariableList;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h
index 6a9e60482b91..ce851d8af5fc 100644
--- a/include/lldb/Core/ModuleSpec.h
+++ b/include/lldb/Core/ModuleSpec.h
@@ -12,10 +12,10 @@
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/UUID.h"
// Other libraries and framework includes
#include "llvm/Support/Chrono.h"
diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h
index d5376d44b814..33857457b2c4 100644
--- a/include/lldb/Core/Opcode.h
+++ b/include/lldb/Core/Opcode.h
@@ -10,20 +10,25 @@
#ifndef lldb_Opcode_h
#define lldb_Opcode_h
-// C Includes
-#include <string.h>
+#include "lldb/Utility/Endian.h"
+#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eByteOrde...
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/Support/MathExtras.h"
-// Project includes
-#include "lldb/Host/Endian.h"
-#include "lldb/lldb-public.h"
+#include <assert.h> // for assert
+#include <stdint.h> // for uint32_t, uint8_t, uint16_t
+#include <string.h>
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb {
class SBInstruction;
-} // namespace lldb
+}
namespace lldb_private {
diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h
index e0de65a6bf16..645ab85eaa7e 100644
--- a/include/lldb/Core/PluginManager.h
+++ b/include/lldb/Core/PluginManager.h
@@ -10,13 +10,28 @@
#ifndef liblldb_PluginManager_h_
#define liblldb_PluginManager_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Host/FileSpec.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-enumerations.h" // for ScriptLanguage
+#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP
+#include "lldb/lldb-private-interfaces.h" // for DebuggerInitializeCallback
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class CommandInterpreter;
+}
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class Debugger;
+}
+namespace lldb_private {
+class StringList;
+}
namespace lldb_private {
class PluginManager {
@@ -210,22 +225,6 @@ public:
GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
//------------------------------------------------------------------
- // LogChannel
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
- LogChannelCreateInstance create_callback);
-
- static bool UnregisterPlugin(LogChannelCreateInstance create_callback);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackAtIndex(uint32_t idx);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackForPluginName(const ConstString &name);
-
- static const char *GetLogChannelCreateNameAtIndex(uint32_t idx);
-
- //------------------------------------------------------------------
// Platform
//------------------------------------------------------------------
static bool
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h
index 73a949fcd25f..e37dcd7df443 100644
--- a/include/lldb/Core/RangeMap.h
+++ b/include/lldb/Core/RangeMap.h
@@ -59,6 +59,18 @@ template <typename B, typename S> struct Range {
void Slide(BaseType slide) { base += slide; }
+ bool Union(const Range &rhs)
+ {
+ if (DoesAdjoinOrIntersect(rhs))
+ {
+ auto new_end = std::max<BaseType>(GetRangeEnd(), rhs.GetRangeEnd());
+ base = std::min<BaseType>(base, rhs.base);
+ size = new_end - base;
+ return true;
+ }
+ return false;
+ }
+
BaseType GetRangeEnd() const { return base + size; }
void SetRangeEnd(BaseType end) {
@@ -348,7 +360,33 @@ public:
void Append(B base, S size) { m_entries.emplace_back(base, size); }
- bool RemoveEntrtAtIndex(uint32_t idx) {
+ // Insert an item into a sorted list and optionally combine it with any
+ // adjacent blocks if requested.
+ void Insert(const Entry &entry, bool combine) {
+ if (m_entries.empty()) {
+ m_entries.push_back(entry);
+ return;
+ }
+ auto begin = m_entries.begin();
+ auto end = m_entries.end();
+ auto pos = std::lower_bound(begin, end, entry);
+ if (combine) {
+ if (pos != end && pos->Union(entry)) {
+ CombinePrevAndNext(pos);
+ return;
+ }
+ if (pos != begin) {
+ auto prev = pos - 1;
+ if (prev->Union(entry)) {
+ CombinePrevAndNext(prev);
+ return;
+ }
+ }
+ }
+ m_entries.insert(pos, entry);
+ }
+
+ bool RemoveEntryAtIndex(uint32_t idx) {
if (idx < m_entries.size()) {
m_entries.erase(m_entries.begin() + idx);
return true;
@@ -458,6 +496,7 @@ public:
// Clients must ensure that "i" is a valid index prior to calling this
// function
+ Entry &GetEntryRef(size_t i) { return m_entries[i]; }
const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
@@ -538,6 +577,28 @@ public:
}
protected:
+
+ void CombinePrevAndNext(typename Collection::iterator pos) {
+ // Check if the prev or next entries in case they need to be unioned with
+ // the entry pointed to by "pos".
+ if (pos != m_entries.begin()) {
+ auto prev = pos - 1;
+ if (prev->Union(*pos))
+ m_entries.erase(pos);
+ pos = prev;
+ }
+
+ auto end = m_entries.end();
+ if (pos != end) {
+ auto next = pos + 1;
+ if (next != end) {
+ if (pos->Union(*next))
+ m_entries.erase(next);
+ }
+ }
+ return;
+ }
+
Collection m_entries;
};
diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h
index 78dfbea97032..66c4689d702d 100644
--- a/include/lldb/Core/RegisterValue.h
+++ b/include/lldb/Core/RegisterValue.h
@@ -10,20 +10,28 @@
#ifndef lldb_RegisterValue_h
#define lldb_RegisterValue_h
-// C Includes
-#include <string.h>
+#include "lldb/Core/Scalar.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-enumerations.h" // for ByteOrder, Format
+#include "lldb/lldb-types.h" // for offset_t
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/StringRef.h" // for StringRef
-// Project includes
-#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-public.h"
+#include <stdint.h> // for uint32_t, uint8_t, uint64_t, uin...
+#include <string.h>
namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+struct RegisterInfo;
+}
+namespace lldb_private {
class RegisterValue {
public:
diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h
index cee257711c5f..c534044af753 100644
--- a/include/lldb/Core/Scalar.h
+++ b/include/lldb/Core/Scalar.h
@@ -10,10 +10,23 @@
#ifndef liblldb_Scalar_h_
#define liblldb_Scalar_h_
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-enumerations.h" // for Encoding, ByteOrder
+#include "lldb/lldb-private-types.h" // for type128
+
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t, int64_t
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Stream;
+}
+
#define NUM_OF_WORDS_INT128 2
#define BITWIDTH_INT128 128
#define NUM_OF_WORDS_INT256 4
diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h
index 6b3a79e99520..829305ff5dee 100644
--- a/include/lldb/Core/SearchFilter.h
+++ b/include/lldb/Core/SearchFilter.h
@@ -10,13 +10,44 @@
#ifndef liblldb_SearchFilter_h_
#define liblldb_SearchFilter_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/lldb-private.h"
+
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/lldb-forward.h" // for SearchFilterSP, TargetSP, Modu...
+
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class Breakpoint;
+}
+namespace lldb_private {
+class CompileUnit;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class Function;
+}
+namespace lldb_private {
+class ModuleList;
+}
+namespace lldb_private {
+class SearchFilter;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class Target;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h
index 5afaa11359db..a133298edaf3 100644
--- a/include/lldb/Core/Section.h
+++ b/include/lldb/Core/Section.h
@@ -10,16 +10,39 @@
#ifndef liblldb_Section_h_
#define liblldb_Section_h_
-#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Flags.h"
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/RangeMap.h"
-#include "lldb/Core/UserID.h"
-#include "lldb/Core/VMRange.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/lldb-private.h"
-#include <limits.h>
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/UserID.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for SectionType
+#include "lldb/lldb-forward.h" // for SectionSP, ModuleSP, SectionWP
+#include "lldb/lldb-types.h" // for addr_t, offset_t, user_id_t
+
+#include <memory> // for enable_shared_from_this
+#include <vector> // for vector
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, UINT32_MAX
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class ObjectFile;
+}
+namespace lldb_private {
+class Section;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Target;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h
index 9ca2a3297230..053badf64ddc 100644
--- a/include/lldb/Core/SourceManager.h
+++ b/include/lldb/Core/SourceManager.h
@@ -10,20 +10,33 @@
#ifndef liblldb_SourceManager_h_
#define liblldb_SourceManager_h_
-// Project includes
-#include "lldb/Host/FileSpec.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-forward.h" // for DebuggerSP, DebuggerWP, DataBufferSP
-// Other libraries and framework includes
#include "llvm/Support/Chrono.h"
-// C Includes
-// C++ Includes
+#include <cstdint> // for uint32_t, UINT32_MAX
#include <map>
#include <memory>
+#include <stddef.h> // for size_t
+#include <string> // for string
#include <vector>
namespace lldb_private {
+class RegularExpression;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContextList;
+}
+namespace lldb_private {
+class Target;
+}
+
+namespace lldb_private {
class SourceManager {
public:
diff --git a/include/lldb/Core/State.h b/include/lldb/Core/State.h
index a9d7692ca458..68f0fee254b3 100644
--- a/include/lldb/Core/State.h
+++ b/include/lldb/Core/State.h
@@ -10,11 +10,13 @@
#ifndef liblldb_State_h_
#define liblldb_State_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
+#include "llvm/Support/FormatProviders.h"
+
+#include "lldb/lldb-enumerations.h" // for StateType
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/raw_ostream.h" // for raw_ostream
+
+#include <stdint.h> // for uint32_t
namespace lldb_private {
@@ -71,4 +73,13 @@ const char *GetPermissionsAsCString(uint32_t permissions);
} // namespace lldb_private
+namespace llvm {
+template <> struct format_provider<lldb::StateType> {
+ static void format(const lldb::StateType &state, raw_ostream &Stream,
+ StringRef Style) {
+ Stream << lldb_private::StateAsCString(state);
+ }
+};
+}
+
#endif // liblldb_State_h_
diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h
index b3bb49e16e35..29b109757da7 100644
--- a/include/lldb/Core/StreamAsynchronousIO.h
+++ b/include/lldb/Core/StreamAsynchronousIO.h
@@ -1,5 +1,4 @@
-//===-- StreamAsynchronousIO.h -----------------------------------*- C++
-//-*-===//
+//===-- StreamAsynchronousIO.h -----------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,9 +10,15 @@
#ifndef liblldb_StreamAsynchronousIO_h_
#define liblldb_StreamAsynchronousIO_h_
+#include "lldb/Utility/Stream.h"
+
#include <string>
-#include "lldb/Core/Stream.h"
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class Debugger;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h
index 4eef19ff29f7..3b18573021b3 100644
--- a/include/lldb/Core/StreamBuffer.h
+++ b/include/lldb/Core/StreamBuffer.h
@@ -10,7 +10,7 @@
#ifndef liblldb_StreamBuffer_h_
#define liblldb_StreamBuffer_h_
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallVector.h"
#include <stdio.h>
#include <string>
diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h
index 8b860321b6b7..a26ae84c7be5 100644
--- a/include/lldb/Core/StreamFile.h
+++ b/include/lldb/Core/StreamFile.h
@@ -10,16 +10,13 @@
#ifndef liblldb_StreamFile_h_
#define liblldb_StreamFile_h_
-// C Includes
-// C++ Includes
-
-#include <string>
-
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/Stream.h"
#include "lldb/Host/File.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermission...
+
+#include <stdint.h> // for uint32_t
+#include <stdio.h> // for size_t, FILE
namespace lldb_private {
diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Core/StructuredData.h
index efd8100f1185..eecfd86f7988 100644
--- a/include/lldb/Core/StructuredData.h
+++ b/include/lldb/Core/StructuredData.h
@@ -10,22 +10,29 @@
#ifndef liblldb_StructuredData_h_
#define liblldb_StructuredData_h_
-// C Includes
-// C++ Includes
+#include "llvm/ADT/StringRef.h"
+
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+
#include <functional>
#include <map>
#include <memory>
#include <string>
+#include <type_traits> // for move
#include <utility>
#include <vector>
-// Other libraries and framework includes
-#include "llvm/ADT/StringRef.h"
+#include <assert.h> // for assert
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint64_t
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/lldb-defines.h"
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
@@ -368,13 +375,12 @@ public:
}
ObjectSP GetKeys() const {
- ObjectSP object_sp(new Array());
- Array *array = object_sp->GetAsArray();
+ auto object_sp = std::make_shared<Array>();
collection::const_iterator iter;
for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
- ObjectSP key_object_sp(new String());
- key_object_sp->GetAsString()->SetValue(iter->first.AsCString());
- array->Push(key_object_sp);
+ auto key_object_sp = std::make_shared<String>();
+ key_object_sp->SetValue(iter->first.AsCString());
+ object_sp->Push(key_object_sp);
}
return object_sp;
}
@@ -500,19 +506,19 @@ public:
}
void AddIntegerItem(llvm::StringRef key, uint64_t value) {
- AddItem(key, ObjectSP(new Integer(value)));
+ AddItem(key, std::make_shared<Integer>(value));
}
void AddFloatItem(llvm::StringRef key, double value) {
- AddItem(key, ObjectSP(new Float(value)));
+ AddItem(key, std::make_shared<Float>(value));
}
void AddStringItem(llvm::StringRef key, std::string value) {
- AddItem(key, ObjectSP(new String(std::move(value))));
+ AddItem(key, std::make_shared<String>(std::move(value)));
}
void AddBooleanItem(llvm::StringRef key, bool value) {
- AddItem(key, ObjectSP(new Boolean(value)));
+ AddItem(key, std::make_shared<Boolean>(value));
}
void Dump(Stream &s, bool pretty_print = true) const override;
diff --git a/include/lldb/Core/Timer.h b/include/lldb/Core/Timer.h
index 854d3c31f54f..6da00b0e27a4 100644
--- a/include/lldb/Core/Timer.h
+++ b/include/lldb/Core/Timer.h
@@ -10,18 +10,16 @@
#ifndef liblldb_Timer_h_
#define liblldb_Timer_h_
-// C Includes
-#include <stdarg.h>
-#include <stdio.h>
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "llvm/Support/Chrono.h"
-// C++ Includes
#include <atomic>
-#include <mutex>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
-#include "llvm/Support/Chrono.h"
+#include <stdint.h> // for uint32_t
+
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h
index 77a350aaea15..1475fdaa74d9 100644
--- a/include/lldb/Core/UniqueCStringMap.h
+++ b/include/lldb/Core/UniqueCStringMap.h
@@ -17,7 +17,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Utility/RegularExpression.h"
+
+#include "llvm/ADT/StringRef.h"
namespace lldb_private {
diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h
index a30dfd45121b..0207187f0718 100644
--- a/include/lldb/Core/UserSettingsController.h
+++ b/include/lldb/Core/UserSettingsController.h
@@ -10,21 +10,32 @@
#ifndef liblldb_UserSettingsController_h_
#define liblldb_UserSettingsController_h_
-// C Includes
-// C++ Includes
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP
+#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType
+
+#include "llvm/ADT/StringRef.h" // for StringRef
-#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Interpreter/OptionValue.h"
-#include "lldb/lldb-private.h"
+namespace lldb_private {
+class CommandInterpreter;
+}
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class ExecutionContext;
+}
+namespace lldb_private {
+class Property;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h
index 2800c4f20996..9a667cf65752 100644
--- a/include/lldb/Core/Value.h
+++ b/include/lldb/Core/Value.h
@@ -10,17 +10,39 @@
#ifndef liblldb_Value_h_
#define liblldb_Value_h_
-// C Includes
-// C++ Includes
-#include <vector>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eB...
+#include "lldb/lldb-private-enumerations.h" // for AddressType
+#include "lldb/lldb-private-types.h" // for type128, RegisterInfo
+
+#include "llvm/ADT/APInt.h" // for APInt
+
+#include <vector>
+
+#include <stdint.h> // for uint8_t, uint32_t, uint64_t
+#include <string.h> // for size_t, memcpy
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class ExecutionContext;
+}
+namespace lldb_private {
+class Module;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class Type;
+}
+namespace lldb_private {
+class Variable;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index 84b187e54b6c..1c923f317b7c 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -10,32 +10,67 @@
#ifndef liblldb_ValueObject_h_
#define liblldb_ValueObject_h_
-// C Includes
-// C++ Includes
-#include <functional>
-#include <initializer_list>
-#include <map>
-#include <vector>
-
-// Other libraries and framework includes
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallVector.h"
-
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Core/Value.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/Type.h" // for TypeImpl
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/StackID.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/SharedCluster.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/UserID.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID...
+#include "lldb/lldb-enumerations.h" // for DynamicValue...
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/lldb-private-enumerations.h" // for AddressType
+#include "lldb/lldb-types.h" // for addr_t, offs...
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include <functional>
+#include <initializer_list>
+#include <map>
+#include <mutex> // for recursive_mutex
+#include <string> // for string
+#include <utility> // for pair
+#include <vector>
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
+namespace lldb_private {
+class Declaration;
+}
+namespace lldb_private {
+class EvaluateExpressionOptions;
+}
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class Log;
+}
+namespace lldb_private {
+class Scalar;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolContextScope;
+}
+namespace lldb_private {
+class TypeFormatImpl;
+}
+namespace lldb_private {
+class TypeSummaryImpl;
+}
+namespace lldb_private {
+class TypeSummaryOptions;
+}
namespace lldb_private {
/// ValueObject:
@@ -552,6 +587,9 @@ public:
lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
+ // Change the name of the current ValueObject. Should *not* be used from a
+ // synthetic child provider as it would change the name of the non synthetic
+ // child as well.
void SetName(const ConstString &name);
virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
@@ -600,6 +638,12 @@ public:
virtual lldb::ValueObjectSP Dereference(Error &error);
+ // Creates a copy of the ValueObject with a new name and setting the current
+ // ValueObject as its parent. It should be used when we want to change the
+ // name of a ValueObject without modifying the actual ValueObject itself
+ // (e.g. sythetic child provider).
+ virtual lldb::ValueObjectSP Clone(const ConstString &new_name);
+
virtual lldb::ValueObjectSP AddressOf(Error &error);
virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }
diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h
index 50959b927e70..aaa1ecb67db8 100644
--- a/include/lldb/Core/ValueObjectCast.h
+++ b/include/lldb/Core/ValueObjectCast.h
@@ -10,11 +10,18 @@
#ifndef liblldb_ValueObjectCast_h_
#define liblldb_ValueObjectCast_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ValueType
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
+namespace lldb_private {
+class ConstString;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h
index b84cb3dfa216..ec8c9e805cdf 100644
--- a/include/lldb/Core/ValueObjectChild.h
+++ b/include/lldb/Core/ValueObjectChild.h
@@ -10,14 +10,20 @@
#ifndef liblldb_ValueObjectChild_h_
#define liblldb_ValueObjectChild_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ValueType
+#include "lldb/lldb-private-enumerations.h" // for LazyBool, AddressType
+#include "lldb/lldb-types.h" // for offset_t
+
#include "llvm/ADT/Optional.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t, int32_t
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h
index 994ac477bf2e..403d19324c46 100644
--- a/include/lldb/Core/ValueObjectConstResult.h
+++ b/include/lldb/Core/ValueObjectConstResult.h
@@ -10,15 +10,31 @@
#ifndef liblldb_ValueObjectConstResult_h_
#define liblldb_ValueObjectConstResult_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Core/Value.h" // for Value
#include "lldb/Core/ValueObject.h"
-
#include "lldb/Core/ValueObjectConstResultImpl.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-enumerations.h" // for ByteOrder, Dynamic...
+#include "lldb/lldb-forward.h" // for ValueObjectSP, Dat...
+#include "lldb/lldb-private-enumerations.h" // for AddressType, Addre...
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class Module;
+}
+namespace lldb_private {
//----------------------------------------------------------------------
// A frozen ValueObject copied into host memory
diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h
index 4b2a3e2fb9b0..3443bfb4885b 100644
--- a/include/lldb/Core/ValueObjectConstResultCast.h
+++ b/include/lldb/Core/ValueObjectConstResultCast.h
@@ -10,12 +10,26 @@
#ifndef liblldb_ValueObjectConstResultCast_h_
#define liblldb_ValueObjectConstResultCast_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObjectCast.h"
#include "lldb/Core/ValueObjectConstResultImpl.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_...
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, int32_t
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ValueObject;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h
index 66127b94b422..3da59dc2eb56 100644
--- a/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/include/lldb/Core/ValueObjectConstResultChild.h
@@ -1,5 +1,4 @@
-//===-- ValueObjectConstResultChild.h -------------------------------*- C++
-//-*-===//
+//===-- ValueObjectConstResultChild.h ----------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,12 +10,25 @@
#ifndef liblldb_ValueObjectConstResultChild_h_
#define liblldb_ValueObjectConstResultChild_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObjectChild.h"
#include "lldb/Core/ValueObjectConstResultImpl.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_...
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, int32_t
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ValueObject;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h
index c26bf419b18e..2586aab4c781 100644
--- a/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -10,11 +10,26 @@
#ifndef liblldb_ValueObjectConstResultImpl_h_
#define liblldb_ValueObjectConstResultImpl_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ValueObject.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/lldb-private-enumerations.h" // for AddressType, AddressType...
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, int32_t
+namespace lldb_private {
+class CompilerType;
+}
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ValueObject;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h
index e58e74f534aa..99eb1ebcf977 100644
--- a/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/include/lldb/Core/ValueObjectDynamicValue.h
@@ -10,13 +10,30 @@
#ifndef liblldb_ValueObjectDynamicValue_h_
#define liblldb_ValueObjectDynamicValue_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Core/Address.h" // for Address
#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
#include "lldb/Symbol/Type.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/SharingPtr.h" // for operator==
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua...
+#include "lldb/lldb-forward.h" // for ValueObjectSP, VariableSP
+#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz...
+#include <assert.h> // for assert
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint64_t, uint32_t
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Declaration;
+}
+namespace lldb_private {
+class Error;
+}
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h
index c5427c6a846e..a0d2e681dedb 100644
--- a/include/lldb/Core/ValueObjectList.h
+++ b/include/lldb/Core/ValueObjectList.h
@@ -10,15 +10,16 @@
#ifndef liblldb_ValueObjectList_h_
#define liblldb_ValueObjectList_h_
-// C Includes
-// C++ Includes
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "lldb/lldb-types.h" // for user_id_t
+
#include <vector>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/UserID.h"
-#include "lldb/Target/ExecutionContextScope.h"
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class ValueObject;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h
index f9891c41cec6..8bb649cc3c52 100644
--- a/include/lldb/Core/ValueObjectMemory.h
+++ b/include/lldb/Core/ValueObjectMemory.h
@@ -10,12 +10,21 @@
#ifndef liblldb_ValueObjectMemory_h_
#define liblldb_ValueObjectMemory_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Core/Address.h" // for Address
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ValueType
+#include "lldb/lldb-forward.h" // for TypeSP, ValueObjectSP, ModuleSP
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
+namespace lldb_private {
+class ExecutionContextScope;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h
index 11d205430af8..50d0e12bb3f4 100644
--- a/include/lldb/Core/ValueObjectRegister.h
+++ b/include/lldb/Core/ValueObjectRegister.h
@@ -10,13 +10,33 @@
#ifndef liblldb_ValueObjectRegister_h_
#define liblldb_ValueObjectRegister_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ValueType, ValueType::eValueTy...
+#include "lldb/lldb-forward.h" // for RegisterContextSP, ValueObjectSP
+#include "lldb/lldb-private-types.h" // for RegisterInfo, RegisterSet (ptr...
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t, int32_t
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class Scalar;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h
index 0a5a4d9f7029..d83f038744e5 100644
--- a/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -10,17 +10,31 @@
#ifndef liblldb_ValueObjectSyntheticFilter_h_
#define liblldb_ValueObjectSyntheticFilter_h_
-// C Includes
-// C++ Includes
-#include <memory>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ThreadSafeSTLMap.h"
#include "lldb/Core/ThreadSafeSTLVector.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for ThreadSafeSTLMap::operator=
+#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua...
+#include "lldb/lldb-forward.h" // for ValueObjectSP, Synthetic...
+#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz...
+
+#include <cstdint> // for uint32_t, uint64_t
+#include <memory>
+
+#include <stddef.h> // for size_t
namespace lldb_private {
+class Declaration;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class SyntheticChildrenFrontEnd;
+}
+namespace lldb_private {
//----------------------------------------------------------------------
// A ValueObject that obtains its children from some source other than
diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h
index b76c48a24cd9..dbb7c2b9483e 100644
--- a/include/lldb/Core/ValueObjectVariable.h
+++ b/include/lldb/Core/ValueObjectVariable.h
@@ -10,12 +10,34 @@
#ifndef liblldb_ValueObjectVariable_h_
#define liblldb_ValueObjectVariable_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/Value.h" // for Value
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ValueType
+#include "lldb/lldb-forward.h" // for VariableSP, ModuleSP, ValueObj...
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Declaration;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class SymbolContextScope;
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h
index 7a632d64c8e9..343099bf2a7b 100644
--- a/include/lldb/DataFormatters/DataVisualization.h
+++ b/include/lldb/DataFormatters/DataVisualization.h
@@ -15,9 +15,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h
index b510a3c50311..00baea77f793 100644
--- a/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -27,7 +27,7 @@ namespace lldb_private {
class DumpValueObjectOptions {
public:
struct PointerDepth {
- enum class Mode { Always, Formatters, Default, Never } m_mode;
+ enum class Mode { Always, Default, Never } m_mode;
uint32_t m_count;
PointerDepth operator--() const {
@@ -37,9 +37,6 @@ public:
}
bool CanAllowExpansion() const;
-
- bool CanAllowExpansion(bool is_root, TypeSummaryImpl *entry,
- ValueObject *valobj, const std::string &summary);
};
struct PointerAsArraySettings {
diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h
index ab369a1f0453..9901ec91ebd2 100644
--- a/include/lldb/DataFormatters/FormatCache.h
+++ b/include/lldb/DataFormatters/FormatCache.h
@@ -18,7 +18,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-public.h"
namespace lldb_private {
diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h
index e43209969dd0..2df5bf4efcfb 100644
--- a/include/lldb/DataFormatters/FormattersContainer.h
+++ b/include/lldb/DataFormatters/FormattersContainer.h
@@ -22,7 +22,6 @@
// Project includes
#include "lldb/lldb-public.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/TypeFormat.h"
@@ -30,6 +29,7 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/DataFormatters/TypeValidator.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/StringLexer.h"
namespace lldb_private {
diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h
index 43329466a9a4..8d4a099fbec9 100644
--- a/include/lldb/DataFormatters/StringPrinter.h
+++ b/include/lldb/DataFormatters/StringPrinter.h
@@ -19,7 +19,7 @@
// Project includes
#include "lldb/lldb-forward.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataExtractor.h"
namespace lldb_private {
namespace formatters {
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h
index 7b2feeb8fc22..fbfc25dd9c9f 100644
--- a/include/lldb/DataFormatters/TypeSummary.h
+++ b/include/lldb/DataFormatters/TypeSummary.h
@@ -23,9 +23,9 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-public.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/Error.h"
namespace lldb_private {
class TypeSummaryOptions {
diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h
index f0d09ac01632..41851436873d 100644
--- a/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -19,7 +19,8 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/Symbol/CompilerType.h"
diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h
index 38bcfe9fe4a8..fcf5aba6ecbe 100644
--- a/include/lldb/DataFormatters/VectorIterator.h
+++ b/include/lldb/DataFormatters/VectorIterator.h
@@ -13,8 +13,8 @@
#include "lldb/lldb-forward.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
namespace formatters {
diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h
index ea3f5cc03db1..ae9eb3fb2d16 100644
--- a/include/lldb/Expression/DWARFExpression.h
+++ b/include/lldb/Expression/DWARFExpression.h
@@ -11,10 +11,10 @@
#define liblldb_DWARFExpression_h_
#include "lldb/Core/Address.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private.h"
#include <functional>
diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h
index 99f583d7ca92..9f33908b8f1b 100644
--- a/include/lldb/Expression/ExpressionParser.h
+++ b/include/lldb/Expression/ExpressionParser.h
@@ -10,7 +10,7 @@
#ifndef liblldb_ExpressionParser_h_
#define liblldb_ExpressionParser_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
namespace lldb_private {
diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h
index 3f6b020139de..c7570932c15a 100644
--- a/include/lldb/Expression/ExpressionVariable.h
+++ b/include/lldb/Expression/ExpressionVariable.h
@@ -19,8 +19,8 @@
#include "llvm/ADT/DenseMap.h"
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-public.h"
namespace lldb_private {
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h
index 72c1775b550d..635e0b727d5c 100644
--- a/include/lldb/Expression/IRExecutionUnit.h
+++ b/include/lldb/Expression/IRExecutionUnit.h
@@ -22,10 +22,10 @@
#include "llvm/IR/Module.h"
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h
index b821e6750b2d..f9392c18c25c 100644
--- a/include/lldb/Expression/IRInterpreter.h
+++ b/include/lldb/Expression/IRInterpreter.h
@@ -10,8 +10,8 @@
#ifndef liblldb_IRInterpreter_h_
#define liblldb_IRInterpreter_h_
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-public.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Pass.h"
diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h
index 405de51bfc45..c1a194d1afad 100644
--- a/include/lldb/Expression/IRMemoryMap.h
+++ b/include/lldb/Expression/IRMemoryMap.h
@@ -10,8 +10,8 @@
#ifndef lldb_IRMemoryMap_h_
#define lldb_IRMemoryMap_h_
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/UserID.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-public.h"
#include <map>
diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h
index 4874929136fd..ed3f91cc67ec 100644
--- a/include/lldb/Expression/Materializer.h
+++ b/include/lldb/Expression/Materializer.h
@@ -17,10 +17,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-types.h"
namespace lldb_private {
diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h
index 16845ae9327b..95d0191397b3 100644
--- a/include/lldb/Host/Config.h
+++ b/include/lldb/Host/Config.h
@@ -7,42 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Config_h_
-#define liblldb_Config_h_
-
+#ifndef LLDB_HOST_CONFIG_H
+#define LLDB_HOST_CONFIG_H
+
#if defined(__APPLE__)
-#include "lldb/Host/macosx/Config.h"
-
-#elif defined(__ANDROID__)
-
-#include "lldb/Host/android/Config.h"
-
-#elif defined(__linux__) || defined(__GNU__)
-
-#include "lldb/Host/linux/Config.h"
-
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
- defined(__OpenBSD__)
-
-#include "lldb/Host/freebsd/Config.h"
-
-#elif defined(__NetBSD__)
-
-#include "lldb/Host/netbsd/Config.h"
-
-#elif defined(__MINGW__) || defined(__MINGW32__)
-
-#include "lldb/Host/mingw/Config.h"
-
-#elif defined(_MSC_VER)
+// This block of code only exists to keep the Xcode project working in the
+// absence of a configuration step.
+#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-#include "lldb/Host/msvc/Config.h"
+#define HAVE_SYS_EVENT_H 1
#else
-#error undefined platform
+#error This file is only used by the Xcode build.
#endif
-#endif // #ifndef liblldb_Config_h_
+#endif // #ifndef LLDB_HOST_CONFIG_H
diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake
new file mode 100644
index 000000000000..d072c1a08687
--- /dev/null
+++ b/include/lldb/Host/Config.h.cmake
@@ -0,0 +1,19 @@
+//===-- Config.h -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_CONFIG_H
+#define LLDB_HOST_CONFIG_H
+
+#cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED
+
+#cmakedefine LLDB_DISABLE_POSIX
+
+#cmakedefine01 HAVE_SYS_EVENT_H
+
+#endif // #ifndef LLDB_HOST_CONFIG_H
diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h
index faed373bc218..2b1a8e047261 100644
--- a/include/lldb/Host/Editline.h
+++ b/include/lldb/Host/Editline.h
@@ -43,7 +43,8 @@
// will only be
// used in cases where this is true. This is a compile time dependecy, for now
// selected per target Platform
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
+ defined(__OpenBSD__)
#define LLDB_EDITLINE_USE_WCHAR 1
#include <codecvt>
#else
@@ -64,8 +65,8 @@
#include <vector>
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
namespace line_editor {
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index 6fa4e568218f..35317780f1ce 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -10,18 +10,15 @@
#ifndef liblldb_File_h_
#define liblldb_File_h_
-// C Includes
-// C++ Includes
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Host/IOObject.h"
#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h
index 1667d05e2a52..094ee695ce32 100644
--- a/include/lldb/Host/FileCache.h
+++ b/include/lldb/Host/FileCache.h
@@ -9,13 +9,14 @@
#ifndef liblldb_Host_FileCache_h
#define liblldb_Host_FileCache_h
+#include <map>
#include <stdint.h>
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
class FileCache {
diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h
index 6dbea6d2cce3..794308ff4244 100644
--- a/include/lldb/Host/FileSystem.h
+++ b/include/lldb/Host/FileSystem.h
@@ -10,8 +10,8 @@
#ifndef liblldb_Host_FileSystem_h
#define liblldb_Host_FileSystem_h
-#include "lldb/Core/Error.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/Support/Chrono.h"
#include "lldb/lldb-types.h"
@@ -26,47 +26,15 @@ public:
static const char *DEV_NULL;
static const char *PATH_CONVERSION_ERROR;
- static FileSpec::PathSyntax GetNativePathSyntax();
-
- static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
- static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
-
- static Error GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions);
- static Error SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions);
- static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
- static bool GetFileExists(const FileSpec &file_spec);
-
- static Error Hardlink(const FileSpec &src, const FileSpec &dst);
- static int GetHardlinkCount(const FileSpec &file_spec);
static Error Symlink(const FileSpec &src, const FileSpec &dst);
static Error Readlink(const FileSpec &src, FileSpec &dst);
- static Error Unlink(const FileSpec &file_spec);
static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
- static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
- uint64_t &high);
- static bool CalculateMD5(const FileSpec &file_spec, uint64_t offset,
- uint64_t length, uint64_t &low, uint64_t &high);
-
- static bool CalculateMD5AsString(const FileSpec &file_spec,
- std::string &digest_str);
- static bool CalculateMD5AsString(const FileSpec &file_spec, uint64_t offset,
- uint64_t length, std::string &digest_str);
-
- /// Return \b true if \a spec is on a locally mounted file system, \b false
- /// otherwise.
- static bool IsLocal(const FileSpec &spec);
-
/// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
/// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
static FILE *Fopen(const char *path, const char *mode);
- /// Wraps ::stat in a platform-independent way.
- static int Stat(const char *path, struct stat *stats);
-
static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec);
};
}
diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h
index 64c0dd6cef6b..8415d429d5e2 100644
--- a/include/lldb/Host/Host.h
+++ b/include/lldb/Host/Host.h
@@ -16,10 +16,10 @@
#include <map>
#include <string>
-#include "lldb/Core/StringList.h"
#include "lldb/Host/File.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-private.h"
@@ -100,14 +100,6 @@ public:
static void Kill(lldb::pid_t pid, int signo);
//------------------------------------------------------------------
- /// Get the thread ID for the calling thread in the current process.
- ///
- /// @return
- /// The thread ID for the calling thread in the current process.
- //------------------------------------------------------------------
- static lldb::tid_t GetCurrentThreadID();
-
- //------------------------------------------------------------------
/// Get the thread token (the one returned by ThreadCreate when the thread was
/// created) for the
/// calling thread in the current process.
@@ -193,7 +185,7 @@ public:
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
#if (defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || \
- defined(__GLIBC__) || defined(__NetBSD__)) && \
+ defined(__GLIBC__) || defined(__NetBSD__) || defined(__OpenBSD__)) && \
!defined(__ANDROID__)
static short GetPosixspawnFlags(const ProcessLaunchInfo &launch_info);
@@ -246,10 +238,6 @@ public:
uint32_t timeout_sec,
bool run_in_default_shell = true);
- static lldb::DataBufferSP GetAuxvData(lldb_private::Process *process);
-
- static lldb::DataBufferSP GetAuxvData(lldb::pid_t pid);
-
static bool OpenFileInExternalEditor(const FileSpec &file_spec,
uint32_t line_no);
diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h
index 4646be2b9234..b4a2f8baf37f 100644
--- a/include/lldb/Host/HostInfo.h
+++ b/include/lldb/Host/HostInfo.h
@@ -51,6 +51,9 @@
#elif defined(__NetBSD__)
#include "lldb/Host/netbsd/HostInfoNetBSD.h"
#define HOST_INFO_TYPE HostInfoNetBSD
+#elif defined(__OpenBSD__)
+#include "lldb/Host/openbsd/HostInfoOpenBSD.h"
+#define HOST_INFO_TYPE HostInfoOpenBSD
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostInfoMacOSX.h"
#define HOST_INFO_TYPE HostInfoMacOSX
diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h
index 74ac79b690b9..42e3fc3fd1da 100644
--- a/include/lldb/Host/HostInfoBase.h
+++ b/include/lldb/Host/HostInfoBase.h
@@ -11,7 +11,7 @@
#define lldb_Host_HostInfoBase_h_
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/StringRef.h"
@@ -35,39 +35,6 @@ public:
static void Terminate();
//------------------------------------------------------------------
- /// Returns the number of CPUs on this current host.
- ///
- /// @return
- /// Number of CPUs on this current host, or zero if the number
- /// of CPUs can't be determined on this host.
- //------------------------------------------------------------------
- static uint32_t GetNumberCPUS();
-
- //------------------------------------------------------------------
- /// Returns the maximum length of a thread name on this platform.
- ///
- /// @return
- /// Maximum length of a thread name on this platform.
- //------------------------------------------------------------------
- static uint32_t GetMaxThreadNameLength();
-
- //------------------------------------------------------------------
- /// Gets the host vendor string.
- ///
- /// @return
- /// A const string object containing the host vendor name.
- //------------------------------------------------------------------
- static llvm::StringRef GetVendorString();
-
- //------------------------------------------------------------------
- /// Gets the host Operating System (OS) string.
- ///
- /// @return
- /// A const string object containing the host OS name.
- //------------------------------------------------------------------
- static llvm::StringRef GetOSString();
-
- //------------------------------------------------------------------
/// Gets the host target triple as a const string.
///
/// @return
diff --git a/include/lldb/Host/HostNativeProcessBase.h b/include/lldb/Host/HostNativeProcessBase.h
index 204f78eab583..0befe867c296 100644
--- a/include/lldb/Host/HostNativeProcessBase.h
+++ b/include/lldb/Host/HostNativeProcessBase.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_HostNativeProcessBase_h_
#define lldb_Host_HostNativeProcessBase_h_
-#include "lldb/Core/Error.h"
#include "lldb/Host/HostProcess.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
diff --git a/include/lldb/Host/HostNativeThread.h b/include/lldb/Host/HostNativeThread.h
index b0411cad7a3e..e33d978d5ae4 100644
--- a/include/lldb/Host/HostNativeThread.h
+++ b/include/lldb/Host/HostNativeThread.h
@@ -14,14 +14,10 @@
#if defined(_WIN32)
#include "lldb/Host/windows/HostThreadWindows.h"
-#elif defined(__linux__)
-#include "lldb/Host/linux/HostThreadLinux.h"
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
-#elif defined(__NetBSD__)
-#include "lldb/Host/netbsd/HostThreadNetBSD.h"
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostThreadMacOSX.h"
+#else
+#include "lldb/Host/posix/HostThreadPosix.h"
#endif
#endif
diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h
index 284b754266fb..9bf86e0759f5 100644
--- a/include/lldb/Host/HostNativeThreadBase.h
+++ b/include/lldb/Host/HostNativeThreadBase.h
@@ -10,7 +10,7 @@
#ifndef lldb_Host_HostNativeThreadBase_h_
#define lldb_Host_HostNativeThreadBase_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h
index 5b832136acf5..4691a22ac844 100644
--- a/include/lldb/Host/HostNativeThreadForward.h
+++ b/include/lldb/Host/HostNativeThreadForward.h
@@ -14,18 +14,12 @@ namespace lldb_private {
#if defined(_WIN32)
class HostThreadWindows;
typedef HostThreadWindows HostNativeThread;
-#elif defined(__linux__)
-class HostThreadLinux;
-typedef HostThreadLinux HostNativeThread;
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-class HostThreadFreeBSD;
-typedef HostThreadFreeBSD HostNativeThread;
-#elif defined(__NetBSD__)
-class HostThreadNetBSD;
-typedef HostThreadNetBSD HostNativeThread;
#elif defined(__APPLE__)
class HostThreadMacOSX;
typedef HostThreadMacOSX HostNativeThread;
+#else
+class HostThreadPosix;
+typedef HostThreadPosix HostNativeThread;
#endif
}
diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h
index d14f0f6c638c..96314813cf7c 100644
--- a/include/lldb/Host/HostThread.h
+++ b/include/lldb/Host/HostThread.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_HostThread_h_
#define lldb_Host_HostThread_h_
-#include "lldb/Core/Error.h"
#include "lldb/Host/HostNativeThreadForward.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-types.h"
#include <memory>
diff --git a/include/lldb/Host/LockFileBase.h b/include/lldb/Host/LockFileBase.h
index 3b2f72357bd4..74eafb279324 100644
--- a/include/lldb/Host/LockFileBase.h
+++ b/include/lldb/Host/LockFileBase.h
@@ -10,7 +10,7 @@
#ifndef liblldb_Host_LockFileBase_h_
#define liblldb_Host_LockFileBase_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include <functional>
diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h
index cd29796bc9d6..b746a9cb208c 100644
--- a/include/lldb/Host/MainLoopBase.h
+++ b/include/lldb/Host/MainLoopBase.h
@@ -14,8 +14,8 @@
#include "llvm/Support/ErrorHandling.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/IOObject.h"
+#include "lldb/Utility/Error.h"
namespace lldb_private {
diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h
index e3d7c25a9ae2..f141b5d413a0 100644
--- a/include/lldb/Host/PipeBase.h
+++ b/include/lldb/Host/PipeBase.h
@@ -14,7 +14,7 @@
#include <chrono>
#include <string>
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
diff --git a/include/lldb/Utility/PseudoTerminal.h b/include/lldb/Host/PseudoTerminal.h
index fbe93343452e..fdbf6df1a186 100644
--- a/include/lldb/Utility/PseudoTerminal.h
+++ b/include/lldb/Host/PseudoTerminal.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PseudoTerminal_h_
-#define liblldb_PseudoTerminal_h_
+#ifndef LLDB_HOST_PSEUDOTERMINAL_H
+#define LLDB_HOST_PSEUDOTERMINAL_H
#if defined(__cplusplus)
#include <fcntl.h>
@@ -19,7 +19,7 @@
namespace lldb_utility {
//----------------------------------------------------------------------
-/// @class PseudoTerminal PseudoTerminal.h "lldb/Core/PseudoTerminal.h"
+/// @class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h"
/// @brief A pseudo terminal helper class.
///
/// The pseudo terminal class abstracts the use of pseudo terminals on
diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h
index 1ad3ca765cba..386133e96952 100644
--- a/include/lldb/Host/Socket.h
+++ b/include/lldb/Host/Socket.h
@@ -15,10 +15,10 @@
#include "lldb/lldb-private.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/IOObject.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/SocketAddress.h"
+#include "lldb/Utility/Error.h"
#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
@@ -71,8 +71,7 @@ public:
static Error TcpConnect(llvm::StringRef host_and_port,
bool child_processes_inherit, Socket *&socket);
static Error UdpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&send_socket,
- Socket *&recv_socket);
+ bool child_processes_inherit, Socket *&socket);
static Error UnixDomainConnect(llvm::StringRef host_and_port,
bool child_processes_inherit, Socket *&socket);
static Error UnixDomainAccept(llvm::StringRef host_and_port,
diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h
index 3d1ed906e1ef..bc66ad915bbe 100644
--- a/include/lldb/Host/SocketAddress.h
+++ b/include/lldb/Host/SocketAddress.h
@@ -32,15 +32,23 @@ typedef ADDRESS_FAMILY sa_family_t;
// Other libraries and framework includes
// Project includes
#include <string>
+#include <vector>
namespace lldb_private {
class SocketAddress {
public:
+ //----------------------------------------------------------------------------
+ // Static method to get all address information for a host and/or service
+ //----------------------------------------------------------------------------
+ static std::vector<SocketAddress> GetAddressInfo(const char *hostname,
+ const char *servname);
+
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
SocketAddress();
+ SocketAddress(const struct addrinfo *addr_info);
SocketAddress(const struct sockaddr &s);
SocketAddress(const struct sockaddr_in &s);
SocketAddress(const struct sockaddr_in6 &s);
@@ -63,6 +71,9 @@ public:
const SocketAddress &operator=(const struct sockaddr_storage &s);
+ bool operator==(const SocketAddress &rhs) const;
+ bool operator!=(const SocketAddress &rhs) const;
+
//------------------------------------------------------------------
// Clear the contents of this socket address
//------------------------------------------------------------------
@@ -135,6 +146,11 @@ public:
bool IsValid() const;
//------------------------------------------------------------------
+ // Returns true if the socket is INADDR_ANY
+ //------------------------------------------------------------------
+ bool IsAnyAddr() const;
+
+ //------------------------------------------------------------------
// Direct access to all of the sockaddr structures
//------------------------------------------------------------------
struct sockaddr &sockaddr() {
diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h
index 1339c064d54c..5f8632d221f7 100644
--- a/include/lldb/Host/Symbols.h
+++ b/include/lldb/Host/Symbols.h
@@ -16,10 +16,14 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
+class ArchSpec;
+class ModuleSpec;
+class UUID;
+
class Symbols {
public:
//----------------------------------------------------------------------
diff --git a/include/lldb/Host/ThisThread.h b/include/lldb/Host/ThisThread.h
deleted file mode 100644
index 1392b10e1382..000000000000
--- a/include/lldb/Host/ThisThread.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//===-- ThisThread.h --------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_Host_ThisThread_h_
-#define lldb_Host_ThisThread_h_
-
-#include "llvm/ADT/StringRef.h"
-
-#include <string>
-
-namespace llvm {
-template <class T> class SmallVectorImpl;
-}
-
-namespace lldb_private {
-
-class ThisThread {
-private:
- ThisThread();
-
-public:
- // ThisThread common functions.
- static void SetName(llvm::StringRef name, int max_length);
-
- // ThisThread platform-specific functions.
- static void SetName(llvm::StringRef name);
- static void GetName(llvm::SmallVectorImpl<char> &name);
-};
-}
-
-#endif
diff --git a/include/lldb/Host/ThreadLauncher.h b/include/lldb/Host/ThreadLauncher.h
index 0f2cb37c835a..4e388ca6bb9c 100644
--- a/include/lldb/Host/ThreadLauncher.h
+++ b/include/lldb/Host/ThreadLauncher.h
@@ -11,8 +11,8 @@
#ifndef lldb_Host_ThreadLauncher_h_
#define lldb_Host_ThreadLauncher_h_
-#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/StringRef.h"
diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h
index 4113b3318dd0..04677625672c 100644
--- a/include/lldb/Host/XML.h
+++ b/include/lldb/Host/XML.h
@@ -24,8 +24,8 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Host/android/Config.h b/include/lldb/Host/android/Config.h
deleted file mode 100644
index f16ed86cabb8..000000000000
--- a/include/lldb/Host/android/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h
index 2bb8e565f464..1d314e02b1d5 100644
--- a/include/lldb/Host/common/NativeBreakpointList.h
+++ b/include/lldb/Host/common/NativeBreakpointList.h
@@ -10,7 +10,7 @@
#ifndef liblldb_NativeBreakpointList_h_
#define liblldb_NativeBreakpointList_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-forward.h"
// #include "lldb/Host/NativeBreakpoint.h"
@@ -19,6 +19,14 @@
#include <mutex>
namespace lldb_private {
+
+struct HardwareBreakpoint {
+ lldb::addr_t m_addr;
+ size_t m_size;
+};
+
+using HardwareBreakpointMap = std::map<lldb::addr_t, HardwareBreakpoint>;
+
class NativeBreakpointList {
public:
typedef std::function<Error(lldb::addr_t addr, size_t size_hint,
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index a0f03b0dafa3..7ad09d41eacf 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -10,14 +10,15 @@
#ifndef liblldb_NativeProcessProtocol_h_
#define liblldb_NativeProcessProtocol_h_
-#include <mutex>
-#include <vector>
-
-#include "lldb/Core/Error.h"
#include "lldb/Host/MainLoop.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include <vector>
#include "NativeBreakpointList.h"
#include "NativeWatchpointList.h"
@@ -64,6 +65,12 @@ public:
virtual Error Kill() = 0;
+ //------------------------------------------------------------------
+ // Tells a process not to stop the inferior on given signals
+ // and just reinject them back.
+ //------------------------------------------------------------------
+ virtual Error IgnoreSignals(llvm::ArrayRef<int> signals);
+
//----------------------------------------------------------------------
// Memory and memory region functions
//----------------------------------------------------------------------
@@ -99,18 +106,28 @@ public:
virtual Error SetBreakpoint(lldb::addr_t addr, uint32_t size,
bool hardware) = 0;
- virtual Error RemoveBreakpoint(lldb::addr_t addr);
+ virtual Error RemoveBreakpoint(lldb::addr_t addr, bool hardware = false);
virtual Error EnableBreakpoint(lldb::addr_t addr);
virtual Error DisableBreakpoint(lldb::addr_t addr);
//----------------------------------------------------------------------
+ // Hardware Breakpoint functions
+ //----------------------------------------------------------------------
+ virtual const HardwareBreakpointMap &GetHardwareBreakpointMap() const;
+
+ virtual Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
+
+ virtual Error RemoveHardwareBreakpoint(lldb::addr_t addr);
+
+ //----------------------------------------------------------------------
// Watchpoint functions
//----------------------------------------------------------------------
virtual const NativeWatchpointList::WatchpointMap &GetWatchpointMap() const;
- virtual uint32_t GetMaxWatchpoints() const;
+ virtual llvm::Optional<std::pair<uint32_t, uint32_t>>
+ GetHardwareDebugSupportInfo() const;
virtual Error SetWatchpoint(lldb::addr_t addr, size_t size,
uint32_t watch_flags, bool hardware);
@@ -134,6 +151,9 @@ public:
bool GetByteOrder(lldb::ByteOrder &byte_order) const;
+ virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ GetAuxvData() const = 0;
+
//----------------------------------------------------------------------
// Exit Status
//----------------------------------------------------------------------
@@ -305,9 +325,14 @@ protected:
std::vector<NativeDelegate *> m_delegates;
NativeBreakpointList m_breakpoint_list;
NativeWatchpointList m_watchpoint_list;
+ HardwareBreakpointMap m_hw_breakpoints_map;
int m_terminal_fd;
uint32_t m_stop_id;
+ // Set of signal numbers that LLDB directly injects back to inferior
+ // without stopping it.
+ llvm::DenseSet<int> m_signals_to_ignore;
+
// lldb_private::Host calls should be used to launch a process for debugging,
// and
// then the process should be attached to. When attaching to a process
diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h
index dd583d7866a8..1d8b51c60cc4 100644
--- a/include/lldb/Host/common/NativeRegisterContext.h
+++ b/include/lldb/Host/common/NativeRegisterContext.h
@@ -75,6 +75,11 @@ public:
virtual bool ClearHardwareBreakpoint(uint32_t hw_idx);
+ virtual Error ClearAllHardwareBreakpoints();
+
+ virtual Error GetHardwareBreakHitIndex(uint32_t &bp_index,
+ lldb::addr_t trap_addr);
+
virtual uint32_t NumSupportedHardwareWatchpoints();
virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h
index 450e74630e71..8f26616a2b4a 100644
--- a/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/include/lldb/Host/common/NativeThreadProtocol.h
@@ -56,6 +56,13 @@ public:
virtual Error RemoveWatchpoint(lldb::addr_t addr) = 0;
+ // ---------------------------------------------------------------------
+ // Thread-specific Hardware Breakpoint routines
+ // ---------------------------------------------------------------------
+ virtual Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) = 0;
+
+ virtual Error RemoveHardwareBreakpoint(lldb::addr_t addr) = 0;
+
protected:
NativeProcessProtocolWP m_process_wp;
lldb::tid_t m_tid;
diff --git a/include/lldb/Host/common/NativeWatchpointList.h b/include/lldb/Host/common/NativeWatchpointList.h
index 2424e5613332..ae3476f5f07e 100644
--- a/include/lldb/Host/common/NativeWatchpointList.h
+++ b/include/lldb/Host/common/NativeWatchpointList.h
@@ -10,7 +10,7 @@
#ifndef liblldb_NativeWatchpointList_h_
#define liblldb_NativeWatchpointList_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-forward.h"
#include <map>
diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h
index 153804be2603..507c9827caf6 100644
--- a/include/lldb/Host/common/UDPSocket.h
+++ b/include/lldb/Host/common/UDPSocket.h
@@ -18,7 +18,7 @@ public:
UDPSocket(bool child_processes_inherit, Error &error);
static Error Connect(llvm::StringRef name, bool child_processes_inherit,
- Socket *&send_socket, Socket *&recv_socket);
+ Socket *&socket);
private:
UDPSocket(NativeSocket socket);
@@ -29,7 +29,7 @@ private:
Error Accept(llvm::StringRef name, bool child_processes_inherit,
Socket *&socket) override;
- SocketAddress m_send_sockaddr;
+ SocketAddress m_sockaddr;
};
}
diff --git a/include/lldb/Host/freebsd/Config.h b/include/lldb/Host/freebsd/Config.h
deleted file mode 100644
index 1e9f55299d52..000000000000
--- a/include/lldb/Host/freebsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index a549f87740c0..945ec835f778 100644
--- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -10,14 +10,13 @@
#ifndef lldb_Host_freebsd_HostInfoFreeBSD_h_
#define lldb_Host_freebsd_HostInfoFreeBSD_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
class HostInfoFreeBSD : public HostInfoPosix {
public:
- static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
diff --git a/include/lldb/Host/freebsd/HostThreadFreeBSD.h b/include/lldb/Host/freebsd/HostThreadFreeBSD.h
deleted file mode 100644
index 2f1d6ceae255..000000000000
--- a/include/lldb/Host/freebsd/HostThreadFreeBSD.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//===-- HostThreadFreeBSD.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_Host_freebsd_HostThreadFreeBSD_h_
-#define lldb_Host_freebsd_HostThreadFreeBSD_h_
-
-#include "lldb/Host/posix/HostThreadPosix.h"
-
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace lldb_private {
-
-class HostThreadFreeBSD : public HostThreadPosix {
-public:
- HostThreadFreeBSD();
- HostThreadFreeBSD(lldb::thread_t thread);
-
- static void GetName(lldb::tid_t tid, llvm::SmallVectorImpl<char> &name);
-};
-}
-
-#endif
diff --git a/include/lldb/Host/linux/Config.h b/include/lldb/Host/linux/Config.h
deleted file mode 100644
index 1e9f55299d52..000000000000
--- a/include/lldb/Host/linux/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/linux/HostInfoLinux.h b/include/lldb/Host/linux/HostInfoLinux.h
index 8cb97c0b4d6b..d1f2e747b117 100644
--- a/include/lldb/Host/linux/HostInfoLinux.h
+++ b/include/lldb/Host/linux/HostInfoLinux.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_linux_HostInfoLinux_h_
#define lldb_Host_linux_HostInfoLinux_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/StringRef.h"
@@ -29,7 +29,6 @@ private:
public:
static void Initialize();
- static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static bool GetOSBuildString(std::string &s);
diff --git a/include/lldb/Host/linux/HostThreadLinux.h b/include/lldb/Host/linux/HostThreadLinux.h
deleted file mode 100644
index ddfa8633ffed..000000000000
--- a/include/lldb/Host/linux/HostThreadLinux.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- HostThreadLinux.h ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_Host_linux_HostThreadLinux_h_
-#define lldb_Host_linux_HostThreadLinux_h_
-
-#include "lldb/Host/posix/HostThreadPosix.h"
-
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace lldb_private {
-
-class HostThreadLinux : public HostThreadPosix {
-public:
- HostThreadLinux();
- HostThreadLinux(lldb::thread_t thread);
-
- static void SetName(lldb::thread_t thread, llvm::StringRef name);
- static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name);
-};
-}
-
-#endif
diff --git a/include/lldb/Host/linux/Support.h b/include/lldb/Host/linux/Support.h
new file mode 100644
index 000000000000..dae76c78fb4a
--- /dev/null
+++ b/include/lldb/Host/linux/Support.h
@@ -0,0 +1,27 @@
+//===-- Support.h -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_LINUX_SUPPORT_H
+#define LLDB_HOST_LINUX_SUPPORT_H
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include <memory>
+
+namespace lldb_private {
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file);
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+getProcFile(::pid_t pid, const llvm::Twine &file);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_LINUX_SUPPORT_H
diff --git a/include/lldb/Host/macosx/Config.h b/include/lldb/Host/macosx/Config.h
deleted file mode 100644
index ef8e02cfa4da..000000000000
--- a/include/lldb/Host/macosx/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/macosx/HostInfoMacOSX.h b/include/lldb/Host/macosx/HostInfoMacOSX.h
index b182b9bce147..eee842beec87 100644
--- a/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_macosx_HostInfoMacOSX_h_
#define lldb_Host_macosx_HostInfoMacOSX_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
@@ -30,7 +30,6 @@ public:
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
- static uint32_t GetMaxThreadNameLength();
protected:
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
diff --git a/include/lldb/Host/mingw/Config.h b/include/lldb/Host/mingw/Config.h
deleted file mode 100644
index 9cf2735ab709..000000000000
--- a/include/lldb/Host/mingw/Config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/msvc/Config.h b/include/lldb/Host/msvc/Config.h
deleted file mode 100644
index 37dfbf58a854..000000000000
--- a/include/lldb/Host/msvc/Config.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_host_msvc_Config_h_
-#define liblldb_host_msvc_Config_h_
-
-#define LLDB_DISABLE_POSIX
-
-//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#if _HAS_EXCEPTIONS == 0
-// Due to a bug in <thread>, when _HAS_EXCEPTIONS == 0 the header will try to
-// call
-// uncaught_exception() without having a declaration for it. The fix for this
-// is
-// to manually #include <eh.h>, which contains this declaration.
-#include <eh.h>
-#endif
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/netbsd/Config.h b/include/lldb/Host/netbsd/Config.h
deleted file mode 100644
index 1e9f55299d52..000000000000
--- a/include/lldb/Host/netbsd/Config.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- Config.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-//----------------------------------------------------------------------
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//----------------------------------------------------------------------
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 684e54e9f052..9ebff6ba6b0e 100644
--- a/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -10,14 +10,13 @@
#ifndef lldb_Host_netbsd_HostInfoNetBSD_h_
#define lldb_Host_netbsd_HostInfoNetBSD_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
class HostInfoNetBSD : public HostInfoPosix {
public:
- static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
diff --git a/include/lldb/Host/netbsd/HostThreadNetBSD.h b/include/lldb/Host/netbsd/HostThreadNetBSD.h
deleted file mode 100644
index 385f014899f7..000000000000
--- a/include/lldb/Host/netbsd/HostThreadNetBSD.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- HostThreadNetBSD.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_Host_netbsd_HostThreadNetBSD_h_
-#define lldb_Host_netbsd_HostThreadNetBSD_h_
-
-#include "lldb/Host/posix/HostThreadPosix.h"
-
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace lldb_private {
-
-class HostThreadNetBSD : public HostThreadPosix {
-public:
- HostThreadNetBSD();
- HostThreadNetBSD(lldb::thread_t thread);
-
- static void SetName(lldb::thread_t tid, llvm::StringRef &name);
- static void GetName(lldb::thread_t tid, llvm::SmallVectorImpl<char> &name);
-};
-}
-
-#endif
diff --git a/include/lldb/Host/openbsd/HostInfoOpenBSD.h b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
new file mode 100644
index 000000000000..5a0388ffdd97
--- /dev/null
+++ b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -0,0 +1,27 @@
+//===-- HostInfoOpenBSD.h --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Host_openbsd_HostInfoOpenBSD_h_
+#define lldb_Host_openbsd_HostInfoOpenBSD_h_
+
+#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
+
+namespace lldb_private {
+
+class HostInfoOpenBSD : public HostInfoPosix {
+public:
+ static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static bool GetOSBuildString(std::string &s);
+ static bool GetOSKernelDescription(std::string &s);
+ static FileSpec GetProgramFileSpec();
+};
+}
+
+#endif
diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h
index 6d22776e1854..34994aea44fe 100644
--- a/include/lldb/Host/posix/HostInfoPosix.h
+++ b/include/lldb/Host/posix/HostInfoPosix.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_posix_HostInfoPosix_h_
#define lldb_Host_posix_HostInfoPosix_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfoBase.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h
index 1535e679dd53..aed3cccef2e2 100644
--- a/include/lldb/Host/posix/HostProcessPosix.h
+++ b/include/lldb/Host/posix/HostProcessPosix.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Host/HostNativeProcessBase.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-types.h"
namespace lldb_private {
diff --git a/include/lldb/Host/linux/ProcessLauncherLinux.h b/include/lldb/Host/posix/ProcessLauncherPosixFork.h
index 8ad00d091606..77bdab535c1b 100644
--- a/include/lldb/Host/linux/ProcessLauncherLinux.h
+++ b/include/lldb/Host/posix/ProcessLauncherPosixFork.h
@@ -1,4 +1,4 @@
-//===-- ProcessLauncherAndroid.h --------------------------------*- C++ -*-===//
+//===-- ProcessLauncherPosixFork.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,17 +7,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_android_ProcessLauncherAndroid_h_
-#define lldb_Host_android_ProcessLauncherAndroid_h_
+#ifndef lldb_Host_posix_ProcessLauncherPosixFork_h_
+#define lldb_Host_posix_ProcessLauncherPosixFork_h_
#include "lldb/Host/ProcessLauncher.h"
namespace lldb_private {
-class ProcessLauncherLinux : public ProcessLauncher {
+class ProcessLauncherPosixFork : public ProcessLauncher {
public:
- virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
- Error &error);
+ HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error) override;
};
} // end of namespace lldb_private
diff --git a/include/lldb/Host/windows/HostInfoWindows.h b/include/lldb/Host/windows/HostInfoWindows.h
index 5a5d72c2466c..9dfbf93591ed 100644
--- a/include/lldb/Host/windows/HostInfoWindows.h
+++ b/include/lldb/Host/windows/HostInfoWindows.h
@@ -10,8 +10,8 @@
#ifndef lldb_Host_windows_HostInfoWindows_h_
#define lldb_Host_windows_HostInfoWindows_h_
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfoBase.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h
index 4f2573781620..de70266a5efb 100644
--- a/include/lldb/Host/windows/PosixApi.h
+++ b/include/lldb/Host/windows/PosixApi.h
@@ -82,8 +82,6 @@ char *strcasestr(const char *s, const char *find);
char *realpath(const char *name, char *resolved);
int usleep(uint32_t useconds);
-char *getcwd(char *path, int max);
-int chdir(const char *path);
char *basename(char *path);
char *dirname(char *path);
diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h
index 6610be14d0dd..bdbf81e02d9d 100644
--- a/include/lldb/Interpreter/Args.h
+++ b/include/lldb/Interpreter/Args.h
@@ -21,13 +21,14 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Host/OptionParser.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-types.h"
#include "lldb/lldb-types.h"
namespace lldb_private {
+struct Option;
+
typedef std::vector<std::tuple<std::string, int, std::string>> OptionArgVector;
typedef std::shared_ptr<OptionArgVector> OptionArgVectorSP;
@@ -193,6 +194,15 @@ public:
const char **GetConstArgumentVector() const;
//------------------------------------------------------------------
+ /// Gets the argument as an ArrayRef. Note that the return value does *not*
+ /// have a nullptr const char * at the end, as the size of the list is
+ /// embedded in the ArrayRef object.
+ //------------------------------------------------------------------
+ llvm::ArrayRef<const char *> GetArgumentArrayRef() const {
+ return llvm::makeArrayRef(m_argv).drop_back();
+ }
+
+ //------------------------------------------------------------------
/// Appends a new argument to the end of the list argument list.
///
/// @param[in] arg_cstr
diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h
index 2e117358c399..8bac3e8639d7 100644
--- a/include/lldb/Interpreter/CommandCompletions.h
+++ b/include/lldb/Interpreter/CommandCompletions.h
@@ -17,11 +17,14 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/SearchFilter.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/lldb-private.h"
+#include "llvm/ADT/Twine.h"
+
namespace lldb_private {
+class TildeExpressionResolver;
class CommandCompletions {
public:
//----------------------------------------------------------------------
@@ -76,12 +79,19 @@ public:
int max_return_elements, SearchFilter *searcher,
bool &word_complete, StringList &matches);
+ static int DiskFiles(const llvm::Twine &partial_file_name,
+ StringList &matches, TildeExpressionResolver &Resolver);
+
static int DiskDirectories(CommandInterpreter &interpreter,
llvm::StringRef partial_file_name,
int match_start_point, int max_return_elements,
SearchFilter *searcher, bool &word_complete,
StringList &matches);
+ static int DiskDirectories(const llvm::Twine &partial_file_name,
+ StringList &matches,
+ TildeExpressionResolver &Resolver);
+
static int SourceFiles(CommandInterpreter &interpreter,
llvm::StringRef partial_file_name,
int match_start_point, int max_return_elements,
diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h
index f1a6c855e3b9..faef220bbe94 100644
--- a/include/lldb/Interpreter/CommandHistory.h
+++ b/include/lldb/Interpreter/CommandHistory.h
@@ -18,7 +18,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h
index 00dec5134c8f..031ea10d6ad4 100644
--- a/include/lldb/Interpreter/CommandInterpreter.h
+++ b/include/lldb/Interpreter/CommandInterpreter.h
@@ -19,13 +19,13 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandAlias.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h
index 9104fd8f9bb7..ff4c829e5c70 100644
--- a/include/lldb/Interpreter/CommandObject.h
+++ b/include/lldb/Interpreter/CommandObject.h
@@ -18,11 +18,12 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h
index 44dc4f2bfd58..50dbebc21b1d 100644
--- a/include/lldb/Interpreter/CommandObjectRegexCommand.h
+++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h
@@ -16,8 +16,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Utility/RegularExpression.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h
index 40db5635afa4..8e467e118477 100644
--- a/include/lldb/Interpreter/CommandReturnObject.h
+++ b/include/lldb/Interpreter/CommandReturnObject.h
@@ -16,8 +16,8 @@
// Project includes
#include "lldb/Core/STLUtils.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StreamTee.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StreamTee.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/StringRef.h"
diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h
index c51ff5c1f48d..8cee9a671869 100644
--- a/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Interpreter/Options.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h
index 2c1d5df90697..648ad33e2fc8 100644
--- a/include/lldb/Interpreter/OptionValue.h
+++ b/include/lldb/Interpreter/OptionValue.h
@@ -14,10 +14,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-defines.h"
+#include "lldb/lldb-private-enumerations.h"
+#include "lldb/lldb-private-interfaces.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h
index 273e69cc6d66..d47248b72c67 100644
--- a/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -10,16 +10,13 @@
#ifndef liblldb_OptionValueEnumeration_h_
#define liblldb_OptionValueEnumeration_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-private-types.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h
index 8020aa7fb49d..654c04d4d274 100644
--- a/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -12,7 +12,7 @@
#include "lldb/Interpreter/OptionValue.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/Support/Chrono.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h
index bb4202a2ec1f..0b49e0b00672 100644
--- a/include/lldb/Interpreter/OptionValueProperties.h
+++ b/include/lldb/Interpreter/OptionValueProperties.h
@@ -16,11 +16,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/Property.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h
index 7125daffedee..7bb8d419bde0 100644
--- a/include/lldb/Interpreter/OptionValueRegex.h
+++ b/include/lldb/Interpreter/OptionValueRegex.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/RegularExpression.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h
index 5b42003f383f..18b8215fe3c7 100644
--- a/include/lldb/Interpreter/OptionValueString.h
+++ b/include/lldb/Interpreter/OptionValueString.h
@@ -16,7 +16,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Interpreter/OptionValue.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h
index 841de88f9263..62c25859580c 100644
--- a/include/lldb/Interpreter/OptionValueUUID.h
+++ b/include/lldb/Interpreter/OptionValueUUID.h
@@ -14,7 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UUID.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/Interpreter/OptionValue.h"
namespace lldb_private {
diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h
index e09df5cf9dad..9d0dc5fa0fd8 100644
--- a/include/lldb/Interpreter/Property.h
+++ b/include/lldb/Interpreter/Property.h
@@ -10,16 +10,13 @@
#ifndef liblldb_Property_h_
#define liblldb_Property_h_
-// C Includes
-// C++ Includes
-#include <string>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Flags.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
#include "lldb/lldb-defines.h"
+#include "lldb/lldb-private-types.h"
+
+#include <string>
namespace lldb_private {
diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h
index 3fdba0818535..271a5bba761e 100644
--- a/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/include/lldb/Interpreter/ScriptInterpreter.h
@@ -18,11 +18,11 @@
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/Error.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Host/PseudoTerminal.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h
index cc80c0fa9663..ef67a31e7d0d 100644
--- a/include/lldb/Symbol/ArmUnwindInfo.h
+++ b/include/lldb/Symbol/ArmUnwindInfo.h
@@ -12,9 +12,9 @@
#include <vector>
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/lldb-private.h"
/*
diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h
index eb96318dac04..a5387cca21c5 100644
--- a/include/lldb/Symbol/Block.h
+++ b/include/lldb/Symbol/Block.h
@@ -18,11 +18,12 @@
// Project includes
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/RangeMap.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h
index 4262ecb4bf0e..ef1659159697 100644
--- a/include/lldb/Symbol/ClangASTContext.h
+++ b/include/lldb/Symbol/ClangASTContext.h
@@ -31,9 +31,9 @@
// Project includes
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-enumerations.h"
class DWARFASTParserClang;
diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h
index 133a886812b3..630067241735 100644
--- a/include/lldb/Symbol/CompactUnwindInfo.h
+++ b/include/lldb/Symbol/CompactUnwindInfo.h
@@ -13,10 +13,10 @@
#include <mutex>
#include <vector>
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h
index 8465f3bb5777..e7a1ebc8c00f 100644
--- a/include/lldb/Symbol/CompileUnit.h
+++ b/include/lldb/Symbol/CompileUnit.h
@@ -12,10 +12,10 @@
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h
index a612fb689c81..5d744d999bea 100644
--- a/include/lldb/Symbol/CompilerDecl.h
+++ b/include/lldb/Symbol/CompilerDecl.h
@@ -10,8 +10,8 @@
#ifndef liblldb_CompilerDecl_h_
#define liblldb_CompilerDecl_h_
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h
index e4f3e7459aa7..179a1be0248b 100644
--- a/include/lldb/Symbol/CompilerDeclContext.h
+++ b/include/lldb/Symbol/CompilerDeclContext.h
@@ -12,7 +12,7 @@
#include <vector>
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h
index 68221609c0cb..c5bca54ed43f 100644
--- a/include/lldb/Symbol/CompilerType.h
+++ b/include/lldb/Symbol/CompilerType.h
@@ -23,6 +23,8 @@
namespace lldb_private {
+class DataExtractor;
+
//----------------------------------------------------------------------
// A class that can carry around a clang ASTContext and a opaque clang
// QualType. A clang::QualType can be easily reconstructed from an
diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h
index c221a36bd6c8..085def8ff0e5 100644
--- a/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -14,13 +14,13 @@
#include <mutex>
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Core/RangeMap.h"
-#include "lldb/Core/VMRange.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/VMRange.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h
index 4d4a3273db64..640da027cd59 100644
--- a/include/lldb/Symbol/DebugMacros.h
+++ b/include/lldb/Symbol/DebugMacros.h
@@ -17,7 +17,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h
index 5ee8b19b6ed0..16d514fdf1bd 100644
--- a/include/lldb/Symbol/DeclVendor.h
+++ b/include/lldb/Symbol/DeclVendor.h
@@ -11,6 +11,7 @@
#define liblldb_DeclVendor_h_
#include "lldb/Core/ClangForward.h"
+#include "lldb/lldb-defines.h"
#include <vector>
diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h
index 1846e2fdca82..581176e23961 100644
--- a/include/lldb/Symbol/Declaration.h
+++ b/include/lldb/Symbol/Declaration.h
@@ -10,7 +10,7 @@
#ifndef liblldb_Declaration_h_
#define liblldb_Declaration_h_
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h
index 232d0790f492..9d376007a411 100644
--- a/include/lldb/Symbol/Function.h
+++ b/include/lldb/Symbol/Function.h
@@ -12,10 +12,10 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/Utility/UserID.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h
index 5530a35493dc..6feac7abf162 100644
--- a/include/lldb/Symbol/GoASTContext.h
+++ b/include/lldb/Symbol/GoASTContext.h
@@ -20,9 +20,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/JavaASTContext.h b/include/lldb/Symbol/JavaASTContext.h
index 6e97674847f4..4fdd2371b67e 100644
--- a/include/lldb/Symbol/JavaASTContext.h
+++ b/include/lldb/Symbol/JavaASTContext.h
@@ -18,8 +18,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h
index 3076ec41d878..b9a1a1442d47 100644
--- a/include/lldb/Symbol/LineEntry.h
+++ b/include/lldb/Symbol/LineEntry.h
@@ -11,7 +11,7 @@
#define liblldb_LineEntry_h_
#include "lldb/Core/AddressRange.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/OCamlASTContext.h b/include/lldb/Symbol/OCamlASTContext.h
index 9560866d33e6..a261d43519e0 100644
--- a/include/lldb/Symbol/OCamlASTContext.h
+++ b/include/lldb/Symbol/OCamlASTContext.h
@@ -21,9 +21,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h
index 6f38b50ba567..110379234fb5 100644
--- a/include/lldb/Symbol/ObjectContainer.h
+++ b/include/lldb/Symbol/ObjectContainer.h
@@ -14,11 +14,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h
index e2e4500ace46..03564eca4b58 100644
--- a/include/lldb/Symbol/ObjectFile.h
+++ b/include/lldb/Symbol/ObjectFile.h
@@ -10,14 +10,15 @@
#ifndef liblldb_ObjectFile_h_
#define liblldb_ObjectFile_h_
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Symbol/UnwindTable.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -563,6 +564,45 @@ public:
virtual uint32_t GetNumThreadContexts() { return 0; }
+ //------------------------------------------------------------------
+ /// Some object files may have an identifier string embedded in them,
+ /// e.g. in a Mach-O core file using the LC_IDENT load command (which
+ /// is obsolete, but can still be found in some old files)
+ ///
+ /// @return
+ /// Returns the identifier string if one exists, else an empty
+ /// string.
+ //------------------------------------------------------------------
+ virtual std::string GetIdentifierString () {
+ return std::string();
+ }
+
+ //------------------------------------------------------------------
+ /// When the ObjectFile is a core file, lldb needs to locate the
+ /// "binary" in the core file. lldb can iterate over the pages looking
+ /// for a valid binary, but some core files may have metadata
+ /// describing where the main binary is exactly which removes ambiguity
+ /// when there are multiple binaries present in the captured memory pages.
+ ///
+ /// @param[out] address
+ /// If the address of the binary is specified, this will be set.
+ /// This is an address is the virtual address space of the core file
+ /// memory segments; it is not an offset into the object file.
+ /// If no address is available, will be set to LLDB_INVALID_ADDRESS.
+ ///
+ /// @param[out] uuid
+ /// If the uuid of the binary is specified, this will be set.
+ /// If no UUID is available, will be cleared.
+ ///
+ /// @return
+ /// Returns true if either address or uuid has been set.
+ //------------------------------------------------------------------
+ virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) {
+ address = LLDB_INVALID_ADDRESS;
+ uuid.Clear();
+ return false;
+ }
+
virtual lldb::RegisterContextSP
GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
return lldb::RegisterContextSP();
@@ -774,6 +814,20 @@ public:
llvm::StringRef name,
lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
+ //------------------------------------------------------------------
+ /// Loads this objfile to memory.
+ ///
+ /// Loads the bits needed to create an executable image to the memory.
+ /// It is useful with bare-metal targets where target does not have the
+ /// ability to start a process itself.
+ ///
+ /// @param[in] target
+ /// Target where to load.
+ ///
+ /// @return
+ //------------------------------------------------------------------
+ virtual Error LoadInMemory(Target &target, bool set_pc);
+
protected:
//------------------------------------------------------------------
// Member variables.
diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h
index 3f12b9a99b04..44c67f6f4716 100644
--- a/include/lldb/Symbol/Symbol.h
+++ b/include/lldb/Symbol/Symbol.h
@@ -12,8 +12,8 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h
index b2a65fabf8f9..9740dc25a587 100644
--- a/include/lldb/Symbol/Type.h
+++ b/include/lldb/Symbol/Type.h
@@ -11,11 +11,11 @@
#define liblldb_Type_h_
#include "lldb/Core/ClangForward.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/APSInt.h"
@@ -23,7 +23,6 @@
#include <set>
namespace lldb_private {
-
//----------------------------------------------------------------------
// CompilerContext allows an array of these items to be passed to
// perform detailed lookups in SymbolVendor and SymbolFile functions.
diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h
index dfcf55bc8864..abb57a2c499d 100644
--- a/include/lldb/Symbol/UnwindPlan.h
+++ b/include/lldb/Symbol/UnwindPlan.h
@@ -19,8 +19,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h
index 33249891d36b..f076a04434e1 100644
--- a/include/lldb/Symbol/Variable.h
+++ b/include/lldb/Symbol/Variable.h
@@ -15,9 +15,9 @@
#include "lldb/Core/Mangled.h"
#include "lldb/Core/RangeMap.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private.h"
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h
index 8a1243613616..4b611d244e21 100644
--- a/include/lldb/Target/ABI.h
+++ b/include/lldb/Target/ABI.h
@@ -14,9 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h
index 071cbe69d880..ced6ef44000a 100644
--- a/include/lldb/Target/DynamicLoader.h
+++ b/include/lldb/Target/DynamicLoader.h
@@ -11,10 +11,38 @@
#define liblldb_DynamicLoader_h_
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/UUID.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for ModuleSP, ThreadPlanSP
+#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz...
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for int64_t
+namespace lldb_private {
+class ModuleList;
+}
+namespace lldb_private {
+class Process;
+}
+namespace lldb_private {
+class SectionList;
+}
+namespace lldb_private {
+class Symbol;
+}
+namespace lldb_private {
+class SymbolContext;
+}
+namespace lldb_private {
+class SymbolContextList;
+}
+namespace lldb_private {
+class Thread;
+}
namespace lldb_private {
@@ -331,6 +359,10 @@ protected:
// Read a pointer from memory at the given addr.
// Return LLDB_INVALID_ADDRESS if the read fails.
lldb::addr_t ReadPointer(lldb::addr_t addr);
+
+ // Calls into the Process protected method LoadOperatingSystemPlugin:
+ void LoadOperatingSystemPlugin(bool flush);
+
//------------------------------------------------------------------
// Member variables.
diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Target/FileAction.h
index 81122ec68798..f80f57ac588b 100644
--- a/include/lldb/Target/FileAction.h
+++ b/include/lldb/Target/FileAction.h
@@ -10,7 +10,7 @@
#ifndef liblldb_Target_FileAction_h
#define liblldb_Target_FileAction_h
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include <string>
namespace lldb_private {
diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h
index 57275bbda593..f0a4bc5881f0 100644
--- a/include/lldb/Target/Memory.h
+++ b/include/lldb/Target/Memory.h
@@ -75,6 +75,8 @@ private:
DISALLOW_COPY_AND_ASSIGN(MemoryCache);
};
+
+
class AllocatedBlock {
public:
AllocatedBlock(lldb::addr_t addr, uint32_t byte_size, uint32_t permissions,
@@ -86,32 +88,34 @@ public:
bool FreeBlock(lldb::addr_t addr);
- lldb::addr_t GetBaseAddress() const { return m_addr; }
+ lldb::addr_t GetBaseAddress() const { return m_range.GetRangeBase(); }
- uint32_t GetByteSize() const { return m_byte_size; }
+ uint32_t GetByteSize() const { return m_range.GetByteSize(); }
uint32_t GetPermissions() const { return m_permissions; }
uint32_t GetChunkSize() const { return m_chunk_size; }
bool Contains(lldb::addr_t addr) const {
- return ((addr >= m_addr) && addr < (m_addr + m_byte_size));
+ return m_range.Contains(addr);
}
protected:
- uint32_t TotalChunks() const { return m_byte_size / m_chunk_size; }
+ uint32_t TotalChunks() const { return GetByteSize() / GetChunkSize(); }
uint32_t CalculateChunksNeededForSize(uint32_t size) const {
return (size + m_chunk_size - 1) / m_chunk_size;
}
- const lldb::addr_t m_addr; // Base address of this block of memory
- const uint32_t m_byte_size; // 4GB of chunk should be enough...
- const uint32_t m_permissions; // Permissions for this memory (logical OR of
- // lldb::Permissions bits)
- const uint32_t m_chunk_size; // The size of chunks that the memory at m_addr
- // is divied up into
- typedef std::map<uint32_t, uint32_t> OffsetToChunkSize;
- OffsetToChunkSize m_offset_to_chunk_size;
+ // Base address of this block of memory 4GB of chunk should be enough.
+ Range<lldb::addr_t, uint32_t> m_range;
+ // Permissions for this memory (logical OR of lldb::Permissions bits)
+ const uint32_t m_permissions;
+ // The size of chunks that the memory at m_addr is divied up into.
+ const uint32_t m_chunk_size;
+ // A sorted list of free address ranges.
+ RangeVector<lldb::addr_t, uint32_t> m_free_blocks;
+ // A sorted list of reserved address.
+ RangeVector<lldb::addr_t, uint32_t> m_reserved_blocks;
};
//----------------------------------------------------------------------
diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h
index be0cfa429b8f..0824b2442acc 100644
--- a/include/lldb/Target/MemoryRegionInfo.h
+++ b/include/lldb/Target/MemoryRegionInfo.h
@@ -11,8 +11,9 @@
#ifndef lldb_MemoryRegionInfo_h
#define lldb_MemoryRegionInfo_h
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/RangeMap.h"
+#include "llvm/Support/FormatProviders.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Range.h"
namespace lldb_private {
@@ -100,4 +101,24 @@ protected:
};
}
+namespace llvm {
+template <>
+struct format_provider<lldb_private::MemoryRegionInfo::OptionalBool> {
+ static void format(const lldb_private::MemoryRegionInfo::OptionalBool &B,
+ raw_ostream &OS, StringRef Options) {
+ switch(B) {
+ case lldb_private::MemoryRegionInfo::eNo:
+ OS << "no";
+ return;
+ case lldb_private::MemoryRegionInfo::eYes:
+ OS << "yes";
+ return;
+ case lldb_private::MemoryRegionInfo::eDontKnow:
+ OS << "don't know";
+ return;
+ }
+ }
+};
+}
+
#endif // #ifndef lldb_MemoryRegionInfo_h
diff --git a/source/Utility/ModuleCache.h b/include/lldb/Target/ModuleCache.h
index 6faa5ffb1816..49a7c97c60c3 100644
--- a/source/Utility/ModuleCache.h
+++ b/include/lldb/Target/ModuleCache.h
@@ -7,15 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ModuleCache_h_
-#define utility_ModuleCache_h_
+#ifndef LLDB_TARGET_MODULECACHE_H
+#define LLDB_TARGET_MODULECACHE_H
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/File.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
#include <functional>
#include <string>
@@ -27,7 +27,7 @@ class Module;
class UUID;
//----------------------------------------------------------------------
-/// @class ModuleCache ModuleCache.h "Utility/ModuleCache.h"
+/// @class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h"
/// @brief A module cache class.
///
/// Caches locally modules that are downloaded from remote targets.
diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h
index 4e5a5693235a..2b844882e4ad 100644
--- a/include/lldb/Target/PathMappingList.h
+++ b/include/lldb/Target/PathMappingList.h
@@ -15,8 +15,8 @@
#include <map>
#include <vector>
// Other libraries and framework includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
// Project includes
namespace lldb_private {
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index 9707093440a5..fb05d3e06dd5 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -22,11 +22,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/UserSettingsController.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/Options.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index 251dfe6a17c0..56bbbfd53fdd 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -30,7 +30,6 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Communication.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/LoadedModuleInfoList.h"
@@ -48,6 +47,8 @@
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/QueueList.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/NameMatches.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
@@ -305,11 +306,11 @@ public:
class ProcessInstanceInfoMatch {
public:
ProcessInstanceInfoMatch()
- : m_match_info(), m_name_match_type(eNameMatchIgnore),
+ : m_match_info(), m_name_match_type(NameMatch::Ignore),
m_match_all_users(false) {}
ProcessInstanceInfoMatch(const char *process_name,
- NameMatchType process_name_match_type)
+ NameMatch process_name_match_type)
: m_match_info(), m_name_match_type(process_name_match_type),
m_match_all_users(false) {
m_match_info.GetExecutableFile().SetFile(process_name, false);
@@ -323,9 +324,9 @@ public:
void SetMatchAllUsers(bool b) { m_match_all_users = b; }
- NameMatchType GetNameMatchType() const { return m_name_match_type; }
+ NameMatch GetNameMatchType() const { return m_name_match_type; }
- void SetNameMatchType(NameMatchType name_match_type) {
+ void SetNameMatchType(NameMatch name_match_type) {
m_name_match_type = name_match_type;
}
@@ -338,7 +339,7 @@ public:
protected:
ProcessInstanceInfo m_match_info;
- NameMatchType m_name_match_type;
+ NameMatch m_name_match_type;
bool m_match_all_users;
};
@@ -504,6 +505,7 @@ class Process : public std::enable_shared_from_this<Process>,
public PluginInterface {
friend class FunctionCaller; // For WaitForStateChangeEventsPrivate
friend class Debugger; // For PopProcessIOHandler and ProcessIOHandlerIsActive
+ friend class DynamicLoader; // For LoadOperatingSystemPlugin
friend class ProcessEventData;
friend class StopInfo;
friend class Target;
@@ -2605,7 +2607,7 @@ public:
bool RunPreResumeActions();
void ClearPreResumeActions();
-
+
void ClearPreResumeAction(PreResumeActionCallback callback, void *baton);
ProcessRunLock &GetRunLock();
@@ -3143,6 +3145,8 @@ protected:
Error StopForDestroyOrDetach(lldb::EventSP &exit_event_sp);
+ virtual Error UpdateAutomaticSignalFiltering();
+
bool StateChangedIsExternallyHijacked();
void LoadOperatingSystemPlugin(bool flush);
diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h
index f8d37fa4ebb4..03b15242f7ee 100644
--- a/include/lldb/Target/ProcessInfo.h
+++ b/include/lldb/Target/ProcessInfo.h
@@ -12,8 +12,8 @@
// LLDB headers
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h
index 2c192c24da87..083e0bbed8bd 100644
--- a/include/lldb/Target/ProcessLaunchInfo.h
+++ b/include/lldb/Target/ProcessLaunchInfo.h
@@ -14,12 +14,13 @@
#include <string>
// LLDB Headers
-#include "lldb/Core/Flags.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Host/Host.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/ProcessInfo.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
diff --git a/include/lldb/Utility/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h
index eb5126329bc0..acc5c1f32686 100644
--- a/include/lldb/Utility/ProcessStructReader.h
+++ b/include/lldb/Target/ProcessStructReader.h
@@ -1,5 +1,4 @@
-//===---------------------ProcessStructReader.h ------------------*- C++
-//-*-===//
+//===---------------------ProcessStructReader.h ------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,17 +7,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ProcessStructReader_h_
-#define utility_ProcessStructReader_h_
+#ifndef LLDB_TARGET_PROCESSSTRUCTREADER_H
+#define LLDB_TARGET_PROCESSSTRUCTREADER_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
#include <initializer_list>
#include <map>
diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h
index f6378502c19c..acbf94e1b0f9 100644
--- a/include/lldb/Target/QueueItem.h
+++ b/include/lldb/Target/QueueItem.h
@@ -23,7 +23,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h
index 038463d9ab02..91cf3eb6d4c2 100644
--- a/include/lldb/Target/QueueList.h
+++ b/include/lldb/Target/QueueList.h
@@ -13,8 +13,8 @@
#include <mutex>
#include <vector>
-#include "lldb/Core/UserID.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h
index 8391cadcdf66..578cf25eef25 100644
--- a/include/lldb/Target/RegisterCheckpoint.h
+++ b/include/lldb/Target/RegisterCheckpoint.h
@@ -10,8 +10,8 @@
#ifndef liblldb_RegisterCheckpoint_h_
#define liblldb_RegisterCheckpoint_h_
-#include "lldb/Core/UserID.h"
#include "lldb/Target/StackID.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Utility/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h
index b3845ac0d46b..5649c8022ee7 100644
--- a/include/lldb/Utility/RegisterNumber.h
+++ b/include/lldb/Target/RegisterNumber.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterNumber_h
-#define liblldb_RegisterNumber_h
+#ifndef LLDB_TARGET_REGISTERNUMBER_H
+#define LLDB_TARGET_REGISTERNUMBER_H
#include "lldb/lldb-private.h"
#include <map>
diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h
index 34bd187b776c..1f25575e236a 100644
--- a/include/lldb/Target/StackFrame.h
+++ b/include/lldb/Target/StackFrame.h
@@ -17,15 +17,16 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackID.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UserID.h"
namespace lldb_private {
diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h
index 3a2a544fe0b0..f50c9c1b4a56 100644
--- a/include/lldb/Target/SystemRuntime.h
+++ b/include/lldb/Target/SystemRuntime.h
@@ -16,12 +16,12 @@
// Project includes
#include <vector>
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/QueueList.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index 63449bbf930e..47d0b7d767d6 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -22,11 +22,11 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/RegisterCheckpoint.h"
#include "lldb/Target/StackFrameList.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
#define LLDB_THREAD_MAX_STOP_EXC_DATA 8
@@ -126,6 +126,7 @@ public:
// bit of data.
lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you
// might continue with the wrong signals.
+ std::vector<lldb::ThreadPlanSP> m_completed_plan_stack;
lldb::RegisterCheckpointSP
register_backup_sp; // You need to restore the registers, of course...
uint32_t current_inlined_depth;
@@ -1029,6 +1030,15 @@ public:
bool WasThreadPlanDiscarded(ThreadPlan *plan);
//------------------------------------------------------------------
+ /// Check if we have completed plan to override breakpoint stop reason
+ ///
+ /// @return
+ /// Returns true if completed plan stack is not empty
+ /// false otherwise.
+ //------------------------------------------------------------------
+ bool CompletedPlanOverridesBreakpoint();
+
+ //------------------------------------------------------------------
/// Queues a generic thread plan.
///
/// @param[in] plan_sp
@@ -1213,6 +1223,8 @@ public:
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp);
+ void ResetStopInfo();
+
void SetShouldReportStop(Vote vote);
//----------------------------------------------------------------------
diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h
index 9e3c940c3c2d..2ebcd0b0e2c9 100644
--- a/include/lldb/Target/ThreadList.h
+++ b/include/lldb/Target/ThreadList.h
@@ -13,10 +13,10 @@
#include <mutex>
#include <vector>
-#include "lldb/Core/UserID.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadCollection.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h
index fd25cd08f2ba..acc63ffe562b 100644
--- a/include/lldb/Target/ThreadPlan.h
+++ b/include/lldb/Target/ThreadPlan.h
@@ -17,12 +17,12 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UserID.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanTracer.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -40,9 +40,10 @@ namespace lldb_private {
// The thread maintaining a thread plan stack, and you program the actions of a
// particular thread
// by pushing plans onto the plan stack.
-// There is always a "Current" plan, which is the head of the plan stack,
+// There is always a "Current" plan, which is the top of the plan stack,
// though in some cases
-// a plan may defer to plans higher in the stack for some piece of information.
+// a plan may defer to plans higher in the stack for some piece of information
+// (let us define that the plan stack grows downwards).
//
// The plan stack is never empty, there is always a Base Plan which persists
// through the life
@@ -109,6 +110,15 @@ namespace lldb_private {
// plans in the time between when
// your plan gets unshipped and the next resume.
//
+// Thread State Checkpoint:
+//
+// Note that calling functions on target process (ThreadPlanCallFunction) changes
+// current thread state. The function can be called either by direct user demand or
+// internally, for example lldb allocates memory on device to calculate breakpoint
+// condition expression - on Linux it is performed by calling mmap on device.
+// ThreadStateCheckpoint saves Thread state (stop info and completed
+// plan stack) to restore it after completing function call.
+//
// Over the lifetime of the plan, various methods of the ThreadPlan are then
// called in response to changes of state in
// the process we are debugging as follows:
@@ -149,7 +159,7 @@ namespace lldb_private {
// If the Current plan answers "true" then it is asked if the stop should
// percolate all the way to the
// user by calling the ShouldStop method. If the current plan doesn't explain
-// the stop, then we query down
+// the stop, then we query up
// the plan stack for a plan that does explain the stop. The plan that does
// explain the stop then needs to
// figure out what to do about the plans below it in the stack. If the stop is
@@ -170,7 +180,7 @@ namespace lldb_private {
// event it didn't directly handle
// it can designate itself a "Master" plan by responding true to IsMasterPlan,
// and then if it wants not to be
-// discarded, it can return true to OkayToDiscard, and it and all its dependent
+// discarded, it can return false to OkayToDiscard, and it and all its dependent
// plans will be preserved when
// we resume execution.
//
@@ -207,7 +217,7 @@ namespace lldb_private {
//
// If a plan says responds "true" to ShouldStop, then it is asked if it's job
// is complete by calling
-// MischiefManaged. If that returns true, the thread is popped from the plan
+// MischiefManaged. If that returns true, the plan is popped from the plan
// stack and added to the
// Completed Plan Stack. Then the next plan in the stack is asked if it
// ShouldStop, and it returns "true",
@@ -241,9 +251,9 @@ namespace lldb_private {
//
// When the process stops, the thread is given a StopReason, in the form of a
// StopInfo object. If there is a completed
-// plan corresponding to the stop, then the "actual" stop reason will be
+// plan corresponding to the stop, then the "actual" stop reason can be
// suppressed, and instead a StopInfoThreadPlan
-// object will be cons'ed up from the highest completed plan in the stack.
+// object will be cons'ed up from the top completed plan in the stack.
// However, if the plan doesn't want to be
// the stop reason, then it can call SetPlanComplete and pass in "false" for
// the "success" parameter. In that case,
diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h
index a053b5bcb77d..9b7e5d029912 100644
--- a/include/lldb/Target/ThreadPlanPython.h
+++ b/include/lldb/Target/ThreadPlanPython.h
@@ -18,13 +18,13 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanTracer.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h
index 1c58d6452b5f..a209f3549aed 100644
--- a/include/lldb/Target/UnixSignals.h
+++ b/include/lldb/Target/UnixSignals.h
@@ -14,11 +14,13 @@
// C++ Includes
#include <map>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
+#include "llvm/ADT/Optional.h"
namespace lldb_private {
@@ -88,6 +90,19 @@ public:
void RemoveSignal(int signo);
+ // Returns a current version of the data stored in this class.
+ // Version gets incremented each time Set... method is called.
+ uint64_t GetVersion() const;
+
+ // Returns a vector of signals that meet criteria provided in arguments.
+ // Each should_[suppress|stop|notify] flag can be
+ // None - no filtering by this flag
+ // true - only signals that have it set to true are returned
+ // false - only signals that have it set to true are returned
+ std::vector<int32_t> GetFilteredSignals(llvm::Optional<bool> should_suppress,
+ llvm::Optional<bool> should_stop,
+ llvm::Optional<bool> should_notify);
+
protected:
//------------------------------------------------------------------
// Classes that inherit from UnixSignals can see and modify these
@@ -111,6 +126,12 @@ protected:
collection m_signals;
+ // This version gets incremented every time something is changing in
+ // this class, including when we call AddSignal from the constructor.
+ // So after the object is constructed m_version is going to be > 0
+ // if it has at least one signal registered in it.
+ uint64_t m_version = 0;
+
// GDBRemote signals need to be copyable.
UnixSignals(const UnixSignals &rhs);
diff --git a/include/lldb/Core/Baton.h b/include/lldb/Utility/Baton.h
index c2ab9f74907d..065f2960962d 100644
--- a/include/lldb/Core/Baton.h
+++ b/include/lldb/Utility/Baton.h
@@ -10,12 +10,15 @@
#ifndef lldb_Baton_h_
#define lldb_Baton_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "lldb/lldb-enumerations.h" // for DescriptionLevel
#include "lldb/lldb-public.h"
+#include <memory> // for unique_ptr
+
+namespace lldb_private {
+class Stream;
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Utility/ConstString.h
index c6531cab3cf6..fbf1a9bf536e 100644
--- a/include/lldb/Core/ConstString.h
+++ b/include/lldb/Utility/ConstString.h
@@ -10,18 +10,22 @@
#ifndef liblldb_ConstString_h_
#define liblldb_ConstString_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h" // for format_provider
-// Project includes
-#include "lldb/lldb-private.h"
+#include <stddef.h> // for size_t
+
+namespace lldb_private {
+class Stream;
+}
+namespace llvm {
+class raw_ostream;
+}
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class ConstString ConstString.h "lldb/Core/ConstString.h"
+/// @class ConstString ConstString.h "lldb/Utility/ConstString.h"
/// @brief A uniqued constant string class.
///
/// Provides an efficient way to store strings as uniqued strings. After
@@ -476,4 +480,11 @@ Stream &operator<<(Stream &s, const ConstString &str);
} // namespace lldb_private
+namespace llvm {
+template <> struct format_provider<lldb_private::ConstString> {
+ static void format(const lldb_private::ConstString &CS, llvm::raw_ostream &OS,
+ llvm::StringRef Options);
+};
+}
+
#endif // liblldb_ConstString_h_
diff --git a/include/lldb/Utility/ConvertEnum.h b/include/lldb/Utility/ConvertEnum.h
deleted file mode 100644
index 239247d6a1da..000000000000
--- a/include/lldb/Utility/ConvertEnum.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- ConvertEnum.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_UTILITY_CONVERTENUM_H
-#define LLDB_UTILITY_CONVERTENUM_H
-
-#include "lldb/lldb-enumerations.h"
-#include "lldb/lldb-private-enumerations.h"
-
-namespace lldb_private {
-
-const char *GetVoteAsCString(Vote vote);
-const char *GetSectionTypeAsCString(lldb::SectionType sect_type);
-}
-
-#endif
diff --git a/include/lldb/Core/DataBuffer.h b/include/lldb/Utility/DataBuffer.h
index ffa71c06be80..ffa71c06be80 100644
--- a/include/lldb/Core/DataBuffer.h
+++ b/include/lldb/Utility/DataBuffer.h
diff --git a/include/lldb/Core/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h
index 5528ebd9135f..20e27ef8950c 100644
--- a/include/lldb/Core/DataBufferHeap.h
+++ b/include/lldb/Utility/DataBufferHeap.h
@@ -10,10 +10,12 @@
#ifndef liblldb_DataBufferHeap_h_
#define liblldb_DataBufferHeap_h_
-#include <vector>
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/lldb-types.h" // for offset_t
+#include "llvm/ADT/StringRef.h" // for StringRef
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/lldb-private.h"
+#include <cstdint> // for uint8_t, uint64_t
+#include <vector>
namespace lldb_private {
@@ -25,7 +27,8 @@ namespace lldb_private {
/// the object. This class is best used to store chunks of data that
/// are created or read from sources that can't intelligently and lazily
/// fault new data pages in. Large amounts of data that comes from files
-/// should probably use the DataBufferMemoryMap class.
+/// should probably use DataBufferLLVM, which can intelligently determine
+/// when memory mapping is optimal.
//----------------------------------------------------------------------
class DataBufferHeap : public DataBuffer {
public:
diff --git a/include/lldb/Utility/DataBufferLLVM.h b/include/lldb/Utility/DataBufferLLVM.h
new file mode 100644
index 000000000000..737e2d019044
--- /dev/null
+++ b/include/lldb/Utility/DataBufferLLVM.h
@@ -0,0 +1,52 @@
+//===--- DataBufferLLVM.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_CORE_DATABUFFERLLVM_H
+#define LLDB_CORE_DATABUFFERLLVM_H
+
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/lldb-types.h" // for offset_t
+
+#include <memory>
+#include <stdint.h> // for uint8_t, uint64_t
+
+namespace llvm {
+class MemoryBuffer;
+class Twine;
+}
+
+namespace lldb_private {
+
+class DataBufferLLVM : public DataBuffer {
+public:
+ ~DataBufferLLVM();
+
+ static std::shared_ptr<DataBufferLLVM>
+ CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, uint64_t Offset, bool Private = false);
+
+ static std::shared_ptr<DataBufferLLVM>
+ CreateFromPath(const llvm::Twine &Path, bool NullTerminate = false, bool Private = false);
+
+ uint8_t *GetBytes() override;
+ const uint8_t *GetBytes() const override;
+ lldb::offset_t GetByteSize() const override;
+
+ char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
+
+private:
+ /// \brief Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a
+ /// valid pointer.
+ explicit DataBufferLLVM(std::unique_ptr<llvm::MemoryBuffer> Buffer);
+ const uint8_t *GetBuffer() const;
+
+ std::unique_ptr<llvm::MemoryBuffer> Buffer;
+};
+}
+
+#endif
diff --git a/include/lldb/Core/DataEncoder.h b/include/lldb/Utility/DataEncoder.h
index a2bc4dcce330..ea347d86237b 100644
--- a/include/lldb/Core/DataEncoder.h
+++ b/include/lldb/Utility/DataEncoder.h
@@ -12,8 +12,12 @@
#if defined(__cplusplus)
-#include "lldb/lldb-private.h"
-#include <limits.h>
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "lldb/lldb-enumerations.h" // for ByteOrder
+#include "lldb/lldb-forward.h" // for DataBufferSP
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
#include <stdint.h>
namespace lldb_private {
@@ -384,9 +388,9 @@ protected:
lldb::ByteOrder
m_byte_order; ///< The byte order of the data we are extracting from.
uint8_t m_addr_size; ///< The address size to use when extracting pointers or
- ///addresses
+ /// addresses
mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
- ///be shared among multiple instances
+ /// be shared among multiple instances
private:
DISALLOW_COPY_AND_ASSIGN(DataEncoder);
diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Utility/DataExtractor.h
index 89cc00548e46..58240d9a5268 100644
--- a/include/lldb/Core/DataExtractor.h
+++ b/include/lldb/Utility/DataExtractor.h
@@ -7,20 +7,28 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DataExtractor_h_
-#define liblldb_DataExtractor_h_
+#ifndef LLDB_UTILITY_DATAEXTRACTOR_H
+#define LLDB_UTILITY_DATAEXTRACTOR_H
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h" // for ByteOrder
+#include "lldb/lldb-forward.h" // for DataBufferSP
+#include "lldb/lldb-types.h"
-// C Includes
-#include <limits.h>
#include <stdint.h>
#include <string.h>
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/SmallVector.h"
+namespace lldb_private {
+class Log;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace llvm {
+template <typename T> class SmallVectorImpl;
+}
-// Project includes
-#include "lldb/lldb-private.h"
+// C++ Includes
namespace lldb_private {
@@ -43,8 +51,6 @@ public:
//------------------------------------------------------------------
/// @typedef DataExtractor::Type
/// @brief Type enumerations used in the dump routines.
- /// @see DataExtractor::Dump()
- /// @see DataExtractor::DumpRawHexBytes()
//------------------------------------------------------------------
typedef enum {
TypeUInt8, ///< Format output as unsigned 8 bit integers
@@ -57,12 +63,6 @@ public:
TypeSLEB128 ///< Format output as SLEB128 numbers
} Type;
- static void DumpHexBytes(Stream *s, const void *src, size_t src_len,
- uint32_t bytes_per_line,
- lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS
- // to not show address at
- // start of line
-
//------------------------------------------------------------------
/// Default constructor.
///
@@ -172,7 +172,9 @@ public:
/// reference count on the data will be decremented, and if zero,
/// the data will be freed.
//------------------------------------------------------------------
- ~DataExtractor();
+ virtual ~DataExtractor();
+
+ uint32_t getTargetByteSize() const { return m_target_byte_size; }
//------------------------------------------------------------------
/// Clears the object state.
@@ -225,73 +227,6 @@ public:
const char *type_format = nullptr) const;
//------------------------------------------------------------------
- /// Dumps \a item_count objects into the stream \a s.
- ///
- /// Dumps \a item_count objects using \a item_format, each of which
- /// are \a item_byte_size bytes long starting at offset \a offset
- /// bytes into the contained data, into the stream \a s. \a
- /// num_per_line objects will be dumped on each line before a new
- /// line will be output. If \a base_addr is a valid address, then
- /// each new line of output will be preceded by the address value
- /// plus appropriate offset, and a colon and space. Bitfield values
- /// can be dumped by calling this function multiple times with the
- /// same start offset, format and size, yet differing \a
- /// item_bit_size and \a item_bit_offset values.
- ///
- /// @param[in] s
- /// The stream to dump the output to. This value can not be nullptr.
- ///
- /// @param[in] offset
- /// The offset into the data at which to start dumping.
- ///
- /// @param[in] item_format
- /// The format to use when dumping each item.
- ///
- /// @param[in] item_byte_size
- /// The byte size of each item.
- ///
- /// @param[in] item_count
- /// The number of items to dump.
- ///
- /// @param[in] num_per_line
- /// The number of items to display on each line.
- ///
- /// @param[in] base_addr
- /// The base address that gets added to the offset displayed on
- /// each line if the value is valid. Is \a base_addr is
- /// LLDB_INVALID_ADDRESS then no address values will be prepended
- /// to any lines.
- ///
- /// @param[in] item_bit_size
- /// If the value to display is a bitfield, this value should
- /// be the number of bits that the bitfield item has within the
- /// item's byte size value. This function will need to be called
- /// multiple times with identical \a offset and \a item_byte_size
- /// values in order to display multiple bitfield values that
- /// exist within the same integer value. If the items being
- /// displayed are not bitfields, this value should be zero.
- ///
- /// @param[in] item_bit_offset
- /// If the value to display is a bitfield, this value should
- /// be the offset in bits, or shift right amount, that the
- /// bitfield item occupies within the item's byte size value.
- /// This function will need to be called multiple times with
- /// identical \a offset and \a item_byte_size values in order
- /// to display multiple bitfield values that exist within the
- /// same integer value. If the items being displayed are not
- /// bitfields, this value should be zero.
- ///
- /// @return
- /// The offset at which dumping ended.
- //------------------------------------------------------------------
- lldb::offset_t Dump(Stream *s, lldb::offset_t offset,
- lldb::Format item_format, size_t item_byte_size,
- size_t item_count, size_t num_per_line,
- uint64_t base_addr, uint32_t item_bit_size,
- uint32_t item_bit_offset,
- ExecutionContextScope *exe_scope = nullptr) const;
-
- //------------------------------------------------------------------
/// Dump a UUID value at \a offset.
///
/// Dump a UUID starting at \a offset bytes into this object's data.
@@ -573,38 +508,6 @@ public:
long double GetLongDouble(lldb::offset_t *offset_ptr) const;
//------------------------------------------------------------------
- /// Extract a GNU encoded pointer value from \a *offset_ptr.
- ///
- /// @param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// @param[in] eh_ptr_enc
- /// The GNU pointer encoding type.
- ///
- /// @param[in] pc_rel_addr
- /// The PC relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_pcrel.
- ///
- /// @param[in] text_addr
- /// The text (code) relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_textrel.
- ///
- /// @param[in] data_addr
- /// The data relative address to use when the encoding is
- /// \c DW_GNU_EH_PE_datarel.
- ///
- /// @return
- /// The extracted GNU encoded pointer value.
- //------------------------------------------------------------------
- uint64_t GetGNUEHPointer(lldb::offset_t *offset_ptr, uint32_t eh_ptr_enc,
- lldb::addr_t pc_rel_addr, lldb::addr_t text_addr,
- lldb::addr_t data_addr);
-
- //------------------------------------------------------------------
/// Extract an integer of size \a byte_size from \a *offset_ptr.
///
/// Extract a single integer value and update the offset pointed to
@@ -1243,9 +1146,9 @@ protected:
lldb::ByteOrder
m_byte_order; ///< The byte order of the data we are extracting from.
uint32_t m_addr_size; ///< The address size to use when extracting pointers or
- ///addresses
+ /// addresses
mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
- ///be shared among multiple instances
+ /// be shared among multiple instances
const uint32_t m_target_byte_size;
};
diff --git a/include/lldb/Host/Endian.h b/include/lldb/Utility/Endian.h
index 82bc0b7749b1..2a102b63aa10 100644
--- a/include/lldb/Host/Endian.h
+++ b/include/lldb/Utility/Endian.h
@@ -7,11 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_host_endian_h_
-#define liblldb_host_endian_h_
+#ifndef LLDB_UTILITY_ENDIAN_H
+#define LLDB_UTILITY_ENDIAN_H
#include "lldb/lldb-enumerations.h"
+#include <stdint.h>
+
namespace lldb_private {
namespace endian {
diff --git a/include/lldb/Core/Error.h b/include/lldb/Utility/Error.h
index 8131580991ad..a236ab45a0bb 100644
--- a/include/lldb/Core/Error.h
+++ b/include/lldb/Utility/Error.h
@@ -11,23 +11,26 @@
#define __DCError_h__
#if defined(__cplusplus)
-#include "llvm/Support/DataTypes.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType...
+#include "llvm/ADT/StringRef.h" // for StringRef
#include "llvm/Support/FormatVariadic.h"
#include <cstdarg>
-#include <cstdio>
#include <string>
+#include <system_error> // for error_code
+#include <type_traits> // for forward
-#include "lldb/lldb-private.h"
+#include <stdint.h> // for uint32_t
-#include "llvm/Support/FormatVariadic.h"
+namespace llvm {
+class raw_ostream;
+}
namespace lldb_private {
-class Log;
-
//----------------------------------------------------------------------
-/// @class Error Error.h "lldb/Core/Error.h"
+/// @class Error Error.h "lldb/Utility/Error.h"
/// @brief An error handling class.
///
/// This class is designed to be able to hold any error code that can be
@@ -69,6 +72,8 @@ public:
explicit Error(ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric);
+ /* implicit */ Error(std::error_code EC);
+
explicit Error(const char *format, ...) __attribute__((format(printf, 2, 3)));
Error(const Error &rhs);
@@ -148,48 +153,6 @@ public:
lldb::ErrorType GetType() const;
//------------------------------------------------------------------
- /// Log an error to Log().
- ///
- /// Log the error given a formatted string \a format. If the this
- /// object contains an error code, update the error string to
- /// contain the prefix "error: ", followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object. Logging always occurs
- /// even when the error code contains a non-error value.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void PutToLog(Log *log, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
-
- //------------------------------------------------------------------
- /// Log an error to Log() if the error value is an error.
- ///
- /// Log the error given a formatted string \a format only if the
- /// error value in this object describes an error condition. If the
- /// this object contains an error, update the error string to
- /// contain the prefix "error: " followed by the formatted string,
- /// followed by the error value and any string that describes the
- /// error value. This allows more context to be given to an error
- /// string that remains cached in this object.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- void LogIfError(Log *log, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
-
- //------------------------------------------------------------------
/// Set accessor from a kern_return_t.
///
/// Set accesssor for the error value to \a err and the error type
@@ -304,10 +267,7 @@ protected:
namespace llvm {
template <> struct format_provider<lldb_private::Error> {
static void format(const lldb_private::Error &error, llvm::raw_ostream &OS,
- llvm::StringRef Options) {
- llvm::format_provider<llvm::StringRef>::format(error.AsCString(), OS,
- Options);
- }
+ llvm::StringRef Options);
};
}
diff --git a/include/lldb/Core/FastDemangle.h b/include/lldb/Utility/FastDemangle.h
index f779aaa04606..f779aaa04606 100644
--- a/include/lldb/Core/FastDemangle.h
+++ b/include/lldb/Utility/FastDemangle.h
diff --git a/include/lldb/Host/FileSpec.h b/include/lldb/Utility/FileSpec.h
index b8df7453886c..67926d01e529 100644
--- a/include/lldb/Host/FileSpec.h
+++ b/include/lldb/Utility/FileSpec.h
@@ -17,13 +17,28 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/STLUtils.h"
-#include "lldb/Host/PosixApi.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/ConstString.h"
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t
+
+namespace lldb_private {
+class Stream;
+}
+namespace llvm {
+class Triple;
+}
+namespace llvm {
+class raw_ostream;
+}
+namespace llvm {
+template <typename T> class SmallVectorImpl;
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -46,17 +61,6 @@ namespace lldb_private {
//----------------------------------------------------------------------
class FileSpec {
public:
- typedef enum FileType {
- eFileTypeInvalid = -1,
- eFileTypeUnknown = 0,
- eFileTypeDirectory,
- eFileTypePipe,
- eFileTypeRegular,
- eFileTypeSocket,
- eFileTypeSymbolicLink,
- eFileTypeOther
- } FileType;
-
enum PathSyntax {
ePathSyntaxPosix,
ePathSyntaxWindows,
@@ -85,7 +89,8 @@ public:
explicit FileSpec(llvm::StringRef path, bool resolve_path,
PathSyntax syntax = ePathSyntaxHostNative);
- explicit FileSpec(llvm::StringRef path, bool resolve_path, ArchSpec arch);
+ explicit FileSpec(llvm::StringRef path, bool resolve_path,
+ const llvm::Triple &Triple);
//------------------------------------------------------------------
/// Copy constructor
@@ -454,8 +459,6 @@ public:
//------------------------------------------------------------------
ConstString GetFileNameStrippingExtension() const;
- FileType GetFileType() const;
-
//------------------------------------------------------------------
/// Return the current permissions of the path.
///
@@ -470,20 +473,6 @@ public:
//------------------------------------------------------------------
uint32_t GetPermissions() const;
- bool IsDirectory() const {
- return GetFileType() == FileSpec::eFileTypeDirectory;
- }
-
- bool IsPipe() const { return GetFileType() == FileSpec::eFileTypePipe; }
-
- bool IsRegularFile() const {
- return GetFileType() == FileSpec::eFileTypeRegular;
- }
-
- bool IsSocket() const { return GetFileType() == FileSpec::eFileTypeSocket; }
-
- bool IsSymbolicLink() const;
-
//------------------------------------------------------------------
/// Get the memory cost of this object.
///
@@ -499,124 +488,6 @@ public:
size_t MemorySize() const;
//------------------------------------------------------------------
- /// Memory map part of, or the entire contents of, a file.
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data is memory mapped and
- /// will lazily page in data from the file as memory is accessed.
- /// The data that is mapped will start \a offset bytes into the
- /// file, and \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function on the return
- /// shared data pointer object contents.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP MemoryMapFileContents(off_t offset = 0,
- size_t length = SIZE_MAX) const;
-
- //------------------------------------------------------------------
- /// Memory map part of, or the entire contents of, a file only if
- /// the file is local (not on a network mount).
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data will be memory mapped
- /// if the file is local and will lazily page in data from the file
- /// as memory is accessed. If the data is memory mapped, the data
- /// that is mapped will start \a offset bytes into the file, and
- /// \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function on the return
- /// shared data pointer object contents.
- ///
- /// If the file is on a network mount the data will be read into a
- /// heap buffer immediately so that accesses to the data won't later
- /// cause a crash if we touch a page that isn't paged in and the
- /// network mount has been disconnected or gone away.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP MemoryMapFileContentsIfLocal(off_t file_offset,
- size_t file_size) const;
-
- //------------------------------------------------------------------
- /// Read part of, or the entire contents of, a file into a heap based data
- /// buffer.
- ///
- /// Returns a shared pointer to a data buffer that contains all or
- /// part of the contents of a file. The data copies into a heap based
- /// buffer that lives in the DataBuffer shared pointer object returned.
- /// The data that is cached will start \a offset bytes into the
- /// file, and \a length bytes will be mapped. If \a length is
- /// greater than the number of bytes available in the file starting
- /// at \a offset, the number of bytes will be appropriately
- /// truncated. The final number of bytes that get mapped can be
- /// verified using the DataBuffer::GetByteSize() function.
- ///
- /// @param[in] offset
- /// The offset in bytes from the beginning of the file where
- /// memory mapping should begin.
- ///
- /// @param[in] length
- /// The size in bytes that should be mapped starting \a offset
- /// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
- ///
- /// @return
- /// A shared pointer to the memory mapped data. This shared
- /// pointer can contain a nullptr DataBuffer pointer, so the contained
- /// pointer must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP ReadFileContents(off_t offset = 0,
- size_t length = SIZE_MAX,
- Error *error_ptr = nullptr) const;
-
- size_t ReadFileContents(off_t file_offset, void *dst, size_t dst_len,
- Error *error_ptr) const;
-
- //------------------------------------------------------------------
- /// Read the entire contents of a file as data that can be used
- /// as a C string.
- ///
- /// Read the entire contents of a file and ensure that the data
- /// is NULL terminated so it can be used as a C string.
- ///
- /// @return
- /// A shared pointer to the data. This shared pointer can
- /// contain a nullptr DataBuffer pointer, so the contained pointer
- /// must be checked prior to using it.
- //------------------------------------------------------------------
- lldb::DataBufferSP ReadFileContentsAsCString(Error *error_ptr = nullptr);
-
- //------------------------------------------------------------------
/// Normalize a pathname by collapsing redundant separators and
/// up-level references.
//------------------------------------------------------------------
@@ -639,7 +510,8 @@ public:
void SetFile(llvm::StringRef path, bool resolve_path,
PathSyntax syntax = ePathSyntaxHostNative);
- void SetFile(llvm::StringRef path, bool resolve_path, ArchSpec arch);
+ void SetFile(llvm::StringRef path, bool resolve_path,
+ const llvm::Triple &Triple);
bool IsResolved() const { return m_is_resolved; }
@@ -659,21 +531,6 @@ public:
void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; }
//------------------------------------------------------------------
- /// Read the file into an array of strings, one per line.
- ///
- /// Opens and reads the file in this object into an array of strings,
- /// one string per line of the file. Returns a boolean indicating
- /// success or failure.
- ///
- /// @param[out] lines
- /// The string array into which to read the file.
- ///
- /// @result
- /// Returns the number of lines that were read from the file.
- //------------------------------------------------------------------
- size_t ReadFileLines(STLStringArray &lines);
-
- //------------------------------------------------------------------
/// Resolves user name and links in \a path, and overwrites the input
/// argument with the resolved path.
///
@@ -696,53 +553,27 @@ public:
ConstString GetLastPathComponent() const;
- //------------------------------------------------------------------
- /// Resolves the user name at the beginning of \a src_path, and writes the
- /// output
- /// to \a dst_path. Note, \a src_path can contain other path components after
- /// the
- /// user name, they will be copied over, and if the path doesn't start with
- /// "~" it
- /// will also be copied over to \a dst_path.
- ///
- /// @param[in] src_path
- /// Input path to be resolved.
- ///
- /// @param[in] dst_path
- /// Buffer to store the resolved path.
- //------------------------------------------------------------------
- static void ResolveUsername(llvm::SmallVectorImpl<char> &path);
-
- static size_t ResolvePartialUsername(llvm::StringRef partial_name,
- StringList &matches);
-
enum EnumerateDirectoryResult {
eEnumerateDirectoryResultNext, // Enumerate next entry in the current
// directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a
// directory or symlink, or next if not
- eEnumerateDirectoryResultExit, // Exit from the current directory at the
- // current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
- void *baton, FileType file_type, const FileSpec &spec);
+ void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec);
- static EnumerateDirectoryResult
- EnumerateDirectory(llvm::StringRef dir_path, bool find_directories,
- bool find_files, bool find_other,
- EnumerateDirectoryCallbackType callback,
- void *callback_baton);
+ static void EnumerateDirectory(llvm::StringRef dir_path,
+ bool find_directories, bool find_files,
+ bool find_other,
+ EnumerateDirectoryCallbackType callback,
+ void *callback_baton);
- typedef std::function<EnumerateDirectoryResult(FileType file_type,
- const FileSpec &spec)>
+ typedef std::function<EnumerateDirectoryResult(
+ llvm::sys::fs::file_type file_type, const FileSpec &spec)>
DirectoryCallback;
- static EnumerateDirectoryResult
- ForEachItemInDirectory(llvm::StringRef dir_path,
- DirectoryCallback const &callback);
-
protected:
//------------------------------------------------------------------
// Member variables
diff --git a/include/lldb/Core/Flags.h b/include/lldb/Utility/Flags.h
index d1bf685bced7..1b303858b1c1 100644
--- a/include/lldb/Core/Flags.h
+++ b/include/lldb/Utility/Flags.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Flags_h_
-#define liblldb_Flags_h_
+#ifndef LLDB_UTILITY_FLAGS_H
+#define LLDB_UTILITY_FLAGS_H
#include <cstddef>
#include <cstdint>
@@ -16,7 +16,7 @@
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class Flags Flags.h "lldb/Core/Flags.h"
+/// @class Flags Flags.h "lldb/Utility/Flags.h"
/// @brief A class to manage flags.
///
/// The Flags class managed flag bits and allows testing and
diff --git a/include/lldb/Core/History.h b/include/lldb/Utility/History.h
index fcffcdd901bb..c6882b65fd8e 100644
--- a/include/lldb/Core/History.h
+++ b/include/lldb/Utility/History.h
@@ -10,17 +10,19 @@
#ifndef lldb_History_h_
#define lldb_History_h_
-// C Includes
-#include <stdint.h>
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
// C++ Includes
#include <mutex>
#include <stack>
#include <string>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-public.h"
+#include <stddef.h> // for size_t
+#include <stdint.h>
+
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h
index 145ef4868d2f..5c5d382048c1 100644
--- a/include/lldb/Utility/JSON.h
+++ b/include/lldb/Utility/JSON.h
@@ -10,19 +10,20 @@
#ifndef utility_JSON_h_
#define utility_JSON_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Utility/StringExtractor.h"
-#include <inttypes.h>
#include <map>
#include <memory>
-#include <stdint.h>
#include <string>
+#include <type_traits>
#include <vector>
-#include "llvm/Support/Casting.h"
+#include <stdint.h>
namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
class JSONValue {
public:
diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h
index 328a4d4f9258..9d9f3ceefab0 100644
--- a/include/lldb/Utility/LLDBAssert.h
+++ b/include/lldb/Utility/LLDBAssert.h
@@ -1,5 +1,4 @@
-//===----------------- LLDBAssert.h --------------------------------*- C++
-//-*-===//
+//===----------------- LLDBAssert.h ------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,8 +10,6 @@
#ifndef utility_LLDBAssert_h_
#define utility_LLDBAssert_h_
-#include <assert.h>
-
#ifdef LLDB_CONFIGURATION_DEBUG
#define lldbassert(x) assert(x)
#else
diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h
new file mode 100644
index 000000000000..bfc0f4c9590a
--- /dev/null
+++ b/include/lldb/Utility/Log.h
@@ -0,0 +1,218 @@
+//===-- Log.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_UTILITY_LOG_H
+#define LLDB_UTILITY_LOG_H
+
+#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/Logging.h"
+#include "lldb/lldb-defines.h"
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringMap.h" // for StringMap
+#include "llvm/ADT/StringRef.h" // for StringRef, StringLiteral
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/RWMutex.h"
+
+#include <atomic>
+#include <cstdarg>
+#include <cstdint>
+#include <memory> // for shared_ptr
+#include <string> // for string
+#include <type_traits> // for forward
+
+namespace llvm {
+class raw_ostream;
+}
+namespace llvm {
+template <class C> class ManagedStatic;
+}
+//----------------------------------------------------------------------
+// Logging Options
+//----------------------------------------------------------------------
+#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
+#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
+#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
+#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
+#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
+#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6)
+#define LLDB_LOG_OPTION_BACKTRACE (1U << 7)
+#define LLDB_LOG_OPTION_APPEND (1U << 8)
+#define LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION (1U << 9)
+
+//----------------------------------------------------------------------
+// Logging Functions
+//----------------------------------------------------------------------
+namespace lldb_private {
+
+class Log final {
+public:
+ // Description of a log channel category.
+ struct Category {
+ llvm::StringLiteral name;
+ llvm::StringLiteral description;
+ uint32_t flag;
+ };
+
+ // This class describes a log channel. It also encapsulates the behavior
+ // necessary to enable a log channel in an atomic manner.
+ class Channel {
+ std::atomic<Log *> log_ptr;
+ friend class Log;
+
+ public:
+ const llvm::ArrayRef<Category> categories;
+ const uint32_t default_flags;
+
+ constexpr Channel(llvm::ArrayRef<Log::Category> categories,
+ uint32_t default_flags)
+ : log_ptr(nullptr), categories(categories),
+ default_flags(default_flags) {}
+
+ // This function is safe to call at any time
+ // If the channel is disabled after (or concurrently with) this function
+ // returning a non-null Log pointer, it is still safe to attempt to write to
+ // the Log object -- the output will be discarded.
+ Log *GetLogIfAll(uint32_t mask) {
+ Log *log = log_ptr.load(std::memory_order_relaxed);
+ if (log && log->GetMask().AllSet(mask))
+ return log;
+ return nullptr;
+ }
+
+ // This function is safe to call at any time
+ // If the channel is disabled after (or concurrently with) this function
+ // returning a non-null Log pointer, it is still safe to attempt to write to
+ // the Log object -- the output will be discarded.
+ Log *GetLogIfAny(uint32_t mask) {
+ Log *log = log_ptr.load(std::memory_order_relaxed);
+ if (log && log->GetMask().AnySet(mask))
+ return log;
+ return nullptr;
+ }
+ };
+
+ //------------------------------------------------------------------
+ // Static accessors for logging channels
+ //------------------------------------------------------------------
+ static void Register(llvm::StringRef name, Channel &channel);
+ static void Unregister(llvm::StringRef name);
+
+ static bool
+ EnableLogChannel(const std::shared_ptr<llvm::raw_ostream> &log_stream_sp,
+ uint32_t log_options, llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ llvm::raw_ostream &error_stream);
+
+ static bool DisableLogChannel(llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ llvm::raw_ostream &error_stream);
+
+ static bool ListChannelCategories(llvm::StringRef channel, llvm::raw_ostream &stream);
+
+ static void DisableAllLogChannels();
+
+ static void ListAllLogChannels(llvm::raw_ostream &stream);
+
+ //------------------------------------------------------------------
+ // Member functions
+ //
+ // These functions are safe to call at any time you have a Log* obtained from
+ // the Channel class. If logging is disabled between you obtaining the Log
+ // object and writing to it, the output will be silently discarded.
+ //------------------------------------------------------------------
+ Log(Channel &channel) : m_channel(channel) {}
+ ~Log() = default;
+
+ void PutCString(const char *cstr);
+ void PutString(llvm::StringRef str);
+
+ template <typename... Args>
+ void Format(llvm::StringRef file, llvm::StringRef function,
+ const char *format, Args &&... args) {
+ Format(file, function, llvm::formatv(format, std::forward<Args>(args)...));
+ }
+
+ void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ void VAPrintf(const char *format, va_list args);
+
+ void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+
+ void VAError(const char *format, va_list args);
+
+ void Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+
+ void Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+
+ const Flags GetOptions() const;
+
+ const Flags GetMask() const;
+
+ bool GetVerbose() const;
+
+private:
+ Channel &m_channel;
+
+ // The mutex makes sure enable/disable operations are thread-safe. The options
+ // and mask variables are atomic to enable their reading in
+ // Channel::GetLogIfAny without taking the mutex to speed up the fast path.
+ // Their modification however, is still protected by this mutex.
+ llvm::sys::RWMutex m_mutex;
+
+ std::shared_ptr<llvm::raw_ostream> m_stream_sp;
+ std::atomic<uint32_t> m_options{0};
+ std::atomic<uint32_t> m_mask{0};
+
+ void WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
+ llvm::StringRef function);
+ void WriteMessage(const std::string &message);
+
+ void Format(llvm::StringRef file, llvm::StringRef function,
+ const llvm::formatv_object_base &payload);
+
+ std::shared_ptr<llvm::raw_ostream> GetStream() {
+ llvm::sys::ScopedReader lock(m_mutex);
+ return m_stream_sp;
+ }
+
+ void Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp,
+ uint32_t options, uint32_t flags);
+
+ void Disable(uint32_t flags);
+
+ typedef llvm::StringMap<Log> ChannelMap;
+ static llvm::ManagedStatic<ChannelMap> g_channel_map;
+
+ static void ListCategories(llvm::raw_ostream &stream,
+ const ChannelMap::value_type &entry);
+ static uint32_t GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry,
+ llvm::ArrayRef<const char *> categories);
+
+ Log(const Log &) = delete;
+ void operator=(const Log &) = delete;
+};
+
+} // namespace lldb_private
+
+#define LLDB_LOG(log, ...) \
+ do { \
+ ::lldb_private::Log *log_private = (log); \
+ if (log_private) \
+ log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \
+ } while (0)
+
+#define LLDB_LOGV(log, ...) \
+ do { \
+ ::lldb_private::Log *log_private = (log); \
+ if (log_private && log_private->GetVerbose()) \
+ log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \
+ } while (0)
+
+#endif // LLDB_UTILITY_LOG_H
diff --git a/include/lldb/Core/Logging.h b/include/lldb/Utility/Logging.h
index d93fa05af125..865097e7c194 100644
--- a/include/lldb/Core/Logging.h
+++ b/include/lldb/Utility/Logging.h
@@ -7,19 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Core_Logging_h_
-#define liblldb_Core_Logging_h_
+#ifndef LLDB_UTILITY_LOGGING_H
+#define LLDB_UTILITY_LOGGING_H
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
+#include <cstdint>
//----------------------------------------------------------------------
// Log Bits specific to logging in lldb
//----------------------------------------------------------------------
-#define LIBLLDB_LOG_VERBOSE (1u << 0)
#define LIBLLDB_LOG_PROCESS (1u << 1)
#define LIBLLDB_LOG_THREAD (1u << 2)
#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
@@ -59,7 +54,7 @@
namespace lldb_private {
-void LogIfAllCategoriesSet(uint32_t mask, const char *format, ...);
+class Log;
void LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...);
@@ -67,17 +62,8 @@ Log *GetLogIfAllCategoriesSet(uint32_t mask);
Log *GetLogIfAnyCategoriesSet(uint32_t mask);
-uint32_t GetLogMask();
-
-bool IsLogVerbose();
-
-void DisableLog(const char **categories, Stream *feedback_strm);
-
-Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- const char **categories, Stream *feedback_strm);
-
-void ListLogCategories(Stream *strm);
+void InitializeLog();
} // namespace lldb_private
-#endif // liblldb_Core_Logging_h_
+#endif // LLDB_UTILITY_LOGGING_H
diff --git a/include/lldb/Utility/NameMatches.h b/include/lldb/Utility/NameMatches.h
index 50ea7ba7f887..bc9ec703770a 100644
--- a/include/lldb/Utility/NameMatches.h
+++ b/include/lldb/Utility/NameMatches.h
@@ -9,12 +9,20 @@
#ifndef LLDB_UTILITY_NAMEMATCHES_H
#define LLDB_UTILITY_NAMEMATCHES_H
-#include "lldb/lldb-private-enumerations.h"
-
#include "llvm/ADT/StringRef.h"
namespace lldb_private {
-bool NameMatches(llvm::StringRef name, NameMatchType match_type,
+
+enum class NameMatch {
+ Ignore,
+ Equals,
+ Contains,
+ StartsWith,
+ EndsWith,
+ RegularExpression
+};
+
+bool NameMatches(llvm::StringRef name, NameMatch match_type,
llvm::StringRef match);
}
diff --git a/include/lldb/Utility/PriorityPointerPair.h b/include/lldb/Utility/PriorityPointerPair.h
deleted file mode 100644
index 2bd369e78a9a..000000000000
--- a/include/lldb/Utility/PriorityPointerPair.h
+++ /dev/null
@@ -1,86 +0,0 @@
-//===-- PriorityPointerPair.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_PriorityPointerPair_h_
-#define liblldb_PriorityPointerPair_h_
-
-#include "lldb/Utility/SharingPtr.h"
-#include "lldb/lldb-public.h"
-
-namespace lldb_utility {
-
-//----------------------------------------------------------------------
-// A prioritized pair of SharedPtr<T>. One of the two pointers is high
-// priority, the other is low priority.
-// The Get() method always returns high, if *high != NULL,
-// otherwise, low is returned (even if *low == NULL)
-//----------------------------------------------------------------------
-
-template <typename T> class PriorityPointerPair {
-public:
- typedef T &reference_type;
- typedef T *pointer_type;
-
- typedef typename std::shared_ptr<T> T_SP;
-
- PriorityPointerPair() : m_high(), m_low() {}
-
- PriorityPointerPair(pointer_type high, pointer_type low)
- : m_high(high), m_low(low) {}
-
- PriorityPointerPair(pointer_type low) : m_high(), m_low(low) {}
-
- PriorityPointerPair(T_SP &high, T_SP &low) : m_high(high), m_low(low) {}
-
- PriorityPointerPair(T_SP &low) : m_high(), m_low(low) {}
-
- void SwapLow(pointer_type l) { m_low.swap(l); }
-
- void SwapHigh(pointer_type h) { m_high.swap(h); }
-
- void SwapLow(T_SP l) { m_low.swap(l); }
-
- void SwapHigh(T_SP h) { m_high.swap(h); }
-
- T_SP GetLow() { return m_low; }
-
- T_SP GetHigh() { return m_high; }
-
- T_SP Get() {
- if (m_high.get())
- return m_high;
- return m_low;
- }
-
- void ResetHigh() { m_high.reset(); }
-
- void ResetLow() { m_low.reset(); }
-
- void Reset() {
- ResetLow();
- ResetHigh();
- }
-
- reference_type operator*() const { return Get().operator*(); }
-
- pointer_type operator->() const { return Get().operator->(); }
-
- ~PriorityPointerPair();
-
-private:
- T_SP m_high;
- T_SP m_low;
-
- DISALLOW_COPY_AND_ASSIGN(PriorityPointerPair);
-};
-
-} // namespace lldb_utility
-
-#endif // #ifndef liblldb_PriorityPointerPair_h_
diff --git a/include/lldb/Utility/Range.h b/include/lldb/Utility/Range.h
index c13bc0d08bd6..60880dbdbc87 100644
--- a/include/lldb/Utility/Range.h
+++ b/include/lldb/Utility/Range.h
@@ -10,7 +10,6 @@
#ifndef utility_Range_h_
#define utility_Range_h_
-#include <algorithm>
#include <stdint.h>
namespace lldb_utility {
diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Utility/RegularExpression.h
index fe34ef545dc4..d97e35647583 100644
--- a/include/lldb/Core/RegularExpression.h
+++ b/include/lldb/Utility/RegularExpression.h
@@ -36,11 +36,13 @@ inline void regfree(llvm_regex_t *a) { llvm_regfree(a); }
#endif
#include <regex.h>
#endif
-#include <stdint.h>
#include <string>
#include <vector>
+#include <stddef.h> // for size_t
+#include <stdint.h>
+
namespace llvm {
class StringRef;
} // namespace llvm
@@ -48,7 +50,8 @@ class StringRef;
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class RegularExpression RegularExpression.h "lldb/Core/RegularExpression.h"
+/// @class RegularExpression RegularExpression.h
+/// "lldb/Utility/RegularExpression.h"
/// @brief A C++ wrapper class for regex.
///
/// This regular expression class wraps the posix regex functions
diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h
index 0251c8e72cde..5fa856b15d9f 100644
--- a/include/lldb/Utility/SelectHelper.h
+++ b/include/lldb/Utility/SelectHelper.h
@@ -10,16 +10,13 @@
#ifndef liblldb_SelectHelper_h_
#define liblldb_SelectHelper_h_
-// C Includes
-// C++ Includes
-#include <chrono>
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-types.h" // for socket_t
-// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
-// Project includes
-#include "lldb/lldb-forward.h"
+#include <chrono>
class SelectHelper {
public:
diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h
index 4e91222b3c31..49b0020da3ef 100644
--- a/include/lldb/Utility/SharingPtr.h
+++ b/include/lldb/Utility/SharingPtr.h
@@ -12,7 +12,6 @@
// C Includes
// C++ Includes
-#include <algorithm>
#include <memory>
// Microsoft Visual C++ currently does not enable std::atomic to work
@@ -24,6 +23,8 @@
#include <atomic>
#endif
+#include <stddef.h>
+
// Other libraries and framework includes
// Project includes
diff --git a/include/lldb/Core/Stream.h b/include/lldb/Utility/Stream.h
index 1bea3e179223..5a00f0a50ca3 100644
--- a/include/lldb/Core/Stream.h
+++ b/include/lldb/Utility/Stream.h
@@ -10,21 +10,21 @@
#ifndef liblldb_Stream_h_
#define liblldb_Stream_h_
-// C Includes
-#include <stdarg.h>
-
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Flags.h"
-#include "lldb/lldb-private.h"
-
+#include "lldb/Utility/Flags.h"
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid
+#include "llvm/ADT/StringRef.h" // for StringRef
#include "llvm/Support/FormatVariadic.h"
+#include <stdarg.h>
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t, uint64_t, uint8_t
+#include <type_traits> // for forward
+
namespace lldb_private {
//----------------------------------------------------------------------
-/// @class Stream Stream.h "lldb/Core/Stream.h"
+/// @class Stream Stream.h "lldb/Utility/Stream.h"
/// @brief A stream class that can stream formatted output to a file.
//----------------------------------------------------------------------
class Stream {
@@ -33,12 +33,8 @@ public:
/// \a m_flags bit values.
//------------------------------------------------------------------
enum {
- eVerbose = (1 << 0), ///< If set, verbose logging is enabled
- eDebug = (1 << 1), ///< If set, debug logging is enabled
- eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex
- ///when eBinary is clear
- eBinary = (1 << 3) ///< Get and put data as binary instead of as the default
- ///string mode.
+ eBinary = (1 << 0) ///< Get and put data as binary instead of as the default
+ /// string mode.
};
//------------------------------------------------------------------
@@ -385,15 +381,6 @@ public:
uint32_t GetAddressByteSize() const;
//------------------------------------------------------------------
- /// Test if debug logging is enabled.
- ///
- /// @return
- // \b true if the debug flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool GetDebug() const;
-
- //------------------------------------------------------------------
/// The flags accessor.
///
/// @return
@@ -426,15 +413,6 @@ public:
int GetIndentLevel() const;
//------------------------------------------------------------------
- /// Test if verbose logging is enabled.
- ///
- /// @return
- // \b true if the verbose flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool GetVerbose() const;
-
- //------------------------------------------------------------------
/// Indent the current line in the stream.
///
/// Indent the current line using the current indentation level and
diff --git a/include/lldb/Core/StreamCallback.h b/include/lldb/Utility/StreamCallback.h
index 4dc72c8c54c8..0aa9d5d57b2f 100644
--- a/include/lldb/Core/StreamCallback.h
+++ b/include/lldb/Utility/StreamCallback.h
@@ -10,32 +10,25 @@
#ifndef liblldb_StreamCallback_h_
#define liblldb_StreamCallback_h_
-#include <mutex>
-#include <string>
+#include "lldb/lldb-types.h"
+#include "llvm/Support/raw_ostream.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint64_t
namespace lldb_private {
-class StreamCallback : public Stream {
+class StreamCallback : public llvm::raw_ostream {
public:
StreamCallback(lldb::LogOutputCallback callback, void *baton);
-
- ~StreamCallback() override;
-
- void Flush() override;
-
- size_t Write(const void *src, size_t src_len) override;
+ ~StreamCallback() override = default;
private:
- typedef std::map<lldb::tid_t, StreamString> collection;
lldb::LogOutputCallback m_callback;
void *m_baton;
- collection m_accumulated_data;
- std::mutex m_collection_mutex;
- StreamString &FindStreamForThread(lldb::tid_t cur_tid);
+ void write_impl(const char *Ptr, size_t Size) override;
+ uint64_t current_pos() const override;
};
} // namespace lldb_private
diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Utility/StreamGDBRemote.h
index 150b3012cd0d..79234cc03d86 100644
--- a/include/lldb/Core/StreamGDBRemote.h
+++ b/include/lldb/Utility/StreamGDBRemote.h
@@ -1,5 +1,4 @@
-//===-- StreamGDBRemote.h ----------------------------------------*- C++
-//-*-===//
+//===-- StreamGDBRemote.h ----------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,13 +10,11 @@
#ifndef liblldb_StreamGDBRemote_h_
#define liblldb_StreamGDBRemote_h_
-// C Includes
-// C++ Includes
+#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/lldb-enumerations.h" // for ByteOrder
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/StreamString.h"
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
namespace lldb_private {
diff --git a/include/lldb/Core/StreamString.h b/include/lldb/Utility/StreamString.h
index 88501a1bf611..0ae3e82a3498 100644
--- a/include/lldb/Core/StreamString.h
+++ b/include/lldb/Utility/StreamString.h
@@ -10,9 +10,14 @@
#ifndef liblldb_StreamString_h_
#define liblldb_StreamString_h_
-#include <string>
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/lldb-enumerations.h" // for ByteOrder
+#include "llvm/ADT/StringRef.h" // for StringRef
-#include "lldb/Core/Stream.h"
+#include <string> // for string
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
namespace lldb_private {
diff --git a/include/lldb/Core/StreamTee.h b/include/lldb/Utility/StreamTee.h
index 48f92c839481..676178a0fe75 100644
--- a/include/lldb/Core/StreamTee.h
+++ b/include/lldb/Utility/StreamTee.h
@@ -14,7 +14,7 @@
#include <mutex>
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h
index 624d1ef3edfd..40c1ef79cffb 100644
--- a/include/lldb/Utility/StringExtractor.h
+++ b/include/lldb/Utility/StringExtractor.h
@@ -10,16 +10,15 @@
#ifndef utility_StringExtractor_h_
#define utility_StringExtractor_h_
-// C Includes
-// C++ Includes
-#include <stdint.h>
-#include <string>
-
// Other libraries and framework includes
// Project includes
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
+#include <stddef.h> // for size_t
+#include <stdint.h>
+#include <string>
+
class StringExtractor {
public:
enum { BigEndian = 0, LittleEndian = 1 };
diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h
index 3a399dfd7812..e2c31db329cc 100644
--- a/include/lldb/Utility/StringLexer.h
+++ b/include/lldb/Utility/StringLexer.h
@@ -11,9 +11,9 @@
#ifndef utility_StringLexer_h_
#define utility_StringLexer_h_
-#include <initializer_list>
-#include <list>
-#include <string>
+#include <initializer_list> // for initializer_list
+#include <string> // for string
+#include <utility> // for pair
namespace lldb_utility {
diff --git a/include/lldb/Core/StringList.h b/include/lldb/Utility/StringList.h
index 2cd974dea947..2be9a6bd8346 100644
--- a/include/lldb/Core/StringList.h
+++ b/include/lldb/Utility/StringList.h
@@ -10,18 +10,18 @@
#ifndef liblldb_StringList_h_
#define liblldb_StringList_h_
-// C Includes
-#include <stdint.h>
+#include "llvm/ADT/StringRef.h"
-// C++ Includes
+#include <stddef.h> // for size_t
#include <string>
+#include <vector>
-// Other libraries and framework includes
-#include "llvm/ADT/StringRef.h"
-
-// Project includes
-#include "lldb/Core/STLUtils.h"
-#include "lldb/lldb-forward.h"
+namespace lldb_private {
+class Log;
+}
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
@@ -49,8 +49,6 @@ public:
void AppendList(StringList strings);
- bool ReadFileLines(FileSpec &input_file);
-
size_t GetSize() const;
void SetSize(size_t n) { m_strings.resize(n); }
@@ -133,7 +131,7 @@ public:
}
private:
- STLStringArray m_strings;
+ std::vector<std::string> m_strings;
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h
index db15b208171b..fb936bbb739a 100644
--- a/include/lldb/Utility/TaskPool.h
+++ b/include/lldb/Utility/TaskPool.h
@@ -10,29 +10,12 @@
#ifndef utility_TaskPool_h_
#define utility_TaskPool_h_
-#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
-// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
-// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
-// declared. This may not be necessary after MSVC 12.
-#include <eh.h>
-#endif
-
-#if defined(_MSC_VER)
-// Due to another bug in MSVC 2013, including <future> will generate hundreds of
-// warnings in the Concurrency Runtime. This can be removed when we switch to
-// MSVC 2015
-#pragma warning(push)
-#pragma warning(disable : 4062)
-#endif
-
-#include <cassert>
-#include <cstdint>
+#include <functional> // for bind, function
#include <future>
#include <list>
-#include <queue>
-#include <thread>
-#include <vector>
+#include <memory> // for make_shared
+#include <mutex> // for mutex, unique_lock, condition_variable
+#include <type_traits> // for forward, result_of, move
// Global TaskPool class for running tasks in parallel on a set of worker thread
// created the first
@@ -203,8 +186,4 @@ template <typename T> void TaskRunner<T>::WaitForAllTasks() {
;
}
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
#endif // #ifndef utility_TaskPool_h_
diff --git a/include/lldb/Utility/TildeExpressionResolver.h b/include/lldb/Utility/TildeExpressionResolver.h
new file mode 100644
index 000000000000..84620320c7ac
--- /dev/null
+++ b/include/lldb/Utility/TildeExpressionResolver.h
@@ -0,0 +1,65 @@
+//===--------------------- TildeExpressionResolver.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_UTILITY_TILDE_EXPRESSION_RESOLVER_H
+#define LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace llvm {
+template <typename T> class SmallVectorImpl;
+}
+
+namespace lldb_private {
+class TildeExpressionResolver {
+public:
+ virtual ~TildeExpressionResolver();
+
+ /// \brief Resolve a Tilde Expression contained according to bash rules.
+ ///
+ /// \param Expr Contains the tilde expression to resolve. A valid tilde
+ /// expression must begin with a tilde and contain only non
+ /// separator characters.
+ ///
+ /// \param Output Contains the resolved tilde expression, or the original
+ /// input if the tilde expression could not be resolved.
+ ///
+ /// \returns true if \p Expr was successfully resolved, false otherwise.
+ virtual bool ResolveExact(llvm::StringRef Expr,
+ llvm::SmallVectorImpl<char> &Output) = 0;
+
+ /// \brief Auto-complete a tilde expression with all matching values.
+ ///
+ /// \param Expr Contains the tilde expression prefix to resolve. See
+ /// ResolveExact() for validity rules.
+ ///
+ /// \param Output Contains all matching home directories, each one
+ /// itself unresolved (i.e. you need to call ResolveExact
+ /// on each item to turn it into a real path).
+ ///
+ /// \returns true if there were any matches, false otherwise.
+ virtual bool ResolvePartial(llvm::StringRef Expr,
+ llvm::StringSet<> &Output) = 0;
+
+ /// \brief Resolve an entire path that begins with a tilde expression,
+ /// replacing the username portion with the matched result.
+ bool ResolveFullPath(llvm::StringRef Expr,
+ llvm::SmallVectorImpl<char> &Output);
+};
+
+class StandardTildeExpressionResolver : public TildeExpressionResolver {
+public:
+ bool ResolveExact(llvm::StringRef Expr,
+ llvm::SmallVectorImpl<char> &Output) override;
+ bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) override;
+};
+}
+
+#endif // #ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h
index 6c6fd009acb0..7b627a45fc63 100644
--- a/include/lldb/Utility/Timeout.h
+++ b/include/lldb/Utility/Timeout.h
@@ -11,7 +11,8 @@
#define liblldb_Timeout_h_
#include "llvm/ADT/Optional.h"
-#include <chrono>
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FormatProviders.h"
namespace lldb_private {
@@ -52,4 +53,19 @@ public:
} // namespace lldb_private
+namespace llvm {
+template<typename Ratio>
+struct format_provider<lldb_private::Timeout<Ratio>, void> {
+ static void format(const lldb_private::Timeout<Ratio> &timeout,
+ raw_ostream &OS, StringRef Options) {
+ typedef typename lldb_private::Timeout<Ratio>::value_type Dur;
+
+ if (!timeout)
+ OS << "<infinite>";
+ else
+ format_provider<Dur>::format(*timeout, OS, Options);
+ }
+};
+}
+
#endif // liblldb_Timeout_h_
diff --git a/include/lldb/Core/UUID.h b/include/lldb/Utility/UUID.h
index 7cf5cf389400..28069bbe4c73 100644
--- a/include/lldb/Core/UUID.h
+++ b/include/lldb/Utility/UUID.h
@@ -7,19 +7,23 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UUID_h_
-#define liblldb_UUID_h_
+#ifndef LLDB_UTILITY_UUID_H
+#define LLDB_UTILITY_UUID_H
// C Includes
// C++ Includes
+#include <stddef.h>
+#include <stdint.h>
#include <string>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-private.h"
+namespace llvm {
+ class StringRef;
+}
namespace lldb_private {
+ class Stream;
+
class UUID {
public:
// Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
@@ -93,4 +97,4 @@ bool operator>=(const UUID &lhs, const UUID &rhs);
} // namespace lldb_private
-#endif // liblldb_UUID_h_
+#endif // LLDB_UTILITY_UUID_H
diff --git a/source/Utility/UriParser.h b/include/lldb/Utility/UriParser.h
index 7ebf76f89cad..db0049d9684c 100644
--- a/source/Utility/UriParser.h
+++ b/include/lldb/Utility/UriParser.h
@@ -10,14 +10,9 @@
#ifndef utility_UriParser_h_
#define utility_UriParser_h_
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
-// Project includes
-
+namespace lldb_private {
class UriParser {
public:
// Parses
@@ -32,5 +27,6 @@ public:
llvm::StringRef &hostname, int &port,
llvm::StringRef &path);
};
+}
#endif // utility_UriParser_h_
diff --git a/include/lldb/Core/UserID.h b/include/lldb/Utility/UserID.h
index 596448334555..b178efd44fe4 100644
--- a/include/lldb/Core/UserID.h
+++ b/include/lldb/Utility/UserID.h
@@ -10,7 +10,11 @@
#ifndef liblldb_UserID_h_
#define liblldb_UserID_h_
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_UID
+#include "lldb/lldb-types.h" // for user_id_t
+namespace lldb_private {
+class Stream;
+}
namespace lldb_private {
diff --git a/include/lldb/Utility/Utils.h b/include/lldb/Utility/Utils.h
deleted file mode 100644
index 46bc1847c0b7..000000000000
--- a/include/lldb/Utility/Utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Utils.h -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_Utils_h_
-#define utility_Utils_h_
-
-// These utilities have llvm namespace.
-#include "llvm/ADT/STLExtras.h"
-
-namespace lldb_private {
-
-// Add lldb utilities here.
-
-} // namespace lldb_private
-
-#endif // utility_Utils
diff --git a/include/lldb/Utility/VASPrintf.h b/include/lldb/Utility/VASPrintf.h
new file mode 100644
index 000000000000..6e2404ecef93
--- /dev/null
+++ b/include/lldb/Utility/VASPrintf.h
@@ -0,0 +1,21 @@
+//===-- VASPrintf.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_UTILITY_VASPRINTF_H
+#define LLDB_UTILITY_VASPRINTF_H
+
+#include "llvm/ADT/SmallVector.h"
+
+#include <cstdarg>
+
+namespace lldb_private {
+bool VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, va_list args);
+}
+
+#endif // #ifdef LLDB_UTILITY_VASPRINTF_H
diff --git a/include/lldb/Core/VMRange.h b/include/lldb/Utility/VMRange.h
index 4ec64c997553..98362f4d7608 100644
--- a/include/lldb/Core/VMRange.h
+++ b/include/lldb/Utility/VMRange.h
@@ -10,10 +10,17 @@
#ifndef liblldb_VMRange_h_
#define liblldb_VMRange_h_
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint32_t
#include <vector>
namespace lldb_private {
+class Stream;
+}
+
+namespace lldb_private {
//----------------------------------------------------------------------
// A vm address range. These can represent offsets ranges or actual
diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h
index 8f70a59ca5fc..0970d691d802 100644
--- a/include/lldb/lldb-forward.h
+++ b/include/lldb/lldb-forward.h
@@ -127,7 +127,6 @@ class MemoryRegionInfo;
class LineTable;
class Listener;
class Log;
-class LogChannel;
class Mangled;
class Materializer;
class MemoryHistory;
@@ -362,7 +361,6 @@ typedef std::unique_ptr<lldb_private::SystemRuntime> SystemRuntimeUP;
typedef std::shared_ptr<lldb_private::LineTable> LineTableSP;
typedef std::shared_ptr<lldb_private::Listener> ListenerSP;
typedef std::weak_ptr<lldb_private::Listener> ListenerWP;
-typedef std::shared_ptr<lldb_private::LogChannel> LogChannelSP;
typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP;
typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP;
typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP;
diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h
index d6e30b33b3eb..9572bee81177 100644
--- a/include/lldb/lldb-private-enumerations.h
+++ b/include/lldb/lldb-private-enumerations.h
@@ -10,6 +10,10 @@
#ifndef LLDB_lldb_private_enumerations_h_
#define LLDB_lldb_private_enumerations_h_
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatProviders.h"
+#include "llvm/Support/raw_ostream.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -112,19 +116,6 @@ typedef enum LazyBool {
} LazyBool;
//------------------------------------------------------------------
-/// Name matching
-//------------------------------------------------------------------
-typedef enum NameMatchType {
- eNameMatchIgnore,
- eNameMatchEquals,
- eNameMatchContains,
- eNameMatchStartsWith,
- eNameMatchEndsWith,
- eNameMatchRegularExpression
-
-} NameMatchType;
-
-//------------------------------------------------------------------
/// Instruction types
//------------------------------------------------------------------
typedef enum InstructionType {
@@ -257,4 +248,24 @@ enum class CompilerContextKind {
} // namespace lldb_private
+namespace llvm {
+template <> struct format_provider<lldb_private::Vote> {
+ static void format(const lldb_private::Vote &V, llvm::raw_ostream &Stream,
+ StringRef Style) {
+ switch (V) {
+ case lldb_private::eVoteNo:
+ Stream << "no";
+ return;
+ case lldb_private::eVoteNoOpinion:
+ Stream << "no opinion";
+ return;
+ case lldb_private::eVoteYes:
+ Stream << "yes";
+ return;
+ }
+ Stream << "invalid";
+ }
+};
+}
+
#endif // LLDB_lldb_private_enumerations_h_
diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h
index c0d5c859a44e..d3e80075625e 100644
--- a/include/lldb/lldb-private-interfaces.h
+++ b/include/lldb/lldb-private-interfaces.h
@@ -16,6 +16,8 @@
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
+#include "lldb/lldb-private-enumerations.h"
+
#include <set>
namespace lldb_private {
@@ -45,7 +47,6 @@ typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
const lldb::ProcessSP &process_sp, lldb::addr_t offset);
typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
const FileSpec &outfile, Error &error);
-typedef LogChannel *(*LogChannelCreateInstance)();
typedef EmulateInstruction *(*EmulateInstructionCreateInstance)(
const ArchSpec &arch, InstructionType inst_type);
typedef OperatingSystem *(*OperatingSystemCreateInstance)(Process *process,
diff --git a/lit/lit.cfg b/lit/lit.cfg
index dd89b45fadec..a3d5f9ca7524 100644
--- a/lit/lit.cfg
+++ b/lit/lit.cfg
@@ -39,18 +39,24 @@ config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
# Tweak the PATH to include the tools dir and the scripts dir.
if lldb_obj_root is not None:
+ lldb_tools_dir = getattr(config, 'lldb_tools_dir', None)
+ if not lldb_tools_dir:
+ lit_config.fatal('No LLDB tools dir set!')
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if not llvm_tools_dir:
lit_config.fatal('No LLVM tools dir set!')
- path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
+ path = os.path.pathsep.join((lldb_tools_dir, llvm_tools_dir, config.environment['PATH']))
path = os.path.pathsep.join((os.path.join(getattr(config, 'llvm_src_root', None),'test','Scripts'),path))
config.environment['PATH'] = path
+ lldb_libs_dir = getattr(config, 'lldb_libs_dir', None)
+ if not lldb_libs_dir:
+ lit_config.fatal('No LLDB libs dir set!')
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
if not llvm_libs_dir:
lit_config.fatal('No LLVM libs dir set!')
- path = os.path.pathsep.join((llvm_libs_dir,
+ path = os.path.pathsep.join((lldb_libs_dir, llvm_libs_dir,
config.environment.get('LD_LIBRARY_PATH','')))
config.environment['LD_LIBRARY_PATH'] = path
@@ -115,14 +121,14 @@ if config.test_exec_root is None:
# Register substitutions
config.substitutions.append(('%python', config.python_executable))
-debugserver = lit.util.which('debugserver', llvm_tools_dir)
-lldb = lit.util.which('lldb', llvm_tools_dir)
+debugserver = lit.util.which('debugserver', lldb_tools_dir)
+lldb = lit.util.which('lldb', lldb_tools_dir)
if not os.path.exists(config.cc):
- config.cc = lit.util.which(config.cc, llvm_tools_dir)
+ config.cc = lit.util.which(config.cc, config.environment['PATH'])
if not os.path.exists(config.cxx):
- config.cxx = lit.util.which(config.cxx, llvm_tools_dir)
+ config.cxx = lit.util.which(config.cxx, config.environment['PATH'])
if platform.system() in ['Darwin']:
try:
diff --git a/lit/lit.site.cfg.in b/lit/lit.site.cfg.in
index 904521c9dac4..03aa3df9ac55 100644
--- a/lit/lit.site.cfg.in
+++ b/lit/lit.site.cfg.in
@@ -6,6 +6,8 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
+config.lldb_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
+config.lldb_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.cc = "@CMAKE_C_COMPILER@"
diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index fcfff212d2b6..8e44b5f07dc9 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/lldb.xcodeproj/project.pbxproj
@@ -115,7 +115,6 @@
23DDF226196C3EE600BB8417 /* CommandOptionValidators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DDF224196C3EE600BB8417 /* CommandOptionValidators.cpp */; };
23E2E5251D90373D006F38BB /* ArchSpecTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */; };
23E2E5271D903782006F38BB /* MinidumpParserTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E51A1D9036F2006F38BB /* MinidumpParserTest.cpp */; };
- 23E2E52B1D9037E6006F38BB /* ModuleCacheTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23CB15011D66CD8400EDDDE1 /* ModuleCacheTest.cpp */; };
23E2E5321D903832006F38BB /* BreakpointIDTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E52D1D90382B006F38BB /* BreakpointIDTest.cpp */; };
23E2E5441D904913006F38BB /* MinidumpParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E5371D9048FB006F38BB /* MinidumpParser.cpp */; };
23E2E5451D904913006F38BB /* MinidumpTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E5391D9048FB006F38BB /* MinidumpTypes.cpp */; };
@@ -132,7 +131,6 @@
255EFF741AFABA720069F277 /* LockFileBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 255EFF731AFABA720069F277 /* LockFileBase.cpp */; };
255EFF761AFABA950069F277 /* LockFilePosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 255EFF751AFABA950069F277 /* LockFilePosix.cpp */; };
256CBDB41ADD0EFD00BC6CDC /* RegisterContextPOSIXCore_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 256CBDB21ADD0EFD00BC6CDC /* RegisterContextPOSIXCore_arm.cpp */; };
- 256CBDBA1ADD107200BC6CDC /* RegisterContextLinux_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 256CBDB61ADD107200BC6CDC /* RegisterContextLinux_arm.cpp */; };
256CBDBC1ADD107200BC6CDC /* RegisterContextLinux_mips64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 256CBDB81ADD107200BC6CDC /* RegisterContextLinux_mips64.cpp */; };
256CBDC01ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 256CBDBE1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp */; };
2579065C1BD0488100178368 /* TCPSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2579065A1BD0488100178368 /* TCPSocket.cpp */; };
@@ -140,7 +138,6 @@
2579065F1BD0488D00178368 /* DomainSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2579065E1BD0488D00178368 /* DomainSocket.cpp */; };
257906641BD5AFD000178368 /* Acceptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 257906621BD5AFD000178368 /* Acceptor.cpp */; };
257906651BD5AFD000178368 /* Acceptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 257906631BD5AFD000178368 /* Acceptor.h */; };
- 257E47171AA56C2000A62F81 /* ModuleCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 257E47151AA56C2000A62F81 /* ModuleCache.cpp */; };
25EF23781AC09B3700908DF0 /* AdbClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25EF23751AC09AD800908DF0 /* AdbClient.cpp */; };
260157C61885F51C00F875CF /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 260157C41885F4FF00F875CF /* libpanel.dylib */; };
260157C81885F53100F875CF /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 260157C41885F4FF00F875CF /* libpanel.dylib */; };
@@ -199,7 +196,6 @@
26474CCD18D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CC618D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp */; };
26491E3E15E1DB9F00CBFFC2 /* OptionValueRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26491E3D15E1DB9F00CBFFC2 /* OptionValueRegex.cpp */; };
264A12FC1372522000875C42 /* EmulateInstructionARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A12FA1372522000875C42 /* EmulateInstructionARM64.cpp */; };
- 264A1300137252C700875C42 /* ARM64_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A12FE137252C700875C42 /* ARM64_DWARF_Registers.cpp */; };
264A58EE1A7DBCAD00A6B1B0 /* OptionValueFormatEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A58ED1A7DBCAD00A6B1B0 /* OptionValueFormatEntity.cpp */; };
264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; };
264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */; };
@@ -207,6 +203,10 @@
265205A813D3E3F700132FE2 /* RegisterContextKDP_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A213D3E3F700132FE2 /* RegisterContextKDP_arm.cpp */; };
265205AA13D3E3F700132FE2 /* RegisterContextKDP_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A413D3E3F700132FE2 /* RegisterContextKDP_i386.cpp */; };
265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */; };
+ 2654A6801E54D59400DA1013 /* ModuleCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A67F1E54D59400DA1013 /* ModuleCache.cpp */; };
+ 2654A6831E54D5E200DA1013 /* RegisterNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A6821E54D5E200DA1013 /* RegisterNumber.cpp */; };
+ 2654A68D1E552D1500DA1013 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A68C1E552D1500DA1013 /* PseudoTerminal.cpp */; };
+ 2654A6901E552ED500DA1013 /* VASprintf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A68F1E552ED500DA1013 /* VASprintf.cpp */; };
2656BBC31AE0739C00441749 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32A10F3DFDD009D5894 /* libedit.dylib */; };
2656BBC41AE073A800441749 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; };
2656BBC51AE073AD00441749 /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 260157C41885F4FF00F875CF /* libpanel.dylib */; };
@@ -332,6 +332,11 @@
2670F8121862B44A006B332C /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; };
26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; };
26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; };
+ 26764C971E48F482008D3573 /* ConstString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C961E48F482008D3573 /* ConstString.cpp */; };
+ 26764C991E48F4D2008D3573 /* Error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C981E48F4D2008D3573 /* Error.cpp */; };
+ 26764C9E1E48F51E008D3573 /* Stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C9D1E48F51E008D3573 /* Stream.cpp */; };
+ 26764CA01E48F528008D3573 /* RegularExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C9F1E48F528008D3573 /* RegularExpression.cpp */; };
+ 26764CA21E48F547008D3573 /* StreamString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764CA11E48F547008D3573 /* StreamString.cpp */; };
26780C611867C33D00234593 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; };
267A47FB1B1411C40021A5BC /* NativeRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267A47FA1B1411C40021A5BC /* NativeRegisterContext.cpp */; };
267A47FF1B1411D90021A5BC /* NativeWatchpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267A47FE1B1411D90021A5BC /* NativeWatchpointList.cpp */; };
@@ -390,18 +395,12 @@
2689002D13353E0400698AC0 /* AddressResolverFileLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7034211752C720086C050 /* AddressResolverFileLine.cpp */; };
2689002E13353E0400698AC0 /* AddressResolverName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7034411752C790086C050 /* AddressResolverName.cpp */; };
2689002F13353E0400698AC0 /* ArchSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6B10F1B85900F91463 /* ArchSpec.cpp */; };
- 2689003013353E0400698AC0 /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A0604811A5D03C00F75969 /* Baton.cpp */; };
2689003113353E0400698AC0 /* Broadcaster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */; };
2689003213353E0400698AC0 /* Communication.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6E10F1B85900F91463 /* Communication.cpp */; };
2689003313353E0400698AC0 /* Connection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6F10F1B85900F91463 /* Connection.cpp */; };
- 2689003513353E0400698AC0 /* ConstString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9410F1B85900F91463 /* ConstString.cpp */; };
- 2689003613353E0400698AC0 /* DataBufferHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7210F1B85900F91463 /* DataBufferHeap.cpp */; };
- 2689003713353E0400698AC0 /* DataBufferMemoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7310F1B85900F91463 /* DataBufferMemoryMap.cpp */; };
- 2689003813353E0400698AC0 /* DataExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7110F1B85900F91463 /* DataExtractor.cpp */; };
2689003913353E0400698AC0 /* Debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263664921140A4930075843B /* Debugger.cpp */; };
2689003A13353E0400698AC0 /* Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7610F1B85900F91463 /* Disassembler.cpp */; };
2689003B13353E0400698AC0 /* EmulateInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */; };
- 2689003C13353E0400698AC0 /* Error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7810F1B85900F91463 /* Error.cpp */; };
2689003D13353E0400698AC0 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7910F1B85900F91463 /* Event.cpp */; };
2689003E13353E0400698AC0 /* FileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */; };
2689004113353E0400698AC0 /* Listener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7E10F1B85900F91463 /* Listener.cpp */; };
@@ -411,20 +410,15 @@
2689004513353E0400698AC0 /* ModuleChild.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8210F1B85900F91463 /* ModuleChild.cpp */; };
2689004613353E0400698AC0 /* ModuleList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8310F1B85900F91463 /* ModuleList.cpp */; };
2689004713353E0400698AC0 /* PluginManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */; };
- 2689004813353E0400698AC0 /* RegularExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8C10F1B85900F91463 /* RegularExpression.cpp */; };
2689004913353E0400698AC0 /* Scalar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8D10F1B85900F91463 /* Scalar.cpp */; };
2689004A13353E0400698AC0 /* SearchFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1510F1B83100F91463 /* SearchFilter.cpp */; };
2689004B13353E0400698AC0 /* Section.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8E10F1B85900F91463 /* Section.cpp */; };
2689004C13353E0400698AC0 /* SourceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8F10F1B85900F91463 /* SourceManager.cpp */; };
2689004D13353E0400698AC0 /* State.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9010F1B85900F91463 /* State.cpp */; };
- 2689004E13353E0400698AC0 /* Stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9110F1B85900F91463 /* Stream.cpp */; };
2689004F13353E0400698AC0 /* StreamFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9210F1B85900F91463 /* StreamFile.cpp */; };
- 2689005013353E0400698AC0 /* StreamString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9310F1B85900F91463 /* StreamString.cpp */; };
2689005113353E0400698AC0 /* StringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A35765F116E76B900E8ED2F /* StringList.cpp */; };
2689005213353E0400698AC0 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9610F1B85900F91463 /* Timer.cpp */; };
- 2689005313353E0400698AC0 /* UserID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9810F1B85900F91463 /* UserID.cpp */; };
2689005413353E0400698AC0 /* UserSettingsController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4633DC11F65D9A00955CE1 /* UserSettingsController.cpp */; };
- 2689005513353E0400698AC0 /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C81CA511335651004BDC5A /* UUID.cpp */; };
2689005613353E0400698AC0 /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9910F1B85900F91463 /* Value.cpp */; };
2689005713353E0400698AC0 /* ValueObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */; };
2689005813353E0400698AC0 /* ValueObjectChild.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */; };
@@ -432,7 +426,6 @@
2689005A13353E0400698AC0 /* ValueObjectList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9C10F1B85900F91463 /* ValueObjectList.cpp */; };
2689005B13353E0400698AC0 /* ValueObjectRegister.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */; };
2689005C13353E0400698AC0 /* ValueObjectVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9D10F1B85900F91463 /* ValueObjectVariable.cpp */; };
- 2689005D13353E0400698AC0 /* VMRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9E10F1B85900F91463 /* VMRange.cpp */; };
2689005E13353E0E00698AC0 /* ClangASTSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */; };
2689005F13353E0E00698AC0 /* ClangFunctionCaller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C98D3DA118FB96F00E575D0 /* ClangFunctionCaller.cpp */; };
2689006013353E0E00698AC0 /* ClangExpressionDeclMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */; };
@@ -572,7 +565,6 @@
2689011013353E8200698AC0 /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; };
2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660D9F611922A1300958FBD /* StringExtractor.cpp */; };
2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */; };
- 2689011313353E8200698AC0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; };
268901161335BBC300698AC0 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; };
2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7410F1B85900F91463 /* lldb.cpp */; };
2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0A10F1B83100F91463 /* Breakpoint.cpp */; };
@@ -660,7 +652,6 @@
26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; };
26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; };
26E152261419CAD4007967D0 /* ObjectFilePECOFF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E152231419CACA007967D0 /* ObjectFilePECOFF.cpp */; };
- 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */; };
26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */; };
26EFB61B1BFE8D3E00544801 /* PlatformNetBSD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26EFB6181BFE8D3E00544801 /* PlatformNetBSD.cpp */; };
26EFB61C1BFE8D3E00544801 /* PlatformNetBSD.h in Headers */ = {isa = PBXBuildFile; fileRef = 26EFB6191BFE8D3E00544801 /* PlatformNetBSD.h */; };
@@ -669,7 +660,6 @@
26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */; };
26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; };
26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; };
- 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; };
26FFC19914FC072100087D58 /* AuxVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FFC19314FC072100087D58 /* AuxVector.cpp */; };
26FFC19B14FC072100087D58 /* DYLDRendezvous.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FFC19514FC072100087D58 /* DYLDRendezvous.cpp */; };
26FFC19D14FC072100087D58 /* DynamicLoaderPOSIXDYLD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FFC19714FC072100087D58 /* DynamicLoaderPOSIXDYLD.cpp */; };
@@ -679,7 +669,6 @@
332CCB181AFF41620034D4C4 /* SBLanguageRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 3392EBB71AFF402200858B9F /* SBLanguageRuntime.h */; settings = {ATTRIBUTES = (Public, ); }; };
33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33E5E8411A672A240024ED68 /* StringConvert.cpp */; };
3F8160A61AB9F7DD001DA9DF /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8160A51AB9F7DD001DA9DF /* Logging.cpp */; };
- 3F8169191ABA2419001DA9DF /* ConvertEnum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169171ABA2419001DA9DF /* ConvertEnum.cpp */; };
3F81691A1ABA2419001DA9DF /* NameMatches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169181ABA2419001DA9DF /* NameMatches.cpp */; };
3F81692C1ABB7A1E001DA9DF /* SystemInitializerFull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692A1ABB7A16001DA9DF /* SystemInitializerFull.cpp */; };
3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F81692E1ABB7A6D001DA9DF /* SystemInitializer.cpp */; };
@@ -697,13 +686,10 @@
3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE56A19AF9C44009756A7 /* HostProcessPosix.cpp */; };
3FDFE56D19AF9C44009756A7 /* HostThreadPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFE56B19AF9C44009756A7 /* HostThreadPosix.cpp */; };
3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */; };
- 3FDFED0C19B7C8E7009756A7 /* ThisThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0619B7C898009756A7 /* ThisThread.cpp */; };
- 3FDFED0F19B7D269009756A7 /* ThisThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED0D19B7D269009756A7 /* ThisThread.cpp */; };
3FDFED2719BA6D96009756A7 /* HostNativeThreadBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */; };
3FDFED2819BA6D96009756A7 /* HostThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2519BA6D96009756A7 /* HostThread.cpp */; };
3FDFED2919BA6D96009756A7 /* ThreadLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */; };
3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFED2C19C257A0009756A7 /* HostProcess.cpp */; };
- 449ACC98197DEA0B008D175E /* FastDemangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 449ACC96197DE9EC008D175E /* FastDemangle.cpp */; };
490A36C0180F0E6F00BA31F8 /* PlatformWindows.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490A36BD180F0E6F00BA31F8 /* PlatformWindows.cpp */; };
490A966B1628C3BF00F0002E /* SBDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9452573816262CEF00325455 /* SBDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };
4939EA8D1BD56B6D00084382 /* REPL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4939EA8C1BD56B6D00084382 /* REPL.cpp */; };
@@ -715,21 +701,26 @@
4984BA181B979C08008658D4 /* ExpressionVariable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4984BA171B979C08008658D4 /* ExpressionVariable.h */; };
49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; };
49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; };
- 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268ED0A4140FF54200DE830F /* DataEncoder.cpp */; };
+ 49CA96FC1E6AACC900C03FEE /* DataBufferHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E61E6AAC6600C03FEE /* DataBufferHeap.cpp */; };
+ 49CA96FD1E6AACC900C03FEE /* DataBufferLLVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E71E6AAC6600C03FEE /* DataBufferLLVM.cpp */; };
+ 49CA96FE1E6AACC900C03FEE /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E81E6AAC6600C03FEE /* DataEncoder.cpp */; };
+ 49CA96FF1E6AACC900C03FEE /* DataExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */; };
+ 49CA97001E6AACC900C03FEE /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */; };
49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; };
49DA65031485C92A005FF180 /* AppleObjCDeclVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA65021485C92A005FF180 /* AppleObjCDeclVendor.cpp */; };
49DCF6FE170E6B4A0092F75E /* IRMemoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DCF6FD170E6B4A0092F75E /* IRMemoryMap.cpp */; };
49DCF702170E70120092F75E /* Materializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DCF700170E70120092F75E /* Materializer.cpp */; };
49DEF1251CD7C6DF006A7C7D /* BlockPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DEF11F1CD7BD90006A7C7D /* BlockPointer.cpp */; };
49E4F66B1C9CAD16008487EA /* DiagnosticManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E4F6681C9CAD12008487EA /* DiagnosticManager.cpp */; };
+ 49F811F31E931B2100F4E163 /* CPlusPlusNameParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49F811EF1E931B1500F4E163 /* CPlusPlusNameParser.cpp */; };
4C0083401B9F9BA900D5CF24 /* UtilityFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00833F1B9F9BA900D5CF24 /* UtilityFunction.cpp */; };
4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0083321B9A5DE200D5CF24 /* FunctionCaller.cpp */; };
4C3ADCD61810D88B00357218 /* BreakpointResolverFileRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */; };
+ 4C4EB7811E6A4DCC002035C0 /* DumpDataExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4EB77F1E6A4DB8002035C0 /* DumpDataExtractor.cpp */; };
4C562CC71CC07DF700C52EAC /* PDBASTParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C562CC21CC07DDD00C52EAC /* PDBASTParser.cpp */; };
4C56543119D1EFAA002E9C44 /* ThreadPlanPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C56543019D1EFAA002E9C44 /* ThreadPlanPython.cpp */; };
4C56543519D2297A002E9C44 /* SBThreadPlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C56543419D2297A002E9C44 /* SBThreadPlan.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C56543719D22B32002E9C44 /* SBThreadPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C56543619D22B32002E9C44 /* SBThreadPlan.cpp */; };
- 4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C6649A214EEE81000B0316F /* StreamCallback.cpp */; };
4C88BC2A1BA3722B00AA0964 /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C88BC291BA3722B00AA0964 /* Expression.cpp */; };
4C88BC2D1BA391B000AA0964 /* UserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0083331B9A5DE200D5CF24 /* UserExpression.cpp */; };
4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; };
@@ -745,6 +736,9 @@
4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; };
4CDB8D6D1DBA91B6006C5B13 /* LibStdcppUniquePointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */; };
4CDB8D6E1DBA91B6006C5B13 /* LibStdcppTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp */; };
+ 4CE4EFAA1E8999B900A80C06 /* PlatformOpenBSD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */; };
+ 4CE4EFB31E899A3400A80C06 /* RegisterContextOpenBSD_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */; };
+ 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */; };
4CE4F673162C971A00F75CB3 /* SBExpressionOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
4CE4F675162C973F00F75CB3 /* SBExpressionOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */; };
4CF3D80C15AF4DC800845BF3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework */; };
@@ -818,7 +812,6 @@
9455630F1BEAD0600073F75F /* PlatformAppleSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9455630A1BEAD0570073F75F /* PlatformAppleSimulator.cpp */; };
945563101BEAD0650073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9455630D1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm */; };
945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945759651534941F005A9070 /* PlatformPOSIX.cpp */; };
- 945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };
9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };
9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568B14E35621003A195C /* SBTypeFormat.cpp */; };
9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568C14E35621003A195C /* SBTypeSummary.cpp */; };
@@ -872,6 +865,7 @@
966C6B7A18E6A56A0093F5EC /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 966C6B7818E6A56A0093F5EC /* libz.dylib */; };
966C6B7C18E6A56A0093F5EC /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 966C6B7818E6A56A0093F5EC /* libz.dylib */; };
9694FA711B32AA64005EBB16 /* ABISysV_mips.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9694FA6F1B32AA64005EBB16 /* ABISysV_mips.cpp */; };
+ 9A0FDEA71E8EF5110086B2F5 /* RegisterContextLinux_mips.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */; };
9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
@@ -883,11 +877,12 @@
9A3576A8116E9AB700E8ED2F /* SBHostOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; };
9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */; };
- 9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; };
+ 9A77AD541E64E2760025CE04 /* RegisterInfoPOSIX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A77AD501E64E24E0025CE04 /* RegisterInfoPOSIX_arm.cpp */; };
9AC7038E117674FB0086C050 /* SBInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038D117674EB0086C050 /* SBInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; };
9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; };
9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; };
9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; };
+ 9AD9449F1E8DB26C004796ED /* RegisterContextNetBSD_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */; };
A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A36FF33B17D8E94600244D40 /* OptionParser.cpp */; };
AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */; };
AE44FB311BB07EB80033EB62 /* GoLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2A1BB07DD80033EB62 /* GoLexer.cpp */; };
@@ -912,7 +907,6 @@
AF1729D7182C907200E0AB97 /* HistoryUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */; };
AF1D88691B575E8D003CB899 /* ValueObjectConstResultCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF94726E1B575E430063D65C /* ValueObjectConstResultCast.cpp */; };
AF1F7B07189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1F7B05189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp */; };
- AF1FA88A1A60A69500272AFC /* RegisterNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1FA8891A60A69500272AFC /* RegisterNumber.cpp */; };
AF20F7661AF18F8500751A6E /* ABISysV_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF20F7641AF18F8500751A6E /* ABISysV_arm.cpp */; };
AF20F76A1AF18F9000751A6E /* ABISysV_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF20F7681AF18F9000751A6E /* ABISysV_arm64.cpp */; };
AF23B4DB19009C66003E2A58 /* FreeBSDSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF23B4D919009C66003E2A58 /* FreeBSDSignals.cpp */; };
@@ -952,8 +946,16 @@
AF9107EE168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF9107EC168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp */; };
AF9107EF168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF9107EC168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp */; };
AF9B8F33182DB52900DA866F /* SystemRuntimeMacOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF9B8F31182DB52900DA866F /* SystemRuntimeMacOSX.cpp */; };
+ AFAFD80A1E57E1B90017A14F /* ModuleCacheTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFAFD8091E57E1B90017A14F /* ModuleCacheTest.cpp */; };
AFB3D2801AC262AB003B4B30 /* MICmdCmdGdbShow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFB3D27E1AC262AB003B4B30 /* MICmdCmdGdbShow.cpp */; };
AFC234091AF85CE100CDE8B6 /* CommandObjectLanguage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC234061AF85CE000CDE8B6 /* CommandObjectLanguage.cpp */; };
+ AFC2DCE71E6E2ED000283714 /* FastDemangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */; };
+ AFC2DCE91E6E2F2C00283714 /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCE81E6E2F2C00283714 /* Baton.cpp */; };
+ AFC2DCEB1E6E2F7D00283714 /* UserID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCEA1E6E2F7D00283714 /* UserID.cpp */; };
+ AFC2DCF01E6E2FD200283714 /* VMRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCEF1E6E2FD200283714 /* VMRange.cpp */; };
+ AFC2DCF31E6E30CF00283714 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCF21E6E30CF00283714 /* History.cpp */; };
+ AFC2DCF61E6E316A00283714 /* StreamCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCF51E6E316A00283714 /* StreamCallback.cpp */; };
+ AFC2DCF91E6E318000283714 /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCF81E6E318000283714 /* StreamGDBRemote.cpp */; };
AFCB2BBD1BF577F40018B553 /* PythonExceptionState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFCB2BBB1BF577F40018B553 /* PythonExceptionState.cpp */; };
AFCB2BBE1BF577F40018B553 /* PythonExceptionState.h in Headers */ = {isa = PBXBuildFile; fileRef = AFCB2BBC1BF577F40018B553 /* PythonExceptionState.h */; };
AFD65C811D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */; };
@@ -964,6 +966,7 @@
AFEC5FD81D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFEC5FD51D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp */; };
AFF87C87150FF669000E1742 /* com.apple.debugserver.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = AFF87C86150FF669000E1742 /* com.apple.debugserver.plist */; };
AFF87C8F150FF688000E1742 /* com.apple.debugserver.applist.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = AFF87C8E150FF688000E1742 /* com.apple.debugserver.applist.plist */; };
+ AFF8FF0C1E779D4B003830EF /* TildeExpressionResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFF8FF0B1E779D4B003830EF /* TildeExpressionResolver.cpp */; };
B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */; };
B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */; };
B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointList.cpp */; };
@@ -973,7 +976,6 @@
B2A58724143119D50092BFBA /* SBWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A58723143119D50092BFBA /* SBWatchpoint.cpp */; };
B2B7CCEB15D1BD6700EEFB57 /* CommandObjectWatchpointCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2B7CCEA15D1BD6600EEFB57 /* CommandObjectWatchpointCommand.cpp */; };
B2B7CCF015D1C20F00EEFB57 /* WatchpointOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2B7CCEF15D1C20F00EEFB57 /* WatchpointOptions.cpp */; };
- B5EFAE861AE53B1D007059F3 /* RegisterContextFreeBSD_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5EFAE841AE53B1D007059F3 /* RegisterContextFreeBSD_arm.cpp */; };
E769331C1A94D15400C73337 /* lldb-gdbserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D6F3F4183E7F9300194858 /* lldb-gdbserver.cpp */; };
E769331E1A94D18100C73337 /* lldb-server.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E769331D1A94D18100C73337 /* lldb-server.cpp */; };
E7723D441AC4A7FB002BA082 /* RegisterContextPOSIXCore_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7723D421AC4A7FB002BA082 /* RegisterContextPOSIXCore_arm64.cpp */; };
@@ -1293,7 +1295,6 @@
23CB14F91D66CCF100EDDDE1 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
23CB14FA1D66CCF100EDDDE1 /* CPlusPlusLanguageTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPlusPlusLanguageTest.cpp; sourceTree = "<group>"; };
23CB14FD1D66CD2400EDDDE1 /* FileSpecTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSpecTest.cpp; sourceTree = "<group>"; };
- 23CB15011D66CD8400EDDDE1 /* ModuleCacheTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleCacheTest.cpp; sourceTree = "<group>"; };
23CB15051D66CDB400EDDDE1 /* TestModule.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = TestModule.c; sourceTree = "<group>"; };
23CB15061D66CDB400EDDDE1 /* TestModule.so */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestModule.so; sourceTree = "<group>"; };
23CB150B1D66CF5600EDDDE1 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
@@ -1350,8 +1351,8 @@
23EDE3371926AAD500F6A132 /* RegisterInfoInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterInfoInterface.h; path = Utility/RegisterInfoInterface.h; sourceTree = "<group>"; };
23EFE388193D1ABC00E54E54 /* SBTypeEnumMember.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeEnumMember.h; path = include/lldb/API/SBTypeEnumMember.h; sourceTree = "<group>"; };
23EFE38A193D1AEC00E54E54 /* SBTypeEnumMember.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeEnumMember.cpp; path = source/API/SBTypeEnumMember.cpp; sourceTree = "<group>"; };
- 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeRegisterContextRegisterInfo.h; path = include/lldb/Host/common/NativeRegisterContextRegisterInfo.h; sourceTree = "<group>"; };
- 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeRegisterContextRegisterInfo.cpp; path = source/Host/common/NativeRegisterContextRegisterInfo.cpp; sourceTree = "<group>"; };
+ 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeRegisterContextRegisterInfo.h; path = Utility/NativeRegisterContextRegisterInfo.h; sourceTree = "<group>"; };
+ 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeRegisterContextRegisterInfo.cpp; path = Utility/NativeRegisterContextRegisterInfo.cpp; sourceTree = "<group>"; };
250D6AE11A9679270049CC70 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = "<group>"; };
25420ECC1A6490B8009ADBCB /* OptionValueChar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionValueChar.cpp; path = source/Interpreter/OptionValueChar.cpp; sourceTree = "<group>"; };
25420ECE1A64911B009ADBCB /* OptionValueChar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionValueChar.h; path = include/lldb/Interpreter/OptionValueChar.h; sourceTree = "<group>"; };
@@ -1369,8 +1370,6 @@
255EFF751AFABA950069F277 /* LockFilePosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LockFilePosix.cpp; sourceTree = "<group>"; };
256CBDB21ADD0EFD00BC6CDC /* RegisterContextPOSIXCore_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextPOSIXCore_arm.cpp; sourceTree = "<group>"; };
256CBDB31ADD0EFD00BC6CDC /* RegisterContextPOSIXCore_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextPOSIXCore_arm.h; sourceTree = "<group>"; };
- 256CBDB61ADD107200BC6CDC /* RegisterContextLinux_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextLinux_arm.cpp; path = Utility/RegisterContextLinux_arm.cpp; sourceTree = "<group>"; };
- 256CBDB71ADD107200BC6CDC /* RegisterContextLinux_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_arm.h; path = Utility/RegisterContextLinux_arm.h; sourceTree = "<group>"; };
256CBDB81ADD107200BC6CDC /* RegisterContextLinux_mips64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextLinux_mips64.cpp; path = Utility/RegisterContextLinux_mips64.cpp; sourceTree = "<group>"; };
256CBDB91ADD107200BC6CDC /* RegisterContextLinux_mips64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_mips64.h; path = Utility/RegisterContextLinux_mips64.h; sourceTree = "<group>"; };
256CBDBE1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextPOSIX_arm.cpp; path = Utility/RegisterContextPOSIX_arm.cpp; sourceTree = "<group>"; };
@@ -1380,8 +1379,6 @@
2579065E1BD0488D00178368 /* DomainSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DomainSocket.cpp; sourceTree = "<group>"; };
257906621BD5AFD000178368 /* Acceptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Acceptor.cpp; path = "tools/lldb-server/Acceptor.cpp"; sourceTree = "<group>"; };
257906631BD5AFD000178368 /* Acceptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Acceptor.h; path = "tools/lldb-server/Acceptor.h"; sourceTree = "<group>"; };
- 257E47151AA56C2000A62F81 /* ModuleCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleCache.cpp; path = source/Utility/ModuleCache.cpp; sourceTree = "<group>"; };
- 257E47161AA56C2000A62F81 /* ModuleCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModuleCache.h; path = source/Utility/ModuleCache.h; sourceTree = "<group>"; };
25EF23751AC09AD800908DF0 /* AdbClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AdbClient.cpp; sourceTree = "<group>"; };
25EF23761AC09AD800908DF0 /* AdbClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdbClient.h; sourceTree = "<group>"; };
260157C41885F4FF00F875CF /* libpanel.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpanel.dylib; path = /usr/lib/libpanel.dylib; sourceTree = "<absolute>"; };
@@ -1529,7 +1526,6 @@
2611FF11142D83060017FEA3 /* SBType.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBType.i; sourceTree = "<group>"; };
2611FF12142D83060017FEA3 /* SBValue.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBValue.i; sourceTree = "<group>"; };
2611FF13142D83060017FEA3 /* SBValueList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBValueList.i; sourceTree = "<group>"; };
- 2613F6CA1B17B85400D4DB85 /* FastDemangle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FastDemangle.h; path = include/lldb/Core/FastDemangle.h; sourceTree = "<group>"; };
2615DB841208A9C90021781D /* StopInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StopInfo.h; path = include/lldb/Target/StopInfo.h; sourceTree = "<group>"; };
2615DB861208A9E40021781D /* StopInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StopInfo.cpp; path = source/Target/StopInfo.cpp; sourceTree = "<group>"; };
2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StopInfoMachException.cpp; path = Utility/StopInfoMachException.cpp; sourceTree = "<group>"; };
@@ -1632,7 +1628,6 @@
26491E3D15E1DB9F00CBFFC2 /* OptionValueRegex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionValueRegex.cpp; path = source/Interpreter/OptionValueRegex.cpp; sourceTree = "<group>"; };
264A12FA1372522000875C42 /* EmulateInstructionARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulateInstructionARM64.cpp; sourceTree = "<group>"; };
264A12FB1372522000875C42 /* EmulateInstructionARM64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmulateInstructionARM64.h; sourceTree = "<group>"; };
- 264A12FE137252C700875C42 /* ARM64_DWARF_Registers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ARM64_DWARF_Registers.cpp; path = source/Utility/ARM64_DWARF_Registers.cpp; sourceTree = "<group>"; };
264A12FF137252C700875C42 /* ARM64_DWARF_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM64_DWARF_Registers.h; path = source/Utility/ARM64_DWARF_Registers.h; sourceTree = "<group>"; };
264A43BB1320B3B4005B4096 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Platform.h; path = include/lldb/Target/Platform.h; sourceTree = "<group>"; };
264A43BD1320BCEB005B4096 /* Platform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Platform.cpp; path = source/Target/Platform.cpp; sourceTree = "<group>"; };
@@ -1652,6 +1647,15 @@
265205A513D3E3F700132FE2 /* RegisterContextKDP_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_i386.h; sourceTree = "<group>"; };
265205A613D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextKDP_x86_64.cpp; sourceTree = "<group>"; };
265205A713D3E3F700132FE2 /* RegisterContextKDP_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextKDP_x86_64.h; sourceTree = "<group>"; };
+ 2654A67F1E54D59400DA1013 /* ModuleCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleCache.cpp; path = source/Target/ModuleCache.cpp; sourceTree = "<group>"; };
+ 2654A6811E54D5A200DA1013 /* ModuleCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ModuleCache.h; path = include/lldb/Target/ModuleCache.h; sourceTree = "<group>"; };
+ 2654A6821E54D5E200DA1013 /* RegisterNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterNumber.cpp; path = source/Target/RegisterNumber.cpp; sourceTree = "<group>"; };
+ 2654A6841E54D5EE00DA1013 /* RegisterNumber.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterNumber.h; path = include/lldb/Target/RegisterNumber.h; sourceTree = "<group>"; };
+ 2654A68C1E552D1500DA1013 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Host/common/PseudoTerminal.cpp; sourceTree = "<group>"; };
+ 2654A68E1E552D2400DA1013 /* PseudoTerminal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Host/PseudoTerminal.h; sourceTree = "<group>"; };
+ 2654A68F1E552ED500DA1013 /* VASprintf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VASprintf.cpp; path = source/Utility/VASprintf.cpp; sourceTree = "<group>"; };
+ 2654A6911E552F3C00DA1013 /* UriParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UriParser.h; path = include/lldb/Utility/UriParser.h; sourceTree = "<group>"; };
+ 2654A6921E552F4600DA1013 /* VASPrintf.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VASPrintf.h; path = include/lldb/Utility/VASPrintf.h; sourceTree = "<group>"; };
26579F68126A25920007C5CB /* darwin-debug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "darwin-debug"; sourceTree = BUILT_PRODUCTS_DIR; };
2657AFB51B8690EC00958979 /* CompilerDeclContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CompilerDeclContext.h; path = include/lldb/Symbol/CompilerDeclContext.h; sourceTree = "<group>"; };
2657AFB61B86910100958979 /* CompilerDeclContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompilerDeclContext.cpp; path = source/Symbol/CompilerDeclContext.cpp; sourceTree = "<group>"; };
@@ -1841,6 +1845,17 @@
26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationServer.h; sourceTree = "<group>"; };
2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformRemoteiOS.cpp; sourceTree = "<group>"; };
2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRemoteiOS.h; sourceTree = "<group>"; };
+ 26764C951E48F46F008D3573 /* ConstString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConstString.h; path = include/lldb/Utility/ConstString.h; sourceTree = "<group>"; };
+ 26764C961E48F482008D3573 /* ConstString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConstString.cpp; path = source/Utility/ConstString.cpp; sourceTree = "<group>"; };
+ 26764C981E48F4D2008D3573 /* Error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Error.cpp; path = source/Utility/Error.cpp; sourceTree = "<group>"; };
+ 26764C9A1E48F4DD008D3573 /* Error.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Error.h; path = include/lldb/Utility/Error.h; sourceTree = "<group>"; };
+ 26764C9B1E48F50C008D3573 /* Stream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Stream.h; path = include/lldb/Utility/Stream.h; sourceTree = "<group>"; };
+ 26764C9C1E48F516008D3573 /* RegularExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegularExpression.h; path = include/lldb/Utility/RegularExpression.h; sourceTree = "<group>"; };
+ 26764C9D1E48F51E008D3573 /* Stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stream.cpp; path = source/Utility/Stream.cpp; sourceTree = "<group>"; };
+ 26764C9F1E48F528008D3573 /* RegularExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegularExpression.cpp; path = source/Utility/RegularExpression.cpp; sourceTree = "<group>"; };
+ 26764CA11E48F547008D3573 /* StreamString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamString.cpp; path = source/Utility/StreamString.cpp; sourceTree = "<group>"; };
+ 26764CA31E48F550008D3573 /* StreamString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamString.h; path = include/lldb/Utility/StreamString.h; sourceTree = "<group>"; };
+ 26764CA41E48F566008D3573 /* StreamTee.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Utility/StreamTee.h; sourceTree = "<group>"; };
2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = "<group>"; };
2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = "<group>"; };
267A47F21B14115A0021A5BC /* SoftwareBreakpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SoftwareBreakpoint.h; path = include/lldb/Host/common/SoftwareBreakpoint.h; sourceTree = "<group>"; };
@@ -1870,8 +1885,6 @@
267F68561CC02EAE0086832B /* RegisterContextPOSIX_s390x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextPOSIX_s390x.h; path = Utility/RegisterContextPOSIX_s390x.h; sourceTree = "<group>"; };
267F68591CC02EBE0086832B /* RegisterInfos_s390x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_s390x.h; path = Utility/RegisterInfos_s390x.h; sourceTree = "<group>"; };
2682100C143A59AE004BCF2D /* MappedHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MappedHash.h; path = include/lldb/Core/MappedHash.h; sourceTree = "<group>"; };
- 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Utility/PseudoTerminal.cpp; sourceTree = "<group>"; };
- 2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = "<group>"; };
2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = "<group>"; };
2682F286115EF3BD00CCFF99 /* SBError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBError.h; path = include/lldb/API/SBError.h; sourceTree = "<group>"; };
268648C116531BF800F04704 /* com.apple.debugserver.posix.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.posix.plist; path = tools/debugserver/source/com.apple.debugserver.posix.plist; sourceTree = "<group>"; };
@@ -1891,8 +1904,6 @@
268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = "<group>"; };
268DA871130095D000C9483A /* Terminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Terminal.h; path = include/lldb/Host/Terminal.h; sourceTree = "<group>"; };
268DA873130095ED00C9483A /* Terminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Terminal.cpp; sourceTree = "<group>"; };
- 268ED0A2140FF52F00DE830F /* DataEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataEncoder.h; path = include/lldb/Core/DataEncoder.h; sourceTree = "<group>"; };
- 268ED0A4140FF54200DE830F /* DataEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataEncoder.cpp; path = source/Core/DataEncoder.cpp; sourceTree = "<group>"; };
268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = "<group>"; };
268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = "<group>"; };
2690B36F1381D5B600ECFBAE /* Memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Memory.h; path = include/lldb/Target/Memory.h; sourceTree = "<group>"; };
@@ -1926,8 +1937,6 @@
269FF07D12494F7D00225026 /* FuncUnwinders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FuncUnwinders.h; path = include/lldb/Symbol/FuncUnwinders.h; sourceTree = "<group>"; };
269FF07F12494F8E00225026 /* UnwindPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindPlan.h; path = include/lldb/Symbol/UnwindPlan.h; sourceTree = "<group>"; };
269FF08112494FC200225026 /* UnwindTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindTable.h; path = include/lldb/Symbol/UnwindTable.h; sourceTree = "<group>"; };
- 26A0604711A5BC7A00F75969 /* Baton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Core/Baton.h; sourceTree = "<group>"; };
- 26A0604811A5D03C00F75969 /* Baton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Baton.cpp; path = source/Core/Baton.cpp; sourceTree = "<group>"; };
26A0DA4D140F721D006DA411 /* HashedNameToDIE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HashedNameToDIE.h; sourceTree = "<group>"; };
26A3757F1D59462700D6CBDB /* SelectHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SelectHelper.cpp; path = source/Utility/SelectHelper.cpp; sourceTree = "<group>"; };
26A375831D59486000D6CBDB /* StringExtractor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringExtractor.h; path = include/lldb/Utility/StringExtractor.h; sourceTree = "<group>"; };
@@ -2035,19 +2044,13 @@
26BC7D5510F1B77400F91463 /* ClangForward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangForward.h; path = include/lldb/Core/ClangForward.h; sourceTree = "<group>"; };
26BC7D5610F1B77400F91463 /* Communication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Communication.h; path = include/lldb/Core/Communication.h; sourceTree = "<group>"; };
26BC7D5710F1B77400F91463 /* Connection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Connection.h; path = include/lldb/Core/Connection.h; sourceTree = "<group>"; };
- 26BC7D5910F1B77400F91463 /* DataBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBuffer.h; path = include/lldb/Core/DataBuffer.h; sourceTree = "<group>"; };
- 26BC7D5A10F1B77400F91463 /* DataExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataExtractor.h; path = include/lldb/Core/DataExtractor.h; sourceTree = "<group>"; };
- 26BC7D5B10F1B77400F91463 /* DataBufferHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBufferHeap.h; path = include/lldb/Core/DataBufferHeap.h; sourceTree = "<group>"; };
- 26BC7D5C10F1B77400F91463 /* DataBufferMemoryMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBufferMemoryMap.h; path = include/lldb/Core/DataBufferMemoryMap.h; sourceTree = "<group>"; };
26BC7D5E10F1B77400F91463 /* Disassembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Disassembler.h; path = include/lldb/Core/Disassembler.h; sourceTree = "<group>"; };
26BC7D5F10F1B77400F91463 /* dwarf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dwarf.h; path = include/lldb/Core/dwarf.h; sourceTree = "<group>"; };
- 26BC7D6010F1B77400F91463 /* Error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Error.h; path = include/lldb/Core/Error.h; sourceTree = "<group>"; };
26BC7D6110F1B77400F91463 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Event.h; path = include/lldb/Core/Event.h; sourceTree = "<group>"; };
26BC7D6310F1B77400F91463 /* FileSpecList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpecList.h; path = include/lldb/Core/FileSpecList.h; sourceTree = "<group>"; };
- 26BC7D6410F1B77400F91463 /* Flags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Flags.h; path = include/lldb/Core/Flags.h; sourceTree = "<group>"; };
26BC7D6510F1B77400F91463 /* IOStreamMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOStreamMacros.h; path = include/lldb/Core/IOStreamMacros.h; sourceTree = "<group>"; };
26BC7D6710F1B77400F91463 /* Listener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Listener.h; path = include/lldb/Core/Listener.h; sourceTree = "<group>"; };
- 26BC7D6810F1B77400F91463 /* Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Log.h; path = include/lldb/Core/Log.h; sourceTree = "<group>"; };
+ 26BC7D6810F1B77400F91463 /* Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Log.h; path = include/lldb/Utility/Log.h; sourceTree = "<group>"; };
26BC7D6910F1B77400F91463 /* Mangled.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mangled.h; path = include/lldb/Core/Mangled.h; sourceTree = "<group>"; };
26BC7D6A10F1B77400F91463 /* Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Module.h; path = include/lldb/Core/Module.h; sourceTree = "<group>"; };
26BC7D6B10F1B77400F91463 /* ModuleChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModuleChild.h; path = include/lldb/Core/ModuleChild.h; sourceTree = "<group>"; };
@@ -2055,24 +2058,18 @@
26BC7D6D10F1B77400F91463 /* Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Options.h; path = include/lldb/Interpreter/Options.h; sourceTree = "<group>"; };
26BC7D7010F1B77400F91463 /* PluginInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PluginInterface.h; path = include/lldb/Core/PluginInterface.h; sourceTree = "<group>"; };
26BC7D7110F1B77400F91463 /* PluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PluginManager.h; path = include/lldb/Core/PluginManager.h; sourceTree = "<group>"; };
- 26BC7D7310F1B77400F91463 /* RegularExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegularExpression.h; path = include/lldb/Core/RegularExpression.h; sourceTree = "<group>"; };
26BC7D7410F1B77400F91463 /* Scalar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Scalar.h; path = include/lldb/Core/Scalar.h; sourceTree = "<group>"; };
26BC7D7510F1B77400F91463 /* Section.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Section.h; path = include/lldb/Core/Section.h; sourceTree = "<group>"; };
26BC7D7610F1B77400F91463 /* SourceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceManager.h; path = include/lldb/Core/SourceManager.h; sourceTree = "<group>"; };
26BC7D7710F1B77400F91463 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = State.h; path = include/lldb/Core/State.h; sourceTree = "<group>"; };
26BC7D7810F1B77400F91463 /* STLUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STLUtils.h; path = include/lldb/Core/STLUtils.h; sourceTree = "<group>"; };
- 26BC7D7910F1B77400F91463 /* Stream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stream.h; path = include/lldb/Core/Stream.h; sourceTree = "<group>"; };
26BC7D7A10F1B77400F91463 /* StreamFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamFile.h; path = include/lldb/Core/StreamFile.h; sourceTree = "<group>"; };
- 26BC7D7B10F1B77400F91463 /* StreamString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamString.h; path = include/lldb/Core/StreamString.h; sourceTree = "<group>"; };
- 26BC7D7C10F1B77400F91463 /* ConstString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConstString.h; path = include/lldb/Core/ConstString.h; sourceTree = "<group>"; };
26BC7D7E10F1B77400F91463 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timer.h; path = include/lldb/Core/Timer.h; sourceTree = "<group>"; };
- 26BC7D8010F1B77400F91463 /* UserID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserID.h; path = include/lldb/Core/UserID.h; sourceTree = "<group>"; };
26BC7D8110F1B77400F91463 /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Value.h; path = include/lldb/Core/Value.h; sourceTree = "<group>"; };
26BC7D8210F1B77400F91463 /* ValueObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObject.h; path = include/lldb/Core/ValueObject.h; sourceTree = "<group>"; };
26BC7D8310F1B77400F91463 /* ValueObjectChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectChild.h; path = include/lldb/Core/ValueObjectChild.h; sourceTree = "<group>"; };
26BC7D8410F1B77400F91463 /* ValueObjectList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectList.h; path = include/lldb/Core/ValueObjectList.h; sourceTree = "<group>"; };
26BC7D8510F1B77400F91463 /* ValueObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectVariable.h; path = include/lldb/Core/ValueObjectVariable.h; sourceTree = "<group>"; };
- 26BC7D8610F1B77400F91463 /* VMRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMRange.h; path = include/lldb/Core/VMRange.h; sourceTree = "<group>"; };
26BC7DC010F1B79500F91463 /* ClangExpressionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionHelper.h; path = ExpressionParser/Clang/ClangExpressionHelper.h; sourceTree = "<group>"; };
26BC7DC310F1B79500F91463 /* DWARFExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DWARFExpression.h; path = include/lldb/Expression/DWARFExpression.h; sourceTree = "<group>"; };
26BC7DD310F1B7D500F91463 /* Endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Endian.h; path = include/lldb/Host/Endian.h; sourceTree = "<group>"; };
@@ -2130,40 +2127,30 @@
26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Broadcaster.cpp; path = source/Core/Broadcaster.cpp; sourceTree = "<group>"; };
26BC7E6E10F1B85900F91463 /* Communication.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Communication.cpp; path = source/Core/Communication.cpp; sourceTree = "<group>"; };
26BC7E6F10F1B85900F91463 /* Connection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Connection.cpp; path = source/Core/Connection.cpp; sourceTree = "<group>"; };
- 26BC7E7110F1B85900F91463 /* DataExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataExtractor.cpp; path = source/Core/DataExtractor.cpp; sourceTree = "<group>"; };
- 26BC7E7210F1B85900F91463 /* DataBufferHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataBufferHeap.cpp; path = source/Core/DataBufferHeap.cpp; sourceTree = "<group>"; };
- 26BC7E7310F1B85900F91463 /* DataBufferMemoryMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataBufferMemoryMap.cpp; path = source/Core/DataBufferMemoryMap.cpp; sourceTree = "<group>"; };
26BC7E7410F1B85900F91463 /* lldb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lldb.cpp; path = source/lldb.cpp; sourceTree = "<group>"; };
26BC7E7610F1B85900F91463 /* Disassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disassembler.cpp; path = source/Core/Disassembler.cpp; sourceTree = "<group>"; };
26BC7E7710F1B85900F91463 /* DynamicLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DynamicLoader.cpp; path = source/Core/DynamicLoader.cpp; sourceTree = "<group>"; };
- 26BC7E7810F1B85900F91463 /* Error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Error.cpp; path = source/Core/Error.cpp; sourceTree = "<group>"; };
26BC7E7910F1B85900F91463 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Event.cpp; path = source/Core/Event.cpp; sourceTree = "<group>"; };
26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSpecList.cpp; path = source/Core/FileSpecList.cpp; sourceTree = "<group>"; };
26BC7E7E10F1B85900F91463 /* Listener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Listener.cpp; path = source/Core/Listener.cpp; sourceTree = "<group>"; };
- 26BC7E7F10F1B85900F91463 /* Log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Log.cpp; path = source/Core/Log.cpp; sourceTree = "<group>"; };
+ 26BC7E7F10F1B85900F91463 /* Log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Log.cpp; path = source/Utility/Log.cpp; sourceTree = "<group>"; };
26BC7E8010F1B85900F91463 /* Mangled.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mangled.cpp; path = source/Core/Mangled.cpp; sourceTree = "<group>"; };
26BC7E8110F1B85900F91463 /* Module.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Module.cpp; path = source/Core/Module.cpp; sourceTree = "<group>"; };
26BC7E8210F1B85900F91463 /* ModuleChild.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleChild.cpp; path = source/Core/ModuleChild.cpp; sourceTree = "<group>"; };
26BC7E8310F1B85900F91463 /* ModuleList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleList.cpp; path = source/Core/ModuleList.cpp; sourceTree = "<group>"; };
26BC7E8610F1B85900F91463 /* Options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Options.cpp; path = source/Interpreter/Options.cpp; sourceTree = "<group>"; };
26BC7E8A10F1B85900F91463 /* PluginManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginManager.cpp; path = source/Core/PluginManager.cpp; sourceTree = "<group>"; };
- 26BC7E8C10F1B85900F91463 /* RegularExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegularExpression.cpp; path = source/Core/RegularExpression.cpp; sourceTree = "<group>"; };
26BC7E8D10F1B85900F91463 /* Scalar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Scalar.cpp; path = source/Core/Scalar.cpp; sourceTree = "<group>"; };
26BC7E8E10F1B85900F91463 /* Section.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Section.cpp; path = source/Core/Section.cpp; sourceTree = "<group>"; };
26BC7E8F10F1B85900F91463 /* SourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SourceManager.cpp; path = source/Core/SourceManager.cpp; sourceTree = "<group>"; };
26BC7E9010F1B85900F91463 /* State.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = State.cpp; path = source/Core/State.cpp; sourceTree = "<group>"; };
- 26BC7E9110F1B85900F91463 /* Stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stream.cpp; path = source/Core/Stream.cpp; sourceTree = "<group>"; };
26BC7E9210F1B85900F91463 /* StreamFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamFile.cpp; path = source/Core/StreamFile.cpp; sourceTree = "<group>"; };
- 26BC7E9310F1B85900F91463 /* StreamString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamString.cpp; path = source/Core/StreamString.cpp; sourceTree = "<group>"; };
- 26BC7E9410F1B85900F91463 /* ConstString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConstString.cpp; path = source/Core/ConstString.cpp; sourceTree = "<group>"; };
26BC7E9610F1B85900F91463 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Timer.cpp; path = source/Core/Timer.cpp; sourceTree = "<group>"; };
- 26BC7E9810F1B85900F91463 /* UserID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserID.cpp; path = source/Core/UserID.cpp; sourceTree = "<group>"; };
26BC7E9910F1B85900F91463 /* Value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Value.cpp; path = source/Core/Value.cpp; sourceTree = "<group>"; };
26BC7E9A10F1B85900F91463 /* ValueObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObject.cpp; path = source/Core/ValueObject.cpp; sourceTree = "<group>"; };
26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectChild.cpp; path = source/Core/ValueObjectChild.cpp; sourceTree = "<group>"; };
26BC7E9C10F1B85900F91463 /* ValueObjectList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectList.cpp; path = source/Core/ValueObjectList.cpp; sourceTree = "<group>"; };
26BC7E9D10F1B85900F91463 /* ValueObjectVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectVariable.cpp; path = source/Core/ValueObjectVariable.cpp; sourceTree = "<group>"; };
- 26BC7E9E10F1B85900F91463 /* VMRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VMRange.cpp; path = source/Core/VMRange.cpp; sourceTree = "<group>"; };
26BC7ED510F1B86700F91463 /* ClangUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUserExpression.cpp; path = ExpressionParser/Clang/ClangUserExpression.cpp; sourceTree = "<group>"; };
26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DWARFExpression.cpp; path = source/Expression/DWARFExpression.cpp; sourceTree = "<group>"; };
26BC7EE810F1B88F00F91463 /* Host.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Host.mm; path = source/Host/macosx/Host.mm; sourceTree = "<group>"; };
@@ -2229,8 +2216,6 @@
26C72C951243229A0068DC16 /* SBStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBStream.cpp; path = source/API/SBStream.cpp; sourceTree = "<group>"; };
26C7C4811BFFEA7E009BD01F /* WindowsMiniDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowsMiniDump.cpp; sourceTree = "<group>"; };
26C7C4821BFFEA7E009BD01F /* WindowsMiniDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowsMiniDump.h; sourceTree = "<group>"; };
- 26C81CA411335651004BDC5A /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Core/UUID.h; sourceTree = "<group>"; };
- 26C81CA511335651004BDC5A /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UUID.cpp; path = source/Core/UUID.cpp; sourceTree = "<group>"; };
26CA979F172B1FD5005DC71B /* RegisterContextThreadMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextThreadMemory.cpp; path = Utility/RegisterContextThreadMemory.cpp; sourceTree = "<group>"; };
26CA97A0172B1FD5005DC71B /* RegisterContextThreadMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextThreadMemory.h; path = Utility/RegisterContextThreadMemory.h; sourceTree = "<group>"; };
26CEB5F018762056008F575A /* CommandObjectGUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectGUI.cpp; path = source/Commands/CommandObjectGUI.cpp; sourceTree = "<group>"; };
@@ -2301,7 +2286,6 @@
26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMacOSXFrameBackchain.h; path = Utility/RegisterContextMacOSXFrameBackchain.h; sourceTree = "<group>"; };
26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCallbacks.h; path = include/lldb/Symbol/ClangExternalASTSourceCallbacks.h; sourceTree = "<group>"; };
26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCallbacks.cpp; path = source/Symbol/ClangExternalASTSourceCallbacks.cpp; sourceTree = "<group>"; };
- 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ARM_DWARF_Registers.cpp; path = source/Utility/ARM_DWARF_Registers.cpp; sourceTree = "<group>"; };
26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupVariable.cpp; path = source/Interpreter/OptionGroupVariable.cpp; sourceTree = "<group>"; };
26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupVariable.h; path = include/lldb/Interpreter/OptionGroupVariable.h; sourceTree = "<group>"; };
26EFB6181BFE8D3E00544801 /* PlatformNetBSD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformNetBSD.cpp; sourceTree = "<group>"; };
@@ -2322,11 +2306,9 @@
26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtermcap.dylib; path = /usr/lib/libtermcap.dylib; sourceTree = "<absolute>"; };
26F5C37410F3F61B009D5894 /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
26F5C39010F3FA26009D5894 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
- 26F7305F139D8FC900FD51C7 /* History.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = History.h; path = include/lldb/Core/History.h; sourceTree = "<group>"; };
- 26F73061139D8FDB00FD51C7 /* History.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = History.cpp; path = source/Core/History.cpp; sourceTree = "<group>"; };
26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM_DWARF_Registers.h; path = source/Utility/ARM_DWARF_Registers.h; sourceTree = "<group>"; };
- 26FA4315130103F400E71120 /* FileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpec.h; path = include/lldb/Host/FileSpec.h; sourceTree = "<group>"; };
- 26FA43171301048600E71120 /* FileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSpec.cpp; sourceTree = "<group>"; };
+ 26FA4315130103F400E71120 /* FileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpec.h; path = include/lldb/Utility/FileSpec.h; sourceTree = "<group>"; };
+ 26FA43171301048600E71120 /* FileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSpec.cpp; path = source/Utility/FileSpec.cpp; sourceTree = "<group>"; };
26FFC19314FC072100087D58 /* AuxVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuxVector.cpp; sourceTree = "<group>"; };
26FFC19414FC072100087D58 /* AuxVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuxVector.h; sourceTree = "<group>"; };
26FFC19514FC072100087D58 /* DYLDRendezvous.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DYLDRendezvous.cpp; sourceTree = "<group>"; };
@@ -2337,16 +2319,13 @@
3032B1B91CAAA400004BE1AB /* ClangUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangUtil.h; path = include/lldb/Symbol/ClangUtil.h; sourceTree = "<group>"; };
30DED5DC1B4ECB17004CC508 /* MainLoopPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainLoopPosix.cpp; sourceTree = "<group>"; };
33064C991A5C7A330033D415 /* UriParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UriParser.cpp; path = source/Utility/UriParser.cpp; sourceTree = "<group>"; };
- 33064C9B1A5C7A490033D415 /* UriParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UriParser.h; path = source/Utility/UriParser.h; sourceTree = "<group>"; };
3392EBB71AFF402200858B9F /* SBLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBLanguageRuntime.h; path = include/lldb/API/SBLanguageRuntime.h; sourceTree = "<group>"; };
33E5E8411A672A240024ED68 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = "<group>"; };
33E5E8451A6736D30024ED68 /* StringConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringConvert.h; path = include/lldb/Host/StringConvert.h; sourceTree = SOURCE_ROOT; };
3F5E8AF31A40D4A500A73232 /* PipeBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PipeBase.h; path = include/lldb/Host/PipeBase.h; sourceTree = "<group>"; };
- 3F8160A51AB9F7DD001DA9DF /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Logging.cpp; path = source/Core/Logging.cpp; sourceTree = "<group>"; };
- 3F8160A71AB9F809001DA9DF /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = include/lldb/Core/Logging.h; sourceTree = "<group>"; };
- 3F8169171ABA2419001DA9DF /* ConvertEnum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConvertEnum.cpp; path = source/Utility/ConvertEnum.cpp; sourceTree = "<group>"; };
+ 3F8160A51AB9F7DD001DA9DF /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Logging.cpp; path = source/Utility/Logging.cpp; sourceTree = "<group>"; };
+ 3F8160A71AB9F809001DA9DF /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = include/lldb/Utility/Logging.h; sourceTree = "<group>"; };
3F8169181ABA2419001DA9DF /* NameMatches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NameMatches.cpp; path = source/Utility/NameMatches.cpp; sourceTree = "<group>"; };
- 3F81691B1ABA242B001DA9DF /* ConvertEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConvertEnum.h; path = include/lldb/Utility/ConvertEnum.h; sourceTree = "<group>"; };
3F81691C1ABA242B001DA9DF /* NameMatches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NameMatches.h; path = include/lldb/Utility/NameMatches.h; sourceTree = "<group>"; };
3F81692A1ABB7A16001DA9DF /* SystemInitializerFull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemInitializerFull.cpp; path = source/API/SystemInitializerFull.cpp; sourceTree = "<group>"; };
3F81692D1ABB7A40001DA9DF /* SystemInitializerFull.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SystemInitializerFull.h; path = include/lldb/API/SystemInitializerFull.h; sourceTree = "<group>"; };
@@ -2412,9 +2391,6 @@
3FDFE57419AFABFD009756A7 /* HostProcess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostProcess.h; path = include/lldb/Host/HostProcess.h; sourceTree = "<group>"; };
3FDFE57519AFABFD009756A7 /* HostThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostThread.h; path = include/lldb/Host/HostThread.h; sourceTree = "<group>"; };
3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = HostThreadMacOSX.mm; path = source/Host/macosx/HostThreadMacOSX.mm; sourceTree = "<group>"; };
- 3FDFED0619B7C898009756A7 /* ThisThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThisThread.cpp; path = source/Host/macosx/ThisThread.cpp; sourceTree = "<group>"; };
- 3FDFED0919B7C8C7009756A7 /* ThisThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThisThread.h; path = include/lldb/Host/ThisThread.h; sourceTree = "<group>"; };
- 3FDFED0D19B7D269009756A7 /* ThisThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThisThread.cpp; path = source/Host/common/ThisThread.cpp; sourceTree = "<group>"; };
3FDFED1E19BA6D55009756A7 /* Debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Debug.h; path = include/lldb/Host/Debug.h; sourceTree = "<group>"; };
3FDFED1F19BA6D55009756A7 /* HostGetOpt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostGetOpt.h; path = include/lldb/Host/HostGetOpt.h; sourceTree = "<group>"; };
3FDFED2019BA6D55009756A7 /* HostNativeThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostNativeThread.h; path = include/lldb/Host/HostNativeThread.h; sourceTree = "<group>"; };
@@ -2425,7 +2401,6 @@
3FDFED2519BA6D96009756A7 /* HostThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostThread.cpp; sourceTree = "<group>"; };
3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadLauncher.cpp; sourceTree = "<group>"; };
3FDFED2C19C257A0009756A7 /* HostProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostProcess.cpp; sourceTree = "<group>"; };
- 449ACC96197DE9EC008D175E /* FastDemangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FastDemangle.cpp; path = source/Core/FastDemangle.cpp; sourceTree = "<group>"; };
4906FD4012F2255300A2A77C /* ASTDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTDumper.cpp; path = ExpressionParser/Clang/ASTDumper.cpp; sourceTree = "<group>"; };
4906FD4412F2257600A2A77C /* ASTDumper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTDumper.h; path = ExpressionParser/Clang/ASTDumper.h; sourceTree = "<group>"; };
490A36BD180F0E6F00BA31F8 /* PlatformWindows.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformWindows.cpp; sourceTree = "<group>"; };
@@ -2466,6 +2441,17 @@
49B01A2D15F67B1700666829 /* DeclVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeclVendor.h; path = include/lldb/Symbol/DeclVendor.h; sourceTree = "<group>"; };
49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = "<group>"; };
49C66B1C17011A43004D1922 /* IRMemoryMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IRMemoryMap.h; path = include/lldb/Expression/IRMemoryMap.h; sourceTree = "<group>"; };
+ 49CA96E61E6AAC6600C03FEE /* DataBufferHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataBufferHeap.cpp; path = source/Utility/DataBufferHeap.cpp; sourceTree = "<group>"; };
+ 49CA96E71E6AAC6600C03FEE /* DataBufferLLVM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataBufferLLVM.cpp; path = source/Utility/DataBufferLLVM.cpp; sourceTree = "<group>"; };
+ 49CA96E81E6AAC6600C03FEE /* DataEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataEncoder.cpp; path = source/Utility/DataEncoder.cpp; sourceTree = "<group>"; };
+ 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataExtractor.cpp; path = source/Utility/DataExtractor.cpp; sourceTree = "<group>"; };
+ 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UUID.cpp; path = source/Utility/UUID.cpp; sourceTree = "<group>"; };
+ 49CA96F01E6AAC8E00C03FEE /* DataBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBuffer.h; path = include/lldb/Utility/DataBuffer.h; sourceTree = "<group>"; };
+ 49CA96F11E6AAC8E00C03FEE /* DataBufferHeap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBufferHeap.h; path = include/lldb/Utility/DataBufferHeap.h; sourceTree = "<group>"; };
+ 49CA96F21E6AAC8E00C03FEE /* DataBufferLLVM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataBufferLLVM.h; path = include/lldb/Utility/DataBufferLLVM.h; sourceTree = "<group>"; };
+ 49CA96F31E6AAC8E00C03FEE /* DataEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataEncoder.h; path = include/lldb/Utility/DataEncoder.h; sourceTree = "<group>"; };
+ 49CA96F41E6AAC8E00C03FEE /* DataExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataExtractor.h; path = include/lldb/Utility/DataExtractor.h; sourceTree = "<group>"; };
+ 49CA96F51E6AAC8E00C03FEE /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Utility/UUID.h; sourceTree = "<group>"; };
49CF9829122C70BD007A0B96 /* IRDynamicChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRDynamicChecks.cpp; path = source/Expression/IRDynamicChecks.cpp; sourceTree = "<group>"; };
49CF9833122C718B007A0B96 /* IRDynamicChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRDynamicChecks.h; path = include/lldb/Expression/IRDynamicChecks.h; sourceTree = "<group>"; };
49D4FE821210B5FB00CDB854 /* ClangPersistentVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangPersistentVariables.h; path = ExpressionParser/Clang/ClangPersistentVariables.h; sourceTree = "<group>"; };
@@ -2489,6 +2475,8 @@
49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallFunction.h; path = include/lldb/Target/ThreadPlanCallFunction.h; sourceTree = "<group>"; };
49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionDeclMap.cpp; path = ExpressionParser/Clang/ClangExpressionDeclMap.cpp; sourceTree = "<group>"; };
49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionDeclMap.h; path = ExpressionParser/Clang/ClangExpressionDeclMap.h; sourceTree = "<group>"; };
+ 49F811EF1E931B1500F4E163 /* CPlusPlusNameParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CPlusPlusNameParser.cpp; path = Language/CPlusPlus/CPlusPlusNameParser.cpp; sourceTree = "<group>"; };
+ 49F811F01E931B1500F4E163 /* CPlusPlusNameParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CPlusPlusNameParser.h; path = Language/CPlusPlus/CPlusPlusNameParser.h; sourceTree = "<group>"; };
4C00832C1B9A58A700D5CF24 /* Expression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Expression.h; path = include/lldb/Expression/Expression.h; sourceTree = "<group>"; };
4C00832D1B9A58A700D5CF24 /* FunctionCaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FunctionCaller.h; path = include/lldb/Expression/FunctionCaller.h; sourceTree = "<group>"; };
4C00832E1B9A58A700D5CF24 /* UserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserExpression.h; path = include/lldb/Expression/UserExpression.h; sourceTree = "<group>"; };
@@ -2512,6 +2500,8 @@
4C43DF8611069BFD00E55CBF /* ThreadPlanStepOverRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepOverRange.h; path = include/lldb/Target/ThreadPlanStepOverRange.h; sourceTree = "<group>"; };
4C43DF8911069C3200E55CBF /* ThreadPlanStepInRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepInRange.cpp; path = source/Target/ThreadPlanStepInRange.cpp; sourceTree = "<group>"; };
4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.cpp; sourceTree = "<group>"; };
+ 4C4EB77F1E6A4DB8002035C0 /* DumpDataExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DumpDataExtractor.cpp; path = source/Core/DumpDataExtractor.cpp; sourceTree = "<group>"; };
+ 4C4EB7821E6A4DE7002035C0 /* DumpDataExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpDataExtractor.h; path = include/lldb/Core/DumpDataExtractor.h; sourceTree = "<group>"; };
4C562CC21CC07DDD00C52EAC /* PDBASTParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PDBASTParser.cpp; path = PDB/PDBASTParser.cpp; sourceTree = "<group>"; };
4C562CC31CC07DDD00C52EAC /* PDBASTParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDBASTParser.h; path = PDB/PDBASTParser.h; sourceTree = "<group>"; };
4C56543019D1EFAA002E9C44 /* ThreadPlanPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanPython.cpp; path = source/Target/ThreadPlanPython.cpp; sourceTree = "<group>"; };
@@ -2521,9 +2511,6 @@
4C56543819D22FD9002E9C44 /* SBThreadPlan.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBThreadPlan.i; sourceTree = "<group>"; };
4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = "<group>"; };
4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = "<group>"; };
- 4C626533130F1B0A00C889F6 /* StreamTee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Core/StreamTee.h; sourceTree = "<group>"; };
- 4C66499F14EEE7F100B0316F /* StreamCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamCallback.h; path = include/lldb/Core/StreamCallback.h; sourceTree = "<group>"; };
- 4C6649A214EEE81000B0316F /* StreamCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamCallback.cpp; path = source/Core/StreamCallback.cpp; sourceTree = "<group>"; };
4C73152119B7D71700F865A4 /* Iterable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Iterable.h; path = include/lldb/Utility/Iterable.h; sourceTree = "<group>"; };
4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallUserExpression.h; path = include/lldb/Target/ThreadPlanCallUserExpression.h; sourceTree = "<group>"; };
4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallUserExpression.cpp; path = source/Target/ThreadPlanCallUserExpression.cpp; sourceTree = "<group>"; };
@@ -2570,6 +2557,12 @@
4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = "<group>"; };
4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcppUniquePointer.cpp; path = Language/CPlusPlus/LibStdcppUniquePointer.cpp; sourceTree = "<group>"; };
4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibStdcppTuple.cpp; path = Language/CPlusPlus/LibStdcppTuple.cpp; sourceTree = "<group>"; };
+ 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformOpenBSD.cpp; sourceTree = "<group>"; };
+ 4CE4EFA71E8999B000A80C06 /* PlatformOpenBSD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformOpenBSD.h; sourceTree = "<group>"; };
+ 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextOpenBSD_i386.cpp; path = Utility/RegisterContextOpenBSD_i386.cpp; sourceTree = "<group>"; };
+ 4CE4EFAC1E899A1200A80C06 /* RegisterContextOpenBSD_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextOpenBSD_i386.h; path = Utility/RegisterContextOpenBSD_i386.h; sourceTree = "<group>"; };
+ 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextOpenBSD_x86_64.cpp; path = Utility/RegisterContextOpenBSD_x86_64.cpp; sourceTree = "<group>"; };
+ 4CE4EFAE1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextOpenBSD_x86_64.h; path = Utility/RegisterContextOpenBSD_x86_64.h; sourceTree = "<group>"; };
4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBExpressionOptions.h; path = include/lldb/API/SBExpressionOptions.h; sourceTree = "<group>"; };
4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBExpressionOptions.cpp; path = source/API/SBExpressionOptions.cpp; sourceTree = "<group>"; };
4CE4F676162CE1E100F75CB3 /* SBExpressionOptions.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBExpressionOptions.i; sourceTree = "<group>"; };
@@ -2637,7 +2630,6 @@
8CF02AEE19DD15CF00B14BE0 /* InstrumentationRuntimeStopInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstrumentationRuntimeStopInfo.h; path = include/lldb/Target/InstrumentationRuntimeStopInfo.h; sourceTree = "<group>"; };
94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = "<group>"; };
94005E0513F45A1B001EF42D /* embedded_interpreter.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = embedded_interpreter.py; path = source/Interpreter/embedded_interpreter.py; sourceTree = "<group>"; };
- 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; };
940495781BEC497E00926025 /* NSError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSError.cpp; path = Language/ObjC/NSError.cpp; sourceTree = "<group>"; };
940495791BEC497E00926025 /* NSException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSException.cpp; path = Language/ObjC/NSException.cpp; sourceTree = "<group>"; };
94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
@@ -2699,8 +2691,6 @@
9455630D1BEAD0570073F75F /* PlatformiOSSimulatorCoreSimulatorSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformiOSSimulatorCoreSimulatorSupport.mm; sourceTree = "<group>"; };
945759651534941F005A9070 /* PlatformPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformPOSIX.cpp; path = POSIX/PlatformPOSIX.cpp; sourceTree = "<group>"; };
945759661534941F005A9070 /* PlatformPOSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformPOSIX.h; path = POSIX/PlatformPOSIX.h; sourceTree = "<group>"; };
- 945E8D7D152F6AA80019BCCD /* StreamGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamGDBRemote.h; path = include/lldb/Core/StreamGDBRemote.h; sourceTree = "<group>"; };
- 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamGDBRemote.cpp; path = source/Core/StreamGDBRemote.cpp; sourceTree = "<group>"; };
9461568614E355F2003A195C /* SBTypeFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFilter.h; path = include/lldb/API/SBTypeFilter.h; sourceTree = "<group>"; };
9461568714E355F2003A195C /* SBTypeFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFormat.h; path = include/lldb/API/SBTypeFormat.h; sourceTree = "<group>"; };
9461568814E355F2003A195C /* SBTypeSummary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeSummary.h; path = include/lldb/API/SBTypeSummary.h; sourceTree = "<group>"; };
@@ -2798,7 +2788,6 @@
94EE33F218643C6900CD703B /* FormattersContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormattersContainer.h; path = include/lldb/DataFormatters/FormattersContainer.h; sourceTree = "<group>"; };
94F48F231A01C679005C0EC6 /* StringPrinter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringPrinter.h; path = include/lldb/DataFormatters/StringPrinter.h; sourceTree = "<group>"; };
94F48F241A01C687005C0EC6 /* StringPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringPrinter.cpp; path = source/DataFormatters/StringPrinter.cpp; sourceTree = "<group>"; };
- 94F6C4D119C264C70049D089 /* ProcessStructReader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ProcessStructReader.h; path = include/lldb/Utility/ProcessStructReader.h; sourceTree = "<group>"; };
94FA3DDD1405D4E500833217 /* ValueObjectConstResultChild.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResultChild.h; path = include/lldb/Core/ValueObjectConstResultChild.h; sourceTree = "<group>"; };
94FA3DDF1405D50300833217 /* ValueObjectConstResultChild.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResultChild.cpp; path = source/Core/ValueObjectConstResultChild.cpp; sourceTree = "<group>"; };
94FE476613FC1DA8001F8475 /* finish-swig-Python-LLDB.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "finish-swig-Python-LLDB.sh"; sourceTree = "<group>"; };
@@ -2810,6 +2799,13 @@
966C6B7818E6A56A0093F5EC /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
9694FA6F1B32AA64005EBB16 /* ABISysV_mips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABISysV_mips.cpp; path = "SysV-mips/ABISysV_mips.cpp"; sourceTree = "<group>"; };
9694FA701B32AA64005EBB16 /* ABISysV_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABISysV_mips.h; path = "SysV-mips/ABISysV_mips.h"; sourceTree = "<group>"; };
+ 9A0FDE951E8EF5010086B2F5 /* RegisterContext_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_mips.h; path = Utility/RegisterContext_mips.h; sourceTree = "<group>"; };
+ 9A0FDE961E8EF5010086B2F5 /* RegisterContext_s390x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_s390x.h; path = Utility/RegisterContext_s390x.h; sourceTree = "<group>"; };
+ 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextLinux_mips.cpp; path = Utility/RegisterContextLinux_mips.cpp; sourceTree = "<group>"; };
+ 9A0FDE981E8EF5010086B2F5 /* RegisterContextLinux_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_mips.h; path = Utility/RegisterContextLinux_mips.h; sourceTree = "<group>"; };
+ 9A0FDE991E8EF5010086B2F5 /* RegisterInfos_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_arm.h; path = Utility/RegisterInfos_arm.h; sourceTree = "<group>"; };
+ 9A0FDE9A1E8EF5010086B2F5 /* RegisterInfos_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_arm64.h; path = Utility/RegisterInfos_arm64.h; sourceTree = "<group>"; };
+ 9A0FDE9B1E8EF5010086B2F5 /* RegisterInfos_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_mips.h; path = Utility/RegisterInfos_mips.h; sourceTree = "<group>"; };
9A19A6A51163BB7E00E0D453 /* SBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValue.h; path = include/lldb/API/SBValue.h; sourceTree = "<group>"; };
9A19A6AD1163BB9800E0D453 /* SBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValue.cpp; path = source/API/SBValue.cpp; sourceTree = "<group>"; };
9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulateInstructionARM.cpp; sourceTree = "<group>"; };
@@ -2818,8 +2814,8 @@
9A22A160135E30370024DDC3 /* EmulationStateARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmulationStateARM.h; sourceTree = "<group>"; };
9A357582116CFDEE00E8ED2F /* SBValueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValueList.h; path = include/lldb/API/SBValueList.h; sourceTree = "<group>"; };
9A35758D116CFE0F00E8ED2F /* SBValueList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValueList.cpp; path = source/API/SBValueList.cpp; sourceTree = "<group>"; };
- 9A35765E116E76A700E8ED2F /* StringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringList.h; path = include/lldb/Core/StringList.h; sourceTree = "<group>"; };
- 9A35765F116E76B900E8ED2F /* StringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringList.cpp; path = source/Core/StringList.cpp; sourceTree = "<group>"; };
+ 9A35765E116E76A700E8ED2F /* StringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringList.h; path = include/lldb/Utility/StringList.h; sourceTree = "<group>"; };
+ 9A35765F116E76B900E8ED2F /* StringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringList.cpp; path = source/Utility/StringList.cpp; sourceTree = "<group>"; };
9A357670116E7B5200E8ED2F /* SBStringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBStringList.h; path = include/lldb/API/SBStringList.h; sourceTree = "<group>"; };
9A357672116E7B6400E8ED2F /* SBStringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBStringList.cpp; path = source/API/SBStringList.cpp; sourceTree = "<group>"; };
9A3576A7116E9AB700E8ED2F /* SBHostOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBHostOS.h; path = include/lldb/API/SBHostOS.h; sourceTree = "<group>"; };
@@ -2833,6 +2829,8 @@
9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamAsynchronousIO.h; path = include/lldb/Core/StreamAsynchronousIO.h; sourceTree = "<group>"; };
9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = "<group>"; };
9A633FE8112DCE3C001A7E43 /* SBFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFrame.h; path = include/lldb/API/SBFrame.h; sourceTree = "<group>"; };
+ 9A77AD501E64E24E0025CE04 /* RegisterInfoPOSIX_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterInfoPOSIX_arm.cpp; path = Utility/RegisterInfoPOSIX_arm.cpp; sourceTree = "<group>"; };
+ 9A77AD511E64E24E0025CE04 /* RegisterInfoPOSIX_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfoPOSIX_arm.h; path = Utility/RegisterInfoPOSIX_arm.h; sourceTree = "<group>"; };
9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = "<group>"; };
9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBroadcaster.cpp; path = source/API/SBBroadcaster.cpp; sourceTree = "<group>"; };
9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBroadcaster.h; path = include/lldb/API/SBBroadcaster.h; sourceTree = "<group>"; };
@@ -2865,6 +2863,8 @@
9AC7038F117675270086C050 /* SBInstructionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInstructionList.h; path = include/lldb/API/SBInstructionList.h; sourceTree = "<group>"; };
9AC703AE117675410086C050 /* SBInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInstruction.cpp; path = source/API/SBInstruction.cpp; sourceTree = "<group>"; };
9AC703B0117675490086C050 /* SBInstructionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInstructionList.cpp; path = source/API/SBInstructionList.cpp; sourceTree = "<group>"; };
+ 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextNetBSD_x86_64.cpp; path = Utility/RegisterContextNetBSD_x86_64.cpp; sourceTree = "<group>"; };
+ 9AD9449C1E8DB267004796ED /* RegisterContextNetBSD_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextNetBSD_x86_64.h; path = Utility/RegisterContextNetBSD_x86_64.h; sourceTree = "<group>"; };
9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBreakpoint.cpp; path = source/API/SBBreakpoint.cpp; sourceTree = "<group>"; };
9AF16A9E11402D69007A7B3F /* SBBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBreakpoint.h; path = include/lldb/API/SBBreakpoint.h; sourceTree = "<group>"; };
9AF16CC611408686007A7B3F /* SBBreakpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBreakpointLocation.h; path = include/lldb/API/SBBreakpointLocation.h; sourceTree = "<group>"; };
@@ -2914,7 +2914,6 @@
AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HistoryUnwind.cpp; path = Utility/HistoryUnwind.cpp; sourceTree = "<group>"; };
AF1F7B05189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleGetPendingItemsHandler.cpp; sourceTree = "<group>"; };
AF1F7B06189C904B0087DB9C /* AppleGetPendingItemsHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleGetPendingItemsHandler.h; sourceTree = "<group>"; };
- AF1FA8891A60A69500272AFC /* RegisterNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterNumber.cpp; path = source/Utility/RegisterNumber.cpp; sourceTree = "<group>"; };
AF20F7641AF18F8500751A6E /* ABISysV_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABISysV_arm.cpp; path = "SysV-arm/ABISysV_arm.cpp"; sourceTree = "<group>"; };
AF20F7651AF18F8500751A6E /* ABISysV_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABISysV_arm.h; path = "SysV-arm/ABISysV_arm.h"; sourceTree = "<group>"; };
AF20F7681AF18F9000751A6E /* ABISysV_arm64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABISysV_arm64.cpp; path = "SysV-arm64/ABISysV_arm64.cpp"; sourceTree = "<group>"; };
@@ -2994,10 +2993,25 @@
AF9472701B575E5F0063D65C /* ValueObjectConstResultCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResultCast.h; path = include/lldb/Core/ValueObjectConstResultCast.h; sourceTree = "<group>"; };
AF9B8F31182DB52900DA866F /* SystemRuntimeMacOSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemRuntimeMacOSX.cpp; sourceTree = "<group>"; };
AF9B8F32182DB52900DA866F /* SystemRuntimeMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemRuntimeMacOSX.h; sourceTree = "<group>"; };
+ AFAFD8091E57E1B90017A14F /* ModuleCacheTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleCacheTest.cpp; path = Target/ModuleCacheTest.cpp; sourceTree = "<group>"; };
AFB3D27E1AC262AB003B4B30 /* MICmdCmdGdbShow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MICmdCmdGdbShow.cpp; path = "tools/lldb-mi/MICmdCmdGdbShow.cpp"; sourceTree = SOURCE_ROOT; };
AFB3D27F1AC262AB003B4B30 /* MICmdCmdGdbShow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MICmdCmdGdbShow.h; path = "tools/lldb-mi/MICmdCmdGdbShow.h"; sourceTree = SOURCE_ROOT; };
AFC234061AF85CE000CDE8B6 /* CommandObjectLanguage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectLanguage.cpp; path = source/Commands/CommandObjectLanguage.cpp; sourceTree = "<group>"; };
AFC234071AF85CE000CDE8B6 /* CommandObjectLanguage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectLanguage.h; path = source/Commands/CommandObjectLanguage.h; sourceTree = "<group>"; };
+ AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FastDemangle.cpp; path = source/Utility/FastDemangle.cpp; sourceTree = "<group>"; };
+ AFC2DCE81E6E2F2C00283714 /* Baton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Baton.cpp; path = source/Utility/Baton.cpp; sourceTree = "<group>"; };
+ AFC2DCEA1E6E2F7D00283714 /* UserID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserID.cpp; path = source/Utility/UserID.cpp; sourceTree = "<group>"; };
+ AFC2DCEC1E6E2F8C00283714 /* UserID.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UserID.h; path = include/lldb/Utility/UserID.h; sourceTree = "<group>"; };
+ AFC2DCED1E6E2F9800283714 /* FastDemangle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FastDemangle.h; path = include/lldb/Utility/FastDemangle.h; sourceTree = "<group>"; };
+ AFC2DCEE1E6E2FA300283714 /* Baton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Utility/Baton.h; sourceTree = "<group>"; };
+ AFC2DCEF1E6E2FD200283714 /* VMRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VMRange.cpp; path = source/Utility/VMRange.cpp; sourceTree = "<group>"; };
+ AFC2DCF11E6E2FDA00283714 /* VMRange.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VMRange.h; path = include/lldb/Utility/VMRange.h; sourceTree = "<group>"; };
+ AFC2DCF21E6E30CF00283714 /* History.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = History.cpp; path = source/Utility/History.cpp; sourceTree = "<group>"; };
+ AFC2DCF41E6E30D800283714 /* History.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = History.h; path = include/lldb/Utility/History.h; sourceTree = "<group>"; };
+ AFC2DCF51E6E316A00283714 /* StreamCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamCallback.cpp; path = source/Utility/StreamCallback.cpp; sourceTree = "<group>"; };
+ AFC2DCF71E6E316F00283714 /* StreamCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamCallback.h; path = include/lldb/Utility/StreamCallback.h; sourceTree = "<group>"; };
+ AFC2DCF81E6E318000283714 /* StreamGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamGDBRemote.cpp; path = source/Utility/StreamGDBRemote.cpp; sourceTree = "<group>"; };
+ AFC2DCFA1E6E318600283714 /* StreamGDBRemote.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamGDBRemote.h; path = include/lldb/Utility/StreamGDBRemote.h; sourceTree = "<group>"; };
AFCB2BBB1BF577F40018B553 /* PythonExceptionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PythonExceptionState.cpp; path = ScriptInterpreter/Python/PythonExceptionState.cpp; sourceTree = "<group>"; };
AFCB2BBC1BF577F40018B553 /* PythonExceptionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PythonExceptionState.h; path = ScriptInterpreter/Python/PythonExceptionState.h; sourceTree = "<group>"; };
AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_x86_64.cpp; sourceTree = "<group>"; };
@@ -3009,12 +3023,13 @@
AFF87C8A150FF677000E1742 /* com.apple.debugserver.applist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.applist.plist; path = tools/debugserver/source/com.apple.debugserver.applist.plist; sourceTree = "<group>"; };
AFF87C8C150FF680000E1742 /* com.apple.debugserver.applist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.applist.plist; path = tools/debugserver/source/com.apple.debugserver.applist.plist; sourceTree = "<group>"; };
AFF87C8E150FF688000E1742 /* com.apple.debugserver.applist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.applist.plist; path = tools/debugserver/source/com.apple.debugserver.applist.plist; sourceTree = "<group>"; };
+ AFF8FF0B1E779D4B003830EF /* TildeExpressionResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TildeExpressionResolver.cpp; path = source/Utility/TildeExpressionResolver.cpp; sourceTree = "<group>"; };
+ AFF8FF0D1E779D51003830EF /* TildeExpressionResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TildeExpressionResolver.h; path = include/lldb/Utility/TildeExpressionResolver.h; sourceTree = "<group>"; };
B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectWatchpoint.cpp; path = source/Commands/CommandObjectWatchpoint.cpp; sourceTree = "<group>"; };
B207C4941429609C00F36E4E /* CommandObjectWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectWatchpoint.h; path = source/Commands/CommandObjectWatchpoint.h; sourceTree = "<group>"; };
B23DD24F12EDFAC1000C3894 /* ARMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMUtils.h; path = Utility/ARMUtils.h; sourceTree = "<group>"; };
B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupWatchpoint.cpp; path = source/Interpreter/OptionGroupWatchpoint.cpp; sourceTree = "<group>"; };
B2462248141AD39B00F3D409 /* OptionGroupWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupWatchpoint.h; path = include/lldb/Interpreter/OptionGroupWatchpoint.h; sourceTree = "<group>"; };
- B2462249141AE62200F3D409 /* Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = include/lldb/Utility/Utils.h; sourceTree = "<group>"; };
B27318411416AC12006039C8 /* WatchpointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointList.cpp; path = source/Breakpoint/WatchpointList.cpp; sourceTree = "<group>"; };
B27318431416AC43006039C8 /* WatchpointList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WatchpointList.h; path = include/lldb/Breakpoint/WatchpointList.h; sourceTree = "<group>"; };
B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InferiorCallPOSIX.cpp; path = Utility/InferiorCallPOSIX.cpp; sourceTree = "<group>"; };
@@ -3032,8 +3047,6 @@
B2B7CCED15D1BFB700EEFB57 /* WatchpointOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointOptions.h; path = include/lldb/Breakpoint/WatchpointOptions.h; sourceTree = "<group>"; };
B2B7CCEF15D1C20F00EEFB57 /* WatchpointOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointOptions.cpp; path = source/Breakpoint/WatchpointOptions.cpp; sourceTree = "<group>"; };
B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstructionUtils.h; path = Utility/InstructionUtils.h; sourceTree = "<group>"; };
- B5EFAE841AE53B1D007059F3 /* RegisterContextFreeBSD_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextFreeBSD_arm.cpp; path = Utility/RegisterContextFreeBSD_arm.cpp; sourceTree = "<group>"; };
- B5EFAE851AE53B1D007059F3 /* RegisterContextFreeBSD_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextFreeBSD_arm.h; path = Utility/RegisterContextFreeBSD_arm.h; sourceTree = "<group>"; };
E73A15A41B548EC500786197 /* GDBRemoteSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GDBRemoteSignals.cpp; path = Utility/GDBRemoteSignals.cpp; sourceTree = "<group>"; };
E73A15A51B548EC500786197 /* GDBRemoteSignals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDBRemoteSignals.h; path = Utility/GDBRemoteSignals.h; sourceTree = "<group>"; };
E769331D1A94D18100C73337 /* lldb-server.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-server.cpp"; path = "tools/lldb-server/lldb-server.cpp"; sourceTree = "<group>"; };
@@ -3236,6 +3249,7 @@
2321F93F1BDD33D800BA9A93 /* ScriptInterpreter */,
23CB15091D66CF2B00EDDDE1 /* Symbol */,
23CB150A1D66CF3200EDDDE1 /* SymbolFile */,
+ AFAFD8081E57E19E0017A14F /* Target */,
AFEC5FD31D94F9130076A480 /* UnwindAssembly */,
2321F9421BDD343A00BA9A93 /* Utility */,
);
@@ -3277,7 +3291,6 @@
children = (
2321F9431BDD346100BA9A93 /* CMakeLists.txt */,
23CB15041D66CD9200EDDDE1 /* Inputs */,
- 23CB15011D66CD8400EDDDE1 /* ModuleCacheTest.cpp */,
2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */,
2321F9451BDD346100BA9A93 /* TaskPoolTest.cpp */,
2321F9461BDD346100BA9A93 /* UriParserTest.cpp */,
@@ -4191,21 +4204,32 @@
2682F168115ED9C800CCFF99 /* Utility */ = {
isa = PBXGroup;
children = (
- 6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */,
- 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */,
- 257E47151AA56C2000A62F81 /* ModuleCache.cpp */,
- 257E47161AA56C2000A62F81 /* ModuleCache.h */,
- 33064C9B1A5C7A490033D415 /* UriParser.h */,
- 33064C991A5C7A330033D415 /* UriParser.cpp */,
+ 26FA4315130103F400E71120 /* FileSpec.h */,
+ 26FA43171301048600E71120 /* FileSpec.cpp */,
26CF992414428766001E4138 /* AnsiTerminal.h */,
26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */,
- 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */,
264A12FF137252C700875C42 /* ARM64_DWARF_Registers.h */,
- 264A12FE137252C700875C42 /* ARM64_DWARF_Registers.cpp */,
+ AFC2DCE81E6E2F2C00283714 /* Baton.cpp */,
+ AFC2DCEE1E6E2FA300283714 /* Baton.h */,
264723A511FA076E00DE380C /* CleanUp.h */,
- 3F81691B1ABA242B001DA9DF /* ConvertEnum.h */,
- 3F8169171ABA2419001DA9DF /* ConvertEnum.cpp */,
+ 26764C951E48F46F008D3573 /* ConstString.h */,
+ 26764C961E48F482008D3573 /* ConstString.cpp */,
+ 49CA96F01E6AAC8E00C03FEE /* DataBuffer.h */,
+ 49CA96F11E6AAC8E00C03FEE /* DataBufferHeap.h */,
+ 49CA96E61E6AAC6600C03FEE /* DataBufferHeap.cpp */,
+ 49CA96F21E6AAC8E00C03FEE /* DataBufferLLVM.h */,
+ 49CA96E71E6AAC6600C03FEE /* DataBufferLLVM.cpp */,
+ 49CA96F31E6AAC8E00C03FEE /* DataEncoder.h */,
+ 49CA96E81E6AAC6600C03FEE /* DataEncoder.cpp */,
+ 49CA96F41E6AAC8E00C03FEE /* DataExtractor.h */,
+ 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */,
9481FE6B1B5F2D9200DED357 /* Either.h */,
+ 26764C9A1E48F4DD008D3573 /* Error.h */,
+ 26764C981E48F4D2008D3573 /* Error.cpp */,
+ AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */,
+ AFC2DCED1E6E2F9800283714 /* FastDemangle.h */,
+ AFC2DCF21E6E30CF00283714 /* History.cpp */,
+ AFC2DCF41E6E30D800283714 /* History.h */,
4C73152119B7D71700F865A4 /* Iterable.h */,
942829541A89614000521B30 /* JSON.h */,
942829551A89614C00521B30 /* JSON.cpp */,
@@ -4213,26 +4237,47 @@
943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */,
3F81691C1ABA242B001DA9DF /* NameMatches.h */,
3F8169181ABA2419001DA9DF /* NameMatches.cpp */,
- 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */,
- 94F6C4D119C264C70049D089 /* ProcessStructReader.h */,
- 2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */,
- 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */,
+ 26764C9C1E48F516008D3573 /* RegularExpression.h */,
+ 26764C9F1E48F528008D3573 /* RegularExpression.cpp */,
4CAB257C18EC9DB800BAD33E /* SafeMachO.h */,
26A375841D59487700D6CBDB /* SelectHelper.h */,
26A3757F1D59462700D6CBDB /* SelectHelper.cpp */,
261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */,
4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */,
261B5A5311C3F2AD00AABD0A /* SharingPtr.h */,
+ 26764C9B1E48F50C008D3573 /* Stream.h */,
+ 26764C9D1E48F51E008D3573 /* Stream.cpp */,
+ AFC2DCF51E6E316A00283714 /* StreamCallback.cpp */,
+ AFC2DCF71E6E316F00283714 /* StreamCallback.h */,
+ AFC2DCF81E6E318000283714 /* StreamGDBRemote.cpp */,
+ AFC2DCFA1E6E318600283714 /* StreamGDBRemote.h */,
+ 26764CA31E48F550008D3573 /* StreamString.h */,
+ 26764CA11E48F547008D3573 /* StreamString.cpp */,
+ 26764CA41E48F566008D3573 /* StreamTee.h */,
26A375831D59486000D6CBDB /* StringExtractor.h */,
2660D9F611922A1300958FBD /* StringExtractor.cpp */,
2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */,
2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */,
94380B8019940B0300BFE4A8 /* StringLexer.h */,
94380B8119940B0A00BFE4A8 /* StringLexer.cpp */,
+ 9A35765E116E76A700E8ED2F /* StringList.h */,
+ 9A35765F116E76B900E8ED2F /* StringList.cpp */,
94BA8B6E176F8CA0005A91B5 /* Range.h */,
94BA8B6C176F8C9B005A91B5 /* Range.cpp */,
- AF1FA8891A60A69500272AFC /* RegisterNumber.cpp */,
- B2462249141AE62200F3D409 /* Utils.h */,
+ 6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */,
+ 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */,
+ AFF8FF0B1E779D4B003830EF /* TildeExpressionResolver.cpp */,
+ AFF8FF0D1E779D51003830EF /* TildeExpressionResolver.h */,
+ 2654A6911E552F3C00DA1013 /* UriParser.h */,
+ 33064C991A5C7A330033D415 /* UriParser.cpp */,
+ AFC2DCEA1E6E2F7D00283714 /* UserID.cpp */,
+ AFC2DCEC1E6E2F8C00283714 /* UserID.h */,
+ 49CA96F51E6AAC8E00C03FEE /* UUID.h */,
+ 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */,
+ AFC2DCEF1E6E2FD200283714 /* VMRange.cpp */,
+ AFC2DCF11E6E2FDA00283714 /* VMRange.h */,
+ 2654A6921E552F4600DA1013 /* VASPrintf.h */,
+ 2654A68F1E552ED500DA1013 /* VASprintf.cpp */,
);
name = Utility;
sourceTree = "<group>";
@@ -4486,26 +4531,25 @@
26B4666E11A2080F00CF6220 /* Utility */ = {
isa = PBXGroup;
children = (
- E73A15A41B548EC500786197 /* GDBRemoteSignals.cpp */,
- E73A15A51B548EC500786197 /* GDBRemoteSignals.h */,
- B5EFAE841AE53B1D007059F3 /* RegisterContextFreeBSD_arm.cpp */,
- B5EFAE851AE53B1D007059F3 /* RegisterContextFreeBSD_arm.h */,
- 256CBDBE1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp */,
- 256CBDBF1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.h */,
- 256CBDB61ADD107200BC6CDC /* RegisterContextLinux_arm.cpp */,
- 256CBDB71ADD107200BC6CDC /* RegisterContextLinux_arm.h */,
- 256CBDB81ADD107200BC6CDC /* RegisterContextLinux_mips64.cpp */,
- 256CBDB91ADD107200BC6CDC /* RegisterContextLinux_mips64.h */,
- E7723D4A1AC4A944002BA082 /* RegisterContextPOSIX_arm64.cpp */,
- E7723D4B1AC4A944002BA082 /* RegisterContextPOSIX_arm64.h */,
- 237A8BAB1DEC9BBC00CEBAFF /* RegisterInfoPOSIX_arm64.cpp */,
- 237A8BAC1DEC9BBC00CEBAFF /* RegisterInfoPOSIX_arm64.h */,
+ 9A0FDE951E8EF5010086B2F5 /* RegisterContext_mips.h */,
+ 9A0FDE961E8EF5010086B2F5 /* RegisterContext_s390x.h */,
+ 9A0FDE971E8EF5010086B2F5 /* RegisterContextLinux_mips.cpp */,
+ 9A0FDE981E8EF5010086B2F5 /* RegisterContextLinux_mips.h */,
+ 9A0FDE991E8EF5010086B2F5 /* RegisterInfos_arm.h */,
+ 9A0FDE9A1E8EF5010086B2F5 /* RegisterInfos_arm64.h */,
+ 9A0FDE9B1E8EF5010086B2F5 /* RegisterInfos_mips.h */,
+ 9AD9449B1E8DB267004796ED /* RegisterContextNetBSD_x86_64.cpp */,
+ 9AD9449C1E8DB267004796ED /* RegisterContextNetBSD_x86_64.h */,
+ 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */,
+ 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */,
B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */,
B23DD24F12EDFAC1000C3894 /* ARMUtils.h */,
26954EBC1401EE8B00294D09 /* DynamicRegisterInfo.cpp */,
26954EBD1401EE8B00294D09 /* DynamicRegisterInfo.h */,
AF23B4D919009C66003E2A58 /* FreeBSDSignals.cpp */,
AF23B4DA19009C66003E2A58 /* FreeBSDSignals.h */,
+ E73A15A41B548EC500786197 /* GDBRemoteSignals.cpp */,
+ E73A15A51B548EC500786197 /* GDBRemoteSignals.h */,
AF1729D4182C907200E0AB97 /* HistoryThread.cpp */,
AF061F89182C980000B6A19C /* HistoryThread.h */,
AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */,
@@ -4545,6 +4589,8 @@
AF061F86182C97ED00B6A19C /* RegisterContextHistory.h */,
26474CAE18D0CB180073DEBA /* RegisterContextLinux_i386.cpp */,
26474CAF18D0CB180073DEBA /* RegisterContextLinux_i386.h */,
+ 256CBDB81ADD107200BC6CDC /* RegisterContextLinux_mips64.cpp */,
+ 256CBDB91ADD107200BC6CDC /* RegisterContextLinux_mips64.h */,
267F68511CC02E920086832B /* RegisterContextLinux_s390x.cpp */,
267F68521CC02E920086832B /* RegisterContextLinux_s390x.h */,
26474CB018D0CB180073DEBA /* RegisterContextLinux_x86_64.cpp */,
@@ -4561,6 +4607,14 @@
26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */,
262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */,
262D24E513FB8710002D1960 /* RegisterContextMemory.h */,
+ 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */,
+ 4CE4EFAC1E899A1200A80C06 /* RegisterContextOpenBSD_i386.h */,
+ 4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp */,
+ 4CE4EFAE1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.h */,
+ 256CBDBE1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp */,
+ 256CBDBF1ADD11C000BC6CDC /* RegisterContextPOSIX_arm.h */,
+ E7723D4A1AC4A944002BA082 /* RegisterContextPOSIX_arm64.cpp */,
+ E7723D4B1AC4A944002BA082 /* RegisterContextPOSIX_arm64.h */,
26474CC418D0CB5B0073DEBA /* RegisterContextPOSIX_mips64.cpp */,
26474CC518D0CB5B0073DEBA /* RegisterContextPOSIX_mips64.h */,
AF77E09D1A033D360096C0EA /* RegisterContextPOSIX_powerpc.cpp */,
@@ -4573,6 +4627,10 @@
26CA979F172B1FD5005DC71B /* RegisterContextThreadMemory.cpp */,
26CA97A0172B1FD5005DC71B /* RegisterContextThreadMemory.h */,
23EDE3371926AAD500F6A132 /* RegisterInfoInterface.h */,
+ 9A77AD501E64E24E0025CE04 /* RegisterInfoPOSIX_arm.cpp */,
+ 9A77AD511E64E24E0025CE04 /* RegisterInfoPOSIX_arm.h */,
+ 237A8BAB1DEC9BBC00CEBAFF /* RegisterInfoPOSIX_arm64.cpp */,
+ 237A8BAC1DEC9BBC00CEBAFF /* RegisterInfoPOSIX_arm64.h */,
26474CD018D0CB700073DEBA /* RegisterInfos_i386.h */,
26474CD118D0CB710073DEBA /* RegisterInfos_mips64.h */,
AF77E09F1A033D360096C0EA /* RegisterInfos_powerpc.h */,
@@ -4644,8 +4702,6 @@
9AC7034411752C790086C050 /* AddressResolverName.cpp */,
26BC7D5210F1B77400F91463 /* ArchSpec.h */,
26BC7E6B10F1B85900F91463 /* ArchSpec.cpp */,
- 26A0604711A5BC7A00F75969 /* Baton.h */,
- 26A0604811A5D03C00F75969 /* Baton.cpp */,
26BC7D5410F1B77400F91463 /* Broadcaster.h */,
26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */,
26BC7D5510F1B77400F91463 /* ClangForward.h */,
@@ -4653,39 +4709,23 @@
26BC7E6E10F1B85900F91463 /* Communication.cpp */,
26BC7D5710F1B77400F91463 /* Connection.h */,
26BC7E6F10F1B85900F91463 /* Connection.cpp */,
- 26BC7D7C10F1B77400F91463 /* ConstString.h */,
- 26BC7E9410F1B85900F91463 /* ConstString.cpp */,
- 26BC7D5910F1B77400F91463 /* DataBuffer.h */,
- 26BC7D5B10F1B77400F91463 /* DataBufferHeap.h */,
- 26BC7E7210F1B85900F91463 /* DataBufferHeap.cpp */,
- 26BC7D5C10F1B77400F91463 /* DataBufferMemoryMap.h */,
- 26BC7E7310F1B85900F91463 /* DataBufferMemoryMap.cpp */,
- 268ED0A2140FF52F00DE830F /* DataEncoder.h */,
- 268ED0A4140FF54200DE830F /* DataEncoder.cpp */,
- 26BC7D5A10F1B77400F91463 /* DataExtractor.h */,
- 26BC7E7110F1B85900F91463 /* DataExtractor.cpp */,
263664941140A4C10075843B /* Debugger.h */,
263664921140A4930075843B /* Debugger.cpp */,
26BC7D5E10F1B77400F91463 /* Disassembler.h */,
26BC7E7610F1B85900F91463 /* Disassembler.cpp */,
+ 4C4EB7821E6A4DE7002035C0 /* DumpDataExtractor.h */,
+ 4C4EB77F1E6A4DB8002035C0 /* DumpDataExtractor.cpp */,
26BC7D5F10F1B77400F91463 /* dwarf.h */,
26D9FDC612F784E60003F2EE /* EmulateInstruction.h */,
26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */,
- 26BC7D6010F1B77400F91463 /* Error.h */,
- 26BC7E7810F1B85900F91463 /* Error.cpp */,
26BC7D6110F1B77400F91463 /* Event.h */,
26BC7E7910F1B85900F91463 /* Event.cpp */,
- 2613F6CA1B17B85400D4DB85 /* FastDemangle.h */,
- 449ACC96197DE9EC008D175E /* FastDemangle.cpp */,
26BD407D135D2AC400237D80 /* FileLineResolver.h */,
26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */,
26BC7D6310F1B77400F91463 /* FileSpecList.h */,
26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */,
- 26BC7D6410F1B77400F91463 /* Flags.h */,
263FDE5D1A799F2D00E68013 /* FormatEntity.h */,
263FDE5F1A79A01500E68013 /* FormatEntity.cpp */,
- 26F7305F139D8FC900FD51C7 /* History.h */,
- 26F73061139D8FDB00FD51C7 /* History.cpp */,
260A63161861008E00FECF8E /* IOHandler.h */,
260A63181861009E00FECF8E /* IOHandler.cpp */,
26BC7D6510F1B77400F91463 /* IOStreamMacros.h */,
@@ -4715,8 +4755,6 @@
2626B6AD143E1BEA00EF935C /* RangeMap.h */,
26C6886D137880B900407EDF /* RegisterValue.h */,
26C6886E137880C400407EDF /* RegisterValue.cpp */,
- 26BC7D7310F1B77400F91463 /* RegularExpression.h */,
- 26BC7E8C10F1B85900F91463 /* RegularExpression.cpp */,
26BC7D7410F1B77400F91463 /* Scalar.h */,
26BC7E8D10F1B85900F91463 /* Scalar.cpp */,
26BC7CF910F1B71400F91463 /* SearchFilter.h */,
@@ -4728,22 +4766,11 @@
26BC7D7710F1B77400F91463 /* State.h */,
26BC7E9010F1B85900F91463 /* State.cpp */,
26BC7D7810F1B77400F91463 /* STLUtils.h */,
- 26BC7D7910F1B77400F91463 /* Stream.h */,
- 26BC7E9110F1B85900F91463 /* Stream.cpp */,
9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */,
9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */,
2623096E13D0EFFB006381D9 /* StreamBuffer.h */,
- 4C66499F14EEE7F100B0316F /* StreamCallback.h */,
- 4C6649A214EEE81000B0316F /* StreamCallback.cpp */,
26BC7D7A10F1B77400F91463 /* StreamFile.h */,
26BC7E9210F1B85900F91463 /* StreamFile.cpp */,
- 945E8D7D152F6AA80019BCCD /* StreamGDBRemote.h */,
- 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */,
- 26BC7D7B10F1B77400F91463 /* StreamString.h */,
- 26BC7E9310F1B85900F91463 /* StreamString.cpp */,
- 4C626533130F1B0A00C889F6 /* StreamTee.h */,
- 9A35765E116E76A700E8ED2F /* StringList.h */,
- 9A35765F116E76B900E8ED2F /* StringList.cpp */,
26F2F8FD1B156678007857DE /* StructuredData.h */,
AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */,
26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */,
@@ -4754,12 +4781,8 @@
94ED54A119C8A822007BE2EA /* ThreadSafeDenseMap.h */,
9449B8031B30E0690019342B /* ThreadSafeDenseSet.h */,
268A813F115B19D000F645B0 /* UniqueCStringMap.h */,
- 26BC7D8010F1B77400F91463 /* UserID.h */,
- 26BC7E9810F1B85900F91463 /* UserID.cpp */,
9A4633DA11F65D8600955CE1 /* UserSettingsController.h */,
9A4633DC11F65D9A00955CE1 /* UserSettingsController.cpp */,
- 26C81CA411335651004BDC5A /* UUID.h */,
- 26C81CA511335651004BDC5A /* UUID.cpp */,
26BC7D8110F1B77400F91463 /* Value.h */,
26BC7E9910F1B85900F91463 /* Value.cpp */,
26BC7D8210F1B77400F91463 /* ValueObject.h */,
@@ -4788,8 +4811,6 @@
94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */,
26BC7D8510F1B77400F91463 /* ValueObjectVariable.h */,
26BC7E9D10F1B85900F91463 /* ValueObjectVariable.cpp */,
- 26BC7D8610F1B77400F91463 /* VMRange.h */,
- 26BC7E9E10F1B85900F91463 /* VMRange.cpp */,
);
name = Core;
sourceTree = "<group>";
@@ -5049,7 +5070,6 @@
260C6EA013011578005E16B0 /* File.h */,
3FDFDDC0199D34E2009756A7 /* FileCache.h */,
3FDFDDBE199D345E009756A7 /* FileCache.cpp */,
- 26FA4315130103F400E71120 /* FileSpec.h */,
3FDFDDC1199D34E2009756A7 /* FileSystem.h */,
26BC7DD410F1B7D500F91463 /* Host.h */,
3FDFED1F19BA6D55009756A7 /* HostGetOpt.h */,
@@ -5079,6 +5099,8 @@
3F5E8AF31A40D4A500A73232 /* PipeBase.h */,
26BC7DD610F1B7D500F91463 /* Predicate.h */,
3FDFED2219BA6D55009756A7 /* ProcessRunLock.h */,
+ 2654A68E1E552D2400DA1013 /* PseudoTerminal.h */,
+ 2654A68C1E552D1500DA1013 /* PseudoTerminal.cpp */,
236124A71986B50E004EFC37 /* Socket.h */,
26D7E45B13D5E2F9007FD12B /* SocketAddress.h */,
26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */,
@@ -5086,8 +5108,6 @@
232CB613191E00CC00EF39FC /* SoftwareBreakpoint.cpp */,
2689B0A4113EE3CD00A4AEDB /* Symbols.h */,
268DA871130095D000C9483A /* Terminal.h */,
- 3FDFED0D19B7D269009756A7 /* ThisThread.cpp */,
- 3FDFED0919B7C8C7009756A7 /* ThisThread.h */,
3FDFED2319BA6D55009756A7 /* ThreadLauncher.h */,
267A48031B1416080021A5BC /* XML.h */,
267A48001B1411E40021A5BC /* XML.cpp */,
@@ -5228,6 +5248,8 @@
8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */,
8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */,
2360092C193FB21500189DB1 /* MemoryRegionInfo.h */,
+ 2654A6811E54D5A200DA1013 /* ModuleCache.h */,
+ 2654A67F1E54D59400DA1013 /* ModuleCache.cpp */,
4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */,
4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */,
495BBACF119A0DE700418BEA /* PathMappingList.h */,
@@ -5249,6 +5271,8 @@
26AB54111832DC3400EADFF3 /* RegisterCheckpoint.h */,
26BC7DF410F1B81A00F91463 /* RegisterContext.h */,
26BC7F3710F1B90C00F91463 /* RegisterContext.cpp */,
+ 2654A6841E54D5EE00DA1013 /* RegisterNumber.h */,
+ 2654A6821E54D5E200DA1013 /* RegisterNumber.cpp */,
262173A018395D3800C52091 /* SectionLoadHistory.h */,
262173A218395D4600C52091 /* SectionLoadHistory.cpp */,
2618D78F1240115500F2B8FE /* SectionLoadList.h */,
@@ -5317,8 +5341,6 @@
26E3EEBD11A9870400FBADB6 /* Unwind.h */,
264D8D4E13661BCC003A368F /* UnwindAssembly.h */,
264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */,
- 23F403471926C8D50046DC9B /* NativeRegisterContextRegisterInfo.h */,
- 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */,
);
name = Target;
sourceTree = "<group>";
@@ -5346,7 +5368,6 @@
3FDFED0519B7C898009756A7 /* HostThreadMacOSX.mm */,
3FDFE56719AF9BB2009756A7 /* HostThreadMacOSX.h */,
2689B0B5113EE47E00A4AEDB /* Symbols.cpp */,
- 3FDFED0619B7C898009756A7 /* ThisThread.cpp */,
);
name = MacOSX;
sourceTree = "<group>";
@@ -5379,6 +5400,7 @@
2694E99F14FC0BBD0076DE67 /* Linux */,
26C5577F132575C8008FD8FE /* MacOSX */,
26EFB6151BFE8D3E00544801 /* NetBSD */,
+ 4CE4EFA51E89998800A80C06 /* OpenBSD */,
9457596415349416005A9070 /* POSIX */,
490A36BA180F0E6F00BA31F8 /* Windows */,
);
@@ -5831,6 +5853,15 @@
path = AppleObjCRuntime;
sourceTree = "<group>";
};
+ 4CE4EFA51E89998800A80C06 /* OpenBSD */ = {
+ isa = PBXGroup;
+ children = (
+ 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */,
+ 4CE4EFA71E8999B000A80C06 /* PlatformOpenBSD.h */,
+ );
+ path = OpenBSD;
+ sourceTree = "<group>";
+ };
4CEE62F71145F1C70064CF93 /* GDB Remote */ = {
isa = PBXGroup;
children = (
@@ -5873,7 +5904,6 @@
25420ED11A649D88009ADBCB /* PipeBase.cpp */,
26CFDCA2186163A4000E63E5 /* Editline.cpp */,
260C6EA213011581005E16B0 /* File.cpp */,
- 26FA43171301048600E71120 /* FileSpec.cpp */,
69A01E1C1236C5D400C660B5 /* Host.cpp */,
3FDFE53419A29327009756A7 /* HostInfoBase.cpp */,
3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */,
@@ -6081,6 +6111,8 @@
945261B01B9A11BE00BF138D /* Formatters */,
94B6385C1B8FB174004FE1E4 /* CPlusPlusLanguage.h */,
94B6385B1B8FB174004FE1E4 /* CPlusPlusLanguage.cpp */,
+ 49F811F01E931B1500F4E163 /* CPlusPlusNameParser.h */,
+ 49F811EF1E931B1500F4E163 /* CPlusPlusNameParser.cpp */,
);
name = CPlusPlus;
sourceTree = "<group>";
@@ -6303,6 +6335,14 @@
name = "SysV-ppc64";
sourceTree = "<group>";
};
+ AFAFD8081E57E19E0017A14F /* Target */ = {
+ isa = PBXGroup;
+ children = (
+ AFAFD8091E57E1B90017A14F /* ModuleCacheTest.cpp */,
+ );
+ name = Target;
+ sourceTree = "<group>";
+ };
AFEC5FD31D94F9130076A480 /* UnwindAssembly */ = {
isa = PBXGroup;
children = (
@@ -6914,6 +6954,7 @@
files = (
23CB15331D66DA9300EDDDE1 /* GoParserTest.cpp in Sources */,
23CB15341D66DA9300EDDDE1 /* CPlusPlusLanguageTest.cpp in Sources */,
+ AFAFD80A1E57E1B90017A14F /* ModuleCacheTest.cpp in Sources */,
23CB15351D66DA9300EDDDE1 /* UriParserTest.cpp in Sources */,
23CB15361D66DA9300EDDDE1 /* FileSpecTest.cpp in Sources */,
23E2E5251D90373D006F38BB /* ArchSpecTest.cpp in Sources */,
@@ -6928,7 +6969,6 @@
23CB153D1D66DA9300EDDDE1 /* GDBRemoteCommunicationClientTest.cpp in Sources */,
23CB153E1D66DA9300EDDDE1 /* PythonDataObjectsTests.cpp in Sources */,
23CB153F1D66DA9300EDDDE1 /* SymbolsTest.cpp in Sources */,
- 23E2E52B1D9037E6006F38BB /* ModuleCacheTest.cpp in Sources */,
AFEC5FD81D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp in Sources */,
23CB15401D66DA9300EDDDE1 /* TestClangASTContext.cpp in Sources */,
23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources */,
@@ -7040,7 +7080,9 @@
4CDB8D6E1DBA91B6006C5B13 /* LibStdcppTuple.cpp in Sources */,
AF77E08F1A033C700096C0EA /* ABISysV_ppc.cpp in Sources */,
2689FFF713353DB600698AC0 /* BreakpointLocation.cpp in Sources */,
+ 2654A68D1E552D1500DA1013 /* PseudoTerminal.cpp in Sources */,
2689FFF913353DB600698AC0 /* BreakpointLocationCollection.cpp in Sources */,
+ 49F811F31E931B2100F4E163 /* CPlusPlusNameParser.cpp in Sources */,
2689FFFB13353DB600698AC0 /* BreakpointLocationList.cpp in Sources */,
2689FFFD13353DB600698AC0 /* BreakpointOptions.cpp in Sources */,
2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */,
@@ -7050,7 +7092,6 @@
945261C21B9A11FC00BF138D /* LibCxxList.cpp in Sources */,
2689000313353DB600698AC0 /* BreakpointResolverFileLine.cpp in Sources */,
26474CA818D0CB070073DEBA /* RegisterContextFreeBSD_i386.cpp in Sources */,
- 449ACC98197DEA0B008D175E /* FastDemangle.cpp in Sources */,
2689000513353DB600698AC0 /* BreakpointResolverName.cpp in Sources */,
6D762BEE1B1605D2006C929D /* LLDBServerUtilities.cpp in Sources */,
2689000713353DB600698AC0 /* BreakpointSite.cpp in Sources */,
@@ -7109,6 +7150,7 @@
2689002713353DDE00698AC0 /* CommandObjectTarget.cpp in Sources */,
2689002813353DDE00698AC0 /* CommandObjectThread.cpp in Sources */,
2689002913353DDE00698AC0 /* CommandObjectVersion.cpp in Sources */,
+ AFC2DCF01E6E2FD200283714 /* VMRange.cpp in Sources */,
2689002A13353E0400698AC0 /* Address.cpp in Sources */,
8CF02AE919DCC01900B14BE0 /* InstrumentationRuntime.cpp in Sources */,
2689002B13353E0400698AC0 /* AddressRange.cpp in Sources */,
@@ -7119,18 +7161,13 @@
2689002D13353E0400698AC0 /* AddressResolverFileLine.cpp in Sources */,
2689002E13353E0400698AC0 /* AddressResolverName.cpp in Sources */,
2689002F13353E0400698AC0 /* ArchSpec.cpp in Sources */,
- 2689003013353E0400698AC0 /* Baton.cpp in Sources */,
250D6AE31A9679440049CC70 /* FileSystem.cpp in Sources */,
2689003113353E0400698AC0 /* Broadcaster.cpp in Sources */,
49DCF702170E70120092F75E /* Materializer.cpp in Sources */,
2689003213353E0400698AC0 /* Communication.cpp in Sources */,
2689003313353E0400698AC0 /* Connection.cpp in Sources */,
- 2689003513353E0400698AC0 /* ConstString.cpp in Sources */,
9404957A1BEC497E00926025 /* NSError.cpp in Sources */,
- 2689003613353E0400698AC0 /* DataBufferHeap.cpp in Sources */,
AFCB2BBD1BF577F40018B553 /* PythonExceptionState.cpp in Sources */,
- 2689003713353E0400698AC0 /* DataBufferMemoryMap.cpp in Sources */,
- 2689003813353E0400698AC0 /* DataExtractor.cpp in Sources */,
2689003913353E0400698AC0 /* Debugger.cpp in Sources */,
6D55BAEE1A8CD0B200A70529 /* PlatformAndroidRemoteGDBServer.cpp in Sources */,
2689003A13353E0400698AC0 /* Disassembler.cpp in Sources */,
@@ -7138,9 +7175,10 @@
3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */,
AF1729D7182C907200E0AB97 /* HistoryUnwind.cpp in Sources */,
AF77E0A11A033D360096C0EA /* RegisterContextFreeBSD_powerpc.cpp in Sources */,
+ 26764CA01E48F528008D3573 /* RegularExpression.cpp in Sources */,
2689003B13353E0400698AC0 /* EmulateInstruction.cpp in Sources */,
- 2689003C13353E0400698AC0 /* Error.cpp in Sources */,
2689003D13353E0400698AC0 /* Event.cpp in Sources */,
+ AFC2DCE91E6E2F2C00283714 /* Baton.cpp in Sources */,
26B75B441AD6E29A001F7A57 /* MipsLinuxSignals.cpp in Sources */,
2689003E13353E0400698AC0 /* FileSpecList.cpp in Sources */,
2689004113353E0400698AC0 /* Listener.cpp in Sources */,
@@ -7151,12 +7189,12 @@
2689004513353E0400698AC0 /* ModuleChild.cpp in Sources */,
AF8AD6301BEC28A400150209 /* PlatformAppleWatchSimulator.cpp in Sources */,
266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */,
+ 26764C9E1E48F51E008D3573 /* Stream.cpp in Sources */,
2689004613353E0400698AC0 /* ModuleList.cpp in Sources */,
2689004713353E0400698AC0 /* PluginManager.cpp in Sources */,
AE44FB3E1BB485960033EB62 /* GoLanguageRuntime.cpp in Sources */,
AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */,
AF254E31170CCC33007AE5C9 /* PlatformDarwinKernel.cpp in Sources */,
- 2689004813353E0400698AC0 /* RegularExpression.cpp in Sources */,
2689004913353E0400698AC0 /* Scalar.cpp in Sources */,
263FDE601A79A01500E68013 /* FormatEntity.cpp in Sources */,
AF8AD62E1BEC28A400150209 /* PlatformAppleTVSimulator.cpp in Sources */,
@@ -7171,17 +7209,15 @@
94B9E5121BBF20F4000A48DC /* NSString.cpp in Sources */,
AF0E22F018A09FB20009B7D1 /* AppleGetItemInfoHandler.cpp in Sources */,
AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */,
- 2689004E13353E0400698AC0 /* Stream.cpp in Sources */,
2689004F13353E0400698AC0 /* StreamFile.cpp in Sources */,
- 2689005013353E0400698AC0 /* StreamString.cpp in Sources */,
2689005113353E0400698AC0 /* StringList.cpp in Sources */,
2689005213353E0400698AC0 /* Timer.cpp in Sources */,
- 2689005313353E0400698AC0 /* UserID.cpp in Sources */,
2689005413353E0400698AC0 /* UserSettingsController.cpp in Sources */,
- 2689005513353E0400698AC0 /* UUID.cpp in Sources */,
23059A0719532B96007B8189 /* LinuxSignals.cpp in Sources */,
8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */,
+ 9A77AD541E64E2760025CE04 /* RegisterInfoPOSIX_arm.cpp in Sources */,
2689005613353E0400698AC0 /* Value.cpp in Sources */,
+ 26764CA21E48F547008D3573 /* StreamString.cpp in Sources */,
2689005713353E0400698AC0 /* ValueObject.cpp in Sources */,
3F8169321ABB7A6D001DA9DF /* SystemInitializerCommon.cpp in Sources */,
2689005813353E0400698AC0 /* ValueObjectChild.cpp in Sources */,
@@ -7196,14 +7232,11 @@
8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */,
6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources */,
942612F71B95000000EF842E /* LanguageCategory.cpp in Sources */,
- 2689005D13353E0400698AC0 /* VMRange.cpp in Sources */,
2689005E13353E0E00698AC0 /* ClangASTSource.cpp in Sources */,
- 3FDFED0F19B7D269009756A7 /* ThisThread.cpp in Sources */,
2689005F13353E0E00698AC0 /* ClangFunctionCaller.cpp in Sources */,
2689006013353E0E00698AC0 /* ClangExpressionDeclMap.cpp in Sources */,
2689006113353E0E00698AC0 /* ClangExpressionParser.cpp in Sources */,
4939EA8D1BD56B6D00084382 /* REPL.cpp in Sources */,
- B5EFAE861AE53B1D007059F3 /* RegisterContextFreeBSD_arm.cpp in Sources */,
2689006313353E0E00698AC0 /* ClangPersistentVariables.cpp in Sources */,
2689006413353E0E00698AC0 /* ClangUserExpression.cpp in Sources */,
4C3ADCD61810D88B00357218 /* BreakpointResolverFileRegex.cpp in Sources */,
@@ -7226,20 +7259,24 @@
2635879417822FC2004C30BA /* SymbolVendorELF.cpp in Sources */,
25420ED21A649D88009ADBCB /* PipeBase.cpp in Sources */,
AF20F7661AF18F8500751A6E /* ABISysV_arm.cpp in Sources */,
+ 2654A6801E54D59400DA1013 /* ModuleCache.cpp in Sources */,
949EEDAF1BA76729008C63CF /* NSArray.cpp in Sources */,
942612F81B952C9B00EF842E /* ObjCLanguage.cpp in Sources */,
2689007313353E1A00698AC0 /* Symbols.cpp in Sources */,
26474CBC18D0CB2D0073DEBA /* RegisterContextMach_arm.cpp in Sources */,
- 257E47171AA56C2000A62F81 /* ModuleCache.cpp in Sources */,
2689007413353E1A00698AC0 /* Terminal.cpp in Sources */,
6D0F61431C80AAAE00A4ECEE /* JavaASTContext.cpp in Sources */,
2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */,
+ 9A0FDEA71E8EF5110086B2F5 /* RegisterContextLinux_mips.cpp in Sources */,
94BA8B70176F97CE005A91B5 /* CommandHistory.cpp in Sources */,
2689007713353E1A00698AC0 /* CFCData.cpp in Sources */,
2689007813353E1A00698AC0 /* CFCMutableArray.cpp in Sources */,
9418EBCD1AA910910058B02E /* VectorType.cpp in Sources */,
+ 4C4EB7811E6A4DCC002035C0 /* DumpDataExtractor.cpp in Sources */,
+ 4CE4EFB31E899A3400A80C06 /* RegisterContextOpenBSD_i386.cpp in Sources */,
2689007913353E1A00698AC0 /* CFCMutableDictionary.cpp in Sources */,
2689007A13353E1A00698AC0 /* CFCMutableSet.cpp in Sources */,
+ 26764C971E48F482008D3573 /* ConstString.cpp in Sources */,
2689007B13353E1A00698AC0 /* CFCString.cpp in Sources */,
2689007C13353E1A00698AC0 /* Symbols.cpp in Sources */,
2689007D13353E2200698AC0 /* Args.cpp in Sources */,
@@ -7250,6 +7287,7 @@
2689008013353E2200698AC0 /* CommandInterpreter.cpp in Sources */,
AF77E0A41A033D360096C0EA /* RegisterContextPOSIX_powerpc.cpp in Sources */,
4CDB8D6D1DBA91B6006C5B13 /* LibStdcppUniquePointer.cpp in Sources */,
+ 49CA96FC1E6AACC900C03FEE /* DataBufferHeap.cpp in Sources */,
AF9B8F33182DB52900DA866F /* SystemRuntimeMacOSX.cpp in Sources */,
9447DE431BD5963300E67212 /* DumpValueObjectOptions.cpp in Sources */,
2689008113353E2200698AC0 /* CommandObject.cpp in Sources */,
@@ -7269,6 +7307,7 @@
2689008D13353E4200698AC0 /* DynamicLoaderMacOSXDYLD.cpp in Sources */,
2689008E13353E4200698AC0 /* DynamicLoaderStatic.cpp in Sources */,
2689009613353E4200698AC0 /* ObjectContainerBSDArchive.cpp in Sources */,
+ 49CA96FF1E6AACC900C03FEE /* DataExtractor.cpp in Sources */,
2579065D1BD0488100178368 /* UDPSocket.cpp in Sources */,
AE8F624919EF3E1E00326B21 /* OperatingSystemGo.cpp in Sources */,
26BC179A18C7F2B300D2196D /* JITLoaderList.cpp in Sources */,
@@ -7296,10 +7335,12 @@
268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,
AE44FB321BB07EBC0033EB62 /* GoParser.cpp in Sources */,
3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */,
+ 26764C991E48F4D2008D3573 /* Error.cpp in Sources */,
949EEDB21BA76731008C63CF /* NSIndexPath.cpp in Sources */,
3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */,
268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */,
268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */,
+ 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */,
268900B713353E5F00698AC0 /* DWARFAbbreviationDeclaration.cpp in Sources */,
268900B813353E5F00698AC0 /* DWARFCompileUnit.cpp in Sources */,
268900B913353E5F00698AC0 /* DWARFDebugAbbrev.cpp in Sources */,
@@ -7340,6 +7381,7 @@
268900D013353E6F00698AC0 /* Block.cpp in Sources */,
268900D113353E6F00698AC0 /* ClangASTContext.cpp in Sources */,
265192C61BA8E905002F08F6 /* CompilerDecl.cpp in Sources */,
+ 9AD9449F1E8DB26C004796ED /* RegisterContextNetBSD_x86_64.cpp in Sources */,
268900D213353E6F00698AC0 /* CompilerType.cpp in Sources */,
945261C11B9A11FC00BF138D /* LibCxxInitializerList.cpp in Sources */,
268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */,
@@ -7348,7 +7390,9 @@
2579065C1BD0488100178368 /* TCPSocket.cpp in Sources */,
268900D713353E6F00698AC0 /* DWARFCallFrameInfo.cpp in Sources */,
26C7C4831BFFEA7E009BD01F /* WindowsMiniDump.cpp in Sources */,
+ 49CA96FD1E6AACC900C03FEE /* DataBufferLLVM.cpp in Sources */,
268900D813353E6F00698AC0 /* Function.cpp in Sources */,
+ AFC2DCF31E6E30CF00283714 /* History.cpp in Sources */,
268900D913353E6F00698AC0 /* FuncUnwinders.cpp in Sources */,
268900DA13353E6F00698AC0 /* LineEntry.cpp in Sources */,
268900DB13353E6F00698AC0 /* LineTable.cpp in Sources */,
@@ -7357,15 +7401,18 @@
AF26703A1852D01E00B6CC36 /* Queue.cpp in Sources */,
949EEDAE1BA7671C008C63CF /* CF.cpp in Sources */,
268900DE13353E6F00698AC0 /* SymbolContext.cpp in Sources */,
+ 49CA97001E6AACC900C03FEE /* UUID.cpp in Sources */,
268900DF13353E6F00698AC0 /* SymbolFile.cpp in Sources */,
268900E013353E6F00698AC0 /* SymbolVendor.cpp in Sources */,
268900E113353E6F00698AC0 /* Symtab.cpp in Sources */,
268900E213353E6F00698AC0 /* Type.cpp in Sources */,
+ AFC2DCF61E6E316A00283714 /* StreamCallback.cpp in Sources */,
945261C51B9A11FC00BF138D /* LibCxxVector.cpp in Sources */,
3FDFED2719BA6D96009756A7 /* HostNativeThreadBase.cpp in Sources */,
268900E313353E6F00698AC0 /* TypeList.cpp in Sources */,
268900E413353E6F00698AC0 /* UnwindPlan.cpp in Sources */,
268900E513353E6F00698AC0 /* UnwindTable.cpp in Sources */,
+ AFF8FF0C1E779D4B003830EF /* TildeExpressionResolver.cpp in Sources */,
268900E613353E6F00698AC0 /* Variable.cpp in Sources */,
268900E713353E6F00698AC0 /* VariableList.cpp in Sources */,
257906641BD5AFD000178368 /* Acceptor.cpp in Sources */,
@@ -7386,7 +7433,6 @@
268900EF13353E6F00698AC0 /* Platform.cpp in Sources */,
268900F013353E6F00698AC0 /* Process.cpp in Sources */,
26BC17AD18C7F4CB00D2196D /* RegisterContextPOSIXCore_mips64.cpp in Sources */,
- 3F8169191ABA2419001DA9DF /* ConvertEnum.cpp in Sources */,
268900F113353E6F00698AC0 /* RegisterContext.cpp in Sources */,
6D55BAED1A8CD0A800A70529 /* PlatformAndroid.cpp in Sources */,
268900F213353E6F00698AC0 /* SectionLoadList.cpp in Sources */,
@@ -7413,6 +7459,7 @@
268900FF13353E6F00698AC0 /* ThreadPlanShouldStopHere.cpp in Sources */,
2579065F1BD0488D00178368 /* DomainSocket.cpp in Sources */,
2689010013353E6F00698AC0 /* ThreadPlanStepInstruction.cpp in Sources */,
+ AFC2DCE71E6E2ED000283714 /* FastDemangle.cpp in Sources */,
232CB61B191E00CD00EF39FC /* NativeThreadProtocol.cpp in Sources */,
2689010113353E6F00698AC0 /* ThreadPlanStepOut.cpp in Sources */,
2689010213353E6F00698AC0 /* ThreadPlanStepOverBreakpoint.cpp in Sources */,
@@ -7440,7 +7487,6 @@
2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */,
6D0F615A1C80AB3900A4ECEE /* JavaLanguage.cpp in Sources */,
2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */,
- 2689011313353E8200698AC0 /* PseudoTerminal.cpp in Sources */,
E7723D4C1AC4A944002BA082 /* RegisterContextPOSIX_arm64.cpp in Sources */,
26BC17AB18C7F4CB00D2196D /* ProcessElfCore.cpp in Sources */,
AF1F7B07189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp in Sources */,
@@ -7451,9 +7497,11 @@
26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */,
264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */,
EB8375E71B553DE800BA907D /* ThreadPlanCallFunctionUsingABI.cpp in Sources */,
+ 2654A6831E54D5E200DA1013 /* RegisterNumber.cpp in Sources */,
6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */,
2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */,
23D065911D4A7BEE0008EDE6 /* RenderScriptx86ABIFixups.cpp in Sources */,
+ 4CE4EFAA1E8999B900A80C06 /* PlatformOpenBSD.cpp in Sources */,
26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */,
3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */,
4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */,
@@ -7484,19 +7532,20 @@
264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */,
AF23B4DB19009C66003E2A58 /* FreeBSDSignals.cpp in Sources */,
945261C61B9A11FC00BF138D /* LibStdcpp.cpp in Sources */,
- 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */,
AF061F87182C97ED00B6A19C /* RegisterContextHistory.cpp in Sources */,
AF26703B1852D01E00B6CC36 /* QueueList.cpp in Sources */,
267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */,
+ 49CA96FE1E6AACC900C03FEE /* DataEncoder.cpp in Sources */,
26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */,
+ 2654A6901E552ED500DA1013 /* VASprintf.cpp in Sources */,
AF81DEFA1828A23F0042CF19 /* SystemRuntime.cpp in Sources */,
267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */,
260E07C6136FA69E00CF21D3 /* OptionGroupUUID.cpp in Sources */,
+ AFC2DCF91E6E318000283714 /* StreamGDBRemote.cpp in Sources */,
260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */,
2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */,
268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */,
264A12FC1372522000875C42 /* EmulateInstructionARM64.cpp in Sources */,
- 264A1300137252C700875C42 /* ARM64_DWARF_Registers.cpp in Sources */,
26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */,
26DB3E191379E7AD0080DC73 /* ABIMacOSX_arm64.cpp in Sources */,
2374D7531D4BB2FF005C9575 /* GDBRemoteClientBase.cpp in Sources */,
@@ -7510,7 +7559,6 @@
4C562CC71CC07DF700C52EAC /* PDBASTParser.cpp in Sources */,
B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */,
AF20F76A1AF18F9000751A6E /* ABISysV_arm64.cpp in Sources */,
- 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */,
4CCA644D13B40B82003BDF98 /* ItaniumABILanguageRuntime.cpp in Sources */,
4CCA645013B40B82003BDF98 /* AppleObjCRuntime.cpp in Sources */,
4CCA645213B40B82003BDF98 /* AppleObjCRuntimeV1.cpp in Sources */,
@@ -7531,7 +7579,6 @@
26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */,
26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */,
94CD7D0919A3FBA300908B7C /* AppleObjCClassDescriptorV2.cpp in Sources */,
- 256CBDBA1ADD107200BC6CDC /* RegisterContextLinux_arm.cpp in Sources */,
945261C31B9A11FC00BF138D /* LibCxxMap.cpp in Sources */,
265205A813D3E3F700132FE2 /* RegisterContextKDP_arm.cpp in Sources */,
265205AA13D3E3F700132FE2 /* RegisterContextKDP_i386.cpp in Sources */,
@@ -7561,7 +7608,6 @@
94B638631B8FB7F1004FE1E4 /* ObjCPlusPlusLanguage.cpp in Sources */,
49DEF1251CD7C6DF006A7C7D /* BlockPointer.cpp in Sources */,
49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */,
- 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */,
23DDF226196C3EE600BB8417 /* CommandOptionValidators.cpp in Sources */,
B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */,
26EFC4CD18CFAF0D00865D87 /* ObjectFileJIT.cpp in Sources */,
@@ -7572,7 +7618,6 @@
4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */,
26A527C114E24F5F00F3A14A /* ProcessMachCore.cpp in Sources */,
26A527C314E24F5F00F3A14A /* ThreadMachCore.cpp in Sources */,
- 4C6649A314EEE81000B0316F /* StreamCallback.cpp in Sources */,
B299580B14F2FA1400050A04 /* DisassemblerLLVMC.cpp in Sources */,
26B7564E14F89356008D9CB3 /* PlatformiOSSimulator.cpp in Sources */,
26FFC19914FC072100087D58 /* AuxVector.cpp in Sources */,
@@ -7581,8 +7626,8 @@
26FFC19D14FC072100087D58 /* DynamicLoaderPOSIXDYLD.cpp in Sources */,
2694E99D14FC0BB30076DE67 /* PlatformFreeBSD.cpp in Sources */,
2694E9A414FC0BBD0076DE67 /* PlatformLinux.cpp in Sources */,
+ AFC2DCEB1E6E2F7D00283714 /* UserID.cpp in Sources */,
94D0858C1B9675B8000D24BD /* FormattersHelpers.cpp in Sources */,
- 945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */,
945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */,
26B1EFAE154638AF00E2DAC7 /* DWARFDeclContext.cpp in Sources */,
23D0658F1D4A7BEE0008EDE6 /* RenderScriptExpressionOpts.cpp in Sources */,
@@ -7593,7 +7638,6 @@
260CC64915D0440D002BF2E0 /* OptionValueArray.cpp in Sources */,
260CC64A15D0440D002BF2E0 /* OptionValueBoolean.cpp in Sources */,
260CC64B15D0440D002BF2E0 /* OptionValueProperties.cpp in Sources */,
- 3FDFED0C19B7C8E7009756A7 /* ThisThread.cpp in Sources */,
9455630F1BEAD0600073F75F /* PlatformAppleSimulator.cpp in Sources */,
6D86CEA01B440F8500A7FBFA /* CommandObjectBugreport.cpp in Sources */,
260CC64C15D0440D002BF2E0 /* OptionValueDictionary.cpp in Sources */,
@@ -7632,7 +7676,6 @@
94F48F251A01C687005C0EC6 /* StringPrinter.cpp in Sources */,
94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */,
AF9107EF168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp in Sources */,
- AF1FA88A1A60A69500272AFC /* RegisterNumber.cpp in Sources */,
94CB255C16B069770059775D /* DataVisualization.cpp in Sources */,
94CB255D16B069770059775D /* FormatClasses.cpp in Sources */,
94CB255E16B069770059775D /* FormatManager.cpp in Sources */,
@@ -7745,7 +7788,6 @@
buildActionMask = 2147483647;
files = (
26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */,
- 9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -7919,10 +7961,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
+ LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
@@ -8012,10 +8052,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
+ LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
@@ -8966,10 +9004,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
+ LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
@@ -9685,10 +9721,8 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11internal]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
+ LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
diff --git a/packages/Python/lldbsuite/test/README-TestSuite b/packages/Python/lldbsuite/test/README-TestSuite
index 70e4c91b8894..92649fc9963c 100644
--- a/packages/Python/lldbsuite/test/README-TestSuite
+++ b/packages/Python/lldbsuite/test/README-TestSuite
@@ -54,6 +54,10 @@ o subdirectories of 'test'
C/C++/ObjC source files; they were created to house the Python test case which
does not involve lldb reading in an executable file at all.
+ The sample_test directory contains examples of both a full and an "inline"
+ testcase that run a process to a breakpoint and check a local variable. These
+ are convenient starting points for adding new tests.
+
o make directory
Contains Makefile.rules, which can be utilized by test cases to write Makefile
@@ -158,6 +162,9 @@ o Writing test cases:
from the command in the command return object, and all the part where you are driving the
debugger to the point you want to test will be more robust.
+ The sample_test directory contains a standard and an "inline" test that are good starting
+ points for writing a new test.
+
o Attaching in test cases:
If you need to attach to inferiors in your tests, you must make sure the inferior calls
diff --git a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
index 20e41f0f4121..dc1a0d19f83e 100644
--- a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -6,6 +6,7 @@ from __future__ import print_function
import os
import re
import subprocess
+import sys
import lldb
from lldbsuite.test.decorators import *
@@ -18,6 +19,7 @@ class TestMultipleSimultaneousDebuggers(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipIfNoSBHeaders
+ @expectedFailureAll(bugnumber="rdar://30564102")
@expectedFailureAll(
archs="i[3-6]86",
bugnumber="multi-process-driver.cpp creates an x64 target")
diff --git a/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp b/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
index 448304d83c75..15170a3e5eb5 100644
--- a/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
+++ b/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
-
+#include <string.h>
#include "lldb/API/LLDB.h"
#include "lldb/API/SBCommandInterpreter.h"
@@ -217,6 +217,10 @@ void *do_one_debugger (void *in)
int main (int argc, char **argv)
{
+#if !defined(_MSC_VER)
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
SBDebugger::Initialize();
completed_threads_array = (bool *) malloc (sizeof (bool) * NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
diff --git a/packages/Python/lldbsuite/test/configuration.py b/packages/Python/lldbsuite/test/configuration.py
index a0553a72c19d..120f8247c695 100644
--- a/packages/Python/lldbsuite/test/configuration.py
+++ b/packages/Python/lldbsuite/test/configuration.py
@@ -66,7 +66,7 @@ categoriesList = None
# set to true if we are going to use categories for cherry-picking test cases
useCategories = False
# Categories we want to skip
-skipCategories = []
+skipCategories = ["darwin-log"]
# use this to track per-category failures
failuresPerCategory = {}
@@ -76,11 +76,9 @@ lldbFrameworkPath = None
# Test suite repeat count. Can be overwritten with '-# count'.
count = 1
-# The 'archs' and 'compilers' can be specified via command line. The corresponding
-# options can be specified more than once. For example, "-A x86_64 -A i386"
-# => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang'].
-archs = None # Must be initialized after option parsing
-compilers = None # Must be initialized after option parsing
+# The 'arch' and 'compiler' can be specified via command line.
+arch = None # Must be initialized after option parsing
+compiler = None # Must be initialized after option parsing
# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
# the inferior programs. The global variable cflags_extras provides a hook to do
diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py
index 6e98beb90cca..763793af93ed 100644
--- a/packages/Python/lldbsuite/test/dosep.py
+++ b/packages/Python/lldbsuite/test/dosep.py
@@ -1653,7 +1653,7 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter):
# will be passed along to the timeout pre-kill handler and allows for loose
# coupling of its implementation.
runner_context = {
- "archs": configuration.archs,
+ "arch": configuration.arch,
"platform_name": configuration.lldb_platform_name,
"platform_url": configuration.lldb_platform_url,
"platform_working_dir": configuration.lldb_platform_working_dir,
diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py
index 6b6b2574e638..7d739acba952 100644
--- a/packages/Python/lldbsuite/test/dotest.py
+++ b/packages/Python/lldbsuite/test/dotest.py
@@ -25,6 +25,7 @@ from __future__ import print_function
import atexit
import os
import errno
+import logging
import platform
import re
import signal
@@ -274,22 +275,28 @@ def parseOptionsAndInitTestdirs():
if args.h:
do_help = True
- if args.compilers:
- configuration.compilers = args.compilers
+ if args.compiler:
+ configuration.compiler = os.path.realpath(args.compiler)
+ if not is_exe(configuration.compiler):
+ configuration.compiler = which(args.compiler)
+ if not is_exe(configuration.compiler):
+ logging.error(
+ '%s is not a valid compiler executable; aborting...',
+ args.compiler)
+ sys.exit(-1)
else:
# Use a compiler appropriate appropriate for the Apple SDK if one was
# specified
if platform_system == 'Darwin' and args.apple_sdk:
- configuration.compilers = [
- seven.get_command_output(
- 'xcrun -sdk "%s" -find clang 2> /dev/null' %
- (args.apple_sdk))]
+ configuration.compiler = seven.get_command_output(
+ 'xcrun -sdk "%s" -find clang 2> /dev/null' %
+ (args.apple_sdk))
else:
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
candidateCompilers = ['clang-3.5', 'clang', 'gcc']
for candidate in candidateCompilers:
if which(candidate):
- configuration.compilers = [candidate]
+ configuration.compiler = candidate
break
if args.channels:
@@ -304,18 +311,17 @@ def parseOptionsAndInitTestdirs():
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
(args.apple_sdk))
- if args.archs:
- configuration.archs = args.archs
- for arch in configuration.archs:
- if arch.startswith(
- 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ if args.arch:
+ configuration.arch = args.arch
+ if configuration.arch.startswith(
+ 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ os.environ['SDKROOT'] = seven.get_command_output(
+ 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
+ if not os.path.exists(os.environ['SDKROOT']):
os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
- if not os.path.exists(os.environ['SDKROOT']):
- os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
+ 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
else:
- configuration.archs = [platform_machine]
+ configuration.arch = platform_machine
if args.categoriesList:
configuration.categoriesList = set(
@@ -363,7 +369,18 @@ def parseOptionsAndInitTestdirs():
configuration.lldbFrameworkPath = args.framework
if args.executable:
+ # lldb executable is passed explicitly
lldbtest_config.lldbExec = os.path.realpath(args.executable)
+ if not is_exe(lldbtest_config.lldbExec):
+ lldbtest_config.lldbExec = which(args.executable)
+ if not is_exe(lldbtest_config.lldbExec):
+ logging.error(
+ '%s is not a valid executable to test; aborting...',
+ args.executable)
+ sys.exit(-1)
+
+ if args.server:
+ os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
if args.excluded:
for excl_file in args.excluded:
@@ -1025,6 +1042,49 @@ def setDefaultTripleForPlatform():
return {}
+def checkCompiler():
+ # Add some intervention here to sanity check that the compiler requested is sane.
+ # If found not to be an executable program, we abort.
+ c = configuration.compiler
+ if which(c):
+ return
+
+ if not sys.platform.startswith("darwin"):
+ raise Exception(c + " is not a valid compiler")
+
+ pipe = subprocess.Popen(
+ ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ cmd_output = pipe.stdout.read()
+ if not cmd_output or "not found" in cmd_output:
+ raise Exception(c + " is not a valid compiler")
+
+ configuration.compiler = cmd_output.split('\n')[0]
+ print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
+
+def canRunLibcxxTests():
+ from lldbsuite.test import lldbplatformutil
+
+ platform = lldbplatformutil.getPlatform()
+
+ if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin():
+ return True, "libc++ always present"
+
+ if platform == "linux":
+ if not os.path.isdir("/usr/include/c++/v1"):
+ return False, "Unable to find libc++ installation"
+ return True, "Headers found, let's hope they work"
+
+ return False, "Don't know how to build with libc++ on %s" % platform
+
+def checkLibcxxSupport():
+ result, reason = canRunLibcxxTests()
+ if result:
+ return # libc++ supported
+ if "libc++" in configuration.categoriesList:
+ return # libc++ category explicitly requested, let it run.
+ print("Libc++ tests will not be run because: " + reason)
+ configuration.skipCategories.append("libc++")
+
def run_suite():
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
# does not exist before proceeding to running the test suite.
@@ -1110,8 +1170,15 @@ def run_suite():
if configuration.lldb_platform_working_dir:
print("Setting remote platform working directory to '%s'..." %
(configuration.lldb_platform_working_dir))
- lldb.remote_platform.SetWorkingDirectory(
- configuration.lldb_platform_working_dir)
+ error = lldb.remote_platform.MakeDirectory(
+ configuration.lldb_platform_working_dir, 448) # 448 = 0o700
+ if error.Fail():
+ raise Exception("making remote directory '%s': %s" % (
+ remote_test_dir, error))
+
+ if not lldb.remote_platform.SetWorkingDirectory(
+ configuration.lldb_platform_working_dir):
+ raise Exception("failed to set working directory '%s'" % remote_test_dir)
lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
else:
lldb.remote_platform = None
@@ -1120,6 +1187,8 @@ def run_suite():
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+ checkLibcxxSupport()
+
# Don't do debugserver tests on everything except OS X.
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform
@@ -1174,124 +1243,65 @@ def run_suite():
raise
#
- # Invoke the default TextTestRunner to run the test suite, possibly iterating
- # over different configurations.
+ # Invoke the default TextTestRunner to run the test suite
#
+ checkCompiler()
- iterArchs = False
- iterCompilers = False
+ if not configuration.parsable:
+ print("compiler=%s" % configuration.compiler)
- if isinstance(configuration.archs, list) and len(configuration.archs) >= 1:
- iterArchs = True
+ # Iterating over all possible architecture and compiler combinations.
+ os.environ["ARCH"] = configuration.arch
+ os.environ["CC"] = configuration.compiler
+ configString = "arch=%s compiler=%s" % (configuration.arch,
+ configuration.compiler)
+
+ # Translate ' ' to '-' for pathname component.
+ if six.PY2:
+ import string
+ tbl = string.maketrans(' ', '-')
+ else:
+ tbl = str.maketrans(' ', '-')
+ configPostfix = configString.translate(tbl)
- #
- # Add some intervention here to sanity check that the compilers requested are sane.
- # If found not to be an executable program, the invalid one is dropped
- # from the list.
- for i in range(len(configuration.compilers)):
- c = configuration.compilers[i]
- if which(c):
- continue
- else:
- if sys.platform.startswith("darwin"):
- pipe = subprocess.Popen(
- ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- cmd_output = pipe.stdout.read()
- if cmd_output:
- if "not found" in cmd_output:
- print("dropping %s from the compilers used" % c)
- configuration.compilers.remove(i)
- else:
- configuration.compilers[i] = cmd_output.split('\n')[0]
- print(
- "'xcrun -find %s' returning %s" %
- (c, configuration.compilers[i]))
+ # Output the configuration.
+ if not configuration.parsable:
+ sys.stderr.write("\nConfiguration: " + configString + "\n")
+ # First, write out the number of collected test cases.
if not configuration.parsable:
- print("compilers=%s" % str(configuration.compilers))
-
- if not configuration.compilers or len(configuration.compilers) == 0:
- print("No eligible compiler found, exiting.")
- exitTestSuite(1)
-
- if isinstance(
- configuration.compilers,
- list) and len(
- configuration.compilers) >= 1:
- iterCompilers = True
-
- # If we iterate on archs or compilers, there is a chance we want to split
- # stderr/stdout.
- if iterArchs or iterCompilers:
- old_stderr = sys.stderr
- old_stdout = sys.stdout
- new_stderr = None
- new_stdout = None
+ sys.stderr.write(configuration.separator + "\n")
+ sys.stderr.write(
+ "Collected %d test%s\n\n" %
+ (configuration.suite.countTestCases(),
+ configuration.suite.countTestCases() != 1 and "s" or ""))
- # Iterating over all possible architecture and compiler combinations.
- for ia in range(len(configuration.archs) if iterArchs else 1):
- archConfig = ""
- if iterArchs:
- os.environ["ARCH"] = configuration.archs[ia]
- archConfig = "arch=%s" % configuration.archs[ia]
- for ic in range(len(configuration.compilers) if iterCompilers else 1):
- if iterCompilers:
- os.environ["CC"] = configuration.compilers[ic]
- configString = "%s compiler=%s" % (
- archConfig, configuration.compilers[ic])
- else:
- configString = archConfig
-
- if iterArchs or iterCompilers:
- # Translate ' ' to '-' for pathname component.
- if six.PY2:
- import string
- tbl = string.maketrans(' ', '-')
- else:
- tbl = str.maketrans(' ', '-')
- configPostfix = configString.translate(tbl)
-
- # Output the configuration.
- if not configuration.parsable:
- sys.stderr.write("\nConfiguration: " + configString + "\n")
-
- #print("sys.stderr name is", sys.stderr.name)
- #print("sys.stdout name is", sys.stdout.name)
-
- # First, write out the number of collected test cases.
- if not configuration.parsable:
- sys.stderr.write(configuration.separator + "\n")
- sys.stderr.write(
- "Collected %d test%s\n\n" %
- (configuration.suite.countTestCases(),
- configuration.suite.countTestCases() != 1 and "s" or ""))
-
- if configuration.parsable:
- v = 0
- else:
- v = configuration.verbose
-
- # Invoke the test runner.
- if configuration.count == 1:
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
- else:
- # We are invoking the same test suite more than once. In this case,
- # mark __ignore_singleton__ flag as True so the signleton pattern is
- # not enforced.
- test_result.LLDBTestResult.__ignore_singleton__ = True
- for i in range(configuration.count):
-
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
-
- configuration.failed = configuration.failed or not result.wasSuccessful()
+ if configuration.parsable:
+ v = 0
+ else:
+ v = configuration.verbose
+
+ # Invoke the test runner.
+ if configuration.count == 1:
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
+ else:
+ # We are invoking the same test suite more than once. In this case,
+ # mark __ignore_singleton__ flag as True so the signleton pattern is
+ # not enforced.
+ test_result.LLDBTestResult.__ignore_singleton__ = True
+ for i in range(configuration.count):
+
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
+
+ configuration.failed = not result.wasSuccessful()
if configuration.sdir_has_content and not configuration.parsable:
sys.stderr.write(
diff --git a/packages/Python/lldbsuite/test/dotest_args.py b/packages/Python/lldbsuite/test/dotest_args.py
index fc896d53c0be..bc43a6fc04a9 100644
--- a/packages/Python/lldbsuite/test/dotest_args.py
+++ b/packages/Python/lldbsuite/test/dotest_args.py
@@ -69,10 +69,9 @@ def create_parser():
'-A',
'--arch',
metavar='arch',
- action='append',
- dest='archs',
+ dest='arch',
help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once'''))
- group.add_argument('-C', '--compiler', metavar='compiler', dest='compilers', action='append', help=textwrap.dedent(
+ group.add_argument('-C', '--compiler', metavar='compiler', dest='compiler', help=textwrap.dedent(
'''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
if sys.platform == 'darwin':
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="macosx", help=textwrap.dedent(
@@ -124,6 +123,10 @@ def create_parser():
metavar='executable-path',
help='The path to the lldb executable')
group.add_argument(
+ '--server',
+ metavar='server-path',
+ help='The path to the debug server executable to use')
+ group.add_argument(
'-s',
metavar='name',
help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name')
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
index c0c2267a8362..871363b7aed3 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
@@ -45,14 +45,6 @@ class BreakpointOptionsTestCase(TestBase):
extra_options="-K 0",
num_expected_locations=1)
- # This should create a breakpoint 0 locations.
- lldbutil.run_break_set_by_file_and_line(
- self,
- "main.cpp",
- self.line,
- extra_options="-m 0",
- num_expected_locations=0)
-
# Run the program.
self.runCmd("run", RUN_SUCCEEDED)
@@ -68,8 +60,6 @@ class BreakpointOptionsTestCase(TestBase):
"1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
self.line,
"2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
- self.line,
- "3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" %
self.line])
# Continue the program, there should be another stop.
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
index 363b90003d76..b2e8f523c84d 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
@@ -1,8 +1,4 @@
-// Set break point at this line.
-
extern "C" int foo(void);
-int
-main (int argc, char **argv)
-{
+int main (int argc, char **argv) { // Set break point at this line.
return foo();
}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
new file mode 100644
index 000000000000..3665ae323e7b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../../make
+
+ENABLE_THREADS := YES
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
new file mode 100644
index 000000000000..21fe084d3dfb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -0,0 +1,114 @@
+"""
+Test hardware breakpoints for multiple threads.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+# Hardware breakpoints are supported only by platforms mentioned in oslist.
+@skipUnlessPlatform(oslist=['linux'])
+class HardwareBreakpointMultiThreadTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ @expectedFailureAndroid
+ def test_hw_break_set_delete_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('delete')
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ @expectedFailureAndroid
+ def test_hw_break_set_disable_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('disable')
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.first_stop = line_number(
+ self.source, 'Starting thread creation with hardware breakpoint set')
+
+ def break_multi_thread(self, removal_type):
+ """Test that lldb hardware breakpoints work for multiple threads."""
+ self.runCmd(
+ "file %s" %
+ os.path.join(
+ os.getcwd(),
+ 'a.out'),
+ CURRENT_EXECUTABLE_SET)
+
+ # Stop in main before creating any threads.
+ lldbutil.run_break_set_by_file_and_line(
+ self, None, self.first_stop, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now set a hardware breakpoint in thread function.
+ self.expect("breakpoint set -b hw_break_function --hardware",
+ substrs=[
+ 'Breakpoint',
+ 'hw_break_function',
+ 'address = 0x'])
+
+ # We should stop in hw_break_function function for 4 threads.
+ count = 0
+
+ while count < 2 :
+
+ self.runCmd("process continue")
+
+ # We should be stopped in hw_break_function
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=[
+ 'stop reason = breakpoint',
+ 'hw_break_function'])
+
+ # Continue the loop and test that we are stopped 4 times.
+ count += 1
+
+ if removal_type == 'delete':
+ self.runCmd("settings set auto-confirm true")
+
+ # Now 'breakpoint delete' should just work fine without confirmation
+ # prompt from the command interpreter.
+ self.expect("breakpoint delete",
+ startstr="All breakpoints removed")
+
+ # Restore the original setting of auto-confirm.
+ self.runCmd("settings clear auto-confirm")
+
+ elif removal_type == 'disable':
+ self.expect("breakpoint disable",
+ startstr="All breakpoints disabled.")
+
+ # Continue. Program should exit without stopping anywhere.
+ self.runCmd("process continue")
+
+ # Process should have stopped and exited with status = 0
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* exited with status = 0'])
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
new file mode 100644
index 000000000000..d13393095c61
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
@@ -0,0 +1,51 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <chrono>
+#include <cstdio>
+#include <mutex>
+#include <random>
+#include <thread>
+
+#define NUM_OF_THREADS 4
+
+std::mutex hw_break_mutex;
+
+void
+hw_break_function (uint32_t thread_index) {
+ printf ("%s called by Thread #%u...\n", __FUNCTION__, thread_index);
+}
+
+
+void
+thread_func (uint32_t thread_index) {
+ printf ("%s (thread index = %u) starting...\n", __FUNCTION__, thread_index);
+
+ hw_break_mutex.lock();
+
+ hw_break_function(thread_index); // Call hw_break_function
+
+ hw_break_mutex.unlock();
+}
+
+
+int main (int argc, char const *argv[])
+{
+ std::thread threads[NUM_OF_THREADS];
+
+ printf ("Starting thread creation with hardware breakpoint set...\n");
+
+ for (auto &thread : threads)
+ thread = std::thread{thread_func, std::distance(threads, &thread)};
+
+ for (auto &thread : threads)
+ thread.join();
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
new file mode 100644
index 000000000000..e7a1cab7e195
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../../make
+
+DYLIB_NAME := foo
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS += -fPIC
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
new file mode 100644
index 000000000000..26041c313e57
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
@@ -0,0 +1,63 @@
+from __future__ import print_function
+
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestMoveNearest(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line1 = line_number('foo.h', '// !BR1')
+ self.line2 = line_number('foo.h', '// !BR2')
+ self.line_main = line_number('main.cpp', '// !BR_main')
+
+ def test(self):
+ """Test target.move-to-nearest logic"""
+
+ self.build()
+ target = self.dbg.CreateTarget("a.out")
+ self.assertTrue(target, VALID_TARGET)
+
+ lldbutil.run_break_set_by_symbol(self, 'main', sym_exact=True)
+ environment = self.registerSharedLibrariesWithTarget(target, ["foo"])
+ process = target.LaunchSimple(None, environment, self.get_process_working_directory())
+ self.assertEquals(process.GetState(), lldb.eStateStopped)
+
+ # Regardless of the -m value the breakpoint should have exactly one
+ # location on the foo functions
+ self.runCmd("settings set target.move-to-nearest-code true")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 1")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 1")
+
+ self.runCmd("settings set target.move-to-nearest-code false")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 0")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 0")
+
+
+ # Make sure we set a breakpoint in main with -m 1 for various lines in
+ # the function declaration
+ # "int"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main-1, extra_options="-m 1")
+ # "main()"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main, extra_options="-m 1")
+ # "{"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+1, extra_options="-m 1")
+ # "return .."
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+2, extra_options="-m 1")
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
new file mode 100644
index 000000000000..8dad0a23f368
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.h"
+
+int call_foo1() { return foo1(); }
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
new file mode 100644
index 000000000000..060b91f5a5ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
@@ -0,0 +1,6 @@
+LLDB_TEST_API inline int foo1() { return 1; } // !BR1
+
+LLDB_TEST_API inline int foo2() { return 2; } // !BR2
+
+LLDB_TEST_API extern int call_foo1();
+LLDB_TEST_API extern int call_foo2();
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
new file mode 100644
index 000000000000..c9295a5c7d3c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+
+int call_foo2() { return foo2(); }
+
+int
+main() // !BR_main
+{
+ return call_foo1() + call_foo2();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
new file mode 100644
index 000000000000..f89b52a972e9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+ifneq (,$(findstring icc,$(CC)))
+ CXXFLAGS += -debug inline-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
new file mode 100644
index 000000000000..00ddc628607c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -0,0 +1,120 @@
+"""
+Test that breakpoints do not affect stepping.
+Check for correct StopReason when stepping to the line with breakpoint
+which chould be eStopReasonBreakpoint in general,
+and eStopReasonPlanComplete when breakpoint's condition fails.
+"""
+
+from __future__ import print_function
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class StepOverBreakpointsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ src = lldb.SBFileSpec("main.cpp")
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ # Setup four breakpoints, two of them with false condition
+ self.line1 = line_number('main.cpp', "breakpoint_1")
+ self.line4 = line_number('main.cpp', "breakpoint_4")
+
+ self.breakpoint1 = self.target.BreakpointCreateByLocation(src, self.line1)
+ self.assertTrue(
+ self.breakpoint1 and self.breakpoint1.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ self.breakpoint2 = self.target.BreakpointCreateBySourceRegex("breakpoint_2", src)
+ self.breakpoint2.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint3 = self.target.BreakpointCreateBySourceRegex("breakpoint_3", src)
+ self.breakpoint3.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint4 = self.target.BreakpointCreateByLocation(src, self.line4)
+
+ # Start debugging
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertIsNotNone(self.process, PROCESS_IS_VALID)
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint1)
+ self.assertIsNotNone(self.thread, "Didn't stop at breakpoint 1.")
+
+ def test_step_instruction(self):
+ # Count instructions between breakpoint_1 and breakpoint_4
+ contextList = self.target.FindFunctions('main', lldb.eFunctionNameTypeAuto)
+ self.assertEquals(contextList.GetSize(), 1)
+ symbolContext = contextList.GetContextAtIndex(0)
+ function = symbolContext.GetFunction()
+ self.assertTrue(function)
+ instructions = function.GetInstructions(self.target)
+ addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
+ addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
+ for i in range(instructions.GetSize()) :
+ addr = instructions.GetInstructionAtIndex(i).GetAddress()
+ if (addr == addr_1) : index_1 = i
+ if (addr == addr_4) : index_4 = i
+
+ steps_expected = index_4 - index_1
+ step_count = 0
+ # Step from breakpoint_1 to breakpoint_4
+ while True:
+ self.thread.StepInstruction(True)
+ step_count = step_count + 1
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertTrue(self.thread.GetStopReason() == lldb.eStopReasonPlanComplete or
+ self.thread.GetStopReason() == lldb.eStopReasonBreakpoint)
+ if (self.thread.GetStopReason() == lldb.eStopReasonBreakpoint) :
+ # we should not stop on breakpoint_2 and _3 because they have false condition
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetLineEntry().GetLine(), self.line4)
+ # breakpoint_2 and _3 should not affect step count
+ self.assertTrue(step_count >= steps_expected)
+ break
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
+ @skipIf(bugnumber="llvm.org/pr31972", hostoslist=["windows"])
+ def test_step_over(self):
+ #lldb.DBG.EnableLog("lldb", ["step","breakpoint"])
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_2 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_3 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_4
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint)
+ thread1 = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint4)
+ self.assertEquals(self.thread, thread1, "Didn't stop at breakpoint 4.")
+
+ # Check that stepping does not affect breakpoint's hit count
+ self.assertEquals(self.breakpoint1.GetHitCount(), 1)
+ self.assertEquals(self.breakpoint2.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint3.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint4.GetHitCount(), 1)
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
new file mode 100644
index 000000000000..8cfd34b73b55
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
@@ -0,0 +1,12 @@
+
+int func() { return 1; }
+
+int
+main(int argc, char const *argv[])
+{
+ int a = 0; // breakpoint_1
+ int b = func(); // breakpoint_2
+ a = b + func(); // breakpoint_3
+ return 0; // breakpoint_4
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories b/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories
new file mode 100644
index 000000000000..ea135483a483
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories
@@ -0,0 +1 @@
+darwin-log
diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
index 85281a97c572..f65b1b89d35b 100644
--- a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
+++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
@@ -22,6 +22,7 @@ class TestDarwinLogBasic(darwin_log.DarwinLogEventBasedTestBase):
@decorators.add_test_categories(['pyapi'])
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(archs=["i386"], bugnumber="rdar://28655626")
+ @decorators.expectedFailureAll(bugnumber="rdar://30645203")
def test_SBStructuredData_gets_broadcasted(self):
"""Exercise SBStructuredData API."""
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
index 6a832e02990a..63eb5e087e14 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
@@ -23,8 +23,7 @@ class LibCxxFunctionTestCase(TestBase):
var.SetPreferSyntheticValue(True)
return var
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test(self):
"""Test that std::function as defined by libc++ is correctly printed by LLDB"""
self.build()
@@ -36,9 +35,6 @@ class LibCxxFunctionTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
index 5d23fcef04ce..9b4308f54095 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
@@ -22,9 +22,10 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
TestBase.setUp(self)
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that libc++ iterators format properly."""
self.build()
@@ -35,9 +36,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -57,8 +55,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
self.expect('frame variable ivI', substrs=['item = 3'])
self.expect('expr ivI', substrs=['item = 3'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
index e2e082c795f7..e1ebbd5c226d 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
@@ -19,9 +19,8 @@ class LibcxxListDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
- @add_test_categories(["pyapi"])
+ @add_test_categories(["libc++"])
+ @expectedFailureAndroid(bugnumber="llvm.org/pr32592")
@skipIfDarwin # rdar://25499635
def test_with_run_command(self):
self.build()
@@ -40,8 +39,6 @@ class LibcxxListDataFormatterTestCase(TestBase):
# Run the program, it should stop at breakpoint 1.
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
- lldbutil.skip_if_library_missing(
- self, target, lldbutil.PrintableRegex("libc\+\+"))
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
self.assertEqual(
len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
index 7433a0b0da2c..fc4714ea94e2 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -17,8 +17,12 @@ class LibcxxMapDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -30,9 +34,6 @@ class LibcxxMapDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -52,16 +53,16 @@ class LibcxxMapDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ ns = self.namespace
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=['%s::map' % ns,
+ 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=2',
+ substrs=['%s::map' % ns, 'size=2',
'[0] = ',
'first = 0',
'second = 0',
@@ -72,7 +73,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[2] = ',
'first = 2',
'second = 0',
@@ -83,7 +84,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii",
- substrs=['size=8',
+ substrs=['%s::map' % ns, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -92,7 +93,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'second = 1'])
self.expect("p ii",
- substrs=['size=8',
+ substrs=['%s::map' % ns, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -124,17 +125,17 @@ class LibcxxMapDataFormatterTestCase(TestBase):
self.runCmd("continue")
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
self.runCmd("continue")
self.expect('frame variable si',
- substrs=['size=1',
+ substrs=['%s::map' % ns, 'size=1',
'[0] = ',
'first = \"zero\"',
'second = 0'])
@@ -142,7 +143,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable si",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -157,7 +158,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'second = 3'])
self.expect("p si",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -192,19 +193,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable is",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -219,7 +220,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'first = 3'])
self.expect("p is",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -254,19 +255,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ss",
- substrs=['size=3',
+ substrs=['%s::map' % ns, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -278,7 +279,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'first = \"gatto\"'])
self.expect("p ss",
- substrs=['size=3',
+ substrs=['%s::map' % ns, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -309,5 +310,5 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
index 66091e6e113f..b28a7e6bc31b 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
@@ -18,8 +18,12 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # libc++ not ported to Windows yet
- @skipIf(compiler="gcc")
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -31,9 +35,6 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -53,16 +54,15 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ multimap = self.namespace + "::multimap"
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=2',
+ substrs=[multimap, 'size=2',
'[0] = ',
'first = 0',
'second = 0',
@@ -73,7 +73,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[2] = ',
'first = 2',
'second = 0',
@@ -84,7 +84,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii",
- substrs=['size=8',
+ substrs=[multimap, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -93,7 +93,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'second = 1'])
self.expect("p ii",
- substrs=['size=8',
+ substrs=[multimap, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -125,17 +125,17 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=1',
+ substrs=[multimap, 'size=1',
'[0] = ',
'first = \"zero\"',
'second = 0'])
@@ -143,7 +143,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable si",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -158,7 +158,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'second = 3'])
self.expect("p si",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -193,19 +193,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable is",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -220,7 +220,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'first = 3'])
self.expect("p is",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -255,19 +255,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ss",
- substrs=['size=3',
+ substrs=[multimap, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -279,7 +279,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'first = \"gatto\"'])
self.expect("p ss",
- substrs=['size=3',
+ substrs=[multimap, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -310,5 +310,5 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
index d40bce83e0af..2f448e8fd115 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
@@ -17,8 +17,17 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ def getVariableType(self, name):
+ var = self.frame().FindVariable(name)
+ self.assertTrue(var.IsValid())
+ return var.GetType().GetCanonicalType().GetName()
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -30,9 +39,6 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -52,7 +58,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
+ ii_type = self.getVariableType("ii")
+ self.assertTrue(ii_type.startswith(self.namespace + "::multiset"),
+ "Type: " + ii_type)
self.expect("frame variable ii", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
@@ -86,6 +94,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
self.expect("frame variable ii", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii", substrs=["size=0", "{}"])
+ ss_type = self.getVariableType("ss")
+ self.assertTrue(ss_type.startswith(self.namespace + "::multiset"),
+ "Type: " + ss_type)
self.expect("frame variable ss", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect(
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index b0e84121dded..5b9b14d549e5 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -23,9 +23,10 @@ class LibcxxStringDataFormatterTestCase(TestBase):
TestBase.setUp(self)
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -36,9 +37,6 @@ class LibcxxStringDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -58,17 +56,18 @@ class LibcxxStringDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
+ ns = self.namespace
self.expect(
"frame variable",
substrs=[
- '(std::__1::wstring) s = L"hello world! מזל טוב!"',
- '(std::__1::wstring) S = L"!!!!"',
+ '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
+ '(%s::wstring) S = L"!!!!"'%ns,
'(const wchar_t *) mazeltov = 0x',
'L"מזל טוב"',
- '(std::__1::string) q = "hello world"',
- '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
- '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
- '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0ã¦ã– ル゜䋨ミ㠧槊 ãã‚…ã¸ç‹¦ç©¤è¥© ã˜ã‚ƒé¦©ãƒªãƒ§ 䤦監"'])
+ '(%s::string) q = "hello world"'%ns,
+ '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
+ '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
+ '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0ã¦ã– ル゜䋨ミ㠧槊 ãã‚…ã¸ç‹¦ç©¤è¥© ã˜ã‚ƒé¦©ãƒªãƒ§ 䤦監"'%ns])
self.runCmd("n")
@@ -91,11 +90,11 @@ class LibcxxStringDataFormatterTestCase(TestBase):
self.expect(
"frame variable",
substrs=[
- '(std::__1::wstring) s = L"hello world! מזל טוב!"',
- '(std::__1::wstring) S = L"!!!!!"',
+ '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
+ '(%s::wstring) S = L"!!!!!"'%ns,
'(const wchar_t *) mazeltov = 0x',
'L"מזל טוב"',
- '(std::__1::string) q = "hello world"',
- '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
- '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
- '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0ã¦ã– ル゜䋨ミ㠧槊 ãã‚…ã¸ç‹¦ç©¤è¥© ã˜ã‚ƒé¦©ãƒªãƒ§ 䤦監"'])
+ '(%s::string) q = "hello world"'%ns,
+ '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
+ '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
+ '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0ã¦ã– ル゜䋨ミ㠧槊 ãã‚…ã¸ç‹¦ç©¤è¥© ã˜ã‚ƒé¦©ãƒªãƒ§ 䤦監"'%ns])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
index 8a08d38975cf..f61a715a4d3e 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
@@ -17,10 +17,13 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # libc++ not ported to Windows yet
- @skipIf(compiler="gcc")
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
- """Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
@@ -29,9 +32,6 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -51,30 +51,30 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ ns = self.namespace
self.look_for_content_and_continue(
- "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+ "map", ['%s::unordered_map' %
+ ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
self.look_for_content_and_continue(
- "mmap", ['size=6 {', 'first = 3', 'second = "this"',
- 'first = 2', 'second = "hello"'])
+ "mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+ 'first = 2', 'second = "hello"'])
self.look_for_content_and_continue(
- "iset", ['size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
+ "iset", ['%s::unordered_set' %
+ ns, 'size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
self.look_for_content_and_continue(
- "sset", ['size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
- '\[\d\] = "hello"'])
+ "sset", ['%s::unordered_set' % ns, 'size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
+ '\[\d\] = "hello"'])
self.look_for_content_and_continue(
- "imset", ['size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
- '\[\d\] = 2', '\[\d\] = 1'])
+ "imset", ['%s::unordered_multiset' % ns, 'size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
+ '\[\d\] = 2', '\[\d\] = 1'])
self.look_for_content_and_continue(
- "smset",
- ['size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
- '(\[\d\] = "world"(\\n|.)+){2}'])
+ "smset", ['%s::unordered_multiset' % ns, 'size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
+ '(\[\d\] = "world"(\\n|.)+){2}'])
def look_for_content_and_continue(self, var_name, patterns):
self.expect(("frame variable %s" % var_name), patterns=patterns)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
index 43d5ad4f1033..a7a00068383f 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
@@ -23,16 +23,12 @@ class LibcxxVBoolDataFormatterTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows.
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
index 7b9956ed36ea..91fe509465e7 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
@@ -65,5 +65,6 @@ int main()
vBool.push_back(true);
vBool.push_back(true);
- return 0; // Set break point at this line.
+ printf ("size: %d", (int) vBool.size()); // Set break point at this line.
+ return 0;
}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
index 719ed7300505..9e226a100a10 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -17,16 +17,12 @@ class LibcxxVectorDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
bkpt = self.target().FindBreakpointByID(
lldbutil.run_break_set_by_source_regexp(
self, "break here"))
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
index 770d87178f50..37adb28d7d59 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
@@ -34,21 +34,25 @@ class StdUniquePtrDataFormatterTestCase(TestBase):
self.assertTrue(frame.IsValid())
self.expect("frame variable nup", substrs=['nup = nullptr'])
- self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123'])
- self.expect("frame variable sup", substrs=['sup = 0x', 'object = "foobar"'])
+ self.expect("frame variable iup", substrs=['iup = 0x'])
+ self.expect("frame variable sup", substrs=['sup = 0x'])
self.expect("frame variable ndp", substrs=['ndp = nullptr'])
- self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 'deleter = ', 'a = 1', 'b = 2'])
- self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = "baz"', 'deleter = ', 'a = 3', 'b = 4'])
-
+ self.expect("frame variable idp", substrs=['idp = 0x', 'deleter = ', 'a = 1', 'b = 2'])
+ self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4'])
+
self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
+ self.assertEqual(123, frame.GetValueForVariablePath("*iup").GetValueAsUnsigned())
self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
self.assertEqual('"foobar"', frame.GetValueForVariablePath("sup.object").GetSummary())
+ self.assertEqual('"foobar"', frame.GetValueForVariablePath("*sup").GetSummary())
self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid())
self.assertEqual(456, frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned())
+ self.assertEqual(456, frame.GetValueForVariablePath("*idp").GetValueAsUnsigned())
self.assertEqual('"baz"', frame.GetValueForVariablePath("sdp.object").GetSummary())
+ self.assertEqual('"baz"', frame.GetValueForVariablePath("*sdp").GetSummary())
idp_deleter = frame.GetValueForVariablePath("idp.deleter")
self.assertTrue(idp_deleter.IsValid())
@@ -59,3 +63,34 @@ class StdUniquePtrDataFormatterTestCase(TestBase):
self.assertTrue(sdp_deleter.IsValid())
self.assertEqual(3, sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned())
self.assertEqual(4, sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned())
+
+ @skipIfFreeBSD
+ @skipIfWindows # libstdcpp not ported to Windows
+ @skipIfDarwin # doesn't compile on Darwin
+ def test_recursive_unique_ptr(self):
+ # Tests that LLDB can handle when we have a loop in the unique_ptr
+ # reference chain and that it correctly handles the different options
+ # for the frame variable command in this case.
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp(
+ self, "Set break point at this line.")
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect("frame variable f1->fp",
+ substrs=['fp = 0x'])
+ self.expect("frame variable --ptr-depth=1 f1->fp",
+ substrs=['data = 2', 'fp = 0x'])
+ self.expect("frame variable --ptr-depth=2 f1->fp",
+ substrs=['data = 2', 'fp = 0x', 'data = 1'])
+
+ frame = self.frame()
+ self.assertTrue(frame.IsValid())
+ self.assertEqual(2, frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned())
+ self.assertEqual(2, frame.GetValueForVariablePath("f1->fp->data").GetValueAsUnsigned())
+ self.assertEqual(1, frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned())
+ self.assertEqual(1, frame.GetValueForVariablePath("f1->fp->fp->data").GetValueAsUnsigned())
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
index 4a40309338c1..dd0072764d4e 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
@@ -8,6 +8,11 @@ struct Deleter {
int b;
};
+struct Foo {
+ int data;
+ std::unique_ptr<Foo> fp;
+};
+
int main() {
std::unique_ptr<char> nup;
std::unique_ptr<int> iup(new int{123});
@@ -18,5 +23,13 @@ int main() {
std::unique_ptr<std::string, Deleter> sdp(new std::string("baz"),
Deleter{3, 4});
+ std::unique_ptr<Foo> fp(new Foo{3});
+
+ // Set up a structure where we have a loop in the unique_ptr chain.
+ Foo* f1 = new Foo{1};
+ Foo* f2 = new Foo{2};
+ f1->fp.reset(f2);
+ f2->fp.reset(f1);
+
return 0; // Set break point at this line.
}
diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py
new file mode 100644
index 000000000000..47357cf4f71d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py
@@ -0,0 +1,68 @@
+"""
+Test to ensure SBFrame::Disassemble produces SOME output
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FrameDisassembleTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_frame_disassemble(self):
+ """Sample test to ensure SBFrame::Disassemble produces SOME output."""
+ self.build()
+ self.frame_disassemble_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def frame_disassemble_test(self):
+ """Sample test to ensure SBFrame::Disassemble produces SOME output"""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here", lldb.SBFileSpec("main.cpp"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ frame = threads[0].GetFrameAtIndex(0)
+ disassembly = frame.Disassemble()
+ self.assertTrue(len(disassembly) != 0, "Disassembly was empty.")
diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
index 8813647f6b72..93925829ec82 100644
--- a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
@@ -20,7 +20,7 @@ main(int argc, char const *argv[])
int array[3];
- array[0] = sum (1238, 78392);
+ array[0] = sum (1238, 78392); // Set a breakpoint here
array[1] = sum (379265, 23674);
array[2] = sum (872934, 234);
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile
new file mode 100644
index 000000000000..089fc237b054
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp other.cpp other-2.cpp
+C_SOURCES := somefunc.c
+
+include $(LEVEL)/Makefile.rules
+
+other-2.o: other-2.cpp
+ $(CXX) $(CFLAGS_NO_DEBUG) -c other-2.cpp
+
+somefunc.o: somefunc.c
+ $(CC) $(CFLAGS) -std=c99 -c somefunc.c \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
new file mode 100644
index 000000000000..178e165f3cbe
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
@@ -0,0 +1,87 @@
+"""
+Test the SB API SBFrame::GuessLanguage.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFrameGuessLanguage(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_guess_language(self):
+ """Test GuessLanguage for C and C++."""
+ self.build()
+ self.do_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def check_language(self, thread, frame_no, test_lang):
+ frame = thread.frames[frame_no]
+ self.assertTrue(frame.IsValid(), "Frame %d was not valid."%(frame_no))
+ lang = frame.GuessLanguage()
+ self.assertEqual(lang, test_lang)
+
+ def do_test(self):
+ """Test GuessLanguage for C & C++."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set breakpoint here", lldb.SBFileSpec("somefunc.c"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ thread = threads[0]
+
+ c_frame_language = lldb.eLanguageTypeC99
+ # gcc emits DW_LANG_C89 even if -std=c99 was specified
+ if "gcc" in self.getCompiler():
+ c_frame_language = lldb.eLanguageTypeC89
+
+ self.check_language(thread, 0, c_frame_language)
+ self.check_language(thread, 1, lldb.eLanguageTypeC_plus_plus)
+ self.check_language(thread, 2, lldb.eLanguageTypeC_plus_plus)
+
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp
new file mode 100644
index 000000000000..f5449f217908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include "other.h"
+
+int
+main()
+{
+ int test_var = 10;
+ Other::DoSomethingElse();
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp
new file mode 100644
index 000000000000..77632de3ceb0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp
@@ -0,0 +1,7 @@
+#include "other.h"
+
+void
+Other::DoSomethingElse()
+{
+ DoSomething();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp
new file mode 100644
index 000000000000..41f4f26079ad
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp
@@ -0,0 +1,10 @@
+#include "other.h"
+
+extern "C" void some_func();
+
+void
+Other::DoSomething()
+{
+ some_func();
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other.h b/packages/Python/lldbsuite/test/functionalities/frame-language/other.h
new file mode 100644
index 000000000000..0a2c125e6b42
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other.h
@@ -0,0 +1,7 @@
+class Other
+{
+ public:
+ static void DoSomething();
+ static void DoSomethingElse();
+};
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c b/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c
new file mode 100644
index 000000000000..a4b4f47f32ec
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+some_func()
+{
+ printf("Set breakpoint here.");
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py b/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py
deleted file mode 100644
index 85741f548f33..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py
+++ /dev/null
@@ -1,67 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestHomeDirectory(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @expectedFailureAll(
- hostoslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @no_debug_info_test
- def test_tilde_home_directory(self):
- """Test that we can resolve "~/" in paths correctly.
- When a path starts with "~/", we use llvm::sys::path::home_directory() to
- resolve the home directory. This currently relies on "HOME" being set in the
- environment. While this is usually set, we can't rely upon that. We might
- eventually get a fix into llvm::sys::path::home_directory() so it doesn't rely
- on having to have an environment variable set, but until then we have work around
- code in FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to ensure
- this always works. This test tests that we get the correct answer for with and
- without "HOME" being set in the environment."""
- import pexpect
- prompt = "(lldb) "
-
- child = pexpect.spawn(
- '%s --no-use-colors %s' %
- (lldbtest_config.lldbExec, self.lldbOption))
- # Turn on logging for what the child sends back.
- if self.TraceOn():
- child.logfile_read = sys.stdout
- # So that the spawned lldb session gets shutdown durng teardown.
- self.child = child
-
- # Resolve "~/." to the full path of our home directory + "/."
- if 'HOME' in os.environ:
- home_dir = os.environ['HOME']
- if self.TraceOn():
- print("home directory is: '%s'" % (home_dir))
- if os.path.exists(home_dir):
- home_dir_slash_dot = home_dir + '/.'
- child.expect_exact(prompt)
- child.sendline('''script str(lldb.SBFileSpec("~/.", True))''')
- child.expect_exact(home_dir)
- child.expect_exact(prompt)
- child.sendline(
- '''script import os; os.unsetenv('HOME'); str(lldb.SBFileSpec("~/", True))''')
- child.expect_exact(home_dir)
- child.expect_exact(prompt)
- elif self.TraceOn():
- print(
- '''home directory "%s" doesn't exist, skipping home directory test''' %
- (home_dir))
- elif self.TraceOn():
- print('"HOME" not in environment, skipping home directory test')
-
- child.sendline('quit')
diff --git a/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
index 9d4e44c96bbc..91342fdaf1c3 100644
--- a/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
+++ b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
@@ -118,3 +118,20 @@ class MemoryReadTestCase(TestBase):
'16',
'18',
'20'])
+
+ # the gdb format specifier and the size in characters for
+ # the returned values including the 0x prefix.
+ variations = [['b', 4], ['h', 6], ['w', 10], ['g', 18]]
+ for v in variations:
+ formatter = v[0]
+ expected_object_length = v[1]
+ self.runCmd(
+ "memory read --gdb-format 4%s &my_uint64s" % formatter)
+ lines = self.res.GetOutput().splitlines()
+ objects_read = []
+ for l in lines:
+ objects_read.extend(l.split(':')[1].split())
+ # Check that we got back 4 0x0000 etc bytes
+ for o in objects_read:
+ self.assertTrue (len(o) == expected_object_length)
+ self.assertTrue(len(objects_read) == 4)
diff --git a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
index cd367ff318ab..fdc7b8bdba18 100644
--- a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
@@ -7,12 +7,14 @@
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
+#include <stdint.h>
int main (int argc, char const *argv[])
{
char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0};
double my_double = 1234.5678;
int my_ints[] = {2,4,6,8,10,12,14,16,18,20,22};
+ uint64_t my_uint64s[] = {0, 1, 2, 3, 4, 5, 6, 7};
printf("my_string=%s\n", my_string); // Set break point at this line.
printf("my_double=%g\n", my_double);
return 0;
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
index 7a987aeafb5b..38b55ef40c6b 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -21,10 +21,14 @@ class LinuxCoreTestCase(TestBase):
_i386_pid = 32306
_x86_64_pid = 32259
_s390x_pid = 1045
+ _mips64_n64_pid = 25619
+ _mips64_n32_pid = 3670
+ _mips_o32_pid = 3532
_i386_regions = 4
_x86_64_regions = 5
_s390x_regions = 2
+ _mips_regions = 5
def setUp(self):
super(LinuxCoreTestCase, self).setUp()
@@ -35,24 +39,40 @@ class LinuxCoreTestCase(TestBase):
super(LinuxCoreTestCase, self).tearDown()
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid, self._i386_regions)
+ def test_mips_o32(self):
+ """Test that lldb can read the process information from an MIPS O32 linux core file."""
+ self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions)
+
+ def test_mips_n32(self):
+ """Test that lldb can read the process information from an MIPS N32 linux core file """
+ self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions)
+
+ def test_mips_n64(self):
+ """Test that lldb can read the process information from an MIPS N64 linux core file """
+ self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions)
+
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_s390x(self):
"""Test that lldb can read the process information from an s390x linux core file."""
self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_same_pid_running(self):
"""Test that we read the information from the core correctly even if we have a running
@@ -82,6 +102,7 @@ class LinuxCoreTestCase(TestBase):
self.RemoveTempFile("linux-x86_64-pid.core")
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_two_cores_same_pid(self):
"""Test that we handle the situation if we have two core files with the same PID
@@ -111,6 +132,7 @@ class LinuxCoreTestCase(TestBase):
self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_FPR_SSE(self):
# check x86_64 core file
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
index 5a11a52e93a6..5b398c1ccf0c 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
@@ -23,12 +23,14 @@ class GCoreTestCase(TestBase):
_x86_64_pid = 5669
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
index 9908faffb6eb..f53ce2f35924 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#include <csignal>
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
new file mode 100644
index 000000000000..272c627cd244
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
new file mode 100755
index 000000000000..a230aa4251ae
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
new file mode 100644
index 000000000000..19c8100bdb11
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
new file mode 100755
index 000000000000..d1293a71a856
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
new file mode 100644
index 000000000000..2ad41395a2e0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
new file mode 100755
index 000000000000..dc809c8da482
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
index 7cc3c0775ced..4895c051d63e 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -27,12 +27,14 @@ class LinuxCoreThreadsTestCase(TestBase):
_x86_64_tid = 5250
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid, self._i386_tid)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
index 826d9d3fa972..7e09662edb2d 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#include <csignal>
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
index 44a42fdfe9d1..9becd8756318 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@ class MiniDumpNewTestCase(TestBase):
_linux_x86_64_not_crashed_pid = 29939
_linux_x86_64_not_crashed_pid_offset = 0xD967
+ def setUp(self):
+ super(MiniDumpNewTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(MiniDumpNewTestCase, self).tearDown()
+
def test_process_info_in_minidump(self):
"""Test that lldb can read the process information from the Minidump."""
# target create -c linux-x86_64.dmp
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile
new file mode 100644
index 000000000000..c4855ca9b12d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../make
+
+DYLIB_NAME := unlikely_name
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS += -fPIC
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py
new file mode 100644
index 000000000000..258c3d3fbb9f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py
@@ -0,0 +1,38 @@
+from __future__ import print_function
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+
+class TestPreRunLibraries(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ @skipIf(oslist=no_match(['darwin','macos']))
+ def test(self):
+ """Test that we find directly linked dylib pre-run."""
+
+ self.build()
+ target = self.dbg.CreateTarget("a.out")
+ self.assertTrue(target, VALID_TARGET)
+
+ # I don't know what the name of a shared library
+ # extension is in general, so instead of using FindModule,
+ # I'll iterate through the module and do a basename match.
+ found_it = False
+ for module in target.modules:
+ file_name = module.GetFileSpec().GetFilename()
+ if file_name.find("unlikely_name") != -1:
+ found_it = True
+ break
+
+ self.assertTrue(found_it, "Couldn't find unlikely_to_occur_name in loaded libraries.")
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp
new file mode 100644
index 000000000000..8dad0a23f368
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.h"
+
+int call_foo1() { return foo1(); }
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h
new file mode 100644
index 000000000000..060b91f5a5ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h
@@ -0,0 +1,6 @@
+LLDB_TEST_API inline int foo1() { return 1; } // !BR1
+
+LLDB_TEST_API inline int foo2() { return 2; } // !BR2
+
+LLDB_TEST_API extern int call_foo1();
+LLDB_TEST_API extern int call_foo2();
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp
new file mode 100644
index 000000000000..c9295a5c7d3c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+
+int call_foo2() { return foo2(); }
+
+int
+main() // !BR_main
+{
+ return call_foo1() + call_foo2();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
index 6fcf29a2f58f..6dccaa55a103 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
+++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
@@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil
class TestYMMRegister(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
@skipIfFreeBSD
@skipIfiOSSimulator
diff --git a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
index 157a0a8bd982..cc1389ca6b01 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
+++ b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
@@ -18,6 +18,7 @@ from lldbsuite.test import lldbutil
class RegisterCommandsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
TestBase.setUp(self)
@@ -139,17 +140,10 @@ class RegisterCommandsTestCase(TestBase):
# This intentionally checks the host platform rather than the target
# platform as logging is host side.
self.platform = ""
- if sys.platform.startswith("darwin"):
- self.platform = "" # TODO: add support for "log enable darwin registers"
-
- if sys.platform.startswith("freebsd"):
- self.platform = "freebsd"
-
- if sys.platform.startswith("linux"):
- self.platform = "linux"
-
- if sys.platform.startswith("netbsd"):
- self.platform = "netbsd"
+ if (sys.platform.startswith("freebsd") or
+ sys.platform.startswith("linux") or
+ sys.platform.startswith("netbsd")):
+ self.platform = "posix"
if self.platform != "":
self.log_file = os.path.join(os.getcwd(), 'TestRegisters.log')
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
index f9f33fda82bb..f06761936d12 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
@@ -13,7 +13,7 @@
// breakpoint is hit. The test case should be flexible enough to treat that
// as success.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <chrono>
#include <thread>
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
index 10b55bff3ba4..540b5148aefa 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
@@ -13,7 +13,7 @@
// the main thread (before any worker threads are spawned) and modify variables
// which control the number of threads that are spawned for each action.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <vector>
using namespace std;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
index 70681fd11603..f927e3d9d496 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
@@ -10,7 +10,7 @@
// This test is intended to create a situation in which one thread will be
// created while the debugger is stepping in another thread.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#define do_nothing()
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
index a032da835ea6..e41fbebf380d 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
@@ -13,7 +13,7 @@
// breakpoint is hit. The test case should be flexible enough to treat that
// as success.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <chrono>
#include <thread>
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
index 45adf28ce813..c7affd2a59ab 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
@@ -10,6 +10,7 @@
// This test is intended to create a situation in which one thread will exit
// while the debugger is stepping in another thread.
+#include "pseudo_barrier.h"
#include <thread>
#define do_nothing()
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
index c3d695dbc745..d46038109fc2 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
@@ -12,7 +12,7 @@
// the breakpoint in the second thread will be hit while the breakpoint handler
// in the first thread is trying to stop all threads.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
index 31f9a1576b92..ecc0571f2bd3 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
@@ -10,7 +10,7 @@
// This test is intended to create a situation in which two threads are stopped
// at a breakpoint and the debugger issues a step-out command.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
index c57db9f48527..f9508cf6ecca 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier1;
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
new file mode 100644
index 000000000000..cd9ca5c86d84
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
new file mode 100644
index 000000000000..bbe5be67c08d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
@@ -0,0 +1,67 @@
+"""
+Make sure FindTypes finds struct types with the struct prefix.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFindTypesOnStructType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_find_types_struct_type(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ self.build()
+ self.do_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def do_test(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Make sure this works with struct
+ type_list = target.FindTypes("struct mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with struct")
+
+ # Make sure this works without the struct:
+ type_list = target.FindTypes("mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without struct")
+
+ # Make sure it works with union
+ type_list = target.FindTypes("union myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with union")
+
+ # Make sure this works without the union:
+ type_list = target.FindTypes("myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without union")
+
+ # Make sure it works with typedef
+ type_list = target.FindTypes("typedef MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with typedef")
+
+ # Make sure this works without the typedef:
+ type_list = target.FindTypes("MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without typedef")
+
+
+
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
new file mode 100644
index 000000000000..fa009af27e17
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+struct mytype {
+ int c;
+ int d;
+};
+
+union myunion {
+ int num;
+ char *str;
+};
+
+typedef struct mytype MyType;
+
+int main()
+{
+ struct mytype v;
+ MyType *v_ptr = &v;
+
+ union myunion u = {5};
+ v.c = u.num;
+ v.d = 10;
+ return v.c + v.d;
+}
+
diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
index a09f73fb3fa7..a98622100ff4 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
@@ -2,6 +2,6 @@ LEVEL = ../../../make
C_SOURCES := test.c
-CFLAGS_EXTRAS += -O1
+CFLAGS_EXTRAS += -O1 -D_FORTIFY_SOURCE=0
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
index 6595e33b7269..bea4bf96e601 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
+++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
@@ -13,10 +13,10 @@ endif
all: limit nolimit
limit: main.o length_limit.o a.o
- $(CXX) $(LDFLAGS) main.o length_limit.o a.o -o limit
+ $(CXX) main.o length_limit.o a.o -o limit $(LDFLAGS)
nolimit: main.o length_nolimit.o a.o
- $(CXX) $(LDFLAGS) main.o length_nolimit.o a.o -o nolimit
+ $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS)
main.o: main.cpp
$(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o
diff --git a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
index 82ed362ff609..068594701507 100644
--- a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
+++ b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
@@ -16,10 +16,7 @@ from lldbsuite.test import lldbutil
class CreateDuringInstructionStepTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
+ NO_DEBUG_INFO_TESTCASE = True
@skipUnlessPlatform(['linux'])
@expectedFailureAndroid('llvm.org/pr24737', archs=['arm'])
diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py
index 240a75a1a82a..727e69d412a2 100644
--- a/packages/Python/lldbsuite/test/lldbinline.py
+++ b/packages/Python/lldbsuite/test/lldbinline.py
@@ -226,19 +226,19 @@ def MakeInlineTest(__file, __globals, decorators=None):
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
if test_categories.is_supported_on_platform(
- "dsym", target_platform, configuration.compilers):
+ "dsym", target_platform, configuration.compiler):
test.test_with_dsym = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dsym, decorators)
if test_categories.is_supported_on_platform(
- "dwarf", target_platform, configuration.compilers):
+ "dwarf", target_platform, configuration.compiler):
test.test_with_dwarf = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwarf, decorators)
if test_categories.is_supported_on_platform(
- "dwo", target_platform, configuration.compilers):
+ "dwo", target_platform, configuration.compiler):
test.test_with_dwo = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwo, decorators)
if test_categories.is_supported_on_platform(
- "gmodules", target_platform, configuration.compilers):
+ "gmodules", target_platform, configuration.compiler):
test.test_with_gmodules = ApplyDecoratorsToFunction(
test._InlineTest__test_with_gmodules, decorators)
diff --git a/packages/Python/lldbsuite/test/lldbplatformutil.py b/packages/Python/lldbsuite/test/lldbplatformutil.py
index 0d5254bc0e7a..89ce1d468bd0 100644
--- a/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -52,12 +52,12 @@ def _run_adb_command(cmd, device_id):
return p.returncode, stdout, stderr
-def _target_is_android():
- if not hasattr(_target_is_android, 'result'):
+def target_is_android():
+ if not hasattr(target_is_android, 'result'):
triple = lldb.DBG.GetSelectedPlatform().GetTriple()
match = re.match(".*-.*-.*-android", triple)
- _target_is_android.result = match is not None
- return _target_is_android.result
+ target_is_android.result = match is not None
+ return target_is_android.result
def android_device_api():
@@ -84,7 +84,7 @@ def android_device_api():
def match_android_device(device_arch, valid_archs=None, valid_api_levels=None):
- if not _target_is_android():
+ if not target_is_android():
return False
if valid_archs is not None and device_arch not in valid_archs:
return False
@@ -95,7 +95,7 @@ def match_android_device(device_arch, valid_archs=None, valid_api_levels=None):
def finalize_build_dictionary(dictionary):
- if _target_is_android():
+ if target_is_android():
if dictionary is None:
dictionary = {}
dictionary["OS"] = "Android"
diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py
index ba41d5d31912..bc0fb1b686ad 100644
--- a/packages/Python/lldbsuite/test/lldbtest.py
+++ b/packages/Python/lldbsuite/test/lldbtest.py
@@ -692,31 +692,30 @@ class Base(unittest2.TestCase):
if not lldb.remote_platform or not configuration.lldb_platform_working_dir:
return
- remote_test_dir = lldbutil.join_remote_paths(
- configuration.lldb_platform_working_dir,
- self.getArchitecture(),
- str(self.test_number),
- self.mydir)
- error = lldb.remote_platform.MakeDirectory(
- remote_test_dir, 448) # 448 = 0o700
- if error.Success():
- lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
-
- # This function removes all files from the current working directory while leaving
- # the directories in place. The cleaup is required to reduce the disk space required
- # by the test suit while leaving the directories untached is neccessary because
- # sub-directories might belong to an other test
- def clean_working_directory():
- # TODO: Make it working on Windows when we need it for remote debugging support
- # TODO: Replace the heuristic to remove the files with a logic what collects the
- # list of files we have to remove during test runs.
- shell_cmd = lldb.SBPlatformShellCommand(
- "rm %s/*" % remote_test_dir)
- lldb.remote_platform.Run(shell_cmd)
- self.addTearDownHook(clean_working_directory)
- else:
- print("error: making remote directory '%s': %s" % (
- remote_test_dir, error))
+ components = [str(self.test_number)] + self.mydir.split(os.path.sep)
+ remote_test_dir = configuration.lldb_platform_working_dir
+ for c in components:
+ remote_test_dir = lldbutil.join_remote_paths(remote_test_dir, c)
+ error = lldb.remote_platform.MakeDirectory(
+ remote_test_dir, 448) # 448 = 0o700
+ if error.Fail():
+ raise Exception("making remote directory '%s': %s" % (
+ remote_test_dir, error))
+
+ lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
+
+ # This function removes all files from the current working directory while leaving
+ # the directories in place. The cleaup is required to reduce the disk space required
+ # by the test suit while leaving the directories untached is neccessary because
+ # sub-directories might belong to an other test
+ def clean_working_directory():
+ # TODO: Make it working on Windows when we need it for remote debugging support
+ # TODO: Replace the heuristic to remove the files with a logic what collects the
+ # list of files we have to remove during test runs.
+ shell_cmd = lldb.SBPlatformShellCommand(
+ "rm %s/*" % remote_test_dir)
+ lldb.remote_platform.Run(shell_cmd)
+ self.addTearDownHook(clean_working_directory)
def setUp(self):
"""Fixture for unittest test case setup.
@@ -1119,8 +1118,11 @@ class Base(unittest2.TestCase):
compiler = compiler[2:]
if os.path.altsep is not None:
compiler = compiler.replace(os.path.altsep, os.path.sep)
- components.extend(
- [x for x in compiler.split(os.path.sep) if x != ""])
+ path_components = [x for x in compiler.split(os.path.sep) if x != ""]
+
+ # Add at most 4 path components to avoid generating very long
+ # filenames
+ components.extend(path_components[-4:])
elif c == 'a':
components.append(self.getArchitecture())
elif c == 'm':
@@ -1227,6 +1229,13 @@ class Base(unittest2.TestCase):
# (enables reading of the current test configuration)
# ====================================================
+ def isMIPS(self):
+ """Returns true if the architecture is MIPS."""
+ arch = self.getArchitecture()
+ if re.match("mips", arch):
+ return True
+ return False
+
def getArchitecture(self):
"""Returns the architecture in effect the test suite is running with."""
module = builder_module()
@@ -1704,7 +1713,7 @@ class LLDBTestCaseFactory(type):
supported_categories = [
x for x in categories if test_categories.is_supported_on_platform(
- x, target_platform, configuration.compilers)]
+ x, target_platform, configuration.compiler)]
if "dsym" in supported_categories:
@decorators.add_test_categories(["dsym"])
@wraps(attrvalue)
diff --git a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
index 972021e192b9..eae4ae2e42a3 100644
--- a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
+++ b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
@@ -18,7 +18,7 @@ class TestQueues(TestBase):
@skipUnlessDarwin
@add_test_categories(['pyapi'])
- @expectedFailureAll(bugnumber="rdar://28658529")
+ @expectedFailureAll(bugnumber="rdar://30915340")
def test_with_python_api(self):
"""Test queues inspection SB APIs."""
self.build()
diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules
new file mode 100644
index 000000000000..3e6a093f4bae
--- /dev/null
+++ b/packages/Python/lldbsuite/test/make/Android.rules
@@ -0,0 +1,91 @@
+NDK_ROOT := $(shell dirname $(CC))/../../../../..
+
+ifeq "$(findstring 64, $(ARCH))" "64"
+ # lowest 64-bit API level
+ API_LEVEL := 21
+else ifeq "$(ARCH)" "i386"
+ # clone(2) declaration is present only since this api level
+ API_LEVEL := 17
+else
+ # lowest supported 32-bit API level
+ API_LEVEL := 9
+endif
+
+ifeq "$(ARCH)" "arm"
+ SYSROOT_ARCH := arm
+ STL_ARCH := armeabi-v7a
+ TRIPLE := armv7-none-linux-androideabi
+ ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
+else ifeq "$(ARCH)" "aarch64"
+ SYSROOT_ARCH := arm64
+ TRIPLE := aarch64-none-linux-android
+ STL_ARCH := arm64-v8a
+else ifeq "$(ARCH)" "i386"
+ SYSROOT_ARCH := x86
+ STL_ARCH := x86
+ TRIPLE := i686-none-linux-android
+else ifeq "$(ARCH)" "mips64r6"
+ SYSROOT_ARCH := mips64
+ STL_ARCH := mips64
+ TRIPLE := mips64el-none-linux-android
+else ifeq "$(ARCH)" "mips32"
+ SYSROOT_ARCH := mips
+ STL_ARCH := mips
+ TRIPLE := mipsel-none-linux-android
+else
+ SYSROOT_ARCH := $(ARCH)
+ STL_ARCH := $(ARCH)
+ TRIPLE := $(ARCH)-none-linux-android
+endif
+
+ifeq "$(findstring 86,$(ARCH))" "86"
+ TOOLCHAIN_DIR := $(STL_ARCH)-4.9
+else ifeq "$(ARCH)" "arm"
+ TOOLCHAIN_DIR := arm-linux-androideabi-4.9
+else
+ TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
+endif
+
+ifeq "$(ARCH)" "arm"
+ TOOL_PREFIX := arm-linux-androideabi
+else
+ TOOL_PREFIX := $(subst -none,,$(TRIPLE))
+endif
+
+ifeq "$(HOST_OS)" "Linux"
+ HOST_TAG := linux-x86_64
+else ifeq "$(HOST_OS)" "Darwin"
+ HOST_TAG := darwin-x86_64
+else
+ HOST_TAG := windows-x86_64
+endif
+
+GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
+
+OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy
+
+ifeq "$(findstring clang,$(CC))" "clang"
+ ARCH_CFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
+ ARCH_LDFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
+endif
+
+ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)
+ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+
+ifeq (1,$(USE_LIBCPP))
+ ARCH_CFLAGS += \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
+ -isystem $(NDK_ROOT)/sources/android/support/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+
+ ARCH_LDFLAGS += \
+ -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
+ $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+else
+ ARCH_CFLAGS += \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
+
+ ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
+endif
diff --git a/packages/Python/lldbsuite/test/make/Makefile.rules b/packages/Python/lldbsuite/test/make/Makefile.rules
index 5abbc85e649b..a7b94ef57380 100644
--- a/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -32,10 +32,26 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
#----------------------------------------------------------------------
+# If OS is not defined, use 'uname -s' to determine the OS name.
+#
+# uname on Windows gives "windows32", but most environments standardize
+# on "Windows_NT", so we'll make it consistent here. When running
+# tests from Visual Studio, the environment variable isn't inherited
+# all the way down to the process spawned for make.
+#----------------------------------------------------------------------
+HOST_OS = $(shell uname -s)
+ifeq "$(HOST_OS)" "windows32"
+ HOST_OS = Windows_NT
+endif
+ifeq "$(OS)" ""
+ OS = $(HOST_OS)
+endif
+
+#----------------------------------------------------------------------
# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
# from the triple alone
#----------------------------------------------------------------------
-TRIPLE_CFLAGS :=
+ARCH_CFLAGS :=
ifneq "$(TRIPLE)" ""
triple_space = $(subst -, ,$(TRIPLE))
ARCH =$(word 1, $(triple_space))
@@ -52,33 +68,20 @@ ifneq "$(TRIPLE)" ""
ifeq "$(TRIPLE_VERSION)" ""
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
endif
- TRIPLE_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
+ ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
else
SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
ifeq "$(TRIPLE_VERSION)" ""
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
endif
- TRIPLE_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
+ ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
endif
endif
endif
endif
endif
-
-#----------------------------------------------------------------------
-# If OS is not defined, use 'uname -s' to determine the OS name.
-#
-# uname on Windows gives "windows32", but most environments standardize
-# on "Windows_NT", so we'll make it consistent here. When running
-# tests from Visual Studio, the environment variable isn't inherited
-# all the way down to the process spawned for make.
-#----------------------------------------------------------------------
-HOST_OS = $(shell uname -s)
-ifeq "$(HOST_OS)" "windows32"
- HOST_OS = Windows_NT
-endif
-ifeq "$(OS)" ""
- OS = $(HOST_OS)
+ifeq "$(OS)" "Android"
+ include $(THIS_FILE_DIR)/Android.rules
endif
#----------------------------------------------------------------------
@@ -199,13 +202,13 @@ else
CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include
endif
-CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS)
+CFLAGS += -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) $(ARCH_CFLAGS)
# Use this one if you want to build one part of the result without debug information:
ifeq "$(OS)" "Darwin"
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS)
else
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS)
endif
ifeq "$(MAKE_DWO)" "YES"
@@ -221,7 +224,7 @@ CXXFLAGS += -std=c++11
CXXFLAGS += $(subst -fmodules,, $(CFLAGS))
LD = $(CC)
LDFLAGS ?= $(CFLAGS)
-LDFLAGS += $(LD_EXTRAS)
+LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
ifeq (,$(filter $(OS), Windows_NT Android))
ifneq (,$(filter YES,$(ENABLE_THREADS)))
LDFLAGS += -pthread
@@ -297,10 +300,12 @@ ifeq "$(OS)" "Windows_NT"
# Clang for Windows doesn't support C++ Exceptions
CXXFLAGS += -fno-exceptions
CXXFLAGS += -D_HAS_EXCEPTIONS=0
- ifeq "$(VisualStudioVersion)" "14.0"
- CXXFLAGS += -fms-compatibility-version=19.0
- override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
- endif
+
+ # MSVC 2015 or higher is required, which depends on c++14, so
+ # append these values unconditionally.
+ CXXFLAGS += -fms-compatibility-version=19.0
+ override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
+
# The MSVC linker doesn't understand long section names
# generated by the clang compiler.
LDFLAGS += -fuse-ld=lld
@@ -319,19 +324,21 @@ ifeq (1,$(USE_LIBSTDCPP))
endif
ifeq (1,$(USE_LIBCPP))
- # Clang requires an extra flag: -stdlib=libstdc++
- ifneq (,$(findstring clang,$(CC)))
- ifeq "$(OS)" "Linux"
- # This is the default install location on Ubuntu 14.04
- ifneq ($(wildcard /usr/include/c++/v1/.),)
- CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
- LDFLAGS += -stdlib=libc++
- CXXFLAGS += -I/usr/include/c++/v1
- endif
- else
- CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+ CXXFLAGS += -DLLDB_USING_LIBCPP
+ ifeq "$(OS)" "Linux"
+ ifneq (,$(findstring clang,$(CC)))
+ CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
+ else
+ CXXFLAGS += -isystem /usr/include/c++/v1
+ LDFLAGS += -lc++
endif
+ else ifeq "$(OS)" "Android"
+ # Nothing to do, this is already handled in
+ # Android.rules.
+ else
+ CXXFLAGS += -stdlib=libc++
+ LDFLAGS += -stdlib=libc++
endif
endif
diff --git a/packages/Python/lldbsuite/test/make/pseudo_barrier.h b/packages/Python/lldbsuite/test/make/pseudo_barrier.h
new file mode 100644
index 000000000000..592000ddea4d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/make/pseudo_barrier.h
@@ -0,0 +1,20 @@
+#include <atomic>
+
+// Note that although hogging the CPU while waiting for a variable to change
+// would be terrible in production code, it's great for testing since it
+// avoids a lot of messy context switching to get multiple threads synchronized.
+
+typedef std::atomic<int> pseudo_barrier_t;
+#define pseudo_barrier_wait(barrier) \
+ do \
+ { \
+ --(barrier); \
+ while ((barrier).load() > 0) \
+ ; \
+ } while (0)
+
+#define pseudo_barrier_init(barrier, count) \
+ do \
+ { \
+ (barrier) = (count); \
+ } while (0)
diff --git a/packages/Python/lldbsuite/test/make/test_common.h b/packages/Python/lldbsuite/test/make/test_common.h
index 575ca62c2fc0..529d0952ed3e 100644
--- a/packages/Python/lldbsuite/test/make/test_common.h
+++ b/packages/Python/lldbsuite/test/make/test_common.h
@@ -10,14 +10,6 @@
#define LLDB_TEST_API
#endif
-#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
-// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
-// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
-// declared. This may not be necessary after MSVC 12.
-#include <eh.h>
-#endif
-
#if defined(_WIN32)
#define LLVM_PRETTY_FUNCTION __FUNCSIG__
#else
@@ -53,34 +45,3 @@
#define lldb_enable_attach()
#endif
-
-#if defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)
-
-// on Darwin, libstdc++ is missing <atomic>, so this would cause any test to fail building
-// since this header file is being included in every C-family test case, we need to not include it
-// on Darwin, most tests use libc++ by default, so this will only affect tests that explicitly require libstdc++
-
-#else
-#ifdef __cplusplus
-#include <atomic>
-
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
-
-typedef std::atomic<int> pseudo_barrier_t;
-#define pseudo_barrier_wait(barrier) \
- do \
- { \
- --(barrier); \
- while ((barrier).load() > 0) \
- ; \
- } while (0)
-
-#define pseudo_barrier_init(barrier, count) \
- do \
- { \
- (barrier) = (count); \
- } while (0)
-#endif // __cplusplus
-#endif // defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)
diff --git a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
index 39975632dcb6..4bd4781c7ef5 100644
--- a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
+++ b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
@@ -17,6 +17,7 @@ from lldbsuite.test import lldbutil
class BreakpointAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
@add_test_categories(['pyapi'])
def test_breakpoint_is_valid(self):
@@ -49,3 +50,28 @@ class BreakpointAPITestCase(TestBase):
self.assertTrue(
not breakpoint,
"Breakpoint we deleted is no longer valid.")
+
+ @add_test_categories(['pyapi'])
+ def test_target_delete(self):
+ """Make sure that if an SBTarget gets deleted the associated
+ Breakpoint's IsValid returns false."""
+
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'AFunction'.
+ breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
+ #print("breakpoint:", breakpoint)
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location.IsValid())
+
+ self.assertTrue(self.dbg.DeleteTarget(target))
+ self.assertFalse(breakpoint.IsValid())
+ self.assertFalse(location.IsValid())
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile b/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile
new file mode 100644
index 000000000000..8a7102e347af
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py
new file mode 100644
index 000000000000..b7a683f25f62
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py
@@ -0,0 +1,66 @@
+"""
+Test SBTarget APIs.
+"""
+
+from __future__ import print_function
+
+
+import unittest2
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestNameLookup(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ def test_target(self):
+ """Exercise SBTarget.FindFunctions() with various name masks.
+
+ A previous regression caused mangled names to not be able to be looked up.
+ This test verifies that using a mangled name with eFunctionNameTypeFull works
+ and that using a function basename with eFunctionNameTypeFull works for all
+ C++ functions that are at the global namespace level."""
+ self.build();
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ exe_module = target.FindModule(target.GetExecutable())
+
+ c_name_to_symbol = {}
+ cpp_name_to_symbol = {}
+ mangled_to_symbol = {}
+ num_symbols = exe_module.GetNumSymbols();
+ for i in range(num_symbols):
+ symbol = exe_module.GetSymbolAtIndex(i);
+ name = symbol.GetName()
+ if name and 'unique_function_name' in name and '__PRETTY_FUNCTION__' not in name:
+ mangled = symbol.GetMangledName()
+ if mangled:
+ mangled_to_symbol[mangled] = symbol
+ if name:
+ cpp_name_to_symbol[name] = symbol
+ elif name:
+ c_name_to_symbol[name] = symbol
+
+ # Make sure each mangled name turns up exactly one match when looking up
+ # functions by full name and using the mangled name as the name in the
+ # lookup
+ self.assertGreaterEqual(len(mangled_to_symbol), 6)
+ for mangled in mangled_to_symbol.keys():
+ symbol_contexts = target.FindFunctions(mangled, lldb.eFunctionNameTypeFull)
+ self.assertTrue(symbol_contexts.GetSize() == 1)
+ for symbol_context in symbol_contexts:
+ self.assertTrue(symbol_context.GetFunction().IsValid())
+ self.assertTrue(symbol_context.GetSymbol().IsValid())
+
+
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp
new file mode 100644
index 000000000000..79aa2d0452f4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp
@@ -0,0 +1,54 @@
+#include <stdio.h>
+
+extern "C" int unique_function_name(int i)
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+int unique_function_name()
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+int unique_function_name(float f)
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+namespace e
+{
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+
+ namespace g
+ {
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+ }
+}
+
+class g
+{
+public:
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+
+ int unique_function_name(int i)
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+};
+
+int main (int argc, char const *argv[])
+{
+ g g;
+ g.unique_function_name();
+ g.unique_function_name(argc);
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
index e853d6567e73..0560ac502dcf 100644
--- a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
+++ b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
@@ -22,6 +22,26 @@ class SBDataAPICase(TestBase):
self.line = line_number('main.cpp', '// set breakpoint here')
@add_test_categories(['pyapi'])
+ def test_byte_order_and_address_byte_size(self):
+ """Test the SBData::SetData() to ensure the byte order and address
+ byte size are obeyed"""
+ addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88'
+ error = lldb.SBError()
+ data = lldb.SBData()
+ data.SetData(error, addr_data, lldb.eByteOrderBig, 4)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x11223344);
+ data.SetData(error, addr_data, lldb.eByteOrderBig, 8)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x1122334455667788);
+ data.SetData(error, addr_data, lldb.eByteOrderLittle, 4)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x44332211);
+ data.SetData(error, addr_data, lldb.eByteOrderLittle, 8)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x8877665544332211);
+
+ @add_test_categories(['pyapi'])
def test_with_run_command(self):
"""Test the SBData APIs."""
self.build()
diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
index e4f2c5c7a182..bc925ee693d4 100644
--- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
+++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
@@ -108,3 +108,6 @@ class SetWatchpointAPITestCase(TestBase):
self.assertTrue(
process.GetState() == lldb.eStateExited,
PROCESS_EXITED)
+
+ self.dbg.DeleteTarget(target)
+ self.assertFalse(watchpoint.IsValid())
diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
index 1bef9968b4ab..2685ef819cad 100644
--- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
+++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
@@ -56,7 +56,7 @@ class WatchpointIgnoreCountTestCase(TestBase):
# We should be stopped due to the breakpoint. Get frame #0.
process = target.GetProcess()
- self.assertTrue(process.GetState() == lldb.eStateStopped,
+ self.assertEqual(process.GetState(), lldb.eStateStopped,
PROCESS_STOPPED)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
@@ -75,12 +75,12 @@ class WatchpointIgnoreCountTestCase(TestBase):
self.HideStdout()
# There should be only 1 watchpoint location under the target.
- self.assertTrue(target.GetNumWatchpoints() == 1)
+ self.assertEqual(target.GetNumWatchpoints(), 1)
watchpoint = target.GetWatchpointAtIndex(0)
self.assertTrue(watchpoint.IsEnabled())
- self.assertTrue(watchpoint.GetIgnoreCount() == 0)
+ self.assertEqual(watchpoint.GetIgnoreCount(), 0)
watch_id = watchpoint.GetID()
- self.assertTrue(watch_id != 0)
+ self.assertNotEqual(watch_id, 0)
print(watchpoint)
# Now immediately set the ignore count to 2. When we continue, expect the
@@ -90,12 +90,10 @@ class WatchpointIgnoreCountTestCase(TestBase):
process.Continue()
# At this point, the inferior process should have exited.
- self.assertTrue(
- process.GetState() == lldb.eStateExited,
- PROCESS_EXITED)
+ self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
# Verify some vital statistics.
self.assertTrue(watchpoint)
- self.assertTrue(watchpoint.GetWatchSize() == 4)
- self.assertTrue(watchpoint.GetHitCount() == 2)
+ self.assertEqual(watchpoint.GetWatchSize(), 4)
+ self.assertEqual(watchpoint.GetHitCount(), 2)
print(watchpoint)
diff --git a/packages/Python/lldbsuite/test/sample_test/Makefile b/packages/Python/lldbsuite/test/sample_test/Makefile
new file mode 100644
index 000000000000..0e5a537bbec8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS += -std=c99
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py b/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py
new file mode 100644
index 000000000000..29fad79de811
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py
@@ -0,0 +1,10 @@
+"""
+Describe the purpose of the test here.
+"""
+
+from __future__ import absolute_import
+
+from lldbsuite.test import lldbinline
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), None)
diff --git a/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
new file mode 100644
index 000000000000..bb34727ff81b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
@@ -0,0 +1,74 @@
+"""
+Describe the purpose of the test class here.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class RenameThisSampleTestTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_sample_rename_this(self):
+ """There can be many tests in a test case - describe this test here."""
+ self.build()
+ self.sample_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def sample_test(self):
+ """You might use the test implementation in several ways, say so here."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here", lldb.SBFileSpec("main.c"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ frame = threads[0].GetFrameAtIndex(0)
+ test_var = frame.FindVariable("test_var")
+ self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var")
+ test_value = test_var.GetValueAsUnsigned()
+ self.assertEqual(test_value, 10, "Got the right value for test_var")
+
diff --git a/packages/Python/lldbsuite/test/sample_test/main.c b/packages/Python/lldbsuite/test/sample_test/main.c
new file mode 100644
index 000000000000..0164d7155b09
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/main.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+int
+main()
+{
+ int test_var = 10;
+ printf ("Set a breakpoint here: %d.\n", test_var);
+ //% test_var = self.frame().FindVariable("test_var")
+ //% test_value = test_var.GetValueAsUnsigned()
+ //% self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var")
+ //% self.assertEqual(test_value, 10, "Failed to get the right value for test_var")
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/test_categories.py b/packages/Python/lldbsuite/test/test_categories.py
index e2bec304832f..a1c2859536d1 100644
--- a/packages/Python/lldbsuite/test/test_categories.py
+++ b/packages/Python/lldbsuite/test/test_categories.py
@@ -25,6 +25,7 @@ all_categories = {
'dsym': 'Tests that can be run with DSYM debug information',
'gmodules': 'Tests that can be run with -gmodules debug information',
'expression': 'Tests related to the expression parser',
+ 'libc++': 'Test for libc++ data formatters',
'objc': 'Tests related to the Objective-C programming language support',
'pyapi': 'Tests related to the Python API',
'basic_process': 'Basic process execution sniff tests.',
@@ -32,7 +33,8 @@ all_categories = {
'dyntype': 'Tests related to dynamic type support',
'stresstest': 'Tests related to stressing lldb limits',
'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution',
- 'lldb-mi': 'lldb-mi tests'}
+ 'lldb-mi': 'lldb-mi tests',
+ 'darwin-log': 'Darwin log tests'}
def unique_string_match(yourentry, list):
@@ -46,7 +48,7 @@ def unique_string_match(yourentry, list):
return candidate
-def is_supported_on_platform(category, platform, compiler_paths):
+def is_supported_on_platform(category, platform, compiler_path):
if category == "dwo":
# -gsplit-dwarf is not implemented by clang on Windows.
return platform in ["linux", "freebsd"]
@@ -56,17 +58,7 @@ def is_supported_on_platform(category, platform, compiler_paths):
# First, check to see if the platform can even support gmodules.
if platform not in ["linux", "freebsd", "darwin", "macosx", "ios"]:
return False
- # If all compilers specified support gmodules, we'll enable it.
- for compiler_path in compiler_paths:
- if not gmodules.is_compiler_clang_with_gmodules(compiler_path):
- # Ideally in a multi-compiler scenario during a single test run, this would
- # allow gmodules on compilers that support it and not on ones that don't.
- # However, I didn't see an easy way for all the callers of this to know
- # the compiler being used for a test invocation. As we tend to run with
- # a single compiler per test run, this shouldn't be a major
- # issue.
- return False
- return True
+ return gmodules.is_compiler_clang_with_gmodules(compiler_path)
return True
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
index 786c842bb514..d62224d976c9 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
@@ -18,6 +18,7 @@ class MiEnvironmentCdTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfDarwin # Disabled while I investigate the failure on buildbot.
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_environment_cd(self):
"""Test that 'lldb-mi --interpreter' changes working directory for inferior."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
index 0cc50370b164..4f3562d42de8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
@@ -18,6 +18,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_exit(self):
"""Test that '-gdb-exit' terminates local debug session and exits."""
@@ -44,6 +45,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_quit(self):
"""Test that 'quit' exits immediately."""
@@ -69,6 +71,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_q(self):
"""Test that 'q' exits immediately."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
index 7a99ecf7d1e5..1eea89f4fff4 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
@@ -17,6 +17,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_file(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols exe."""
@@ -33,6 +34,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols fullpath/exe."""
@@ -51,6 +53,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_relative_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols relpath/exe."""
@@ -68,6 +71,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_unknown_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
index 9b575c49bcb0..6bb7619e60b8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
@@ -20,6 +20,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_default(self):
"""Test that 'lldb-mi --interpreter' switches to async mode by default."""
@@ -42,6 +43,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr26028") # Fails in ~1% of cases
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_on(self):
"""Test that 'lldb-mi --interpreter' can execute commands in async mode."""
@@ -75,6 +77,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~11/600 dosep runs (build 3120-3122)")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_off(self):
"""Test that 'lldb-mi --interpreter' can execute commands in sync mode."""
@@ -101,6 +104,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_target_async(self):
"""Test that 'lldb-mi --interpreter' in async mode by default."""
@@ -114,6 +118,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_language(self):
"""Test that 'lldb-mi --interpreter' can get current language."""
@@ -138,6 +143,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-set ignores unknown properties")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when setting an unknown property."""
@@ -151,6 +157,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-show ignores unknown properties")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when showing an unknown property."""
@@ -165,6 +172,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_ouptut_radix(self):
"""Test that 'lldb-mi --interpreter' works for -gdb-set output-radix."""
@@ -211,6 +219,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
bugnumber="llvm.org/pr31485: data-disassemble doesn't follow flavor settings")
def test_lldbmi_gdb_set_disassembly_flavor(self):
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
index 68d670c9cd1e..a597ae1397ad 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -17,6 +17,7 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_library_loaded(self):
"""Test that 'lldb-mi --interpreter' shows the =library-loaded notifications."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
index b853673211bb..20e48ac8dc7c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
@@ -17,6 +17,7 @@ class MiPromptTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_prompt(self):
"""Test that 'lldb-mi --interpreter' echos '(gdb)' after commands and events."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
index 38c6b1f0b179..16f71fe8130c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -19,6 +19,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr24717")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_function_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending function breakpoints."""
@@ -45,6 +46,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_function(self):
"""Test that 'lldb-mi --interpreter' works for function breakpoints."""
@@ -113,6 +115,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending file:line breakpoints."""
@@ -142,6 +145,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
@@ -179,6 +183,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
@@ -206,6 +211,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_settings(self):
"""Test that 'lldb-mi --interpreter' can set breakpoints accoridng to global options."""
@@ -220,38 +226,47 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd(
"-interpreter-exec console \"settings set target.move-to-nearest-code off\"")
self.expect("\^done")
- line = line_number('main.cpp', '// BP_before_main')
- self.runCmd("-break-insert -f main.cpp:%d" % line)
+ line_decl = line_number('main.cpp', '// BP_main_decl')
+ line_in = line_number('main.cpp', '// BP_in_main')
+ self.runCmd("-break-insert -f main.cpp:%d" % line_in)
self.expect("\^done,bkpt={number=\"1\"")
# Test that non-pending BP will not be set on non-existing line if target.move-to-nearest-code=off
# Note: this increases the BP number by 1 even though BP #2 is invalid.
- self.runCmd("-break-insert main.cpp:%d" % line)
+ self.runCmd("-break-insert main.cpp:%d" % line_in)
self.expect(
"\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" %
- line)
+ line_in)
# Set target.move-to-nearest-code=on and target.skip-prologue=on and
- # set BP #3
+ # set BP #3 & #4
self.runCmd(
"-interpreter-exec console \"settings set target.move-to-nearest-code on\"")
self.runCmd(
"-interpreter-exec console \"settings set target.skip-prologue on\"")
self.expect("\^done")
- self.runCmd("-break-insert main.cpp:%d" % line)
+ self.runCmd("-break-insert main.cpp:%d" % line_in)
self.expect("\^done,bkpt={number=\"3\"")
+ self.runCmd("-break-insert main.cpp:%d" % line_decl)
+ self.expect("\^done,bkpt={number=\"4\"")
- # Set target.skip-prologue=off and set BP #4
+ # Set target.skip-prologue=off and set BP #5
self.runCmd(
"-interpreter-exec console \"settings set target.skip-prologue off\"")
self.expect("\^done")
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"4\"")
+ self.runCmd("-break-insert main.cpp:%d" % line_decl)
+ self.expect("\^done,bkpt={number=\"5\"")
- # Test that BP #4 is located before BP #3
+ # Test that BP #5 is located before BP #4
self.runCmd("-exec-run")
self.expect("\^running")
self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"5\"")
+
+ # Test that BP #4 is hit
+ self.runCmd("-exec-continue")
+ self.expect("\^running")
+ self.expect(
"\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"4\"")
# Test that BP #3 is hit
@@ -260,7 +275,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect(
"\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
- # Test that the target.language=pascal setting works and that BP #5 is
+ # Test that the target.language=pascal setting works and that BP #6 is
# NOT set
self.runCmd(
"-interpreter-exec console \"settings set target.language c\"")
@@ -268,16 +283,16 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-break-insert ns.foo1")
self.expect("\^error")
- # Test that the target.language=c++ setting works and that BP #6 is hit
+ # Test that the target.language=c++ setting works and that BP #7 is hit
self.runCmd(
"-interpreter-exec console \"settings set target.language c++\"")
self.expect("\^done")
self.runCmd("-break-insert ns::foo1")
- self.expect("\^done,bkpt={number=\"6\"")
+ self.expect("\^done,bkpt={number=\"7\"")
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect(
- "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"7\"")
# Test that BP #1 and #2 weren't set by running to program exit
self.runCmd("-exec-continue")
@@ -286,6 +301,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_enable_disable(self):
"""Test that 'lldb-mi --interpreter' works for enabling / disabling breakpoints."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
index 9416a0d01c7d..366c53c3143f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
@@ -15,13 +15,16 @@ namespace ns
int foo2(void) { printf("In foo2\n"); return 2; }
}
-// BP_before_main
-
int x;
-int
-main(int argc, char const *argv[])
-{
+int main(int argc, char const *argv[]) { // BP_main_decl
printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]);
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // BP_in_main
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
x = ns::foo1() + ns::foo2();
return 0; // BP_return
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
index 2c0de4238c38..b4e90c71721c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -260,7 +260,7 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
# Depending on compiler, it can stop at different line
self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(29|30|31)\"")
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30|31)\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-next-instruction --thread 0")
@@ -382,7 +382,17 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -exec-step-instruction steps into g_MyFunction
# instruction (and that --thread is optional)
- self.runCmd("-exec-step-instruction --frame 0")
+
+ # In case of MIPS, there might be more than one instruction
+ # before actual call instruction (like load, move and call instructions).
+ # The -exec-step-instruction would step one assembly instruction.
+ # Thus we may not enter into g_MyFunction function. The -exec-step would definitely
+ # step into the function.
+
+ if self.isMIPS():
+ self.runCmd("-exec-step --frame 0")
+ else:
+ self.runCmd("-exec-step-instruction --frame 0")
self.expect("\^running")
self.expect(
"\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
index 7281ae305dbe..0b521812384e 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
@@ -77,7 +77,13 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Linux: {address="0x0000000000400642",func-name="hello_world()",offset="18",size="5",inst="callq 0x4004d0; symbol stub for: printf"}
# To match the escaped characters in the ouptut, we must use four backslashes per matches backslash
# See https://docs.python.org/2/howto/regex.html#the-backslash-plague
- self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
+
+ # The MIPS disassembler never prints stub name
+ if self.isMIPS():
+ self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
+ "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?\"}"])
+ else:
+ self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
"{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; symbol stub for: printf\"}"])
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
index 24b3881c1be1..7a28f297a1c8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
@@ -17,6 +17,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
@@ -36,6 +37,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
@@ -59,6 +61,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
@@ -84,6 +87,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_after(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created."""
@@ -109,6 +113,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
@@ -132,6 +137,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
@@ -164,6 +170,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
@@ -189,6 +196,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
index 23da825d591b..2f207928db7d 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
@@ -17,6 +17,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
@@ -37,6 +38,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
@@ -60,6 +62,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux(bugnumber="llvm.org/pr25470")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
@@ -95,6 +98,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~9/600 dosep runs (build 3120-3122)")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_after(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created."""
@@ -138,6 +142,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
@@ -160,6 +165,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
@@ -191,6 +197,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
@@ -216,6 +223,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr25470")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py
new file mode 100644
index 000000000000..a4186fdc4d01
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py
@@ -0,0 +1,68 @@
+"""
+Test lldb-mi -stack-list-locals -stack-list-variables and -var-create commands
+for variables with the same name in sibling lexical scopes.
+"""
+
+from __future__ import print_function
+
+
+import lldbmi_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiLexicalScopeTestCase(lldbmi_testcase.MiTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
+ def test_lldbmi_var_create_in_sibling_scope(self):
+ """Test that 'lldb-mi --interpreter' works with sibling lexical scopes."""
+
+ self.spawnLldbMi(args=None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Breakpoint inside first scope
+ line = line_number('main.cpp', '// BP_first')
+ self.runCmd("-break-insert --file main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"\d+\"")
+
+ # Breakpoint inside second scope
+ line = line_number('main.cpp', '// BP_second')
+ self.runCmd("-break-insert --file main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"\d+\"")
+
+ # Run to the first scope
+ self.runCmd("-exec-run")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Check that only variables a and b exist with expected values
+ self.runCmd("-stack-list-locals --thread 1 --frame 0 --all-values")
+ self.expect("\^done,locals=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"2\"}\]")
+
+ # Create variable object for local variable b
+ self.runCmd("-var-create - * \"b\"")
+ self.expect(
+ "\^done,name=\"var\d+\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+
+ # Run to the second scope
+ self.runCmd("-exec-continue")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Check that only variables a and b exist with expected values,
+ # but variable b is different from previous breakpoint
+ self.runCmd("-stack-list-variables --thread 1 --frame 0 --all-values")
+ self.expect("\^done,variables=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"3\"}\]")
+
+ # Create variable object for local variable b
+ self.runCmd("-var-create - * \"b\"")
+ self.expect(
+ "\^done,name=\"var\d+\",numchild=\"0\",value=\"3\",type=\"short\",thread-id=\"1\",has_more=\"0\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp
new file mode 100644
index 000000000000..b9a7bff37af1
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp
@@ -0,0 +1,33 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+void
+some_func (void)
+{
+}
+
+void test_sibling_scope (void)
+{
+ int a = 1;
+ {
+ int b = 2;
+ some_func(); // BP_first
+ }
+ {
+ short b = 3;
+ some_func(); // BP_second
+ }
+}
+
+int
+main (int argc, char **argv)
+{
+ test_sibling_scope();
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
index e4cd98b22928..597969dd6c53 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
@@ -17,6 +17,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_interrupt(self):
"""Test that 'lldb-mi --interpreter' interrupt and resume a looping app."""
@@ -56,6 +57,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_stopatentry_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (local)."""
@@ -88,6 +90,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipUnlessDarwin
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_stopatentry_remote(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote)."""
@@ -134,6 +137,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_segfault_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped when segfault occurred (local)."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
index 23374330ba1f..6ac9bf813563 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
@@ -17,6 +17,7 @@ class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
oslist=["linux"],
bugnumber="new failure after r256863")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
index 8e45c95927ba..93f599317c6c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -18,6 +18,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_tokens(self):
"""Test that 'lldb-mi --interpreter' prints command tokens."""
@@ -41,6 +42,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_specialchars(self):
"""Test that 'lldb-mi --interpreter' handles complicated strings."""
@@ -66,6 +68,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~6/600 dosep runs (build 3120-3122)")
@@ -88,6 +91,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(oslist=["macosx"], bugnumber="rdar://28805064")
def test_lldbmi_output_grammar(self):
"""Test that 'lldb-mi --interpreter' uses standard output syntax."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
index 31a05ff402ed..137408a2bd2b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
@@ -17,6 +17,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_wait_for(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor."""
@@ -59,6 +60,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_name(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name>."""
@@ -95,6 +97,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_pid(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach <pid>."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
index 729674e6e111..f9830e6d2024 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
@@ -16,6 +16,7 @@ class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # pthreads not supported on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_info(self):
"""Test that -thread-info prints thread info and the current-thread-id"""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
index 61d54cab055a..4384c79fc845 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
@@ -34,6 +34,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_char_array_as_string(self):
"""Test that 'lldb-mi --interpreter' can print array of chars as string."""
@@ -173,6 +174,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_expand_aggregates(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
@@ -247,6 +249,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_aggregate_field_names(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
index b76b59ab97e3..d4685d39791a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
@@ -17,6 +17,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_eval(self):
"""Test that 'lldb-mi --interpreter' works for evaluating."""
@@ -158,6 +159,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_update(self):
"""Test that 'lldb-mi --interpreter' works for -var-update."""
@@ -227,6 +229,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_register(self):
"""Test that 'lldb-mi --interpreter' works for -var-create $regname."""
@@ -270,6 +273,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_list_children(self):
"""Test that 'lldb-mi --interpreter' works for -var-list-children."""
@@ -389,6 +393,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_for_stl_types(self):
"""Test that 'lldb-mi --interpreter' print summary for STL types."""
@@ -414,6 +419,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_for_unnamed_objects(self):
"""Test that 'lldb-mi --interpreter' can expand unnamed structures and unions."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format b/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format
new file mode 100644
index 000000000000..9b3aa8b7213b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format
@@ -0,0 +1 @@
+BasedOnStyle: LLVM
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
index 5089ee85773f..5089ee85773f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
index 57d4d5ab4bb1..b361b9e6d915 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
@@ -1,11 +1,13 @@
from __future__ import print_function
+import json
+import re
+
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-
class TestGdbRemoteThreadsInStopReply(
gdbremote_testcase.GdbRemoteTestCaseBase):
@@ -16,7 +18,8 @@ class TestGdbRemoteThreadsInStopReply(
"send packet: $OK#00",
]
- def gather_stop_reply_threads(self, post_startup_log_lines, thread_count):
+ def gather_stop_reply_fields(self, post_startup_log_lines, thread_count,
+ field_names):
# Set up the inferior args.
inferior_args = []
for i in range(thread_count - 1):
@@ -25,6 +28,9 @@ class TestGdbRemoteThreadsInStopReply(
procs = self.prep_debug_monitor_and_inferior(
inferior_args=inferior_args)
+ self.add_register_info_collection_packets()
+ self.add_process_info_collection_packets()
+
# Assumes test_sequence has anything added needed to setup the initial state.
# (Like optionally enabling QThreadsInStopReply.)
if post_startup_log_lines:
@@ -34,6 +40,7 @@ class TestGdbRemoteThreadsInStopReply(
], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
+ hw_info = self.parse_hw_info(context)
# Give threads time to start up, then break.
time.sleep(1)
@@ -77,14 +84,89 @@ class TestGdbRemoteThreadsInStopReply(
kv_dict = self.parse_key_val_dict(key_vals_text)
self.assertIsNotNone(kv_dict)
+ result = dict();
+ result["pc_register"] = hw_info["pc_register"]
+ result["little_endian"] = hw_info["little_endian"]
+ for key_field in field_names:
+ result[key_field] = kv_dict.get(key_field)
+
+ return result
+
+ def gather_stop_reply_threads(self, post_startup_log_lines, thread_count):
# Pull out threads from stop response.
- stop_reply_threads_text = kv_dict.get("threads")
+ stop_reply_threads_text = self.gather_stop_reply_fields(
+ post_startup_log_lines, thread_count, ["threads"])["threads"]
if stop_reply_threads_text:
return [int(thread_id, 16)
for thread_id in stop_reply_threads_text.split(",")]
else:
return []
+ def gather_stop_reply_pcs(self, post_startup_log_lines, thread_count):
+ results = self.gather_stop_reply_fields( post_startup_log_lines,
+ thread_count, ["threads", "thread-pcs"])
+ if not results:
+ return []
+
+ threads_text = results["threads"]
+ pcs_text = results["thread-pcs"]
+ thread_ids = threads_text.split(",")
+ pcs = pcs_text.split(",")
+ self.assertTrue(len(thread_ids) == len(pcs))
+
+ thread_pcs = dict()
+ for i in range(0, len(pcs)):
+ thread_pcs[int(thread_ids[i], 16)] = pcs[i]
+
+ result = dict()
+ result["thread_pcs"] = thread_pcs
+ result["pc_register"] = results["pc_register"]
+ result["little_endian"] = results["little_endian"]
+ return result
+
+ def switch_endian(self, egg):
+ return "".join(reversed(re.findall("..", egg)))
+
+ def parse_hw_info(self, context):
+ self.assertIsNotNone(context)
+ process_info = self.parse_process_info_response(context)
+ endian = process_info.get("endian")
+ reg_info = self.parse_register_info_packets(context)
+ (pc_lldb_reg_index, pc_reg_info) = self.find_pc_reg_info(reg_info)
+
+ hw_info = dict()
+ hw_info["pc_register"] = pc_lldb_reg_index
+ hw_info["little_endian"] = (endian == "little")
+ return hw_info
+
+ def gather_threads_info_pcs(self, pc_register, little_endian):
+ self.reset_test_sequence()
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: $jThreadsInfo#c1",
+ {
+ "direction": "send",
+ "regex": r"^\$(.*)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "threads_info"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+ threads_info = context.get("threads_info")
+ register = str(pc_register)
+ # The jThreadsInfo response is not valid JSON data, so we have to
+ # clean it up first.
+ jthreads_info = json.loads(re.sub(r"}]", "}", threads_info))
+ thread_pcs = dict()
+ for thread_info in jthreads_info:
+ tid = thread_info["tid"]
+ pc = thread_info["registers"][register]
+ thread_pcs[tid] = self.switch_endian(pc) if little_endian else pc
+
+ return thread_pcs
+
def QListThreadsInStopReply_supported(self):
procs = self.prep_debug_monitor_and_inferior()
self.test_sequence.add_log_lines(
@@ -183,3 +265,34 @@ class TestGdbRemoteThreadsInStopReply(
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_correct_threads(5)
+
+ def stop_reply_contains_thread_pcs(self, thread_count):
+ results = self.gather_stop_reply_pcs(
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
+ stop_reply_pcs = results["thread_pcs"]
+ pc_register = results["pc_register"]
+ little_endian = results["little_endian"]
+ self.assertEqual(len(stop_reply_pcs), thread_count)
+
+ threads_info_pcs = self.gather_threads_info_pcs(pc_register,
+ little_endian)
+
+ self.assertEqual(len(threads_info_pcs), thread_count)
+ for thread_id in stop_reply_pcs:
+ self.assertTrue(thread_id in threads_info_pcs)
+ self.assertTrue(int(stop_reply_pcs[thread_id], 16)
+ == int(threads_info_pcs[thread_id], 16))
+
+ @llgs_test
+ def test_stop_reply_contains_thread_pcs_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ self.stop_reply_contains_thread_pcs(5)
+
+ @debugserver_test
+ def test_stop_reply_contains_thread_pcs_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ self.stop_reply_contains_thread_pcs(5)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
index b69ac3f8d2a3..6f36fbea470b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -1082,7 +1082,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
- def software_breakpoint_set_and_remove_work(self):
+ def breakpoint_set_and_remove_work(self, want_hardware=False):
# Start up the inferior.
procs = self.prep_debug_monitor_and_inferior(
inferior_args=[
@@ -1126,15 +1126,27 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.assertIsNotNone(context.get("function_address"))
function_address = int(context.get("function_address"), 16)
+ # Get current target architecture
+ target_arch = self.getArchitecture()
+
# Set the breakpoint.
- if self.getArchitecture() == "arm":
+ if (target_arch == "arm") or (target_arch == "aarch64"):
# TODO: Handle case when setting breakpoint in thumb code
BREAKPOINT_KIND = 4
else:
BREAKPOINT_KIND = 1
+
+ # Set default packet type to Z0 (software breakpoint)
+ z_packet_type = 0
+
+ # If hardware breakpoint is requested set packet type to Z1
+ if want_hardware == True:
+ z_packet_type = 1
+
self.reset_test_sequence()
self.add_set_breakpoint_packets(
function_address,
+ z_packet_type,
do_continue=True,
breakpoint_kind=BREAKPOINT_KIND)
@@ -1182,13 +1194,15 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
# Verify that a breakpoint remove and continue gets us the expected
# output.
self.reset_test_sequence()
+
+ # Add breakpoint remove packets
+ self.add_remove_breakpoint_packets(
+ function_address,
+ z_packet_type,
+ breakpoint_kind=BREAKPOINT_KIND)
+
self.test_sequence.add_log_lines(
[
- # Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(
- function_address, BREAKPOINT_KIND),
- # Verify the stub could unset it.
- "send packet: $OK#00",
# Continue running.
"read packet: $c#63",
# We should now receive the output from the call.
@@ -1209,7 +1223,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
else:
self.build()
self.set_inferior_startup_launch()
- self.software_breakpoint_set_and_remove_work()
+ self.breakpoint_set_and_remove_work(want_hardware=False)
@llgs_test
@expectedFlakeyLinux("llvm.org/pr25652")
@@ -1221,7 +1235,35 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
else:
self.build()
self.set_inferior_startup_launch()
- self.software_breakpoint_set_and_remove_work()
+ self.breakpoint_set_and_remove_work(want_hardware=False)
+
+ @debugserver_test
+ @skipUnlessPlatform(oslist=['linux'])
+ @expectedFailureAndroid
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hardware_breakpoint_set_and_remove_work_debugserver(self):
+ self.init_debugserver_test()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
+ self.set_inferior_startup_launch()
+ self.breakpoint_set_and_remove_work(want_hardware=True)
+
+ @llgs_test
+ @skipUnlessPlatform(oslist=['linux'])
+ @expectedFailureAndroid
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hardware_breakpoint_set_and_remove_work_llgs(self):
+ self.init_llgs_test()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
+ self.set_inferior_startup_launch()
+ self.breakpoint_set_and_remove_work(want_hardware=True)
def qSupported_returns_known_stub_features(self):
# Start up the stub and start/prep the inferior.
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
index b97c6ebc18e3..a3691a8d42b9 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
@@ -15,22 +15,24 @@
#if defined(__APPLE__)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-int pthread_threadid_np(pthread_t,__uint64_t*);
+int pthread_threadid_np(pthread_t, __uint64_t *);
#elif defined(__linux__)
#include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
#endif
-static const char *const RETVAL_PREFIX = "retval:";
-static const char *const SLEEP_PREFIX = "sleep:";
-static const char *const STDERR_PREFIX = "stderr:";
-static const char *const SET_MESSAGE_PREFIX = "set-message:";
-static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
-static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
-static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
-static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
+static const char *const RETVAL_PREFIX = "retval:";
+static const char *const SLEEP_PREFIX = "sleep:";
+static const char *const STDERR_PREFIX = "stderr:";
+static const char *const SET_MESSAGE_PREFIX = "set-message:";
+static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
+static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
+static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
+static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
-static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
-static const char *const CALL_FUNCTION_PREFIX = "call-function:";
+static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
+static const char *const CALL_FUNCTION_PREFIX = "call-function:";
static const char *const THREAD_PREFIX = "thread:";
static const char *const THREAD_COMMAND_NEW = "new";
@@ -50,342 +52,304 @@ static char g_message[256];
static volatile char g_c1 = '0';
static volatile char g_c2 = '1';
-static void
-print_thread_id ()
-{
- // Put in the right magic here for your platform to spit out the thread id (tid) that debugserver/lldb-gdbserver would see as a TID.
- // Otherwise, let the else clause print out the unsupported text so that the unit test knows to skip verifying thread ids.
+static void print_thread_id() {
+// Put in the right magic here for your platform to spit out the thread id (tid)
+// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
+// clause print out the unsupported text so that the unit test knows to skip
+// verifying thread ids.
#if defined(__APPLE__)
- __uint64_t tid = 0;
- pthread_threadid_np(pthread_self(), &tid);
- printf ("%" PRIx64, tid);
-#elif defined (__linux__)
- // This is a call to gettid() via syscall.
- printf ("%" PRIx64, static_cast<uint64_t> (syscall (__NR_gettid)));
+ __uint64_t tid = 0;
+ pthread_threadid_np(pthread_self(), &tid);
+ printf("%" PRIx64, tid);
+#elif defined(__linux__)
+ // This is a call to gettid() via syscall.
+ printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+ // Technically lwpid_t is 32-bit signed integer
+ printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
#else
- printf("{no-tid-support}");
+ printf("{no-tid-support}");
#endif
}
-static void
-signal_handler (int signo)
-{
- const char *signal_name = nullptr;
- switch (signo)
- {
- case SIGUSR1: signal_name = "SIGUSR1"; break;
- case SIGSEGV: signal_name = "SIGSEGV"; break;
- default: signal_name = nullptr;
- }
-
- // Print notice that we received the signal on a given thread.
- pthread_mutex_lock (&g_print_mutex);
- if (signal_name)
- printf ("received %s on thread id: ", signal_name);
- else
- printf ("received signo %d (%s) on thread id: ", signo, strsignal (signo));
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
-
- // Reset the signal handler if we're one of the expected signal handlers.
- switch (signo)
- {
- case SIGSEGV:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This needs to happen if nothing intercepts the SIGSEGV
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- case SIGUSR1:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This is used to test gdb remote signal delivery.
- // A SIGSEGV will be raised when the thread is created, switched out for a SIGUSR1, and
- // then this code still needs to fix the seg fault.
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- }
-
- // Reset the signal handler.
- sig_t sig_result = signal (signo, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
- exit (1);
- }
+static void signal_handler(int signo) {
+ const char *signal_name = nullptr;
+ switch (signo) {
+ case SIGUSR1:
+ signal_name = "SIGUSR1";
+ break;
+ case SIGSEGV:
+ signal_name = "SIGSEGV";
+ break;
+ default:
+ signal_name = nullptr;
+ }
+
+ // Print notice that we received the signal on a given thread.
+ pthread_mutex_lock(&g_print_mutex);
+ if (signal_name)
+ printf("received %s on thread id: ", signal_name);
+ else
+ printf("received signo %d (%s) on thread id: ", signo, strsignal(signo));
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+
+ // Reset the signal handler if we're one of the expected signal handlers.
+ switch (signo) {
+ case SIGSEGV:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This needs to happen if nothing
+ // intercepts the SIGSEGV (i.e. if somebody runs this from the command
+ // line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ case SIGUSR1:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This is used to test gdb remote
+ // signal delivery. A SIGSEGV will be raised when the thread is created,
+ // switched out for a SIGUSR1, and then this code still needs to fix the
+ // seg fault. (i.e. if somebody runs this from the command line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ }
+
+ // Reset the signal handler.
+ sig_t sig_result = signal(signo, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
+ exit(1);
+ }
}
-static void
-swap_chars ()
-{
- g_c1 = '1';
- g_c2 = '0';
+static void swap_chars() {
+ g_c1 = '1';
+ g_c2 = '0';
- g_c1 = '0';
- g_c2 = '1';
+ g_c1 = '0';
+ g_c2 = '1';
}
-static void
-hello ()
-{
- pthread_mutex_lock (&g_print_mutex);
- printf ("hello, world\n");
- pthread_mutex_unlock (&g_print_mutex);
+static void hello() {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("hello, world\n");
+ pthread_mutex_unlock(&g_print_mutex);
}
-static void*
-thread_func (void *arg)
-{
- static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
- static int s_thread_index = 1;
-
- pthread_mutex_lock (&s_thread_index_mutex);
- const int this_thread_index = s_thread_index++;
- pthread_mutex_unlock (&s_thread_index_mutex);
-
- if (g_print_thread_ids)
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread %d id: ", this_thread_index);
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- if (g_threads_do_segfault)
- {
- // Sleep for a number of seconds based on the thread index.
- // TODO add ability to send commands to test exe so we can
- // handle timing more precisely. This is clunky. All we're
- // trying to do is add predictability as to the timing of
- // signal generation by created threads.
- int sleep_seconds = 2 * (this_thread_index - 1);
- while (sleep_seconds > 0)
- sleep_seconds = sleep(sleep_seconds);
-
- // Test creating a SEGV.
- pthread_mutex_lock (&g_jump_buffer_mutex);
- g_is_segfaulting = true;
- int *bad_p = nullptr;
- if (setjmp(g_jump_buffer) == 0)
- {
- // Force a seg fault signal on this thread.
- *bad_p = 0;
- }
- else
- {
- // Tell the system we're no longer seg faulting.
- // Used by the SIGUSR1 signal handler that we inject
- // in place of the SIGSEGV so it only tries to
- // recover from the SIGSEGV if this seg fault code
- // was in play.
- g_is_segfaulting = false;
- }
- pthread_mutex_unlock (&g_jump_buffer_mutex);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread ");
- print_thread_id ();
- printf (": past SIGSEGV\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- int sleep_seconds_remaining = 60;
- while (sleep_seconds_remaining > 0)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- }
-
- return nullptr;
+static void *thread_func(void *arg) {
+ static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static int s_thread_index = 1;
+
+ pthread_mutex_lock(&s_thread_index_mutex);
+ const int this_thread_index = s_thread_index++;
+ pthread_mutex_unlock(&s_thread_index_mutex);
+
+ if (g_print_thread_ids) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread %d id: ", this_thread_index);
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ if (g_threads_do_segfault) {
+ // Sleep for a number of seconds based on the thread index.
+ // TODO add ability to send commands to test exe so we can
+ // handle timing more precisely. This is clunky. All we're
+ // trying to do is add predictability as to the timing of
+ // signal generation by created threads.
+ int sleep_seconds = 2 * (this_thread_index - 1);
+ while (sleep_seconds > 0)
+ sleep_seconds = sleep(sleep_seconds);
+
+ // Test creating a SEGV.
+ pthread_mutex_lock(&g_jump_buffer_mutex);
+ g_is_segfaulting = true;
+ int *bad_p = nullptr;
+ if (setjmp(g_jump_buffer) == 0) {
+ // Force a seg fault signal on this thread.
+ *bad_p = 0;
+ } else {
+ // Tell the system we're no longer seg faulting.
+ // Used by the SIGUSR1 signal handler that we inject
+ // in place of the SIGSEGV so it only tries to
+ // recover from the SIGSEGV if this seg fault code
+ // was in play.
+ g_is_segfaulting = false;
+ }
+ pthread_mutex_unlock(&g_jump_buffer_mutex);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread ");
+ print_thread_id();
+ printf(": past SIGSEGV\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ int sleep_seconds_remaining = 60;
+ while (sleep_seconds_remaining > 0) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ }
+
+ return nullptr;
}
-int main (int argc, char **argv)
-{
- lldb_enable_attach();
-
- std::vector<pthread_t> threads;
- std::unique_ptr<uint8_t[]> heap_array_up;
- int return_value = 0;
-
- // Set the signal handler.
- sig_t sig_result = signal (SIGALRM, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGUSR1, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGSEGV, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- if (std::strstr (argv[i], STDERR_PREFIX))
- {
- // Treat remainder as text to go to stderr.
- fprintf (stderr, "%s\n", (argv[i] + strlen (STDERR_PREFIX)));
- }
- else if (std::strstr (argv[i], RETVAL_PREFIX))
- {
- // Treat as the return value for the program.
- return_value = std::atoi (argv[i] + strlen (RETVAL_PREFIX));
- }
- else if (std::strstr (argv[i], SLEEP_PREFIX))
- {
- // Treat as the amount of time to have this process sleep (in seconds).
- int sleep_seconds_remaining = std::atoi (argv[i] + strlen (SLEEP_PREFIX));
-
- // Loop around, sleeping until all sleep time is used up. Note that
- // signals will cause sleep to end early with the number of seconds remaining.
- for (int i = 0; sleep_seconds_remaining > 0; ++i)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- // std::cout << "sleep result (call " << i << "): " << sleep_seconds_remaining << std::endl;
- }
- }
- else if (std::strstr (argv[i], SET_MESSAGE_PREFIX))
- {
- // Copy the contents after "set-message:" to the g_message buffer.
- // Used for reading inferior memory and verifying contents match expectations.
- strncpy (g_message, argv[i] + strlen (SET_MESSAGE_PREFIX), sizeof (g_message));
-
- // Ensure we're null terminated.
- g_message[sizeof (g_message) - 1] = '\0';
-
- }
- else if (std::strstr (argv[i], PRINT_MESSAGE_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("message: %s\n", g_message);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_DATA_ADDRESS_PREFIX))
- {
- volatile void *data_p = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_message"))
- data_p = &g_message[0];
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c1"))
- data_p = &g_c1;
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c2"))
- data_p = &g_c2;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("data address: %p\n", data_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_HEAP_ADDRESS_COMMAND))
- {
- // Create a byte array if not already present.
- if (!heap_array_up)
- heap_array_up.reset (new uint8_t[32]);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("heap address: %p\n", heap_array_up.get ());
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_STACK_ADDRESS_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("stack address: %p\n", &return_value);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_CODE_ADDRESS_PREFIX))
- {
- void (*func_p)() = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "hello"))
- func_p = hello;
- else if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "swap_chars"))
- func_p = swap_chars;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("code address: %p\n", func_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], CALL_FUNCTION_PREFIX))
- {
- // Defaut to providing the address of main.
- if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
- else if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "swap_chars") == 0)
- swap_chars();
- else
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("unknown function: %s\n", argv[i] + strlen (CALL_FUNCTION_PREFIX));
- pthread_mutex_unlock (&g_print_mutex);
- }
- }
- else if (std::strstr (argv[i], THREAD_PREFIX))
- {
- // Check if we're creating a new thread.
- if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW))
- {
- // Create a new thread.
- pthread_t new_thread;
- const int err = ::pthread_create (&new_thread, nullptr, thread_func, nullptr);
- if (err)
- {
- fprintf (stderr, "pthread_create() failed with error code %d\n", err);
- exit (err);
- }
- threads.push_back (new_thread);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_PRINT_IDS))
- {
- // Turn on thread id announcing.
- g_print_thread_ids = true;
-
- // And announce us.
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread 0 id: ");
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_SEGFAULT))
- {
- g_threads_do_segfault = true;
- }
- else
- {
- // At this point we don't do anything else with threads.
- // Later use thread index and send command to thread.
- }
- }
- else
- {
- // Treat the argument as text for stdout.
- printf("%s\n", argv[i]);
+int main(int argc, char **argv) {
+ lldb_enable_attach();
+
+ std::vector<pthread_t> threads;
+ std::unique_ptr<uint8_t[]> heap_array_up;
+ int return_value = 0;
+
+ // Set the signal handler.
+ sig_t sig_result = signal(SIGALRM, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGUSR1, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGSEGV, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ if (std::strstr(argv[i], STDERR_PREFIX)) {
+ // Treat remainder as text to go to stderr.
+ fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX)));
+ } else if (std::strstr(argv[i], RETVAL_PREFIX)) {
+ // Treat as the return value for the program.
+ return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX));
+ } else if (std::strstr(argv[i], SLEEP_PREFIX)) {
+ // Treat as the amount of time to have this process sleep (in seconds).
+ int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX));
+
+ // Loop around, sleeping until all sleep time is used up. Note that
+ // signals will cause sleep to end early with the number of seconds
+ // remaining.
+ for (int i = 0; sleep_seconds_remaining > 0; ++i) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ // std::cout << "sleep result (call " << i << "): " <<
+ // sleep_seconds_remaining << std::endl;
+ }
+ } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) {
+ // Copy the contents after "set-message:" to the g_message buffer.
+ // Used for reading inferior memory and verifying contents match
+ // expectations.
+ strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX),
+ sizeof(g_message));
+
+ // Ensure we're null terminated.
+ g_message[sizeof(g_message) - 1] = '\0';
+
+ } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("message: %s\n", g_message);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) {
+ volatile void *data_p = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message"))
+ data_p = &g_message[0];
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1"))
+ data_p = &g_c1;
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2"))
+ data_p = &g_c2;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("data address: %p\n", data_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) {
+ // Create a byte array if not already present.
+ if (!heap_array_up)
+ heap_array_up.reset(new uint8_t[32]);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("heap address: %p\n", heap_array_up.get());
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("stack address: %p\n", &return_value);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) {
+ void (*func_p)() = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello"))
+ func_p = hello;
+ else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX),
+ "swap_chars"))
+ func_p = swap_chars;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("code address: %p\n", func_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
+ // Defaut to providing the address of main.
+ if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
+ hello();
+ else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
+ "swap_chars") == 0)
+ swap_chars();
+ else {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("unknown function: %s\n",
+ argv[i] + strlen(CALL_FUNCTION_PREFIX));
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+ } else if (std::strstr(argv[i], THREAD_PREFIX)) {
+ // Check if we're creating a new thread.
+ if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
+ // Create a new thread.
+ pthread_t new_thread;
+ const int err =
+ ::pthread_create(&new_thread, nullptr, thread_func, nullptr);
+ if (err) {
+ fprintf(stderr, "pthread_create() failed with error code %d\n", err);
+ exit(err);
}
+ threads.push_back(new_thread);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_PRINT_IDS)) {
+ // Turn on thread id announcing.
+ g_print_thread_ids = true;
+
+ // And announce us.
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread 0 id: ");
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_SEGFAULT)) {
+ g_threads_do_segfault = true;
+ } else {
+ // At this point we don't do anything else with threads.
+ // Later use thread index and send command to thread.
+ }
+ } else {
+ // Treat the argument as text for stdout.
+ printf("%s\n", argv[i]);
}
-
- // If we launched any threads, join them
- for (std::vector<pthread_t>::iterator it = threads.begin (); it != threads.end (); ++it)
- {
- void *thread_retval = nullptr;
- const int err = ::pthread_join (*it, &thread_retval);
- if (err != 0)
- fprintf (stderr, "pthread_join() failed with error code %d\n", err);
- }
-
- return return_value;
+ }
+
+ // If we launched any threads, join them
+ for (std::vector<pthread_t>::iterator it = threads.begin();
+ it != threads.end(); ++it) {
+ void *thread_retval = nullptr;
+ const int err = ::pthread_join(*it, &thread_retval);
+ if (err != 0)
+ fprintf(stderr, "pthread_join() failed with error code %d\n", err);
+ }
+
+ return return_value;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index ef6a0a21aaeb..23cb86935857 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -883,12 +883,13 @@ class GdbRemoteTestCaseBase(TestBase):
def add_set_breakpoint_packets(
self,
address,
+ z_packet_type=0,
do_continue=True,
breakpoint_kind=1):
self.test_sequence.add_log_lines(
[ # Set the breakpoint.
- "read packet: $Z0,{0:x},{1}#00".format(
- address, breakpoint_kind),
+ "read packet: $Z{2},{0:x},{1}#00".format(
+ address, breakpoint_kind, z_packet_type),
# Verify the stub could set it.
"send packet: $OK#00",
], True)
@@ -904,11 +905,15 @@ class GdbRemoteTestCaseBase(TestBase):
2: "stop_thread_id"}},
], True)
- def add_remove_breakpoint_packets(self, address, breakpoint_kind=1):
+ def add_remove_breakpoint_packets(
+ self,
+ address,
+ z_packet_type=0,
+ breakpoint_kind=1):
self.test_sequence.add_log_lines(
[ # Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(
- address, breakpoint_kind),
+ "read packet: $z{2},{0:x},{1}#00".format(
+ address, breakpoint_kind, z_packet_type),
# Verify the stub could unset it.
"send packet: $OK#00",
], True)
@@ -929,7 +934,8 @@ class GdbRemoteTestCaseBase(TestBase):
"qXfer:libraries:read",
"qXfer:libraries-svr4:read",
"qXfer:features:read",
- "qEcho"
+ "qEcho",
+ "QPassSignals"
]
def parse_qSupported_response(self, context):
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
index 69d60071aa45..ced7f7125088 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
@@ -2,38 +2,30 @@
#include <cstring>
#include <iostream>
-namespace
-{
- const char *const SEGFAULT_COMMAND = "segfault";
- const char *const ABORT_COMMAND = "abort";
+namespace {
+const char *const SEGFAULT_COMMAND = "segfault";
+const char *const ABORT_COMMAND = "abort";
}
-int main (int argc, char **argv)
-{
- if (argc < 2)
- {
- std::cout << "expected at least one command provided on the command line" << std::endl;
- }
+int main(int argc, char **argv) {
+ if (argc < 2) {
+ std::cout << "expected at least one command provided on the command line"
+ << std::endl;
+ }
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- const char *const command = argv[i];
- if (std::strstr (command, SEGFAULT_COMMAND))
- {
- // Perform a null pointer access.
- int *const null_int_ptr = nullptr;
- *null_int_ptr = 0xDEAD;
- }
- else if (std::strstr (command, ABORT_COMMAND))
- {
- std::abort();
- }
- else
- {
- std::cout << "Unsupported command: " << command << std::endl;
- }
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ const char *const command = argv[i];
+ if (std::strstr(command, SEGFAULT_COMMAND)) {
+ // Perform a null pointer access.
+ int *const null_int_ptr = nullptr;
+ *null_int_ptr = 0xDEAD;
+ } else if (std::strstr(command, ABORT_COMMAND)) {
+ std::abort();
+ } else {
+ std::cout << "Unsupported command: " << command << std::endl;
}
+ }
- return 0;
+ return 0;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
index b97c6ebc18e3..a574b41abf67 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -1,3 +1,12 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
#include <cstdlib>
#include <cstring>
#include <errno.h>
@@ -15,22 +24,24 @@
#if defined(__APPLE__)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-int pthread_threadid_np(pthread_t,__uint64_t*);
+int pthread_threadid_np(pthread_t, __uint64_t *);
#elif defined(__linux__)
#include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
#endif
-static const char *const RETVAL_PREFIX = "retval:";
-static const char *const SLEEP_PREFIX = "sleep:";
-static const char *const STDERR_PREFIX = "stderr:";
-static const char *const SET_MESSAGE_PREFIX = "set-message:";
-static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
-static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
-static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
-static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
+static const char *const RETVAL_PREFIX = "retval:";
+static const char *const SLEEP_PREFIX = "sleep:";
+static const char *const STDERR_PREFIX = "stderr:";
+static const char *const SET_MESSAGE_PREFIX = "set-message:";
+static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
+static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
+static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
+static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
-static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
-static const char *const CALL_FUNCTION_PREFIX = "call-function:";
+static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
+static const char *const CALL_FUNCTION_PREFIX = "call-function:";
static const char *const THREAD_PREFIX = "thread:";
static const char *const THREAD_COMMAND_NEW = "new";
@@ -50,342 +61,304 @@ static char g_message[256];
static volatile char g_c1 = '0';
static volatile char g_c2 = '1';
-static void
-print_thread_id ()
-{
- // Put in the right magic here for your platform to spit out the thread id (tid) that debugserver/lldb-gdbserver would see as a TID.
- // Otherwise, let the else clause print out the unsupported text so that the unit test knows to skip verifying thread ids.
+static void print_thread_id() {
+// Put in the right magic here for your platform to spit out the thread id (tid)
+// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
+// clause print out the unsupported text so that the unit test knows to skip
+// verifying thread ids.
#if defined(__APPLE__)
- __uint64_t tid = 0;
- pthread_threadid_np(pthread_self(), &tid);
- printf ("%" PRIx64, tid);
-#elif defined (__linux__)
- // This is a call to gettid() via syscall.
- printf ("%" PRIx64, static_cast<uint64_t> (syscall (__NR_gettid)));
+ __uint64_t tid = 0;
+ pthread_threadid_np(pthread_self(), &tid);
+ printf("%" PRIx64, tid);
+#elif defined(__linux__)
+ // This is a call to gettid() via syscall.
+ printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+ // Technically lwpid_t is 32-bit signed integer
+ printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
#else
- printf("{no-tid-support}");
+ printf("{no-tid-support}");
#endif
}
-static void
-signal_handler (int signo)
-{
- const char *signal_name = nullptr;
- switch (signo)
- {
- case SIGUSR1: signal_name = "SIGUSR1"; break;
- case SIGSEGV: signal_name = "SIGSEGV"; break;
- default: signal_name = nullptr;
- }
-
- // Print notice that we received the signal on a given thread.
- pthread_mutex_lock (&g_print_mutex);
- if (signal_name)
- printf ("received %s on thread id: ", signal_name);
- else
- printf ("received signo %d (%s) on thread id: ", signo, strsignal (signo));
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
-
- // Reset the signal handler if we're one of the expected signal handlers.
- switch (signo)
- {
- case SIGSEGV:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This needs to happen if nothing intercepts the SIGSEGV
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- case SIGUSR1:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This is used to test gdb remote signal delivery.
- // A SIGSEGV will be raised when the thread is created, switched out for a SIGUSR1, and
- // then this code still needs to fix the seg fault.
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- }
-
- // Reset the signal handler.
- sig_t sig_result = signal (signo, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
- exit (1);
- }
+static void signal_handler(int signo) {
+ const char *signal_name = nullptr;
+ switch (signo) {
+ case SIGUSR1:
+ signal_name = "SIGUSR1";
+ break;
+ case SIGSEGV:
+ signal_name = "SIGSEGV";
+ break;
+ default:
+ signal_name = nullptr;
+ }
+
+ // Print notice that we received the signal on a given thread.
+ pthread_mutex_lock(&g_print_mutex);
+ if (signal_name)
+ printf("received %s on thread id: ", signal_name);
+ else
+ printf("received signo %d (%s) on thread id: ", signo, strsignal(signo));
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+
+ // Reset the signal handler if we're one of the expected signal handlers.
+ switch (signo) {
+ case SIGSEGV:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This needs to happen if nothing
+ // intercepts the SIGSEGV (i.e. if somebody runs this from the command
+ // line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ case SIGUSR1:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This is used to test gdb remote
+ // signal delivery. A SIGSEGV will be raised when the thread is created,
+ // switched out for a SIGUSR1, and then this code still needs to fix the
+ // seg fault. (i.e. if somebody runs this from the command line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ }
+
+ // Reset the signal handler.
+ sig_t sig_result = signal(signo, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
+ exit(1);
+ }
}
-static void
-swap_chars ()
-{
- g_c1 = '1';
- g_c2 = '0';
+static void swap_chars() {
+ g_c1 = '1';
+ g_c2 = '0';
- g_c1 = '0';
- g_c2 = '1';
+ g_c1 = '0';
+ g_c2 = '1';
}
-static void
-hello ()
-{
- pthread_mutex_lock (&g_print_mutex);
- printf ("hello, world\n");
- pthread_mutex_unlock (&g_print_mutex);
+static void hello() {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("hello, world\n");
+ pthread_mutex_unlock(&g_print_mutex);
}
-static void*
-thread_func (void *arg)
-{
- static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
- static int s_thread_index = 1;
-
- pthread_mutex_lock (&s_thread_index_mutex);
- const int this_thread_index = s_thread_index++;
- pthread_mutex_unlock (&s_thread_index_mutex);
-
- if (g_print_thread_ids)
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread %d id: ", this_thread_index);
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- if (g_threads_do_segfault)
- {
- // Sleep for a number of seconds based on the thread index.
- // TODO add ability to send commands to test exe so we can
- // handle timing more precisely. This is clunky. All we're
- // trying to do is add predictability as to the timing of
- // signal generation by created threads.
- int sleep_seconds = 2 * (this_thread_index - 1);
- while (sleep_seconds > 0)
- sleep_seconds = sleep(sleep_seconds);
-
- // Test creating a SEGV.
- pthread_mutex_lock (&g_jump_buffer_mutex);
- g_is_segfaulting = true;
- int *bad_p = nullptr;
- if (setjmp(g_jump_buffer) == 0)
- {
- // Force a seg fault signal on this thread.
- *bad_p = 0;
- }
- else
- {
- // Tell the system we're no longer seg faulting.
- // Used by the SIGUSR1 signal handler that we inject
- // in place of the SIGSEGV so it only tries to
- // recover from the SIGSEGV if this seg fault code
- // was in play.
- g_is_segfaulting = false;
- }
- pthread_mutex_unlock (&g_jump_buffer_mutex);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread ");
- print_thread_id ();
- printf (": past SIGSEGV\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- int sleep_seconds_remaining = 60;
- while (sleep_seconds_remaining > 0)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- }
-
- return nullptr;
+static void *thread_func(void *arg) {
+ static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static int s_thread_index = 1;
+
+ pthread_mutex_lock(&s_thread_index_mutex);
+ const int this_thread_index = s_thread_index++;
+ pthread_mutex_unlock(&s_thread_index_mutex);
+
+ if (g_print_thread_ids) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread %d id: ", this_thread_index);
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ if (g_threads_do_segfault) {
+ // Sleep for a number of seconds based on the thread index.
+ // TODO add ability to send commands to test exe so we can
+ // handle timing more precisely. This is clunky. All we're
+ // trying to do is add predictability as to the timing of
+ // signal generation by created threads.
+ int sleep_seconds = 2 * (this_thread_index - 1);
+ while (sleep_seconds > 0)
+ sleep_seconds = sleep(sleep_seconds);
+
+ // Test creating a SEGV.
+ pthread_mutex_lock(&g_jump_buffer_mutex);
+ g_is_segfaulting = true;
+ int *bad_p = nullptr;
+ if (setjmp(g_jump_buffer) == 0) {
+ // Force a seg fault signal on this thread.
+ *bad_p = 0;
+ } else {
+ // Tell the system we're no longer seg faulting.
+ // Used by the SIGUSR1 signal handler that we inject
+ // in place of the SIGSEGV so it only tries to
+ // recover from the SIGSEGV if this seg fault code
+ // was in play.
+ g_is_segfaulting = false;
+ }
+ pthread_mutex_unlock(&g_jump_buffer_mutex);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread ");
+ print_thread_id();
+ printf(": past SIGSEGV\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ int sleep_seconds_remaining = 60;
+ while (sleep_seconds_remaining > 0) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ }
+
+ return nullptr;
}
-int main (int argc, char **argv)
-{
- lldb_enable_attach();
-
- std::vector<pthread_t> threads;
- std::unique_ptr<uint8_t[]> heap_array_up;
- int return_value = 0;
-
- // Set the signal handler.
- sig_t sig_result = signal (SIGALRM, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGUSR1, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGSEGV, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- if (std::strstr (argv[i], STDERR_PREFIX))
- {
- // Treat remainder as text to go to stderr.
- fprintf (stderr, "%s\n", (argv[i] + strlen (STDERR_PREFIX)));
- }
- else if (std::strstr (argv[i], RETVAL_PREFIX))
- {
- // Treat as the return value for the program.
- return_value = std::atoi (argv[i] + strlen (RETVAL_PREFIX));
- }
- else if (std::strstr (argv[i], SLEEP_PREFIX))
- {
- // Treat as the amount of time to have this process sleep (in seconds).
- int sleep_seconds_remaining = std::atoi (argv[i] + strlen (SLEEP_PREFIX));
-
- // Loop around, sleeping until all sleep time is used up. Note that
- // signals will cause sleep to end early with the number of seconds remaining.
- for (int i = 0; sleep_seconds_remaining > 0; ++i)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- // std::cout << "sleep result (call " << i << "): " << sleep_seconds_remaining << std::endl;
- }
- }
- else if (std::strstr (argv[i], SET_MESSAGE_PREFIX))
- {
- // Copy the contents after "set-message:" to the g_message buffer.
- // Used for reading inferior memory and verifying contents match expectations.
- strncpy (g_message, argv[i] + strlen (SET_MESSAGE_PREFIX), sizeof (g_message));
-
- // Ensure we're null terminated.
- g_message[sizeof (g_message) - 1] = '\0';
-
- }
- else if (std::strstr (argv[i], PRINT_MESSAGE_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("message: %s\n", g_message);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_DATA_ADDRESS_PREFIX))
- {
- volatile void *data_p = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_message"))
- data_p = &g_message[0];
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c1"))
- data_p = &g_c1;
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c2"))
- data_p = &g_c2;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("data address: %p\n", data_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_HEAP_ADDRESS_COMMAND))
- {
- // Create a byte array if not already present.
- if (!heap_array_up)
- heap_array_up.reset (new uint8_t[32]);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("heap address: %p\n", heap_array_up.get ());
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_STACK_ADDRESS_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("stack address: %p\n", &return_value);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_CODE_ADDRESS_PREFIX))
- {
- void (*func_p)() = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "hello"))
- func_p = hello;
- else if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "swap_chars"))
- func_p = swap_chars;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("code address: %p\n", func_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], CALL_FUNCTION_PREFIX))
- {
- // Defaut to providing the address of main.
- if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
- else if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "swap_chars") == 0)
- swap_chars();
- else
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("unknown function: %s\n", argv[i] + strlen (CALL_FUNCTION_PREFIX));
- pthread_mutex_unlock (&g_print_mutex);
- }
- }
- else if (std::strstr (argv[i], THREAD_PREFIX))
- {
- // Check if we're creating a new thread.
- if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW))
- {
- // Create a new thread.
- pthread_t new_thread;
- const int err = ::pthread_create (&new_thread, nullptr, thread_func, nullptr);
- if (err)
- {
- fprintf (stderr, "pthread_create() failed with error code %d\n", err);
- exit (err);
- }
- threads.push_back (new_thread);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_PRINT_IDS))
- {
- // Turn on thread id announcing.
- g_print_thread_ids = true;
-
- // And announce us.
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread 0 id: ");
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_SEGFAULT))
- {
- g_threads_do_segfault = true;
- }
- else
- {
- // At this point we don't do anything else with threads.
- // Later use thread index and send command to thread.
- }
- }
- else
- {
- // Treat the argument as text for stdout.
- printf("%s\n", argv[i]);
+int main(int argc, char **argv) {
+ lldb_enable_attach();
+
+ std::vector<pthread_t> threads;
+ std::unique_ptr<uint8_t[]> heap_array_up;
+ int return_value = 0;
+
+ // Set the signal handler.
+ sig_t sig_result = signal(SIGALRM, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGUSR1, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGSEGV, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ if (std::strstr(argv[i], STDERR_PREFIX)) {
+ // Treat remainder as text to go to stderr.
+ fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX)));
+ } else if (std::strstr(argv[i], RETVAL_PREFIX)) {
+ // Treat as the return value for the program.
+ return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX));
+ } else if (std::strstr(argv[i], SLEEP_PREFIX)) {
+ // Treat as the amount of time to have this process sleep (in seconds).
+ int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX));
+
+ // Loop around, sleeping until all sleep time is used up. Note that
+ // signals will cause sleep to end early with the number of seconds
+ // remaining.
+ for (int i = 0; sleep_seconds_remaining > 0; ++i) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ // std::cout << "sleep result (call " << i << "): " <<
+ // sleep_seconds_remaining << std::endl;
+ }
+ } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) {
+ // Copy the contents after "set-message:" to the g_message buffer.
+ // Used for reading inferior memory and verifying contents match
+ // expectations.
+ strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX),
+ sizeof(g_message));
+
+ // Ensure we're null terminated.
+ g_message[sizeof(g_message) - 1] = '\0';
+
+ } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("message: %s\n", g_message);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) {
+ volatile void *data_p = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message"))
+ data_p = &g_message[0];
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1"))
+ data_p = &g_c1;
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2"))
+ data_p = &g_c2;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("data address: %p\n", data_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) {
+ // Create a byte array if not already present.
+ if (!heap_array_up)
+ heap_array_up.reset(new uint8_t[32]);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("heap address: %p\n", heap_array_up.get());
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("stack address: %p\n", &return_value);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) {
+ void (*func_p)() = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello"))
+ func_p = hello;
+ else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX),
+ "swap_chars"))
+ func_p = swap_chars;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("code address: %p\n", func_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
+ // Defaut to providing the address of main.
+ if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
+ hello();
+ else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
+ "swap_chars") == 0)
+ swap_chars();
+ else {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("unknown function: %s\n",
+ argv[i] + strlen(CALL_FUNCTION_PREFIX));
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+ } else if (std::strstr(argv[i], THREAD_PREFIX)) {
+ // Check if we're creating a new thread.
+ if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
+ // Create a new thread.
+ pthread_t new_thread;
+ const int err =
+ ::pthread_create(&new_thread, nullptr, thread_func, nullptr);
+ if (err) {
+ fprintf(stderr, "pthread_create() failed with error code %d\n", err);
+ exit(err);
}
+ threads.push_back(new_thread);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_PRINT_IDS)) {
+ // Turn on thread id announcing.
+ g_print_thread_ids = true;
+
+ // And announce us.
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread 0 id: ");
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_SEGFAULT)) {
+ g_threads_do_segfault = true;
+ } else {
+ // At this point we don't do anything else with threads.
+ // Later use thread index and send command to thread.
+ }
+ } else {
+ // Treat the argument as text for stdout.
+ printf("%s\n", argv[i]);
}
-
- // If we launched any threads, join them
- for (std::vector<pthread_t>::iterator it = threads.begin (); it != threads.end (); ++it)
- {
- void *thread_retval = nullptr;
- const int err = ::pthread_join (*it, &thread_retval);
- if (err != 0)
- fprintf (stderr, "pthread_join() failed with error code %d\n", err);
- }
-
- return return_value;
+ }
+
+ // If we launched any threads, join them
+ for (std::vector<pthread_t>::iterator it = threads.begin();
+ it != threads.end(); ++it) {
+ void *thread_retval = nullptr;
+ const int err = ::pthread_join(*it, &thread_retval);
+ if (err != 0)
+ fprintf(stderr, "pthread_join() failed with error code %d\n", err);
+ }
+
+ return return_value;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
index 70ae5094fde7..c7ebe0759a40 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
@@ -1,7 +1,6 @@
#include <cstdio>
-int main (int argc, char **argv)
-{
- printf("argc: %d\n", argc);
- return argv[0][0];
+int main(int argc, char **argv) {
+ printf("argc: %d\n", argc);
+ return argv[0][0];
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
new file mode 100644
index 000000000000..7105bcb078bc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
@@ -0,0 +1,115 @@
+# This test makes sure that lldb-server supports and properly handles
+# QPassSignals GDB protocol package.
+from __future__ import print_function
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def expect_signal(self, expected_signo):
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$",
+ "capture": {1: "hex_exit_code"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ hex_exit_code = context.get("hex_exit_code")
+ self.assertIsNotNone(hex_exit_code)
+ self.assertEqual(int(hex_exit_code, 16), expected_signo)
+
+ def expect_exit_code(self, exit_code):
+ self.test_sequence.add_log_lines(
+ ["read packet: $vCont;c#a8",
+ "send packet: $W{0:02x}#00".format(exit_code)],
+ True)
+ self.expect_gdbremote_sequence()
+
+
+ def ignore_signals(self, signals):
+ def signal_name_to_hex(signame):
+ return format(lldbutil.get_signal_number(signame), 'x')
+ signals_str = ";".join(map(signal_name_to_hex, signals))
+
+ self.test_sequence.add_log_lines(["read packet: $QPassSignals:"
+ + signals_str + " #00",
+ "send packet: $OK#00"],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_q_pass_signals(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV",
+ "SIGALRM", "SIGFPE", "SIGBUS", "SIGINT", "SIGHUP"]
+ signals_to_ignore = ["SIGUSR1", "SIGUSR2"]
+ self.ignore_signals(signals_to_ignore)
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ self.expect_exit_code(len(signals_to_ignore))
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_change_signals_at_runtime(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV", "SIGUSR1", "SIGUSR2",
+ "SIGALRM", "SIGHUP"]
+ signals_to_ignore = ["SIGFPE", "SIGBUS", "SIGINT"]
+
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ if signal_name == "SIGALRM":
+ self.ignore_signals(signals_to_ignore)
+ self.expect_exit_code(len(signals_to_ignore))
+
+ @llgs_test
+ def test_default_signals_behavior(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV", "SIGUSR1", "SIGUSR2",
+ "SIGALRM", "SIGFPE", "SIGBUS", "SIGINT", "SIGHUP"]
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ self.expect_exit_code(0)
+
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_support_q_pass_signals(self):
+ self.init_llgs_test()
+ self.build()
+
+ # Start up the stub and start/prep the inferior.
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ self.add_qSupported_packets()
+
+ # Run the packet stream.
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ # Retrieve the qSupported features and check QPassSignals+
+ supported_dict = self.parse_qSupported_response(context)
+ self.assertEqual(supported_dict["QPassSignals"], "+")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp
new file mode 100644
index 000000000000..4991259fe46e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp
@@ -0,0 +1,37 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <signal.h>
+#include <stdio.h>
+#include <vector>
+
+static int signal_counter = 0;
+
+static void count_signal(int signo) {
+ ++signal_counter;
+ printf("Signal %d\n", signo);
+}
+
+static void raise_signals() {
+ std::vector<int> signals(
+ {SIGSEGV, SIGUSR1, SIGUSR2, SIGALRM, SIGFPE, SIGBUS, SIGINT, SIGHUP});
+
+ for (int signal_num : signals) {
+ signal(signal_num, count_signal);
+ }
+
+ for (int signal_num : signals) {
+ raise(signal_num);
+ }
+}
+
+int main() {
+ raise_signals();
+ return signal_counter;
+}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile
index 1370b53b5a67..8817fff55e8c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile
@@ -1,10 +1,6 @@
LEVEL = ../../../make
-VPATH = ..
-
-override CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
ENABLE_THREADS := YES
CXX_SOURCES := main.cpp
-MAKE_DSYM :=NO
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py
new file mode 100644
index 000000000000..5bfcd660c2ac
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py
@@ -0,0 +1,41 @@
+from __future__ import print_function
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestGdbRemoteThreadName(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def run_and_check_name(self, expected_name):
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex":
+ r"^\$T([0-9a-fA-F]{2})([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "signal",
+ 2: "key_vals_text"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ sigint = lldbutil.get_signal_number("SIGINT")
+ self.assertEqual(sigint, int(context.get("signal"), 16))
+ kv_dict = self.parse_key_val_dict(context.get("key_vals_text"))
+ self.assertEqual(expected_name, kv_dict.get("name"))
+
+ @llgs_test
+ def test(self):
+ """ Make sure lldb-server can retrieve inferior thread name"""
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+
+ self.run_and_check_name("hello world")
+ self.run_and_check_name("goodbye world")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp
new file mode 100644
index 000000000000..0403031143ba
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp
@@ -0,0 +1,22 @@
+#include <pthread.h>
+#include <signal.h>
+
+void set_thread_name(const char *name) {
+#if defined(__APPLE__)
+ ::pthread_setname_np(name);
+#elif defined(__FreeBSD__)
+ ::pthread_set_name_np(::pthread_self(), name);
+#elif defined(__linux__)
+ ::pthread_setname_np(::pthread_self(), name);
+#elif defined(__NetBSD__)
+ ::pthread_setname_np(::pthread_self(), "%s", name);
+#endif
+}
+
+int main() {
+ set_thread_name("hello world");
+ raise(SIGINT);
+ set_thread_name("goodbye world");
+ raise(SIGINT);
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
index 35a9fa8d5d56..8e341cb2ce84 100644
--- a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
+++ b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
@@ -126,19 +126,6 @@ class ResultsFormatter(object):
self.terminate_called = False
self.file_is_stream = file_is_stream
- # Store counts of test_result events by status.
- self.result_status_counts = {
- EventBuilder.STATUS_SUCCESS: 0,
- EventBuilder.STATUS_EXPECTED_FAILURE: 0,
- EventBuilder.STATUS_EXPECTED_TIMEOUT: 0,
- EventBuilder.STATUS_SKIP: 0,
- EventBuilder.STATUS_UNEXPECTED_SUCCESS: 0,
- EventBuilder.STATUS_FAILURE: 0,
- EventBuilder.STATUS_ERROR: 0,
- EventBuilder.STATUS_TIMEOUT: 0,
- EventBuilder.STATUS_EXCEPTIONAL_EXIT: 0
- }
-
# Track the most recent test start event by worker index.
# We'll use this to assign TIMEOUT and exceptional
# exits to the most recent test started on a given
@@ -359,18 +346,12 @@ class ResultsFormatter(object):
if event_type == "terminate":
self.terminate_called = True
elif event_type in EventBuilder.RESULT_TYPES:
- # Keep track of event counts per test/job result status
- # type. The only job (i.e. inferior process) results that
- # make it here are ones that cannot be remapped to the most
- # recently started test for the given worker index.
- status = test_event["status"]
- self.result_status_counts[status] += 1
# Clear the most recently started test for the related
# worker.
worker_index = test_event.get("worker_index", None)
if worker_index is not None:
self.started_tests_by_worker.pop(worker_index, None)
-
+ status = test_event["status"]
if status in EventBuilder.TESTRUN_ERROR_STATUS_VALUES:
# A test/job status value in any of those status values
# causes a testrun failure. If such a test fails, check
@@ -393,12 +374,6 @@ class ResultsFormatter(object):
# the need to run a low-load, single-worker test run can
# have the final run's results to always be used.
if test_key in self.result_events:
- # We are replacing the result of something that was
- # already counted by the base class. Remove the double
- # counting by reducing by one the count for the test
- # result status.
- old_status = self.result_events[test_key]["status"]
- self.result_status_counts[old_status] -= 1
self.test_method_rerun_count += 1
self.result_events[test_key] = test_event
elif event_type == EventBuilder.TYPE_TEST_START:
@@ -494,7 +469,9 @@ class ResultsFormatter(object):
@return an integer returning the number of test methods matching
the given test result status.
"""
- return self.result_status_counts[status]
+ return len([
+ [key, event] for (key, event) in self.result_events.items()
+ if event.get("status", "") == status])
@classmethod
def _event_sort_key(cls, event):
diff --git a/packages/Python/lldbsuite/test_event/formatter/xunit.py b/packages/Python/lldbsuite/test_event/formatter/xunit.py
index d3ea8677f0a6..91487cd2c3a1 100644
--- a/packages/Python/lldbsuite/test_event/formatter/xunit.py
+++ b/packages/Python/lldbsuite/test_event/formatter/xunit.py
@@ -336,7 +336,7 @@ class XunitFormatter(ResultsFormatter):
test_event,
inner_content=(
'<error type={} message={}></error>'.format(
- "timeout",
+ XunitFormatter._quote_attribute("timeout"),
XunitFormatter._quote_attribute(message))
))
with self.lock:
diff --git a/scripts/Python/finishSwigPythonLLDB.py b/scripts/Python/finishSwigPythonLLDB.py
index 91e3a41f9ed3..ff6a1318a19a 100644
--- a/scripts/Python/finishSwigPythonLLDB.py
+++ b/scripts/Python/finishSwigPythonLLDB.py
@@ -821,7 +821,9 @@ def main(vDictArgs):
bOk, strMsg = create_symlinks(
vDictArgs, strFrameworkPythonDir, strLldbLibDir)
- if bOk:
+ bUseSystemSix = "--useSystemSix" in vDictArgs
+
+ if not bUseSystemSix and bOk:
bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir)
if bOk:
diff --git a/scripts/Xcode/build-llvm.py b/scripts/Xcode/build-llvm.py
index c00907e935cf..36e491ebf065 100755
--- a/scripts/Xcode/build-llvm.py
+++ b/scripts/Xcode/build-llvm.py
@@ -6,6 +6,7 @@ import fnmatch
import os
import platform
import re
+import repo
import subprocess
import sys
@@ -17,42 +18,36 @@ from lldbbuild import *
def LLVM_HASH_INCLUDES_DIFFS():
return False
-# The use of "x = "..."; return x" here is important because tooling looks for
-# it with regexps. Only change how this works if you know what you are doing.
-
-
-def LLVM_REF():
- llvm_ref = "release_40"
- return llvm_ref
-
+# For use with Xcode-style builds
-def CLANG_REF():
- clang_ref = "release_40"
- return clang_ref
+def process_vcs(vcs):
+ return {
+ "svn": VCS.svn,
+ "git": VCS.git
+ }[vcs]
-# For use with Xcode-style builds
+def process_root(name):
+ return {
+ "llvm": llvm_source_path(),
+ "clang": clang_source_path(),
+ "ninja": ninja_source_path()
+ }[name]
+def process_repo(r):
+ return {
+ 'name': r["name"],
+ 'vcs': process_vcs(r["vcs"]),
+ 'root': process_root(r["name"]),
+ 'url': r["url"],
+ 'ref': r["ref"]
+ }
def XCODE_REPOSITORIES():
- return [
- {'name': "llvm",
- 'vcs': VCS.git,
- 'root': llvm_source_path(),
- 'url': "http://llvm.org/git/llvm.git",
- 'ref': LLVM_REF()},
-
- {'name': "clang",
- 'vcs': VCS.git,
- 'root': clang_source_path(),
- 'url': "http://llvm.org/git/clang.git",
- 'ref': CLANG_REF()},
-
- {'name': "ninja",
- 'vcs': VCS.git,
- 'root': ninja_source_path(),
- 'url': "https://github.com/ninja-build/ninja.git",
- 'ref': "master"}
- ]
+ identifier = repo.identifier()
+ if identifier == None:
+ identifier = "<invalid>" # repo.find will just use the fallback file
+ set = repo.find(identifier)
+ return [process_repo(r) for r in set]
def get_c_compiler():
diff --git a/scripts/Xcode/repo.py b/scripts/Xcode/repo.py
new file mode 100644
index 000000000000..c1e5fe339d26
--- /dev/null
+++ b/scripts/Xcode/repo.py
@@ -0,0 +1,42 @@
+import json
+import os
+import re
+import shutil
+import subprocess
+
+def identifier():
+ try:
+ svn_output = subprocess.check_output(["svn", "info", "--show-item", "url"], stderr=subprocess.STDOUT).rstrip()
+ return svn_output
+ except:
+ pass
+ try:
+ git_remote_and_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], stderr=subprocess.STDOUT).rstrip()
+ git_remote = git_remote_and_branch.split("/")[0]
+ git_branch = "/".join(git_remote_and_branch.split("/")[1:])
+ git_url = subprocess.check_output(["git", "remote", "get-url", git_remote]).rstrip()
+ return git_url + ":" + git_branch
+ except:
+ pass
+ return None
+
+def find(identifier):
+ dir = os.path.dirname(os.path.realpath(__file__))
+ repos_dir = os.path.join(dir, "repos")
+ json_regex = re.compile(r"^.*.json$")
+ override_path = os.path.join(repos_dir, "OVERRIDE")
+ if os.path.isfile(override_path):
+ override_set = json.load(open(override_path))
+ return override_set["repos"]
+ fallback_path = os.path.join(repos_dir, "FALLBACK")
+ for path in [os.path.join(repos_dir, f) for f in filter(json_regex.match, os.listdir(repos_dir))]:
+ fd = open(path)
+ set = json.load(fd)
+ fd.close()
+ if any(re.match(set_regex, identifier) for set_regex in set["regexs"]):
+ shutil.copyfile(path, fallback_path)
+ return set["repos"]
+ if os.path.isfile(fallback_path):
+ fallback_set = json.load(open(fallback_path))
+ return fallback_set["repos"]
+ sys.exit("Couldn't find a branch configuration for " + identifier + " and there was no " + fallback_path)
diff --git a/scripts/Xcode/repos/FALLBACK b/scripts/Xcode/repos/FALLBACK
new file mode 100644
index 000000000000..a3bd72424aa0
--- /dev/null
+++ b/scripts/Xcode/repos/FALLBACK
@@ -0,0 +1,19 @@
+{
+ "regexs" : [".*llvm\\.org.*"],
+ "repos" : [
+ {"name": "llvm",
+ "vcs": "git",
+ "url": "http://llvm.org/git/llvm.git",
+ "ref": "master"},
+
+ {"name": "clang",
+ "vcs": "git",
+ "url": "http://llvm.org/git/clang.git",
+ "ref": "master"},
+
+ {"name": "ninja",
+ "vcs": "git",
+ "url": "https://github.com/ninja-build/ninja.git",
+ "ref": "master"}
+ ]
+}
diff --git a/scripts/Xcode/repos/svn-trunk.json b/scripts/Xcode/repos/svn-trunk.json
new file mode 100644
index 000000000000..a3bd72424aa0
--- /dev/null
+++ b/scripts/Xcode/repos/svn-trunk.json
@@ -0,0 +1,19 @@
+{
+ "regexs" : [".*llvm\\.org.*"],
+ "repos" : [
+ {"name": "llvm",
+ "vcs": "git",
+ "url": "http://llvm.org/git/llvm.git",
+ "ref": "master"},
+
+ {"name": "clang",
+ "vcs": "git",
+ "url": "http://llvm.org/git/clang.git",
+ "ref": "master"},
+
+ {"name": "ninja",
+ "vcs": "git",
+ "url": "https://github.com/ninja-build/ninja.git",
+ "ref": "master"}
+ ]
+}
diff --git a/scripts/analyze-project-deps.py b/scripts/analyze-project-deps.py
new file mode 100644
index 000000000000..e06d7035d43d
--- /dev/null
+++ b/scripts/analyze-project-deps.py
@@ -0,0 +1,206 @@
+import argparse
+import itertools
+import os
+import re
+import sys
+from collections import defaultdict
+
+from use_lldb_suite import lldb_root
+
+parser = argparse.ArgumentParser(
+ description='Analyze LLDB project #include dependencies.')
+parser.add_argument('--show-counts', default=False, action='store_true',
+ help='When true, show the number of dependencies from each subproject')
+parser.add_argument('--discover-cycles', default=False, action='store_true',
+ help='When true, find and display all project dependency cycles. Note,'
+ 'this option is very slow')
+
+args = parser.parse_args()
+
+src_dir = os.path.join(lldb_root, "source")
+inc_dir = os.path.join(lldb_root, "include")
+
+src_map = {}
+
+include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"')
+
+def is_sublist(small, big):
+ it = iter(big)
+ return all(c in it for c in small)
+
+def normalize_host(str):
+ if str.startswith("lldb/Host"):
+ return "lldb/Host"
+ if str.startswith("Plugins"):
+ return "lldb/" + str
+ if str.startswith("lldb/../../source"):
+ return str.replace("lldb/../../source", "lldb")
+ return str
+
+def scan_deps(this_dir, file):
+ global src_map
+ deps = {}
+ this_dir = normalize_host(this_dir)
+ if this_dir in src_map:
+ deps = src_map[this_dir]
+
+ with open(file) as f:
+ for line in list(f):
+ m = include_regex.match(line)
+ if m is None:
+ continue
+ relative = m.groups()[0].rstrip("/")
+ if relative == this_dir:
+ continue
+ relative = normalize_host(relative)
+ if relative in deps:
+ deps[relative] += 1
+ elif relative != this_dir:
+ deps[relative] = 1
+ if this_dir not in src_map and len(deps) > 0:
+ src_map[this_dir] = deps
+
+for (base, dirs, files) in os.walk(inc_dir):
+ dir = os.path.basename(base)
+ relative = os.path.relpath(base, inc_dir)
+ inc_files = filter(lambda x : os.path.splitext(x)[1] in [".h"], files)
+ relative = relative.replace("\\", "/")
+ for inc in inc_files:
+ inc_path = os.path.join(base, inc)
+ scan_deps(relative, inc_path)
+
+for (base, dirs, files) in os.walk(src_dir):
+ dir = os.path.basename(base)
+ relative = os.path.relpath(base, src_dir)
+ src_files = filter(lambda x : os.path.splitext(x)[1] in [".cpp", ".h", ".mm"], files)
+ norm_base_path = os.path.normpath(os.path.join("lldb", relative))
+ norm_base_path = norm_base_path.replace("\\", "/")
+ for src in src_files:
+ src_path = os.path.join(base, src)
+ scan_deps(norm_base_path, src_path)
+ pass
+
+def is_existing_cycle(path, cycles):
+ # If we have a cycle like # A -> B -> C (with an implicit -> A at the end)
+ # then we don't just want to check for an occurrence of A -> B -> C in the
+ # list of known cycles, but every possible rotation of A -> B -> C. For
+ # example, if we previously encountered B -> C -> A (with an implicit -> B
+ # at the end), then A -> B -> C is also a cycle. This is an important
+ # optimization which reduces the search space by multiple orders of
+ # magnitude.
+ for i in xrange(0,len(path)):
+ if any(is_sublist(x, path) for x in cycles):
+ return True
+ path = [path[-1]] + path[0:-1]
+ return False
+
+def expand(path_queue, path_lengths, cycles, src_map):
+ # We do a breadth first search, to make sure we visit all paths in order
+ # of ascending length. This is an important optimization to make sure that
+ # short cycles are discovered first, which will allow us to discard longer
+ # cycles which grow the search space exponentially the longer they get.
+ while len(path_queue) > 0:
+ cur_path = path_queue.pop(0)
+ if is_existing_cycle(cur_path, cycles):
+ continue
+
+ next_len = path_lengths.pop(0) + 1
+ last_component = cur_path[-1]
+
+ for item in src_map[last_component]:
+ if item.startswith("clang"):
+ continue
+
+ if item in cur_path:
+ # This is a cycle. Minimize it and then check if the result is
+ # already in the list of cycles. Insert it (or not) and then
+ # exit.
+ new_index = cur_path.index(item)
+ cycle = cur_path[new_index:]
+ if not is_existing_cycle(cycle, cycles):
+ cycles.append(cycle)
+ continue
+
+ path_lengths.append(next_len)
+ path_queue.append(cur_path + [item])
+ pass
+
+cycles = []
+
+path_queue = [[x] for x in src_map.iterkeys()]
+path_lens = [1] * len(path_queue)
+
+items = list(src_map.iteritems())
+items.sort(lambda A, B : cmp(A[0], B[0]))
+
+for (path, deps) in items:
+ print path + ":"
+ sorted_deps = list(deps.iteritems())
+ if args.show_counts:
+ sorted_deps.sort(lambda A, B: cmp(A[1], B[1]))
+ for dep in sorted_deps:
+ print "\t{} [{}]".format(dep[0], dep[1])
+ else:
+ sorted_deps.sort(lambda A, B: cmp(A[0], B[0]))
+ for dep in sorted_deps:
+ print "\t{}".format(dep[0])
+
+def iter_cycles(cycles):
+ global src_map
+ for cycle in cycles:
+ cycle.append(cycle[0])
+ zipper = list(zip(cycle[0:-1], cycle[1:]))
+ result = [(x, src_map[x][y], y) for (x,y) in zipper]
+ total = 0
+ smallest = result[0][1]
+ for (first, value, last) in result:
+ total += value
+ smallest = min(smallest, value)
+ yield (total, smallest, result)
+
+if args.discover_cycles:
+ print "Analyzing cycles..."
+
+ expand(path_queue, path_lens, cycles, src_map)
+
+ average = sum([len(x)+1 for x in cycles]) / len(cycles)
+
+ print "Found {} cycles. Average cycle length = {}.".format(len(cycles), average)
+ counted = list(iter_cycles(cycles))
+ if args.show_counts:
+ counted.sort(lambda A, B: cmp(A[0], B[0]))
+ for (total, smallest, cycle) in counted:
+ sys.stdout.write("{} deps to break: ".format(total))
+ sys.stdout.write(cycle[0][0])
+ for (first, count, last) in cycle:
+ sys.stdout.write(" [{}->] {}".format(count, last))
+ sys.stdout.write("\n")
+ else:
+ for cycle in cycles:
+ cycle.append(cycle[0])
+ print " -> ".join(cycle)
+
+ print "Analyzing islands..."
+ islands = []
+ outgoing_counts = defaultdict(int)
+ incoming_counts = defaultdict(int)
+ for (total, smallest, cycle) in counted:
+ for (first, count, last) in cycle:
+ outgoing_counts[first] += count
+ incoming_counts[last] += count
+ for cycle in cycles:
+ this_cycle = set(cycle)
+ disjoints = [x for x in islands if this_cycle.isdisjoint(x)]
+ overlaps = [x for x in islands if not this_cycle.isdisjoint(x)]
+ islands = disjoints + [set.union(this_cycle, *overlaps)]
+ print "Found {} disjoint cycle islands...".format(len(islands))
+ for island in islands:
+ print "Island ({} elements)".format(len(island))
+ sorted = []
+ for node in island:
+ sorted.append((node, incoming_counts[node], outgoing_counts[node]))
+ sorted.sort(lambda x, y: cmp(x[1]+x[2], y[1]+y[2]))
+ for (node, inc, outg) in sorted:
+ print " {} [{} in, {} out]".format(node, inc, outg)
+ sys.stdout.flush()
+pass \ No newline at end of file
diff --git a/scripts/finishSwigWrapperClasses.py b/scripts/finishSwigWrapperClasses.py
index 4607624e14b7..4d08b86e9e47 100644
--- a/scripts/finishSwigWrapperClasses.py
+++ b/scripts/finishSwigWrapperClasses.py
@@ -81,6 +81,7 @@ Args: -h (optional) Print help information on this program.\n\
created for a Windows build.\n\
--argsFile= The args are read from a file instead of the\n\
command line. Other command line args are ignored.\n\
+ --useSystemSix Use system six.py version.\n\
\n\
Usage:\n\
finishSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath\n\
@@ -178,7 +179,8 @@ def validate_arguments(vArgv):
"prefix=",
"cmakeBuildConfiguration=",
"lldbLibDir=",
- "argsFile"]
+ "argsFile",
+ "useSystemSix"]
dictArgReq = {"-h": "o", # o = optional, m = mandatory
"-d": "o",
"-m": "o",
@@ -188,7 +190,8 @@ def validate_arguments(vArgv):
"--prefix": "o",
"--cmakeBuildConfiguration": "o",
"--lldbLibDir": "o",
- "--argsFile": "o"}
+ "--argsFile": "o",
+ "--useSystemSix": "o"}
# Check for mandatory parameters
nResult, dictArgs, strMsg = utilsArgsParse.parse(vArgv, strListArgs,
@@ -376,9 +379,11 @@ def main(vArgv):
(optional) "lib" by default.
--argsFile= The args are read from a file instead of the
command line. Other command line args are ignored.
+ --useSystemSix Use system six.py version.
Usage:
finishSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath
--cfgBldDir=ADirPath --prefix=ADirPath --lldbLibDir=ADirPath -m -d
+ --useSystemSix
Results: 0 Success
-1 Error - invalid parameters passed.
diff --git a/scripts/interface/SBFrame.i b/scripts/interface/SBFrame.i
index 1c10a9b6e3e8..b8654cb0eb60 100644
--- a/scripts/interface/SBFrame.i
+++ b/scripts/interface/SBFrame.i
@@ -133,6 +133,14 @@ public:
const char *
GetFunctionName() const;
+
+ %feature("docstring", "
+ /// Returns the language of the frame's SBFunction, or if there.
+ /// is no SBFunction, guess the language from the mangled name.
+ /// .
+ ") GuessLanguage;
+ lldb::LanguageType
+ GuessLanguage() const;
%feature("docstring", "
/// Return true if this frame represents an inlined function.
diff --git a/scripts/interface/SBThread.i b/scripts/interface/SBThread.i
index 9aacb4374dcc..c36b1b519e66 100644
--- a/scripts/interface/SBThread.i
+++ b/scripts/interface/SBThread.i
@@ -182,12 +182,14 @@ public:
lldb::queue_id_t
GetQueueID() const;
- %feature("autodoc", "
- Takes a path string and a SBStream reference as parameters, returns a bool.
- Collects the thread's 'info' dictionary from the remote system, uses the path
- argument to descend into the dictionary to an item of interest, and prints
- it into the SBStream in a natural format. Return bool is to indicate if
- anything was printed into the stream (true) or not (false).
+ %feature("docstring", "
+ //--------------------------------------------------------------------------
+ /// Takes a path string and a SBStream reference as parameters, returns a bool.
+ /// Collects the thread's 'info' dictionary from the remote system, uses the path
+ /// argument to descend into the dictionary to an item of interest, and prints
+ /// it into the SBStream in a natural format. Return bool is to indicate if
+ /// anything was printed into the stream (true) or not (false).
+ //--------------------------------------------------------------------------
") GetInfoItemByPathAsString;
bool
diff --git a/scripts/utilsArgsParse.py b/scripts/utilsArgsParse.py
index 4486661863b1..fadf4b498316 100644
--- a/scripts/utilsArgsParse.py
+++ b/scripts/utilsArgsParse.py
@@ -113,12 +113,12 @@ def parse(vArgv, vstrListArgs, vListLongArgs, vDictArgReq, vstrHelpInfo):
break
if match == 0:
for arg in vListLongArgs:
- argg = "--" + arg[:arg.__len__() - 1]
+ argg = "--" + arg.rstrip('=')
if opt == argg:
if "m" == vDictArgReq[opt]:
countMandatoryOpts = countMandatoryOpts + 1
dictArgs[opt] = val
- if val.__len__() == 0:
+ if arg[-1:] == '=' and val.__len__() == 0:
bFoundNoInputValue = True
break
diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt
index 7e1e66bee3b2..3b852a3d7402 100644
--- a/source/API/CMakeLists.txt
+++ b/source/API/CMakeLists.txt
@@ -16,6 +16,8 @@ if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
endif()
+get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
+
add_lldb_library(liblldb SHARED
SBAddress.cpp
SBAttachInfo.cpp
@@ -80,6 +82,22 @@ add_lldb_library(liblldb SHARED
SBUnixSignals.cpp
SystemInitializerFull.cpp
${LLDB_WRAP_PYTHON}
+
+ LINK_LIBS
+ lldbBase
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbInitialization
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ ${LLDB_ALL_PLUGINS}
+ LINK_COMPONENTS
+ Support
)
if (LLVM_ENABLE_WERROR)
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index 0ef374f47a92..b452ce327ab7 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -12,11 +12,11 @@
#include "lldb/API/SBSection.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp
index 471b7fbebb23..cd453872201a 100644
--- a/source/API/SBBlock.cpp
+++ b/source/API/SBBlock.cpp
@@ -14,7 +14,6 @@
#include "lldb/API/SBStream.h"
#include "lldb/API/SBValue.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
@@ -22,6 +21,7 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index 0eab2c2a363f..0b661a646f31 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -26,8 +26,6 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -36,6 +34,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-enumerations.h"
@@ -59,83 +59,74 @@ public:
}
};
-SBBreakpoint::SBBreakpoint() : m_opaque_sp() {}
+SBBreakpoint::SBBreakpoint() {}
SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {}
SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
- : m_opaque_sp(bp_sp) {}
+ : m_opaque_wp(bp_sp) {}
SBBreakpoint::~SBBreakpoint() = default;
const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
+ m_opaque_wp = rhs.m_opaque_wp;
return *this;
}
bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
- if (m_opaque_sp && rhs.m_opaque_sp)
- return m_opaque_sp.get() == rhs.m_opaque_sp.get();
- return false;
+ return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
}
bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
- if (m_opaque_sp && rhs.m_opaque_sp)
- return m_opaque_sp.get() != rhs.m_opaque_sp.get();
- return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp);
+ return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
}
break_id_t SBBreakpoint::GetID() const {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
break_id_t break_id = LLDB_INVALID_BREAK_ID;
- if (m_opaque_sp)
- break_id = m_opaque_sp->GetID();
-
- if (log) {
- if (break_id == LLDB_INVALID_BREAK_ID)
- log->Printf("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID",
- static_cast<void *>(m_opaque_sp.get()));
- else
- log->Printf("SBBreakpoint(%p)::GetID () => %u",
- static_cast<void *>(m_opaque_sp.get()), break_id);
- }
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp)
+ break_id = bkpt_sp->GetID();
+ LLDB_LOG(log, "breakpoint = {0}, id = {1}", bkpt_sp.get(), break_id);
return break_id;
}
bool SBBreakpoint::IsValid() const {
- if (!m_opaque_sp)
+ BreakpointSP bkpt_sp = GetSP();
+ if (!bkpt_sp)
return false;
- else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID()))
+ else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
return true;
else
return false;
}
void SBBreakpoint::ClearAllBreakpointSites() {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->ClearAllBreakpointSites();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->ClearAllBreakpointSites();
}
}
SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
SBBreakpointLocation sb_bp_location;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
if (vm_addr != LLDB_INVALID_ADDRESS) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
Address address;
- Target &target = m_opaque_sp->GetTarget();
+ Target &target = bkpt_sp->GetTarget();
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
address.SetRawAddress(vm_addr);
}
- sb_bp_location.SetLocation(m_opaque_sp->FindLocationByAddress(address));
+ sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
}
}
return sb_bp_location;
@@ -143,16 +134,17 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
break_id_t break_id = LLDB_INVALID_BREAK_ID;
+ BreakpointSP bkpt_sp = GetSP();
- if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) {
+ if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
Address address;
- Target &target = m_opaque_sp->GetTarget();
+ Target &target = bkpt_sp->GetTarget();
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
address.SetRawAddress(vm_addr);
}
- break_id = m_opaque_sp->FindLocationIDByAddress(address);
+ break_id = bkpt_sp->FindLocationIDByAddress(address);
}
return break_id;
@@ -160,11 +152,12 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
SBBreakpointLocation sb_bp_location;
+ BreakpointSP bkpt_sp = GetSP();
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- sb_bp_location.SetLocation(m_opaque_sp->FindLocationByID(bp_loc_id));
+ bkpt_sp->GetTarget().GetAPIMutex());
+ sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
}
return sb_bp_location;
@@ -172,11 +165,12 @@ SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
SBBreakpointLocation sb_bp_location;
+ BreakpointSP bkpt_sp = GetSP();
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- sb_bp_location.SetLocation(m_opaque_sp->GetLocationAtIndex(index));
+ bkpt_sp->GetTarget().GetAPIMutex());
+ sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
}
return sb_bp_location;
@@ -184,290 +178,282 @@ SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
void SBBreakpoint::SetEnabled(bool enable) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
- if (log)
- log->Printf("SBBreakpoint(%p)::SetEnabled (enabled=%i)",
- static_cast<void *>(m_opaque_sp.get()), enable);
+ LLDB_LOG(log, "breakpoint = {0}, enable = {1}", bkpt_sp.get(), enable);
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetEnabled(enable);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->SetEnabled(enable);
}
}
bool SBBreakpoint::IsEnabled() {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->IsEnabled();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return bkpt_sp->IsEnabled();
} else
return false;
}
void SBBreakpoint::SetOneShot(bool one_shot) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
- if (log)
- log->Printf("SBBreakpoint(%p)::SetOneShot (one_shot=%i)",
- static_cast<void *>(m_opaque_sp.get()), one_shot);
+ LLDB_LOG(log, "breakpoint = {0}, one_shot = {1}", bkpt_sp.get(), one_shot);
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetOneShot(one_shot);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->SetOneShot(one_shot);
}
}
bool SBBreakpoint::IsOneShot() const {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->IsOneShot();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return bkpt_sp->IsOneShot();
} else
return false;
}
bool SBBreakpoint::IsInternal() {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->IsInternal();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return bkpt_sp->IsInternal();
} else
return false;
}
void SBBreakpoint::SetIgnoreCount(uint32_t count) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
- if (log)
- log->Printf("SBBreakpoint(%p)::SetIgnoreCount (count=%u)",
- static_cast<void *>(m_opaque_sp.get()), count);
+ LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetIgnoreCount(count);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->SetIgnoreCount(count);
}
}
void SBBreakpoint::SetCondition(const char *condition) {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetCondition(condition);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->SetCondition(condition);
}
}
const char *SBBreakpoint::GetCondition() {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetConditionText();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return bkpt_sp->GetConditionText();
}
return nullptr;
}
uint32_t SBBreakpoint::GetHitCount() const {
uint32_t count = 0;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- count = m_opaque_sp->GetHitCount();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ count = bkpt_sp->GetHitCount();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetHitCount () => %u",
- static_cast<void *>(m_opaque_sp.get()), count);
+ LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
return count;
}
uint32_t SBBreakpoint::GetIgnoreCount() const {
uint32_t count = 0;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- count = m_opaque_sp->GetIgnoreCount();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ count = bkpt_sp->GetIgnoreCount();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetIgnoreCount () => %u",
- static_cast<void *>(m_opaque_sp.get()), count);
+ LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
return count;
}
void SBBreakpoint::SetThreadID(tid_t tid) {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetThreadID(tid);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->SetThreadID(tid);
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")",
- static_cast<void *>(m_opaque_sp.get()), tid);
+ LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
}
tid_t SBBreakpoint::GetThreadID() {
tid_t tid = LLDB_INVALID_THREAD_ID;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- tid = m_opaque_sp->GetThreadID();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ tid = bkpt_sp->GetThreadID();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64,
- static_cast<void *>(m_opaque_sp.get()), tid);
+ LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
return tid;
}
void SBBreakpoint::SetThreadIndex(uint32_t index) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::SetThreadIndex (%u)",
- static_cast<void *>(m_opaque_sp.get()), index);
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), index);
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
}
}
uint32_t SBBreakpoint::GetThreadIndex() const {
uint32_t thread_idx = UINT32_MAX;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec =
- m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+ bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != nullptr)
thread_idx = thread_spec->GetIndex();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetThreadIndex () => %u",
- static_cast<void *>(m_opaque_sp.get()), thread_idx);
+ LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), thread_idx);
return thread_idx;
}
void SBBreakpoint::SetThreadName(const char *thread_name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::SetThreadName (%s)",
- static_cast<void *>(m_opaque_sp.get()), thread_name);
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), thread_name);
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
}
}
const char *SBBreakpoint::GetThreadName() const {
const char *name = nullptr;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec =
- m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+ bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != nullptr)
name = thread_spec->GetName();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetThreadName () => %s",
- static_cast<void *>(m_opaque_sp.get()), name);
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
return name;
}
void SBBreakpoint::SetQueueName(const char *queue_name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::SetQueueName (%s)",
- static_cast<void *>(m_opaque_sp.get()), queue_name);
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, queue_name = {1}", bkpt_sp.get(),
+ queue_name);
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
}
}
const char *SBBreakpoint::GetQueueName() const {
const char *name = nullptr;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec =
- m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+ bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec)
name = thread_spec->GetQueueName();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetQueueName () => %s",
- static_cast<void *>(m_opaque_sp.get()), name);
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
return name;
}
size_t SBBreakpoint::GetNumResolvedLocations() const {
size_t num_resolved = 0;
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- num_resolved = m_opaque_sp->GetNumResolvedLocations();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ num_resolved = bkpt_sp->GetNumResolvedLocations();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64,
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<uint64_t>(num_resolved));
+ LLDB_LOG(log, "breakpoint = {0}, num_resolved = {1}", bkpt_sp.get(),
+ num_resolved);
return num_resolved;
}
size_t SBBreakpoint::GetNumLocations() const {
+ BreakpointSP bkpt_sp = GetSP();
size_t num_locs = 0;
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- num_locs = m_opaque_sp->GetNumLocations();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ num_locs = bkpt_sp->GetNumLocations();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64,
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<uint64_t>(num_locs));
+ LLDB_LOG(log, "breakpoint = {0}, num_locs = {1}", bkpt_sp.get(), num_locs);
return num_locs;
}
void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
- if (!m_opaque_sp)
+ BreakpointSP bkpt_sp = GetSP();
+ if (!bkpt_sp)
return;
if (commands.GetSize() == 0)
return;
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
- m_opaque_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
+ bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
}
bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
- if (!m_opaque_sp)
+ BreakpointSP bkpt_sp = GetSP();
+ if (!bkpt_sp)
return false;
StringList command_list;
bool has_commands =
- m_opaque_sp->GetOptions()->GetCommandLineCallbacks(command_list);
+ bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list);
if (has_commands)
commands.AppendList(command_list);
return has_commands;
@@ -478,14 +464,15 @@ bool SBBreakpoint::GetDescription(SBStream &s) {
}
bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
- if (m_opaque_sp) {
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
- m_opaque_sp->GetResolverDescription(s.get());
- m_opaque_sp->GetFilterDescription(s.get());
+ bkpt_sp->GetTarget().GetAPIMutex());
+ s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
+ bkpt_sp->GetResolverDescription(s.get());
+ bkpt_sp->GetFilterDescription(s.get());
if (include_locations) {
- const size_t num_locations = m_opaque_sp->GetNumLocations();
+ const size_t num_locations = bkpt_sp->GetNumLocations();
s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
}
return true;
@@ -526,36 +513,31 @@ bool SBBreakpoint::PrivateBreakpointHitCallback(void *baton,
void SBBreakpoint::SetCallback(BreakpointHitCallback callback, void *baton) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, callback = {1}, baton = {2}", bkpt_sp.get(),
+ callback, baton);
- if (log) {
- void *pointer = &callback;
- log->Printf("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)",
- static_cast<void *>(m_opaque_sp.get()),
- *static_cast<void **>(&pointer), static_cast<void *>(baton));
- }
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
- m_opaque_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback,
- baton_sp, false);
+ bkpt_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback, baton_sp,
+ false);
}
}
void SBBreakpoint::SetScriptCallbackFunction(
const char *callback_function_name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, callback = {1}", bkpt_sp.get(),
+ callback_function_name);
- if (log)
- log->Printf("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)",
- static_cast<void *>(m_opaque_sp.get()), callback_function_name);
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
- m_opaque_sp->GetTarget()
+ bkpt_sp->GetTarget().GetAPIMutex());
+ BreakpointOptions *bp_options = bkpt_sp->GetOptions();
+ bkpt_sp->GetTarget()
.GetDebugger()
.GetCommandInterpreter()
.GetScriptInterpreter()
@@ -566,18 +548,17 @@ void SBBreakpoint::SetScriptCallbackFunction(
SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)",
- static_cast<void *>(m_opaque_sp.get()), callback_body_text);
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, callback body:\n{1}", bkpt_sp.get(),
+ callback_body_text);
SBError sb_error;
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
+ bkpt_sp->GetTarget().GetAPIMutex());
+ BreakpointOptions *bp_options = bkpt_sp->GetOptions();
Error error =
- m_opaque_sp->GetTarget()
+ bkpt_sp->GetTarget()
.GetDebugger()
.GetCommandInterpreter()
.GetScriptInterpreter()
@@ -591,17 +572,15 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
bool SBBreakpoint::AddName(const char *new_name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), new_name);
- if (log)
- log->Printf("SBBreakpoint(%p)::AddName (name=%s)",
- static_cast<void *>(m_opaque_sp.get()), new_name);
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
Error error; // Think I'm just going to swallow the error here, it's
// probably more annoying to have to provide it.
- return m_opaque_sp->AddName(new_name, error);
+ return bkpt_sp->AddName(new_name, error);
}
return false;
@@ -609,29 +588,25 @@ bool SBBreakpoint::AddName(const char *new_name) {
void SBBreakpoint::RemoveName(const char *name_to_remove) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name_to_remove);
- if (log)
- log->Printf("SBBreakpoint(%p)::RemoveName (name=%s)",
- static_cast<void *>(m_opaque_sp.get()), name_to_remove);
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->RemoveName(name_to_remove);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->RemoveName(name_to_remove);
}
}
bool SBBreakpoint::MatchesName(const char *name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
- if (log)
- log->Printf("SBBreakpoint(%p)::MatchesName (name=%s)",
- static_cast<void *>(m_opaque_sp.get()), name);
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->MatchesName(name);
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return bkpt_sp->MatchesName(name);
}
return false;
@@ -639,36 +614,20 @@ bool SBBreakpoint::MatchesName(const char *name) {
void SBBreakpoint::GetNames(SBStringList &names) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointSP bkpt_sp = GetSP();
+ LLDB_LOG(log, "breakpoint = {0}", bkpt_sp.get());
- if (log)
- log->Printf("SBBreakpoint(%p)::GetNames ()",
- static_cast<void *>(m_opaque_sp.get()));
-
- if (m_opaque_sp) {
+ if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
+ bkpt_sp->GetTarget().GetAPIMutex());
std::vector<std::string> names_vec;
- m_opaque_sp->GetNames(names_vec);
+ bkpt_sp->GetNames(names_vec);
for (std::string name : names_vec) {
names.AppendString(name.c_str());
}
}
}
-lldb_private::Breakpoint *SBBreakpoint::operator->() const {
- return m_opaque_sp.get();
-}
-
-lldb_private::Breakpoint *SBBreakpoint::get() const {
- return m_opaque_sp.get();
-}
-
-lldb::BreakpointSP &SBBreakpoint::operator*() { return m_opaque_sp; }
-
-const lldb::BreakpointSP &SBBreakpoint::operator*() const {
- return m_opaque_sp;
-}
-
bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
nullptr;
@@ -683,11 +642,10 @@ SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
}
SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
- SBBreakpoint sb_breakpoint;
if (event.IsValid())
- sb_breakpoint.m_opaque_sp =
- Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP());
- return sb_breakpoint;
+ return SBBreakpoint(
+ Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP()));
+ return SBBreakpoint();
}
SBBreakpointLocation
@@ -711,6 +669,8 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
return num_locations;
}
+BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
+
// This is simple collection of breakpoint id's and their target.
class SBBreakpointListImpl {
public:
@@ -745,28 +705,28 @@ public:
return BreakpointSP();
}
- bool Append(Breakpoint &bkpt) {
+ bool Append(BreakpointSP bkpt) {
TargetSP target_sp = m_target_wp.lock();
- if (!target_sp)
+ if (!target_sp || !bkpt)
return false;
- if (bkpt.GetTargetSP() != target_sp)
+ if (bkpt->GetTargetSP() != target_sp)
return false;
- m_break_ids.push_back(bkpt.GetID());
+ m_break_ids.push_back(bkpt->GetID());
return true;
}
- bool AppendIfUnique(Breakpoint &bkpt) {
+ bool AppendIfUnique(BreakpointSP bkpt) {
TargetSP target_sp = m_target_wp.lock();
- if (!target_sp)
+ if (!target_sp || !bkpt)
return false;
- if (bkpt.GetTargetSP() != target_sp)
+ if (bkpt->GetTargetSP() != target_sp)
return false;
- lldb::break_id_t bp_id = bkpt.GetID();
+ lldb::break_id_t bp_id = bkpt->GetID();
if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) ==
m_break_ids.end())
return false;
- m_break_ids.push_back(bkpt.GetID());
+ m_break_ids.push_back(bkpt->GetID());
return true;
}
@@ -827,7 +787,7 @@ void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
return;
if (!m_opaque_sp)
return;
- m_opaque_sp->Append(*sb_bkpt.get());
+ m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
}
void SBBreakpointList::AppendByID(lldb::break_id_t id) {
@@ -841,7 +801,7 @@ bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
return false;
if (!m_opaque_sp)
return false;
- return m_opaque_sp->AppendIfUnique(*sb_bkpt.get());
+ return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
}
void SBBreakpointList::Clear() {
diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp
index c7fac7688f83..d8779ffe2ba8 100644
--- a/source/API/SBBreakpointLocation.cpp
+++ b/source/API/SBBreakpointLocation.cpp
@@ -16,118 +16,124 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
using namespace lldb;
using namespace lldb_private;
-SBBreakpointLocation::SBBreakpointLocation() : m_opaque_sp() {}
+SBBreakpointLocation::SBBreakpointLocation() {}
SBBreakpointLocation::SBBreakpointLocation(
const lldb::BreakpointLocationSP &break_loc_sp)
- : m_opaque_sp(break_loc_sp) {
+ : m_opaque_wp(break_loc_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log) {
SBStream sstr;
GetDescription(sstr, lldb::eDescriptionLevelBrief);
- log->Printf("SBBreakpointLocation::SBBreakpointLocaiton (const "
- "lldb::BreakpointLocationsSP &break_loc_sp"
- "=%p) => this.sp = %p (%s)",
- static_cast<void *>(break_loc_sp.get()),
- static_cast<void *>(m_opaque_sp.get()), sstr.GetData());
+ LLDB_LOG(log, "location = {0} ({1})", break_loc_sp.get(), sstr.GetData());
}
}
SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {}
const SBBreakpointLocation &SBBreakpointLocation::
operator=(const SBBreakpointLocation &rhs) {
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
+ m_opaque_wp = rhs.m_opaque_wp;
return *this;
}
SBBreakpointLocation::~SBBreakpointLocation() {}
-bool SBBreakpointLocation::IsValid() const { return m_opaque_sp.get() != NULL; }
+BreakpointLocationSP SBBreakpointLocation::GetSP() const {
+ return m_opaque_wp.lock();
+}
+
+bool SBBreakpointLocation::IsValid() const { return bool(GetSP()); }
SBAddress SBBreakpointLocation::GetAddress() {
- if (m_opaque_sp)
- return SBAddress(&m_opaque_sp->GetAddress());
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp)
+ return SBAddress(&loc_sp->GetAddress());
else
return SBAddress();
}
addr_t SBBreakpointLocation::GetLoadAddress() {
addr_t ret_addr = LLDB_INVALID_ADDRESS;
+ BreakpointLocationSP loc_sp = GetSP();
- if (m_opaque_sp) {
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- ret_addr = m_opaque_sp->GetLoadAddress();
+ loc_sp->GetTarget().GetAPIMutex());
+ ret_addr = loc_sp->GetLoadAddress();
}
return ret_addr;
}
void SBBreakpointLocation::SetEnabled(bool enabled) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetEnabled(enabled);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetEnabled(enabled);
}
}
bool SBBreakpointLocation::IsEnabled() {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->IsEnabled();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->IsEnabled();
} else
return false;
}
uint32_t SBBreakpointLocation::GetIgnoreCount() {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetIgnoreCount();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetIgnoreCount();
} else
return 0;
}
void SBBreakpointLocation::SetIgnoreCount(uint32_t n) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetIgnoreCount(n);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetIgnoreCount(n);
}
}
void SBBreakpointLocation::SetCondition(const char *condition) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetCondition(condition);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetCondition(condition);
}
}
const char *SBBreakpointLocation::GetCondition() {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetConditionText();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetConditionText();
}
return NULL;
}
@@ -135,17 +141,15 @@ const char *SBBreakpointLocation::GetCondition() {
void SBBreakpointLocation::SetScriptCallbackFunction(
const char *callback_function_name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ BreakpointLocationSP loc_sp = GetSP();
+ LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(),
+ callback_function_name);
- if (log)
- log->Printf(
- "SBBreakpointLocation(%p)::SetScriptCallbackFunction (callback=%s)",
- static_cast<void *>(m_opaque_sp.get()), callback_function_name);
-
- if (m_opaque_sp) {
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions();
- m_opaque_sp->GetBreakpoint()
+ loc_sp->GetTarget().GetAPIMutex());
+ BreakpointOptions *bp_options = loc_sp->GetLocationOptions();
+ loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
.GetCommandInterpreter()
@@ -158,18 +162,17 @@ void SBBreakpointLocation::SetScriptCallbackFunction(
SBError
SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)",
- static_cast<void *>(m_opaque_sp.get()), callback_body_text);
+ BreakpointLocationSP loc_sp = GetSP();
+ LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(),
+ callback_body_text);
SBError sb_error;
- if (m_opaque_sp) {
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions();
+ loc_sp->GetTarget().GetAPIMutex());
+ BreakpointOptions *bp_options = loc_sp->GetLocationOptions();
Error error =
- m_opaque_sp->GetBreakpoint()
+ loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
.GetCommandInterpreter()
@@ -183,80 +186,89 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
}
void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetThreadID(thread_id);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetThreadID(thread_id);
}
}
tid_t SBBreakpointLocation::GetThreadID() {
tid_t tid = LLDB_INVALID_THREAD_ID;
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetThreadID();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetThreadID();
}
return tid;
}
void SBBreakpointLocation::SetThreadIndex(uint32_t index) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetThreadIndex(index);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetThreadIndex(index);
}
}
uint32_t SBBreakpointLocation::GetThreadIndex() const {
uint32_t thread_idx = UINT32_MAX;
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetThreadIndex();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetThreadIndex();
}
return thread_idx;
}
void SBBreakpointLocation::SetThreadName(const char *thread_name) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetThreadName(thread_name);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetThreadName(thread_name);
}
}
const char *SBBreakpointLocation::GetThreadName() const {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetThreadName();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetThreadName();
}
return NULL;
}
void SBBreakpointLocation::SetQueueName(const char *queue_name) {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->SetQueueName(queue_name);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->SetQueueName(queue_name);
}
}
const char *SBBreakpointLocation::GetQueueName() const {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->GetQueueName();
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->GetQueueName();
}
return NULL;
}
bool SBBreakpointLocation::IsResolved() {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->IsResolved();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->IsResolved();
}
return false;
}
@@ -264,17 +276,18 @@ bool SBBreakpointLocation::IsResolved() {
void SBBreakpointLocation::SetLocation(
const lldb::BreakpointLocationSP &break_loc_sp) {
// Uninstall the callbacks?
- m_opaque_sp = break_loc_sp;
+ m_opaque_wp = break_loc_sp;
}
bool SBBreakpointLocation::GetDescription(SBStream &description,
DescriptionLevel level) {
Stream &strm = description.ref();
+ BreakpointLocationSP loc_sp = GetSP();
- if (m_opaque_sp) {
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- m_opaque_sp->GetDescription(&strm, level);
+ loc_sp->GetTarget().GetAPIMutex());
+ loc_sp->GetDescription(&strm, level);
strm.EOL();
} else
strm.PutCString("No value");
@@ -283,34 +296,31 @@ bool SBBreakpointLocation::GetDescription(SBStream &description,
}
break_id_t SBBreakpointLocation::GetID() {
- if (m_opaque_sp) {
+ BreakpointLocationSP loc_sp = GetSP();
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- return m_opaque_sp->GetID();
+ loc_sp->GetTarget().GetAPIMutex());
+ return loc_sp->GetID();
} else
return LLDB_INVALID_BREAK_ID;
}
SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- // if (log)
- // log->Printf ("SBBreakpointLocation::GetBreakpoint ()");
+ BreakpointLocationSP loc_sp = GetSP();
SBBreakpoint sb_bp;
- if (m_opaque_sp) {
+ if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
- m_opaque_sp->GetTarget().GetAPIMutex());
- *sb_bp = m_opaque_sp->GetBreakpoint().shared_from_this();
+ loc_sp->GetTarget().GetAPIMutex());
+ sb_bp = loc_sp->GetBreakpoint().shared_from_this();
}
if (log) {
SBStream sstr;
sb_bp.GetDescription(sstr);
- log->Printf(
- "SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_bp.get()), sstr.GetData());
+ LLDB_LOG(log, "location = {0}, breakpoint = {1} ({2})", loc_sp.get(),
+ sb_bp.GetSP().get(), sstr.GetData());
}
return sb_bp;
}
diff --git a/source/API/SBBroadcaster.cpp b/source/API/SBBroadcaster.cpp
index 5189dd7bb271..278576b5ddcd 100644
--- a/source/API/SBBroadcaster.cpp
+++ b/source/API/SBBroadcaster.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBEvent.h"
@@ -22,25 +22,15 @@ SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {}
SBBroadcaster::SBBroadcaster(const char *name)
: m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) {
m_opaque_ptr = m_opaque_sp.get();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API |
- LIBLLDB_LOG_VERBOSE));
-
- if (log)
- log->Printf(
- "SBBroadcaster::SBBroadcaster (name=\"%s\") => SBBroadcaster(%p)", name,
- static_cast<void *>(m_opaque_ptr));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_LOGV(log, "(name=\"{0}\") => SBBroadcaster({1})", name, m_opaque_ptr);
}
SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns)
: m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API |
- LIBLLDB_LOG_VERBOSE));
-
- if (log)
- log->Printf("SBBroadcaster::SBBroadcaster (broadcaster=%p, bool owns=%i) "
- "=> SBBroadcaster(%p)",
- static_cast<void *>(broadcaster), owns,
- static_cast<void *>(m_opaque_ptr));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_LOGV(log, "(broadcaster={0}, owns={1}) => SBBroadcaster({2})",
+ broadcaster, owns, m_opaque_ptr);
}
SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs)
diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp
index 41d5147af707..7eed94e05b10 100644
--- a/source/API/SBCommandReturnObject.cpp
+++ b/source/API/SBCommandReturnObject.cpp
@@ -15,9 +15,10 @@
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBCommunication.cpp b/source/API/SBCommunication.cpp
index 9519c02f7e22..8ebc33ca26a6 100644
--- a/source/API/SBCommunication.cpp
+++ b/source/API/SBCommunication.cpp
@@ -10,8 +10,8 @@
#include "lldb/API/SBCommunication.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/Core/Communication.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index 12aed5911de7..149d587913e9 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -10,13 +10,13 @@
#include "lldb/API/SBCompileUnit.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBData.cpp b/source/API/SBData.cpp
index d905d3f272f3..a8ba5808d4f6 100644
--- a/source/API/SBData.cpp
+++ b/source/API/SBData.cpp
@@ -13,10 +13,11 @@
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/DumpDataExtractor.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -347,7 +348,7 @@ bool SBData::GetDescription(lldb::SBStream &description,
Stream &strm = description.ref();
if (m_opaque_sp) {
- m_opaque_sp->Dump(&strm, 0, lldb::eFormatBytesWithASCII, 1,
+ DumpDataExtractor(*m_opaque_sp, &strm, 0, lldb::eFormatBytesWithASCII, 1,
m_opaque_sp->GetByteSize(), 16, base_addr, 0, 0);
} else
strm.PutCString("No value");
@@ -383,7 +384,11 @@ void SBData::SetData(lldb::SBError &error, const void *buf, size_t size,
if (!m_opaque_sp.get())
m_opaque_sp.reset(new DataExtractor(buf, size, endian, addr_size));
else
+ {
m_opaque_sp->SetData(buf, size, endian);
+ m_opaque_sp->SetAddressByteSize(addr_size);
+ }
+
if (log)
log->Printf("SBData::SetData (error=%p,buf=%p,size=%" PRIu64
",endian=%d,addr_size=%c) => "
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index 97e6f7b518a5..8d23d3eb8505 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -1120,13 +1120,23 @@ SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) {
}
#endif // LLDB_DISABLE_PYTHON
+static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
+ if (categories == nullptr)
+ return {};
+ size_t len = 0;
+ while (categories[len] != nullptr)
+ ++len;
+ return llvm::makeArrayRef(categories, len);
+}
+
bool SBDebugger::EnableLog(const char *channel, const char **categories) {
if (m_opaque_sp) {
uint32_t log_options =
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
- StreamString errors;
- return m_opaque_sp->EnableLog(channel, categories, nullptr, log_options,
- errors);
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
+ return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "",
+ log_options, error_stream);
} else
return false;
}
diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp
index fc21f83f7ce9..d6e61e32582d 100644
--- a/source/API/SBDeclaration.cpp
+++ b/source/API/SBDeclaration.cpp
@@ -1,5 +1,4 @@
-//===-- SBDeclaration.cpp -----------------------------------------*- C++
-//-*-===//
+//===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,9 +9,10 @@
#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/Declaration.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include <limits.h>
diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp
index 451c0a709ec6..a692a9678cde 100644
--- a/source/API/SBError.cpp
+++ b/source/API/SBError.cpp
@@ -9,8 +9,8 @@
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include <stdarg.h>
diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp
index e0bb68c66c27..17a16ffd0481 100644
--- a/source/API/SBEvent.cpp
+++ b/source/API/SBEvent.cpp
@@ -12,12 +12,12 @@
#include "lldb/API/SBStream.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -109,13 +109,9 @@ bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) {
// For logging, this gets a little chatty so only enable this when verbose
// logging is on
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API |
- LIBLLDB_LOG_VERBOSE));
- if (log)
- log->Printf(
- "SBEvent(%p)::BroadcasterMatchesRef (SBBroadcaster(%p): %s) => %i",
- static_cast<void *>(get()), static_cast<void *>(broadcaster.get()),
- broadcaster.GetName(), success);
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(),
+ broadcaster.get(), broadcaster.GetName(), success);
return success;
}
diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp
index 88baf3b17ab1..011b88225ef9 100644
--- a/source/API/SBFileSpec.cpp
+++ b/source/API/SBFileSpec.cpp
@@ -12,9 +12,10 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallString.h"
diff --git a/source/API/SBFileSpecList.cpp b/source/API/SBFileSpecList.cpp
index 8ed3f6f03969..67d28dcbe111 100644
--- a/source/API/SBFileSpecList.cpp
+++ b/source/API/SBFileSpecList.cpp
@@ -13,9 +13,10 @@
#include "lldb/API/SBFileSpecList.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 8d8cb48df3b8..d52bbe8069f8 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -21,9 +21,6 @@
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectVariable.h"
@@ -42,6 +39,9 @@
#include "lldb/Target/StackID.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
@@ -1370,6 +1370,25 @@ const char *SBFrame::GetFunctionName() {
return static_cast<const SBFrame *>(this)->GetFunctionName();
}
+lldb::LanguageType SBFrame::GuessLanguage() const {
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+ StackFrame *frame = nullptr;
+ Target *target = exe_ctx.GetTargetPtr();
+ Process *process = exe_ctx.GetProcessPtr();
+ if (target && process) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process->GetRunLock())) {
+ frame = exe_ctx.GetFramePtr();
+ if (frame) {
+ return frame->GuessLanguage();
+ }
+ }
+ }
+ return eLanguageTypeUnknown;
+}
+
const char *SBFrame::GetFunctionName() const {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
const char *name = nullptr;
diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index 9065cc383ef7..6a24f64b43e4 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -11,7 +11,6 @@
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
@@ -19,6 +18,7 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp
index 8df74d931ec0..c25499db89cd 100644
--- a/source/API/SBHostOS.cpp
+++ b/source/API/SBHostOS.cpp
@@ -9,13 +9,13 @@
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBError.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Path.h"
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 8c616da5a7f0..c47307c733a8 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -16,8 +16,6 @@
#include "lldb/API/SBTarget.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Module.h"
@@ -25,6 +23,8 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
//----------------------------------------------------------------------
// We recently fixed a leak in one of the Instruction subclasses where
diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp
index 8ab3aca21816..04c37f50c2d7 100644
--- a/source/API/SBInstructionList.cpp
+++ b/source/API/SBInstructionList.cpp
@@ -12,8 +12,8 @@
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp
index 3469cecfb7ac..7341d3603dfe 100644
--- a/source/API/SBLineEntry.cpp
+++ b/source/API/SBLineEntry.cpp
@@ -11,9 +11,10 @@
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/LineEntry.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp
index 501535a897b4..50fed4e1ee7b 100644
--- a/source/API/SBListener.cpp
+++ b/source/API/SBListener.cpp
@@ -15,8 +15,8 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Listener.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -302,6 +302,8 @@ bool SBListener::HandleBroadcastEvent(const SBEvent &event) {
return false;
}
+lldb::ListenerSP SBListener::GetSP() { return m_opaque_sp; }
+
Listener *SBListener::operator->() const { return m_opaque_sp.get(); }
Listener *SBListener::get() const { return m_opaque_sp.get(); }
diff --git a/source/API/SBMemoryRegionInfo.cpp b/source/API/SBMemoryRegionInfo.cpp
index 3e7227650f7a..c4dbaec707bb 100644
--- a/source/API/SBMemoryRegionInfo.cpp
+++ b/source/API/SBMemoryRegionInfo.cpp
@@ -11,8 +11,8 @@
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBMemoryRegionInfoList.cpp b/source/API/SBMemoryRegionInfoList.cpp
index f7ce81af52d1..fff4044f73e0 100644
--- a/source/API/SBMemoryRegionInfoList.cpp
+++ b/source/API/SBMemoryRegionInfoList.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBMemoryRegionInfoList.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/Log.h"
#include <vector>
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 89643033a1dd..3865ba927977 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -14,10 +14,8 @@
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBSymbolContextList.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -27,6 +25,8 @@
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp
index b82b822859b4..a1c08865c6a4 100644
--- a/source/API/SBModuleSpec.cpp
+++ b/source/API/SBModuleSpec.cpp
@@ -11,9 +11,9 @@
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp
index 6085cef32064..0f1b99236a71 100644
--- a/source/API/SBPlatform.cpp
+++ b/source/API/SBPlatform.cpp
@@ -13,11 +13,13 @@
#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBUnixSignals.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/File.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+
+#include "llvm/Support/FileSystem.h"
#include <functional>
@@ -363,7 +365,7 @@ SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
if (src.Exists()) {
uint32_t permissions = src.ref().GetPermissions();
if (permissions == 0) {
- if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
+ if (llvm::sys::fs::is_directory(src.ref().GetPath()))
permissions = eFilePermissionsDirectoryDefault;
else
permissions = eFilePermissionsFileDefault;
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 59dd56933278..4cb367a03ad6 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -16,11 +16,9 @@
#include "lldb/lldb-types.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/MemoryRegionInfo.h"
@@ -29,6 +27,8 @@
#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
// Project includes
diff --git a/source/API/SBQueue.cpp b/source/API/SBQueue.cpp
index c6f53057a7af..5f852111e077 100644
--- a/source/API/SBQueue.cpp
+++ b/source/API/SBQueue.cpp
@@ -15,11 +15,11 @@
#include "lldb/API/SBQueueItem.h"
#include "lldb/API/SBThread.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Queue.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBQueueItem.cpp b/source/API/SBQueueItem.cpp
index 2e06bc89b3d5..87ba73f9e6d3 100644
--- a/source/API/SBQueueItem.cpp
+++ b/source/API/SBQueueItem.cpp
@@ -13,10 +13,10 @@
#include "lldb/API/SBQueueItem.h"
#include "lldb/API/SBThread.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp
index 8124fe94841d..9da5d170da9e 100644
--- a/source/API/SBSection.cpp
+++ b/source/API/SBSection.cpp
@@ -10,13 +10,14 @@
#include "lldb/API/SBSection.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -165,8 +166,8 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) {
else
file_size = 0;
}
- DataBufferSP data_buffer_sp(
- objfile->GetFileSpec().ReadFileContents(file_offset, file_size));
+ auto data_buffer_sp = DataBufferLLVM::CreateSliceFromPath(
+ objfile->GetFileSpec().GetPath(), file_size, file_offset);
if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) {
DataExtractorSP data_extractor_sp(
new DataExtractor(data_buffer_sp, objfile->GetByteOrder(),
diff --git a/source/API/SBSourceManager.cpp b/source/API/SBSourceManager.cpp
index ecf532c31162..5804c22bacb8 100644
--- a/source/API/SBSourceManager.cpp
+++ b/source/API/SBSourceManager.cpp
@@ -15,8 +15,8 @@
#include "lldb/API/SBFileSpec.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/Target/Target.h"
diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp
index 858e949206f4..5ae5a01589de 100644
--- a/source/API/SBStream.cpp
+++ b/source/API/SBStream.cpp
@@ -9,10 +9,10 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp
index 075ee0d5bc47..9ac69b15ebb7 100644
--- a/source/API/SBStringList.cpp
+++ b/source/API/SBStringList.cpp
@@ -9,7 +9,7 @@
#include "lldb/API/SBStringList.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp
index d9ea072186a9..6d4c862306f9 100644
--- a/source/API/SBStructuredData.cpp
+++ b/source/API/SBStructuredData.cpp
@@ -10,11 +10,11 @@
#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Target/StructuredDataPlugin.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp
index a4cc5252b1c5..5be20a124982 100644
--- a/source/API/SBSymbol.cpp
+++ b/source/API/SBSymbol.cpp
@@ -10,11 +10,11 @@
#include "lldb/API/SBSymbol.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index 474883673310..45dfffd916e7 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -9,11 +9,11 @@
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index c000bf94c234..4032383eb56c 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -34,17 +34,14 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/STLUtils.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -61,6 +58,9 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#include "../source/Commands/CommandObjectBreakpoint.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -686,7 +686,7 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
if (sb_module_list.GetSize() > 0) {
module_list = sb_module_list.get();
}
- *sb_bp = target_sp->CreateBreakpoint(
+ sb_bp = target_sp->CreateBreakpoint(
module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue,
internal, hardware, move_to_nearest_code);
}
@@ -699,7 +699,7 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
"SBBreakpoint(%p): %s",
static_cast<void *>(target_sp.get()), path, line,
- static_cast<void *>(sb_bp.get()), sstr.GetData());
+ static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
}
return sb_bp;
@@ -721,11 +721,11 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
if (module_name && module_name[0]) {
FileSpecList module_spec_list;
module_spec_list.Append(FileSpec(module_name, false));
- *sb_bp = target_sp->CreateBreakpoint(
+ sb_bp = target_sp->CreateBreakpoint(
&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
} else {
- *sb_bp = target_sp->CreateBreakpoint(
+ sb_bp = target_sp->CreateBreakpoint(
NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
offset, skip_prologue, internal, hardware);
}
@@ -735,7 +735,7 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
"module=\"%s\") => SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), symbol_name, module_name,
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -771,7 +771,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- *sb_bp = target_sp->CreateBreakpoint(
+ sb_bp = target_sp->CreateBreakpoint(
module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
symbol_language, 0, skip_prologue, internal, hardware);
}
@@ -780,7 +780,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
"name_type: %d) => SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), symbol_name,
- name_type_mask, static_cast<void *>(sb_bp.get()));
+ name_type_mask, static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -815,7 +815,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateBreakpoint(
+ sb_bp = target_sp->CreateBreakpoint(
module_list.get(), comp_unit_list.get(), symbol_names, num_names,
name_type_mask, symbol_language, offset, skip_prologue, internal,
hardware);
@@ -836,7 +836,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
log->Printf("\"<NULL>\"%c ", sep);
}
log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
}
return sb_bp;
@@ -875,7 +875,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
- *sb_bp = target_sp->CreateFuncRegexBreakpoint(
+ sb_bp = target_sp->CreateFuncRegexBreakpoint(
module_list.get(), comp_unit_list.get(), regexp, symbol_language,
skip_prologue, internal, hardware);
}
@@ -884,7 +884,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
"=> SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), symbol_name_regex,
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -897,7 +897,7 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
- *sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
+ sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
}
if (log)
@@ -905,7 +905,7 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
") => SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()),
static_cast<uint64_t>(address),
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -926,7 +926,7 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
- *sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
+ sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
}
if (log) {
@@ -935,7 +935,7 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
"SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), s.GetData(),
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
}
return sb_bp;
@@ -985,7 +985,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
func_names_set.insert(func_names.GetStringAtIndex(i));
}
- *sb_bp = target_sp->CreateSourceRegexBreakpoint(
+ sb_bp = target_sp->CreateSourceRegexBreakpoint(
module_list.get(), source_file_list.get(), func_names_set, regexp,
false, hardware, move_to_nearest_code);
}
@@ -994,7 +994,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
"=> SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), source_regex,
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -1009,7 +1009,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language,
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
- *sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
+ sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
hardware);
}
@@ -1019,7 +1019,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language,
static_cast<void *>(target_sp.get()),
Language::GetNameForLanguageType(language),
catch_bp ? "on" : "off", throw_bp ? "on" : "off",
- static_cast<void *>(sb_bp.get()));
+ static_cast<void *>(sb_bp.GetSP().get()));
return sb_bp;
}
@@ -1038,7 +1038,7 @@ SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
TargetSP target_sp(GetSP());
if (target_sp) {
// The breakpoint list is thread safe, no need to lock
- *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
+ sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
}
return sb_breakpoint;
}
@@ -1068,14 +1068,14 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
TargetSP target_sp(GetSP());
if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- *sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
+ sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
}
if (log)
log->Printf(
"SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
- static_cast<void *>(sb_breakpoint.get()));
+ static_cast<void *>(sb_breakpoint.GetSP().get()));
return sb_breakpoint;
}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index fbde6dd32686..3961a7f925a0 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -15,7 +15,6 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ValueObject.h"
@@ -34,6 +33,7 @@
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepRange.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
@@ -595,8 +595,8 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
}
if (log)
- log->Printf("SBThread(%p)::GetInfoItemByPathAsString () => %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()), strm.GetData());
+ log->Printf("SBThread(%p)::GetInfoItemByPathAsString (\"%s\") => \"%s\"",
+ static_cast<void *>(exe_ctx.GetThreadPtr()), path, strm.GetData());
return success;
}
diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp
index 74cabf7d4b04..7537a7645390 100644
--- a/source/API/SBThreadPlan.cpp
+++ b/source/API/SBThreadPlan.cpp
@@ -15,7 +15,6 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -28,12 +27,12 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
-#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanPython.h"
#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepRange.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index ca63a875292d..e2ef07cf5c47 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -11,13 +11,13 @@
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeEnumMember.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Mangled.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/APSInt.h"
diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp
index 787a46b17606..5ca9db7ce242 100644
--- a/source/API/SBTypeEnumMember.cpp
+++ b/source/API/SBTypeEnumMember.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/API/SBType.h"
+#include "lldb/API/SBTypeEnumMember.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
-#include "lldb/API/SBTypeEnumMember.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/API/SBType.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp
index bb85912c23de..14bdd39919c3 100644
--- a/source/API/SBUnixSignals.cpp
+++ b/source/API/SBUnixSignals.cpp
@@ -8,10 +8,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Log.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-defines.h"
#include "lldb/API/SBUnixSignals.h"
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 0531a3fe7d7a..ea0f9f591ab9 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -17,12 +17,9 @@
#include "lldb/API/SBTypeSynthetic.h"
#include "lldb/Breakpoint/Watchpoint.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
@@ -39,6 +36,9 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBExpressionOptions.h"
diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp
index 16289d9a9a96..0adf3bb914aa 100644
--- a/source/API/SBValueList.cpp
+++ b/source/API/SBValueList.cpp
@@ -10,8 +10,8 @@
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBValue.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectList.h"
+#include "lldb/Utility/Log.h"
#include <vector>
diff --git a/source/API/SBWatchpoint.cpp b/source/API/SBWatchpoint.cpp
index 50153c8c2346..b7755373abc9 100644
--- a/source/API/SBWatchpoint.cpp
+++ b/source/API/SBWatchpoint.cpp
@@ -16,39 +16,35 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Breakpoint/WatchpointList.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
using namespace lldb;
using namespace lldb_private;
-SBWatchpoint::SBWatchpoint() : m_opaque_sp() {}
+SBWatchpoint::SBWatchpoint() {}
SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp)
- : m_opaque_sp(wp_sp) {
+ : m_opaque_wp(wp_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log) {
SBStream sstr;
GetDescription(sstr, lldb::eDescriptionLevelBrief);
- log->Printf("SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp"
- "=%p) => this.sp = %p (%s)",
- static_cast<void *>(wp_sp.get()),
- static_cast<void *>(m_opaque_sp.get()), sstr.GetData());
+ LLDB_LOG(log, "watchpoint = {0} ({1})", wp_sp.get(), sstr.GetData());
}
}
SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {}
const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
- if (this != &rhs)
- m_opaque_sp = rhs.m_opaque_sp;
+ m_opaque_wp = rhs.m_opaque_wp;
return *this;
}
@@ -74,7 +70,7 @@ watch_id_t SBWatchpoint::GetID() {
return watch_id;
}
-bool SBWatchpoint::IsValid() const { return (bool)m_opaque_sp; }
+bool SBWatchpoint::IsValid() const { return bool(m_opaque_wp.lock()); }
SBError SBWatchpoint::GetError() {
SBError sb_error;
@@ -223,11 +219,11 @@ bool SBWatchpoint::GetDescription(SBStream &description,
return true;
}
-void SBWatchpoint::Clear() { m_opaque_sp.reset(); }
+void SBWatchpoint::Clear() { m_opaque_wp.reset(); }
-lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_sp; }
+lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_wp.lock(); }
-void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_sp = sp; }
+void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_wp = sp; }
bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) {
return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) !=
@@ -245,7 +241,7 @@ SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) {
SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) {
SBWatchpoint sb_watchpoint;
if (event.IsValid())
- sb_watchpoint.m_opaque_sp =
+ sb_watchpoint =
Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP());
return sb_watchpoint;
}
diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp
index 2df056e1b979..23aec1d6fa0a 100644
--- a/source/API/SystemInitializerFull.cpp
+++ b/source/API/SystemInitializerFull.cpp
@@ -74,6 +74,7 @@
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
#include "Plugins/Platform/NetBSD/PlatformNetBSD.h"
+#include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h"
#include "Plugins/Platform/Windows/PlatformWindows.h"
#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
@@ -266,6 +267,7 @@ void SystemInitializerFull::Initialize() {
platform_freebsd::PlatformFreeBSD::Initialize();
platform_linux::PlatformLinux::Initialize();
platform_netbsd::PlatformNetBSD::Initialize();
+ platform_openbsd::PlatformOpenBSD::Initialize();
PlatformWindows::Initialize();
PlatformKalimba::Initialize();
platform_android::PlatformAndroid::Initialize();
@@ -487,6 +489,7 @@ void SystemInitializerFull::Terminate() {
platform_freebsd::PlatformFreeBSD::Terminate();
platform_linux::PlatformLinux::Terminate();
platform_netbsd::PlatformNetBSD::Terminate();
+ platform_openbsd::PlatformOpenBSD::Terminate();
PlatformWindows::Terminate();
PlatformKalimba::Terminate();
platform_android::PlatformAndroid::Terminate();
diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp
index 915756f33353..2b44691186c0 100644
--- a/source/Breakpoint/Breakpoint.cpp
+++ b/source/Breakpoint/Breakpoint.cpp
@@ -19,18 +19,19 @@
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointID.cpp b/source/Breakpoint/BreakpointID.cpp
index 1ea86ca7611a..07742d9d7cf8 100644
--- a/source/Breakpoint/BreakpointID.cpp
+++ b/source/Breakpoint/BreakpointID.cpp
@@ -15,8 +15,8 @@
// Project includes
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointID.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index 578267a412d8..52bdefc4077f 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -15,9 +15,7 @@
#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/ExpressionVariable.h"
@@ -29,6 +27,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index 65c16e22e951..9851990a838e 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -14,14 +14,14 @@
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/source/Breakpoint/BreakpointResolver.cpp b/source/Breakpoint/BreakpointResolver.cpp
index 27c663c60443..f2579a0877e2 100644
--- a/source/Breakpoint/BreakpointResolver.cpp
+++ b/source/Breakpoint/BreakpointResolver.cpp
@@ -22,15 +22,15 @@
#include "lldb/Breakpoint/BreakpointResolverFileRegex.h"
#include "lldb/Breakpoint/BreakpointResolverName.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
using namespace lldb;
diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp
index 90d7415dcd94..4674ef08eae1 100644
--- a/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -15,12 +15,12 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointResolverFileLine.cpp b/source/Breakpoint/BreakpointResolverFileLine.cpp
index acdd29736260..610c8c956cf5 100644
--- a/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -14,11 +14,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -108,6 +108,68 @@ BreakpointResolverFileLine::SerializeToStructuredData() {
return WrapOptionsDict(options_dict_sp);
}
+// Filter the symbol context list to remove contexts where the line number was
+// moved into a new function. We do this conservatively, so if e.g. we cannot
+// resolve the function in the context (which can happen in case of
+// line-table-only debug info), we leave the context as is. The trickiest part
+// here is handling inlined functions -- in this case we need to make sure we
+// look at the declaration line of the inlined function, NOT the function it was
+// inlined into.
+void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
+ if (m_exact_match)
+ return; // Nothing to do. Contexts are precise.
+
+ Log * log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+ for(uint32_t i = 0; i < sc_list.GetSize(); ++i) {
+ SymbolContext sc;
+ sc_list.GetContextAtIndex(i, sc);
+ if (! sc.block)
+ continue;
+
+ FileSpec file;
+ uint32_t line;
+ const Block *inline_block = sc.block->GetContainingInlinedBlock();
+ if (inline_block) {
+ const Declaration &inline_declaration = inline_block->GetInlinedFunctionInfo()->GetDeclaration();
+ if (!inline_declaration.IsValid())
+ continue;
+ file = inline_declaration.GetFile();
+ line = inline_declaration.GetLine();
+ } else if (sc.function)
+ sc.function->GetStartLineSourceInfo(file, line);
+ else
+ continue;
+
+ if (file != sc.line_entry.file) {
+ LLDB_LOG(log, "unexpected symbol context file {0}", sc.line_entry.file);
+ continue;
+ }
+
+ // Compare the requested line number with the line of the function
+ // declaration. In case of a function declared as:
+ //
+ // int
+ // foo()
+ // {
+ // ...
+ //
+ // the compiler will set the declaration line to the "foo" line, which is
+ // the reason why we have -1 here. This can fail in case of two inline
+ // functions defined back-to-back:
+ //
+ // inline int foo1() { ... }
+ // inline int foo2() { ... }
+ //
+ // but that's the best we can do for now.
+ const int decl_line_is_too_late_fudge = 1;
+ if (m_line_number < line - decl_line_is_too_late_fudge) {
+ LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line);
+ sc_list.RemoveContextAtIndex(i);
+ --i;
+ }
+ }
+}
+
Searcher::CallbackReturn
BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
SymbolContext &context,
@@ -117,24 +179,20 @@ BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
assert(m_breakpoint != NULL);
// There is a tricky bit here. You can have two compilation units that
- // #include the same file, and
- // in one of them the function at m_line_number is used (and so code and a
- // line entry for it is generated) but in the
- // other it isn't. If we considered the CU's independently, then in the
- // second inclusion, we'd move the breakpoint
- // to the next function that actually generated code in the header file. That
- // would end up being confusing.
- // So instead, we do the CU iterations by hand here, then scan through the
- // complete list of matches, and figure out
- // the closest line number match, and only set breakpoints on that match.
+ // #include the same file, and in one of them the function at m_line_number is
+ // used (and so code and a line entry for it is generated) but in the other it
+ // isn't. If we considered the CU's independently, then in the second
+ // inclusion, we'd move the breakpoint to the next function that actually
+ // generated code in the header file. That would end up being confusing. So
+ // instead, we do the CU iterations by hand here, then scan through the
+ // complete list of matches, and figure out the closest line number match, and
+ // only set breakpoints on that match.
// Note also that if file_spec only had a file name and not a directory, there
- // may be many different file spec's in
- // the resultant list. The closest line match for one will not be right for
- // some totally different file.
- // So we go through the match list and pull out the sets that have the same
- // file spec in their line_entry
- // and treat each set separately.
+ // may be many different file spec's in the resultant list. The closest line
+ // match for one will not be right for some totally different file. So we go
+ // through the match list and pull out the sets that have the same file spec
+ // in their line_entry and treat each set separately.
const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
for (size_t i = 0; i < num_comp_units; i++) {
@@ -146,6 +204,9 @@ BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
sc_list);
}
}
+
+ FilterContexts(sc_list);
+
StreamString s;
s.Printf("for %s:%d ", m_file_spec.GetFilename().AsCString("<Unknown>"),
m_line_number);
diff --git a/source/Breakpoint/BreakpointResolverFileRegex.cpp b/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 86552969b95d..df6f5c2e4bf2 100644
--- a/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -14,11 +14,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp
index 6cc8f60dbc0a..f8ce775096ce 100644
--- a/source/Breakpoint/BreakpointResolverName.cpp
+++ b/source/Breakpoint/BreakpointResolverName.cpp
@@ -16,13 +16,13 @@
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointSite.cpp b/source/Breakpoint/BreakpointSite.cpp
index 28ba37b1b506..a5c5136eb7a6 100644
--- a/source/Breakpoint/BreakpointSite.cpp
+++ b/source/Breakpoint/BreakpointSite.cpp
@@ -18,7 +18,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSiteList.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/BreakpointSiteList.cpp b/source/Breakpoint/BreakpointSiteList.cpp
index 06155ee8b799..87ce292feb8e 100644
--- a/source/Breakpoint/BreakpointSiteList.cpp
+++ b/source/Breakpoint/BreakpointSiteList.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include <algorithm>
using namespace lldb;
diff --git a/source/Breakpoint/CMakeLists.txt b/source/Breakpoint/CMakeLists.txt
index 85494b15aa08..f6278528eab8 100644
--- a/source/Breakpoint/CMakeLists.txt
+++ b/source/Breakpoint/CMakeLists.txt
@@ -20,4 +20,17 @@ add_lldb_library(lldbBreakpoint
Watchpoint.cpp
WatchpointList.cpp
WatchpointOptions.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbExpression
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginCPlusPlusLanguage
+ lldbPluginObjCLanguage
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp
index 13dba8c8b198..3dbd6d23821c 100644
--- a/source/Breakpoint/Watchpoint.cpp
+++ b/source/Breakpoint/Watchpoint.cpp
@@ -14,7 +14,6 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -23,6 +22,7 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp
index 311dcaafdf4a..558ebc51008c 100644
--- a/source/Breakpoint/WatchpointOptions.cpp
+++ b/source/Breakpoint/WatchpointOptions.cpp
@@ -14,12 +14,12 @@
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index d031be940cb4..e9d8e79be1e5 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -1,26 +1,5 @@
include_directories(.)
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
-include_directories(
- Plugins/Process/Linux
- Plugins/Process/POSIX
- )
-endif ()
-
-if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
-include_directories(
- Plugins/Process/FreeBSD
- Plugins/Process/POSIX
- )
-endif ()
-
-if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
-include_directories(
- Plugins/Process/POSIX
- )
-endif ()
-
-
set(lldbBase_SOURCES
lldb.cpp
)
diff --git a/source/Commands/CMakeLists.txt b/source/Commands/CMakeLists.txt
index 8805bbf6dc94..55b41b1050c5 100644
--- a/source/Commands/CMakeLists.txt
+++ b/source/Commands/CMakeLists.txt
@@ -29,4 +29,20 @@ add_lldb_library(lldbCommands
CommandObjectWatchpoint.cpp
CommandObjectWatchpointCommand.cpp
CommandObjectLanguage.cpp
+
+ LINK_LIBS
+ lldbBase
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginExpressionParserClang
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index 10c1a2429bbe..fd84e1c4f857 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -16,12 +16,12 @@
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSet.h"
// Project includes
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
@@ -31,8 +31,13 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/TildeExpressionResolver.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
using namespace lldb_private;
@@ -98,181 +103,131 @@ int CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
return matches.GetSize();
}
-typedef struct DiskFilesOrDirectoriesBaton {
- const char *remainder;
- char *partial_name_copy;
- bool only_directories;
- bool *saw_directory;
- StringList *matches;
- char *end_ptr;
- size_t baselen;
-} DiskFilesOrDirectoriesBaton;
-
-FileSpec::EnumerateDirectoryResult
-DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type,
- const FileSpec &spec) {
- const char *name = spec.GetFilename().AsCString();
-
- const DiskFilesOrDirectoriesBaton *parameters =
- (DiskFilesOrDirectoriesBaton *)baton;
- char *end_ptr = parameters->end_ptr;
- char *partial_name_copy = parameters->partial_name_copy;
- const char *remainder = parameters->remainder;
-
- // Omit ".", ".." and any . files if the match string doesn't start with .
- if (name[0] == '.') {
- if (name[1] == '\0')
- return FileSpec::eEnumerateDirectoryResultNext;
- else if (name[1] == '.' && name[2] == '\0')
- return FileSpec::eEnumerateDirectoryResultNext;
- else if (remainder[0] != '.')
- return FileSpec::eEnumerateDirectoryResultNext;
- }
+static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
+ bool only_directories, bool &saw_directory,
+ StringList &matches,
+ TildeExpressionResolver &Resolver) {
+ matches.Clear();
+
+ llvm::SmallString<256> CompletionBuffer;
+ llvm::SmallString<256> Storage;
+ partial_name.toVector(CompletionBuffer);
+
+ if (CompletionBuffer.size() >= PATH_MAX)
+ return 0;
+
+ namespace fs = llvm::sys::fs;
+ namespace path = llvm::sys::path;
+
+ llvm::StringRef SearchDir;
+ llvm::StringRef PartialItem;
+
+ if (CompletionBuffer.startswith("~")) {
+ llvm::StringRef Buffer(CompletionBuffer);
+ size_t FirstSep =
+ Buffer.find_if([](char c) { return path::is_separator(c); });
+
+ llvm::StringRef Username = Buffer.take_front(FirstSep);
+ llvm::StringRef Remainder;
+ if (FirstSep != llvm::StringRef::npos)
+ Remainder = Buffer.drop_front(FirstSep + 1);
+
+ llvm::SmallString<PATH_MAX> Resolved;
+ if (!Resolver.ResolveExact(Username, Resolved)) {
+ // We couldn't resolve it as a full username. If there were no slashes
+ // then this might be a partial username. We try to resolve it as such
+ // but after that, we're done regardless of any matches.
+ if (FirstSep == llvm::StringRef::npos) {
+ llvm::StringSet<> MatchSet;
+ saw_directory = Resolver.ResolvePartial(Username, MatchSet);
+ for (const auto &S : MatchSet) {
+ Resolved = S.getKey();
+ path::append(Resolved, path::get_separator());
+ matches.AppendString(Resolved);
+ }
+ saw_directory = (matches.GetSize() > 0);
+ }
+ return matches.GetSize();
+ }
- // If we found a directory, we put a "/" at the end of the name.
+ // If there was no trailing slash, then we're done as soon as we resolve the
+ // expression to the correct directory. Otherwise we need to continue
+ // looking for matches within that directory.
+ if (FirstSep == llvm::StringRef::npos) {
+ // Make sure it ends with a separator.
+ path::append(CompletionBuffer, path::get_separator());
+ saw_directory = true;
+ matches.AppendString(CompletionBuffer);
+ return 1;
+ }
- if (remainder[0] == '\0' || strstr(name, remainder) == name) {
- if (strlen(name) + parameters->baselen >= PATH_MAX)
- return FileSpec::eEnumerateDirectoryResultNext;
+ // We want to keep the form the user typed, so we special case this to
+ // search in the fully resolved directory, but CompletionBuffer keeps the
+ // unmodified form that the user typed.
+ Storage = Resolved;
+ SearchDir = Resolved;
+ } else {
+ SearchDir = path::parent_path(CompletionBuffer);
+ }
- strcpy(end_ptr, name);
+ size_t FullPrefixLen = CompletionBuffer.size();
- bool isa_directory = false;
- if (file_type == FileSpec::eFileTypeDirectory)
- isa_directory = true;
- else if (file_type == FileSpec::eFileTypeSymbolicLink) {
- if (FileSpec(partial_name_copy, false).IsDirectory())
- isa_directory = true;
- }
+ PartialItem = path::filename(CompletionBuffer);
+ if (PartialItem == ".")
+ PartialItem = llvm::StringRef();
- if (isa_directory) {
- *parameters->saw_directory = true;
- size_t len = strlen(parameters->partial_name_copy);
- partial_name_copy[len] = '/';
- partial_name_copy[len + 1] = '\0';
- }
- if (parameters->only_directories && !isa_directory)
- return FileSpec::eEnumerateDirectoryResultNext;
- parameters->matches->AppendString(partial_name_copy);
+ if (SearchDir.empty()) {
+ llvm::sys::fs::current_path(Storage);
+ SearchDir = Storage;
}
+ assert(!PartialItem.contains(path::get_separator()));
- return FileSpec::eEnumerateDirectoryResultNext;
-}
+ // SearchDir now contains the directory to search in, and Prefix contains the
+ // text we want to match against items in that directory.
-static int DiskFilesOrDirectories(llvm::StringRef partial_file_name,
- bool only_directories, bool &saw_directory,
- StringList &matches) {
- // I'm going to use the "glob" function with GLOB_TILDE for user directory
- // expansion.
- // If it is not defined on your host system, you'll need to implement it
- // yourself...
-
- size_t partial_name_len = partial_file_name.size();
-
- if (partial_name_len >= PATH_MAX)
- return matches.GetSize();
-
- // This copy of the string will be cut up into the directory part, and the
- // remainder. end_ptr below will point to the place of the remainder in this
- // string. Then when we've resolved the containing directory, and opened it,
- // we'll read the directory contents and overwrite the partial_name_copy
- // starting from end_ptr with each of the matches. Thus we will preserve the
- // form the user originally typed.
-
- char partial_name_copy[PATH_MAX];
- memcpy(partial_name_copy, partial_file_name.data(), partial_name_len);
- partial_name_copy[partial_name_len] = '\0';
-
- // We'll need to save a copy of the remainder for comparison, which we do
- // here.
- char remainder[PATH_MAX];
-
- // end_ptr will point past the last / in partial_name_copy, or if there is no
- // slash to the beginning of the string.
- char *end_ptr;
-
- end_ptr = strrchr(partial_name_copy, '/');
-
- // This will store the resolved form of the containing directory
- llvm::SmallString<64> containing_part;
-
- if (end_ptr == nullptr) {
- // There's no directory. If the thing begins with a "~" then this is a bare
- // user name.
- if (*partial_name_copy == '~') {
- // Nothing here but the user name. We could just put a slash on the end,
- // but for completeness sake we'll resolve the user name and only put a
- // slash
- // on the end if it exists.
- llvm::SmallString<64> resolved_username(partial_name_copy);
- FileSpec::ResolveUsername(resolved_username);
-
- // Not sure how this would happen, a username longer than PATH_MAX?
- // Still...
- if (resolved_username.size() == 0) {
- // The user name didn't resolve, let's look in the password database for
- // matches.
- // The user name database contains duplicates, and is not in
- // alphabetical order, so
- // we'll use a set to manage that for us.
- FileSpec::ResolvePartialUsername(partial_name_copy, matches);
- if (matches.GetSize() > 0)
- saw_directory = true;
- return matches.GetSize();
- } else {
- // The thing exists, put a '/' on the end, and return it...
- // FIXME: complete user names here:
- partial_name_copy[partial_name_len] = '/';
- partial_name_copy[partial_name_len + 1] = '\0';
- matches.AppendString(partial_name_copy);
- saw_directory = true;
- return matches.GetSize();
- }
- } else {
- // The containing part is the CWD, and the whole string is the remainder.
- containing_part = ".";
- strcpy(remainder, partial_name_copy);
- end_ptr = partial_name_copy;
- }
- } else {
- if (end_ptr == partial_name_copy) {
- // We're completing a file or directory in the root volume.
- containing_part = "/";
- } else {
- containing_part.append(partial_name_copy, end_ptr);
- }
- // Push end_ptr past the final "/" and set remainder.
- end_ptr++;
- strcpy(remainder, end_ptr);
- }
+ std::error_code EC;
+ fs::directory_iterator Iter(SearchDir, EC, false);
+ fs::directory_iterator End;
+ for (; Iter != End && !EC; Iter.increment(EC)) {
+ auto &Entry = *Iter;
- // Look for a user name in the containing part, and if it's there, resolve it
- // and stick the
- // result back into the containing_part:
+ auto Name = path::filename(Entry.path());
- if (*partial_name_copy == '~') {
- FileSpec::ResolveUsername(containing_part);
- // User name doesn't exist, we're not getting any further...
- if (containing_part.empty())
- return matches.GetSize();
- }
+ // Omit ".", ".."
+ if (Name == "." || Name == ".." || !Name.startswith(PartialItem))
+ continue;
- // Okay, containing_part is now the directory we want to open and look for
- // files:
+ // We have a match.
- size_t baselen = end_ptr - partial_name_copy;
+ fs::file_status st;
+ if ((EC = Entry.status(st)))
+ continue;
- DiskFilesOrDirectoriesBaton parameters;
- parameters.remainder = remainder;
- parameters.partial_name_copy = partial_name_copy;
- parameters.only_directories = only_directories;
- parameters.saw_directory = &saw_directory;
- parameters.matches = &matches;
- parameters.end_ptr = end_ptr;
- parameters.baselen = baselen;
+ // If it's a symlink, then we treat it as a directory as long as the target
+ // is a directory.
+ bool is_dir = fs::is_directory(st);
+ if (fs::is_symlink_file(st)) {
+ fs::file_status target_st;
+ if (!fs::status(Entry.path(), target_st))
+ is_dir = fs::is_directory(target_st);
+ }
+ if (only_directories && !is_dir)
+ continue;
+
+ // Shrink it back down so that it just has the original prefix the user
+ // typed and remove the part of the name which is common to the located
+ // item and what the user typed.
+ CompletionBuffer.resize(FullPrefixLen);
+ Name = Name.drop_front(PartialItem.size());
+ CompletionBuffer.append(Name);
+
+ if (is_dir) {
+ saw_directory = true;
+ path::append(CompletionBuffer, path::get_separator());
+ }
- FileSpec::EnumerateDirectory(containing_part.c_str(), true, true, true,
- DiskFilesOrDirectoriesCallback, &parameters);
+ matches.AppendString(CompletionBuffer);
+ }
return matches.GetSize();
}
@@ -283,9 +238,17 @@ int CommandCompletions::DiskFiles(CommandInterpreter &interpreter,
int max_return_elements,
SearchFilter *searcher, bool &word_complete,
StringList &matches) {
- int ret_val =
- DiskFilesOrDirectories(partial_file_name, false, word_complete, matches);
- word_complete = !word_complete;
+ word_complete = false;
+ StandardTildeExpressionResolver Resolver;
+ return DiskFiles(partial_file_name, matches, Resolver);
+}
+
+int CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name,
+ StringList &matches,
+ TildeExpressionResolver &Resolver) {
+ bool word_complete;
+ int ret_val = DiskFilesOrDirectories(partial_file_name, false, word_complete,
+ matches, Resolver);
return ret_val;
}
@@ -293,9 +256,17 @@ int CommandCompletions::DiskDirectories(
CommandInterpreter &interpreter, llvm::StringRef partial_file_name,
int match_start_point, int max_return_elements, SearchFilter *searcher,
bool &word_complete, StringList &matches) {
- int ret_val =
- DiskFilesOrDirectories(partial_file_name, true, word_complete, matches);
word_complete = false;
+ StandardTildeExpressionResolver Resolver;
+ return DiskDirectories(partial_file_name, matches, Resolver);
+}
+
+int CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name,
+ StringList &matches,
+ TildeExpressionResolver &Resolver) {
+ bool word_complete;
+ int ret_val = DiskFilesOrDirectories(partial_file_name, true, word_complete,
+ matches, Resolver);
return ret_val;
}
diff --git a/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp
index d98a246e9684..8042aa9d81db 100644
--- a/source/Commands/CommandObjectArgs.cpp
+++ b/source/Commands/CommandObjectArgs.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -223,9 +224,9 @@ bool CommandObjectArgs::DoExecute(Args &args, CommandReturnObject &result) {
result.GetOutputStream().Printf("Arguments : \n");
for (auto entry : llvm::enumerate(args.entries())) {
- result.GetOutputStream().Printf("%" PRIu64 " (%s): ", (uint64_t)entry.Index,
- entry.Value.c_str());
- value_list.GetValueAtIndex(entry.Index)->Dump(&result.GetOutputStream());
+ result.GetOutputStream().Printf(
+ "%" PRIu64 " (%s): ", (uint64_t)entry.index(), entry.value().c_str());
+ value_list.GetValueAtIndex(entry.index())->Dump(&result.GetOutputStream());
result.GetOutputStream().Printf("\n");
}
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 941dd9a7849a..d77cf55b60e9 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -18,9 +18,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -33,6 +31,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index 5e4ee0ba0700..73c0c314533c 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -19,6 +19,7 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/State.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp
index aa07c104846f..102010e8e6f6 100644
--- a/source/Commands/CommandObjectCommands.cpp
+++ b/source/Commands/CommandObjectCommands.cpp
@@ -17,7 +17,7 @@
#include "CommandObjectHelp.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -28,6 +28,7 @@
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index fa3a1440ffc0..4496462476b4 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -16,7 +16,7 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index cfb3a6dd5117..8a0afce741e9 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -24,7 +24,7 @@
#include "lldb/Expression/REPL.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 5a350545763d..8be9b6f9b7a6 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
@@ -25,7 +24,7 @@
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -47,6 +46,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -192,14 +192,13 @@ protected:
return false;
}
- const bool qualify_cxx_base_classes = false;
- DumpValueObjectOptions::DeclPrintingHelper helper =
- [&valobj_sp, qualify_cxx_base_classes](
- ConstString type, ConstString var,
- const DumpValueObjectOptions &opts, Stream &stream) -> bool {
+ DumpValueObjectOptions::DeclPrintingHelper helper = [&valobj_sp](
+ ConstString type, ConstString var, const DumpValueObjectOptions &opts,
+ Stream &stream) -> bool {
const ValueObject::GetExpressionPathFormat format = ValueObject::
GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers;
+ const bool qualify_cxx_base_classes = false;
valobj_sp->GetExpressionPath(stream, qualify_cxx_base_classes, format);
stream.PutCString(" =");
return true;
diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h
index 721917a16852..cd9006619bc8 100644
--- a/source/Commands/CommandObjectHelp.h
+++ b/source/Commands/CommandObjectHelp.h
@@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/Options.h"
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index 3fdd888d2ed0..2099310d32c3 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -13,15 +13,10 @@
// Project includes
#include "CommandObjectLog.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -32,6 +27,10 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -41,13 +40,13 @@ static OptionDefinition g_log_options[] = {
{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to." },
{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." },
- { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." },
{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
+ { LLDB_OPT_SET_1, false, "file-function",'F',OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend the names of files and function that generate the logs." },
// clang-format on
};
@@ -109,9 +108,6 @@ public:
case 'v':
log_options |= LLDB_LOG_OPTION_VERBOSE;
break;
- case 'g':
- log_options |= LLDB_LOG_OPTION_DEBUG;
- break;
case 's':
log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE;
break;
@@ -130,6 +126,9 @@ public:
case 'a':
log_options |= LLDB_LOG_OPTION_APPEND;
break;
+ case 'F':
+ log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION;
+ break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
@@ -171,9 +170,14 @@ protected:
m_options.log_file.GetPath(log_file, sizeof(log_file));
else
log_file[0] = '\0';
+
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
bool success = m_interpreter.GetDebugger().EnableLog(
- channel.c_str(), args.GetConstArgumentVector(), log_file,
- m_options.log_options, result.GetErrorStream());
+ channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
+ error_stream);
+ result.GetErrorStream() << error_stream.str();
+
if (success)
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
@@ -227,25 +231,18 @@ protected:
return false;
}
- Log::Callbacks log_callbacks;
-
const std::string channel = args[0].ref;
args.Shift(); // Shift off the channel
- if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
- log_callbacks.disable(args.GetConstArgumentVector(),
- &result.GetErrorStream());
+ if (channel == "all") {
+ Log::DisableAllLogChannels();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else if (channel == "all") {
- Log::DisableAllLogChannels(&result.GetErrorStream());
} else {
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(channel.data()));
- if (log_channel_sp) {
- log_channel_sp->Disable(args.GetConstArgumentVector(),
- &result.GetErrorStream());
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
+ if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(),
+ error_stream))
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else
- result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
- channel.data());
+ result.GetErrorStream() << error_stream.str();
}
return result.Succeeded();
}
@@ -280,31 +277,20 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
+ std::string output;
+ llvm::raw_string_ostream output_stream(output);
if (args.empty()) {
- Log::ListAllLogChannels(&result.GetOutputStream());
+ Log::ListAllLogChannels(output_stream);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- for (auto &entry : args.entries()) {
- Log::Callbacks log_callbacks;
-
- if (Log::GetLogChannelCallbacks(ConstString(entry.ref),
- log_callbacks)) {
- log_callbacks.list_categories(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else if (entry.ref == "all") {
- Log::ListAllLogChannels(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(entry.c_str()));
- if (log_channel_sp) {
- log_channel_sp->ListCategories(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else
- result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
- entry.c_str());
- }
- }
+ bool success = true;
+ for (const auto &entry : args.entries())
+ success =
+ success && Log::ListChannelCategories(entry.ref, output_stream);
+ if (success)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
}
+ result.GetOutputStream() << output_stream.str();
return result.Succeeded();
}
};
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index 49ae92389277..1679614fe3f7 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -17,15 +17,13 @@
// Project includes
#include "CommandObjectMemory.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -42,6 +40,9 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private.h"
@@ -861,10 +862,10 @@ protected:
}
assert(output_stream);
- size_t bytes_dumped =
- data.Dump(output_stream, 0, format, item_byte_size, item_count,
- num_per_line / target->GetArchitecture().GetDataByteSize(),
- addr, 0, 0, exe_scope);
+ size_t bytes_dumped = DumpDataExtractor(
+ data, output_stream, 0, format, item_byte_size, item_count,
+ num_per_line / target->GetArchitecture().GetDataByteSize(), addr, 0, 0,
+ exe_scope);
m_next_addr = addr + bytes_dumped;
output_stream->EOL();
return true;
@@ -1131,10 +1132,10 @@ protected:
DataExtractor data(dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(),
process->GetByteOrder(),
process->GetAddressByteSize());
- data.Dump(&result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1,
- dumpbuffer.GetByteSize(), 16,
- found_location + m_memory_options.m_offset.GetCurrentValue(),
- 0, 0);
+ DumpDataExtractor(
+ data, &result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1,
+ dumpbuffer.GetByteSize(), 16,
+ found_location + m_memory_options.m_offset.GetCurrentValue(), 0, 0);
result.GetOutputStream().EOL();
}
@@ -1358,8 +1359,9 @@ protected:
size_t length = SIZE_MAX;
if (item_byte_size > 1)
length = item_byte_size;
- lldb::DataBufferSP data_sp(m_memory_options.m_infile.ReadFileContents(
- m_memory_options.m_infile_offset, length));
+ auto data_sp = DataBufferLLVM::CreateSliceFromPath(
+ m_memory_options.m_infile.GetPath(), length,
+ m_memory_options.m_infile_offset);
if (data_sp) {
length = data_sp->GetByteSize();
if (length > 0) {
@@ -1441,8 +1443,16 @@ protected:
case eFormatHex:
case eFormatHexUppercase:
case eFormatPointer:
+ {
// Decode hex bytes
- if (entry.ref.getAsInteger(16, uval64)) {
+ // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we
+ // have to special case that:
+ bool success = false;
+ if (entry.ref.startswith("0x"))
+ success = !entry.ref.getAsInteger(0, uval64);
+ if (!success)
+ success = !entry.ref.getAsInteger(16, uval64);
+ if (!success) {
result.AppendErrorWithFormat(
"'%s' is not a valid hex string value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -1457,7 +1467,7 @@ protected:
}
buffer.PutMaxHex64(uval64, item_byte_size);
break;
-
+ }
case eFormatBoolean:
uval64 = Args::StringToBoolean(entry.ref, false, &success);
if (!success) {
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index 562572b4c75e..62ea683e6e0d 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -13,10 +13,10 @@
// Other libraries and framework includes
// Project includes
#include "CommandObjectPlatform.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -27,9 +27,10 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
-#include "lldb/Utility/Utils.h"
+#include "lldb/Utility/DataExtractor.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Threading.h"
using namespace lldb;
using namespace lldb_private;
@@ -1182,21 +1183,21 @@ protected:
m_options.match_info.GetProcessInfo().GetName();
if (match_name && match_name[0]) {
switch (m_options.match_info.GetNameMatchType()) {
- case eNameMatchIgnore:
+ case NameMatch::Ignore:
break;
- case eNameMatchEquals:
+ case NameMatch::Equals:
match_desc = "matched";
break;
- case eNameMatchContains:
+ case NameMatch::Contains:
match_desc = "contained";
break;
- case eNameMatchStartsWith:
+ case NameMatch::StartsWith:
match_desc = "started with";
break;
- case eNameMatchEndsWith:
+ case NameMatch::EndsWith:
match_desc = "ended with";
break;
- case eNameMatchRegularExpression:
+ case NameMatch::RegularExpression:
match_desc = "matched the regular expression";
break;
}
@@ -1249,8 +1250,8 @@ protected:
public:
CommandOptions()
: Options(), match_info(), show_args(false), verbose(false) {
- 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, []() {
PosixPlatformCommandOptionValidator *posix_validator =
new PosixPlatformCommandOptionValidator();
for (auto &Option : g_platform_process_list_options) {
@@ -1342,31 +1343,31 @@ protected:
case 'n':
match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg,
false);
- match_info.SetNameMatchType(eNameMatchEquals);
+ match_info.SetNameMatchType(NameMatch::Equals);
break;
case 'e':
match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg,
false);
- match_info.SetNameMatchType(eNameMatchEndsWith);
+ match_info.SetNameMatchType(NameMatch::EndsWith);
break;
case 's':
match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg,
false);
- match_info.SetNameMatchType(eNameMatchStartsWith);
+ match_info.SetNameMatchType(NameMatch::StartsWith);
break;
case 'c':
match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg,
false);
- match_info.SetNameMatchType(eNameMatchContains);
+ match_info.SetNameMatchType(NameMatch::Contains);
break;
case 'r':
match_info.GetProcessInfo().GetExecutableFile().SetFile(option_arg,
false);
- match_info.SetNameMatchType(eNameMatchRegularExpression);
+ match_info.SetNameMatchType(NameMatch::RegularExpression);
break;
case 'A':
@@ -1585,7 +1586,7 @@ public:
if (partial_name) {
match_info.GetProcessInfo().GetExecutableFile().SetFile(
partial_name, false);
- match_info.SetNameMatchType(eNameMatchStartsWith);
+ match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
const uint32_t num_matches = process_infos.GetSize();
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 5b7f1342328b..557bdeecc22c 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -416,7 +417,7 @@ public:
if (partial_name) {
match_info.GetProcessInfo().GetExecutableFile().SetFile(
partial_name, false);
- match_info.SetNameMatchType(eNameMatchStartsWith);
+ match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
const size_t num_matches = process_infos.GetSize();
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index 0ba6526d347d..4d856d6bd1e0 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -14,10 +14,10 @@
// Project includes
#include "CommandObjectRegister.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -31,6 +31,7 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 23fdcb9e895c..4a9f69f9c192 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/StringRef.h"
// Project includes
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index 6ff32080905e..1b9ee1bf8c73 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -18,8 +18,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -31,6 +30,7 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/Utility/FileSpec.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index d2e53aa4a14f..a2df4909dc02 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/Args.h"
@@ -50,6 +51,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "llvm/Support/FileSystem.h"
+
// C Includes
// C++ Includes
#include <cerrno>
@@ -2567,6 +2570,12 @@ public:
m_option_group(),
m_file_option(LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeName,
"Fullpath or basename for module to load.", ""),
+ m_load_option(LLDB_OPT_SET_1, false, "load", 'l',
+ "Write file contents to the memory.", false, true),
+ m_pc_option(LLDB_OPT_SET_1, false, "--set-pc-to-entry", 'p',
+ "Set PC to the entry point."
+ " Only applicable with '--load' option.",
+ false, true),
m_slide_option(LLDB_OPT_SET_1, false, "slide", 's', 0, eArgTypeOffset,
"Set the load address for all sections to be the "
"virtual address in the file plus the offset.",
@@ -2574,6 +2583,8 @@ public:
m_option_group.Append(&m_uuid_option_group, LLDB_OPT_SET_ALL,
LLDB_OPT_SET_1);
m_option_group.Append(&m_file_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append(&m_load_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append(&m_pc_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append(&m_slide_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
@@ -2585,6 +2596,8 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ const bool load = m_load_option.GetOptionValue().GetCurrentValue();
+ const bool set_pc = m_pc_option.GetOptionValue().GetCurrentValue();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2594,6 +2607,21 @@ protected:
const size_t argc = args.GetArgumentCount();
ModuleSpec module_spec;
bool search_using_module_spec = false;
+
+ // Allow "load" option to work without --file or --uuid
+ // option.
+ if (load) {
+ if (!m_file_option.GetOptionValue().OptionWasSet() &&
+ !m_uuid_option_group.GetOptionValue().OptionWasSet()) {
+ ModuleList &module_list = target->GetImages();
+ if (module_list.GetSize() == 1) {
+ search_using_module_spec = true;
+ module_spec.GetFileSpec() =
+ module_list.GetModuleAtIndex(0)->GetFileSpec();
+ }
+ }
+ }
+
if (m_file_option.GetOptionValue().OptionWasSet()) {
search_using_module_spec = true;
const char *arg_cstr = m_file_option.GetOptionValue().GetCurrentValue();
@@ -2721,6 +2749,13 @@ protected:
if (process)
process->Flush();
}
+ if (load) {
+ Error error = module->LoadInMemory(*target, set_pc);
+ if (error.Fail()) {
+ result.AppendError(error.AsCString());
+ return false;
+ }
+ }
} else {
module->GetFileSpec().GetPath(path, sizeof(path));
result.AppendErrorWithFormat(
@@ -2783,6 +2818,8 @@ protected:
OptionGroupOptions m_option_group;
OptionGroupUUID m_uuid_option_group;
OptionGroupString m_file_option;
+ OptionGroupBoolean m_load_option;
+ OptionGroupBoolean m_pc_option;
OptionGroupUInt64 m_slide_option;
};
@@ -4102,20 +4139,21 @@ protected:
module_sp->SetSymbolFileFileSpec(FileSpec());
}
+ namespace fs = llvm::sys::fs;
if (module_spec.GetUUID().IsValid()) {
StreamString ss_symfile_uuid;
module_spec.GetUUID().Dump(&ss_symfile_uuid);
result.AppendErrorWithFormat(
"symbol file '%s' (%s) does not match any existing module%s\n",
symfile_path, ss_symfile_uuid.GetData(),
- (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
+ !fs::is_regular_file(symbol_fspec.GetPath())
? "\n please specify the full path to the symbol file"
: "");
} else {
result.AppendErrorWithFormat(
"symbol file '%s' does not match any existing module%s\n",
symfile_path,
- (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
+ !fs::is_regular_file(symbol_fspec.GetPath())
? "\n please specify the full path to the symbol file"
: "");
}
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index 0c4072b19b84..7ba6f2c19a8d 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/State.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 621ef581a978..b34a42738d4f 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -16,13 +16,11 @@
#include <functional>
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StringList.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -38,6 +36,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/StringList.h"
// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
@@ -82,9 +83,9 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
return false;
for (auto entry : llvm::enumerate(command.entries().drop_back())) {
- if (entry.Value.ref != "unsigned")
+ if (entry.value().ref != "unsigned")
continue;
- auto next = command.entries()[entry.Index + 1].ref;
+ auto next = command.entries()[entry.index() + 1].ref;
if (next == "int" || next == "short" || next == "char" || next == "long") {
result.AppendWarningWithFormat(
"unsigned %s being treated as two types. if you meant the combined "
@@ -1188,8 +1189,7 @@ protected:
category_closure(category_sp);
} else {
DataVisualization::Categories::ForEach(
- [this, &command, &result, &category_regex, &formatter_regex,
- &category_closure](
+ [&category_regex, &category_closure](
const lldb::TypeCategoryImplSP &category) -> bool {
if (category_regex) {
bool escape = true;
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index baa9f4163a63..1ad53cdb88ad 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -20,10 +20,9 @@
// Project includes
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Breakpoint/WatchpointList.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -31,6 +30,7 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp
index 1860d4cca9fe..1509c487a8a7 100644
--- a/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -19,6 +19,7 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/State.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index e2ccf9d72216..91229a9b18eb 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -9,23 +9,53 @@
#include "lldb/Core/Address.h"
-// C Includes
-// C++ Includes
-#include "llvm/ADT/Triple.h"
-
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Core/Section.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Declaration.h" // for Declaration
+#include "lldb/Symbol/LineEntry.h" // for LineEntry
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h" // for Symbol
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Symtab.h" // for Symtab
+#include "lldb/Symbol/Type.h" // for Type
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextScope
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/DataExtractor.h" // for DataExtractor
+#include "lldb/Utility/Endian.h" // for InlHostByteOrder
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h" // for StreamString
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
+
+#include <cstdint> // for uint8_t, uint32_t
+#include <memory> // for shared_ptr, operator!=
+#include <vector> // for vector
+
+#include <assert.h> // for assert
+#include <inttypes.h> // for PRIu64, PRIx64
+#include <string.h> // for size_t, strlen
+
+namespace lldb_private {
+class CompileUnit;
+}
+namespace lldb_private {
+class Function;
+}
using namespace lldb;
using namespace lldb_private;
@@ -143,15 +173,15 @@ static bool DumpUInt(ExecutionContextScope *exe_scope, const Address &address,
if (GetByteOrderAndAddressSize(exe_scope, address, byte_order, addr_size)) {
DataExtractor data(&buf.front(), buf.size(), byte_order, addr_size);
- data.Dump(strm,
- 0, // Start offset in "data"
- eFormatHex, // Print as characters
- buf.size(), // Size of item
- 1, // Items count
- UINT32_MAX, // num per line
- LLDB_INVALID_ADDRESS, // base address
- 0, // bitfield bit size
- 0); // bitfield bit offset
+ DumpDataExtractor(data, strm,
+ 0, // Start offset in "data"
+ eFormatHex, // Print as characters
+ buf.size(), // Size of item
+ 1, // Items count
+ UINT32_MAX, // num per line
+ LLDB_INVALID_ADDRESS, // base address
+ 0, // bitfield bit size
+ 0); // bitfield bit offset
return true;
}
@@ -181,16 +211,16 @@ static size_t ReadCStringFromMemory(ExecutionContextScope *exe_scope,
if (len > bytes_read)
len = bytes_read;
- data.Dump(strm,
- 0, // Start offset in "data"
- eFormatChar, // Print as characters
- 1, // Size of item (1 byte for a char!)
- len, // How many bytes to print?
- UINT32_MAX, // num per line
- LLDB_INVALID_ADDRESS, // base address
- 0, // bitfield bit size
+ DumpDataExtractor(data, strm,
+ 0, // Start offset in "data"
+ eFormatChar, // Print as characters
+ 1, // Size of item (1 byte for a char!)
+ len, // How many bytes to print?
+ UINT32_MAX, // num per line
+ LLDB_INVALID_ADDRESS, // base address
+ 0, // bitfield bit size
- 0); // bitfield bit offset
+ 0); // bitfield bit offset
total_len += bytes_read;
diff --git a/source/Core/AddressRange.cpp b/source/Core/AddressRange.cpp
index e03d721b566d..c1507797b374 100644
--- a/source/Core/AddressRange.cpp
+++ b/source/Core/AddressRange.cpp
@@ -8,10 +8,23 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
+
+#include <memory> // for shared_ptr
+
+#include <inttypes.h> // for PRIx64
+
+namespace lldb_private {
+class SectionList;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/AddressResolver.cpp b/source/Core/AddressResolver.cpp
index 40f4d55340ec..8d7cc9f6a428 100644
--- a/source/Core/AddressResolver.cpp
+++ b/source/Core/AddressResolver.cpp
@@ -9,16 +9,11 @@
#include "lldb/Core/AddressResolver.h"
-// Project includes
-
-#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/ModuleList.h"
#include "lldb/Core/SearchFilter.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Target/Target.h"
+
+namespace lldb_private {
+class ModuleList;
+}
using namespace lldb_private;
diff --git a/source/Core/AddressResolverFileLine.cpp b/source/Core/AddressResolverFileLine.cpp
index 939cf45f3e88..798a9b50079e 100644
--- a/source/Core/AddressResolverFileLine.cpp
+++ b/source/Core/AddressResolverFileLine.cpp
@@ -9,11 +9,21 @@
#include "lldb/Core/AddressResolverFileLine.h"
-// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/AddressRange.h" // for AddressRange
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/LineEntry.h" // for LineEntry
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIB...
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h" // for SymbolContextItem::eSymbolCon...
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <inttypes.h> // for PRIx64
+#include <vector> // for vector
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/AddressResolverName.cpp b/source/Core/AddressResolverName.cpp
index d9b6dad5e4e3..9935362e0e98 100644
--- a/source/Core/AddressResolverName.cpp
+++ b/source/Core/AddressResolverName.cpp
@@ -9,16 +9,25 @@
#include "lldb/Core/AddressResolverName.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Log.h"
+#include "lldb/Core/Address.h" // for Address, operator==
+#include "lldb/Core/AddressRange.h" // for AddressRange
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIB...
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/lldb-enumerations.h" // for SymbolType::eSymbolTypeCode
+#include "lldb/lldb-forward.h" // for ModuleSP
+#include "lldb/lldb-types.h" // for addr_t
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <memory> // for shared_ptr
+#include <string> // for string
+#include <vector> // for vector
+
+#include <stdint.h> // for uint32_t
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index cf7afb83dabd..60ee237aa0f5 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -9,31 +9,30 @@
#include "lldb/Core/ArchSpec.h"
-// C Includes
-// C++ Includes
-#include <cerrno>
-#include <cstdio>
-#include <string>
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StringList.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_C...
+#include "lldb/lldb-forward.h" // for RegisterContextSP
+
+#include "Plugins/Process/Utility/ARMDefines.h"
+#include "Plugins/Process/Utility/InstructionUtils.h"
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Twine.h" // for Twine
#include "llvm/Support/COFF.h"
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
#include "llvm/Support/ELF.h"
#include "llvm/Support/Host.h"
+#include "llvm/Support/MachO.h" // for CPUType::CPU_T...
-// Project includes
-#include "Plugins/Process/Utility/ARMDefines.h"
-#include "Plugins/Process/Utility/InstructionUtils.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/StringList.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Platform.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/NameMatches.h"
-#include "lldb/Utility/SafeMachO.h"
+#include <memory> // for shared_ptr
+#include <string>
+#include <tuple> // for tie, tuple
using namespace lldb;
using namespace lldb_private;
@@ -259,7 +258,7 @@ struct ArchDefinition {
size_t ArchSpec::AutoComplete(llvm::StringRef name, StringList &matches) {
if (!name.empty()) {
for (uint32_t i = 0; i < llvm::array_lengthof(g_core_definitions); ++i) {
- if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
+ if (NameMatches(g_core_definitions[i].name, NameMatch::StartsWith, name))
matches.AppendString(g_core_definitions[i].name);
}
} else {
@@ -657,7 +656,7 @@ void ArchSpec::SetFlags(std::string elf_abi) {
SetFlags(flag);
}
-std::string ArchSpec::GetClangTargetCPU() {
+std::string ArchSpec::GetClangTargetCPU() const {
std::string cpu;
const llvm::Triple::ArchType machine = GetMachine();
@@ -1380,7 +1379,7 @@ static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2,
if (core2 >= ArchSpec::kCore_mips32el_first &&
core2 <= ArchSpec::kCore_mips32el_last)
return true;
- try_inverse = false;
+ try_inverse = true;
}
break;
diff --git a/source/Core/Baton.cpp b/source/Core/Baton.cpp
deleted file mode 100644
index 998a5dffca9c..000000000000
--- a/source/Core/Baton.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Baton.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Stream.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-void UntypedBaton::GetDescription(Stream *s,
- lldb::DescriptionLevel level) const {}
diff --git a/source/Core/Broadcaster.cpp b/source/Core/Broadcaster.cpp
index d2cca7a2a654..7a4932c4987e 100644
--- a/source/Core/Broadcaster.cpp
+++ b/source/Core/Broadcaster.cpp
@@ -9,21 +9,26 @@
#include "lldb/Core/Broadcaster.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAnyCategoriesSet, Get...
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+
+#include <algorithm> // for find_if
+#include <memory> // for make_shared
+#include <type_traits> // for move
+
+#include <assert.h> // for assert
+#include <stddef.h> // for size_t
using namespace lldb;
using namespace lldb_private;
Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name)
- : m_broadcaster_sp(new BroadcasterImpl(*this)), m_manager_sp(manager_sp),
- m_broadcaster_name(name) {
+ : m_broadcaster_sp(std::make_shared<BroadcasterImpl>(*this)),
+ m_manager_sp(manager_sp), m_broadcaster_name(name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p Broadcaster::Broadcaster(\"%s\")",
@@ -242,19 +247,19 @@ void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(EventSP &event_sp,
void Broadcaster::BroadcasterImpl::BroadcastEvent(uint32_t event_type,
EventData *event_data) {
- EventSP event_sp(new Event(event_type, event_data));
+ auto event_sp = std::make_shared<Event>(event_type, event_data);
PrivateBroadcastEvent(event_sp, false);
}
void Broadcaster::BroadcasterImpl::BroadcastEvent(
uint32_t event_type, const lldb::EventDataSP &event_data_sp) {
- EventSP event_sp(new Event(event_type, event_data_sp));
+ auto event_sp = std::make_shared<Event>(event_type, event_data_sp);
PrivateBroadcastEvent(event_sp, false);
}
void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(
uint32_t event_type, EventData *event_data) {
- EventSP event_sp(new Event(event_type, event_data));
+ auto event_sp = std::make_shared<Event>(event_type, event_data);
PrivateBroadcastEvent(event_sp, true);
}
@@ -329,7 +334,7 @@ operator=(const BroadcastEventSpec &rhs) = default;
BroadcasterManager::BroadcasterManager() : m_manager_mutex() {}
lldb::BroadcasterManagerSP BroadcasterManager::MakeBroadcasterManager() {
- return BroadcasterManagerSP(new BroadcasterManager());
+ return lldb::BroadcasterManagerSP(new BroadcasterManager());
}
uint32_t BroadcasterManager::RegisterListenerForEvents(
diff --git a/source/Core/CMakeLists.txt b/source/Core/CMakeLists.txt
index 2bbe7455418a..7dcec050d866 100644
--- a/source/Core/CMakeLists.txt
+++ b/source/Core/CMakeLists.txt
@@ -5,30 +5,20 @@ add_lldb_library(lldbCore
AddressResolverFileLine.cpp
AddressResolverName.cpp
ArchSpec.cpp
- Baton.cpp
Broadcaster.cpp
Communication.cpp
Connection.cpp
- ConstString.cpp
- DataBufferHeap.cpp
- DataBufferMemoryMap.cpp
- DataEncoder.cpp
- DataExtractor.cpp
Debugger.cpp
Disassembler.cpp
+ DumpDataExtractor.cpp
DynamicLoader.cpp
EmulateInstruction.cpp
- Error.cpp
Event.cpp
- FastDemangle.cpp
FileLineResolver.cpp
FileSpecList.cpp
FormatEntity.cpp
- History.cpp
IOHandler.cpp
Listener.cpp
- Log.cpp
- Logging.cpp
Mangled.cpp
Module.cpp
ModuleChild.cpp
@@ -36,24 +26,16 @@ add_lldb_library(lldbCore
Opcode.cpp
PluginManager.cpp
RegisterValue.cpp
- RegularExpression.cpp
Scalar.cpp
SearchFilter.cpp
Section.cpp
SourceManager.cpp
State.cpp
- Stream.cpp
StreamAsynchronousIO.cpp
- StreamCallback.cpp
StreamFile.cpp
- StreamGDBRemote.cpp
- StreamString.cpp
- StringList.cpp
StructuredData.cpp
Timer.cpp
- UserID.cpp
UserSettingsController.cpp
- UUID.cpp
Value.cpp
ValueObject.cpp
ValueObjectCast.cpp
@@ -68,6 +50,27 @@ add_lldb_library(lldbCore
ValueObjectRegister.cpp
ValueObjectSyntheticFilter.cpp
ValueObjectVariable.cpp
- VMRange.cpp
+
+ LINK_LIBS
+ clangAST
+ lldbBreakpoint
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessUtility
+ lldbPluginCPlusPlusLanguage
+ lldbPluginObjCLanguage
+ lldbPluginObjectFileJIT
+
+ LINK_COMPONENTS
+ Support
+ Demangle
)
+# Needed to properly resolve references in a debug build.
+# TODO: Remove once we have better layering
+set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 4)
diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp
index 3d3abea62489..a543858582ef 100644
--- a/source/Core/Communication.cpp
+++ b/source/Core/Communication.cpp
@@ -7,21 +7,30 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-#include <cstring>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Communication.h"
+
#include "lldb/Core/Connection.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for LogIfAnyCategoriesSet, LIBLLDB...
+
+#include "llvm/ADT/None.h" // for None
+#include "llvm/ADT/Optional.h" // for Optional
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
+
+#include <algorithm> // for min
+#include <chrono> // for duration, seconds
+#include <cstring>
+#include <memory> // for shared_ptr
+
+#include <errno.h> // for EIO
+#include <inttypes.h> // for PRIu64
+#include <stdio.h> // for snprintf
using namespace lldb;
using namespace lldb_private;
@@ -115,12 +124,11 @@ bool Communication::HasConnection() const {
size_t Communication::Read(void *dst, size_t dst_len,
const Timeout<std::micro> &timeout,
ConnectionStatus &status, Error *error_ptr) {
- lldb_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Read (dst = %p, dst_len = %" PRIu64
- ", timeout = %u usec) connection = %p",
- this, dst, (uint64_t)dst_len, timeout ? timeout->count() : -1,
- m_connection_sp.get());
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION);
+ LLDB_LOG(
+ log,
+ "this = {0}, dst = {1}, dst_len = {2}, timeout = {3}, connection = {4}",
+ this, dst, dst_len, timeout, m_connection_sp.get());
if (m_read_thread_enabled) {
// We have a dedicated read thread that is getting data for us
@@ -322,10 +330,9 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
comm->Disconnect();
done = true;
}
- if (log)
- error.LogIfError(
- log, "%p Communication::ReadFromConnection () => status = %s", p,
- Communication::ConnectionStatusAsCString(status));
+ if (error.Fail())
+ LLDB_LOG(log, "error: {0}, status = {1}", error,
+ Communication::ConnectionStatusAsCString(status));
break;
case eConnectionStatusInterrupted: // Synchronization signal from
// SynchronizeWithReadThread()
@@ -340,10 +347,9 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
done = true;
LLVM_FALLTHROUGH;
case eConnectionStatusTimedOut: // Request timed out
- if (log)
- error.LogIfError(
- log, "%p Communication::ReadFromConnection () => status = %s", p,
- Communication::ConnectionStatusAsCString(status));
+ if (error.Fail())
+ LLDB_LOG(log, "error: {0}, status = {1}", error,
+ Communication::ConnectionStatusAsCString(status));
break;
}
}
diff --git a/source/Core/Connection.cpp b/source/Core/Connection.cpp
index 1ae046b8a018..60d1221c160c 100644
--- a/source/Core/Connection.cpp
+++ b/source/Core/Connection.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Connection.h"
#if defined(_WIN32)
@@ -19,6 +15,8 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include <string.h> // for strstr
+
using namespace lldb_private;
Connection::Connection() {}
diff --git a/source/Core/DataBufferMemoryMap.cpp b/source/Core/DataBufferMemoryMap.cpp
deleted file mode 100644
index 70e8a394f69e..000000000000
--- a/source/Core/DataBufferMemoryMap.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-//===-- DataBufferMemoryMap.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef _WIN32
-#include "lldb/Host/windows/windows.h"
-#else
-#include <sys/mman.h>
-
-#define MAP_EXTRA_HOST_READ_FLAGS 0
-
-#if defined(__APPLE__)
-//----------------------------------------------------------------------
-// Newer versions of MacOSX have a flag that will allow us to read from
-// binaries whose code signature is invalid without crashing by using
-// the MAP_RESILIENT_CODESIGN flag. Also if a file from removable media
-// is mapped we can avoid crashing and return zeroes to any pages we try
-// to read if the media becomes unavailable by using the
-// MAP_RESILIENT_MEDIA flag.
-//----------------------------------------------------------------------
-#if defined(MAP_RESILIENT_CODESIGN)
-#undef MAP_EXTRA_HOST_READ_FLAGS
-#if defined(MAP_RESILIENT_MEDIA)
-#define MAP_EXTRA_HOST_READ_FLAGS MAP_RESILIENT_CODESIGN | MAP_RESILIENT_MEDIA
-#else
-#define MAP_EXTRA_HOST_READ_FLAGS MAP_RESILIENT_CODESIGN
-#endif
-#endif // #if defined(MAP_RESILIENT_CODESIGN)
-#endif // #if defined (__APPLE__)
-
-#endif // #else #ifdef _WIN32
-// C++ Includes
-#include <cerrno>
-#include <climits>
-
-// Other libraries and framework includes
-#include "llvm/Support/MathExtras.h"
-
-// Project includes
-#include "lldb/Core/DataBufferMemoryMap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Host/File.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/HostInfo.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Default Constructor
-//----------------------------------------------------------------------
-DataBufferMemoryMap::DataBufferMemoryMap()
- : m_mmap_addr(nullptr), m_mmap_size(0), m_data(nullptr), m_size(0) {}
-
-//----------------------------------------------------------------------
-// Virtual destructor since this class inherits from a pure virtual
-// base class.
-//----------------------------------------------------------------------
-DataBufferMemoryMap::~DataBufferMemoryMap() { Clear(); }
-
-//----------------------------------------------------------------------
-// Return a pointer to the bytes owned by this object, or nullptr if
-// the object contains no bytes.
-//----------------------------------------------------------------------
-uint8_t *DataBufferMemoryMap::GetBytes() { return m_data; }
-
-//----------------------------------------------------------------------
-// Return a const pointer to the bytes owned by this object, or nullptr
-// if the object contains no bytes.
-//----------------------------------------------------------------------
-const uint8_t *DataBufferMemoryMap::GetBytes() const { return m_data; }
-
-//----------------------------------------------------------------------
-// Return the number of bytes this object currently contains.
-//----------------------------------------------------------------------
-uint64_t DataBufferMemoryMap::GetByteSize() const { return m_size; }
-
-//----------------------------------------------------------------------
-// Reverts this object to an empty state by unmapping any memory
-// that is currently owned.
-//----------------------------------------------------------------------
-void DataBufferMemoryMap::Clear() {
- if (m_mmap_addr != nullptr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MMAP));
- if (log)
- log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size "
- "= %" PRIu64 "",
- (void *)m_mmap_addr, (uint64_t)m_mmap_size);
-#ifdef _WIN32
- UnmapViewOfFile(m_mmap_addr);
-#else
- ::munmap((void *)m_mmap_addr, m_mmap_size);
-#endif
- m_mmap_addr = nullptr;
- m_mmap_size = 0;
- m_data = nullptr;
- m_size = 0;
- }
-}
-
-//----------------------------------------------------------------------
-// Memory map "length" bytes from "file" starting "offset"
-// bytes into the file. If "length" is set to SIZE_MAX, then
-// map as many bytes as possible.
-//
-// Returns the number of bytes mapped starting from the requested
-// offset.
-//----------------------------------------------------------------------
-size_t DataBufferMemoryMap::MemoryMapFromFileSpec(const FileSpec *filespec,
- lldb::offset_t offset,
- size_t length,
- bool writeable) {
- if (filespec != nullptr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MMAP));
- if (log) {
- log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(file=\"%s\", "
- "offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i",
- filespec->GetPath().c_str(), offset, (uint64_t)length,
- writeable);
- }
- char path[PATH_MAX];
- if (filespec->GetPath(path, sizeof(path))) {
- uint32_t options = File::eOpenOptionRead;
- if (writeable)
- options |= File::eOpenOptionWrite;
-
- File file;
- Error error(file.Open(path, options));
- if (error.Success()) {
- const bool fd_is_file = true;
- return MemoryMapFromFileDescriptor(file.GetDescriptor(), offset, length,
- writeable, fd_is_file);
- }
- }
- }
- // We should only get here if there was an error
- Clear();
- return 0;
-}
-
-#ifdef _WIN32
-static size_t win32memmapalignment = 0;
-void LoadWin32MemMapAlignment() {
- SYSTEM_INFO data;
- GetSystemInfo(&data);
- win32memmapalignment = data.dwAllocationGranularity;
-}
-#endif
-
-//----------------------------------------------------------------------
-// The file descriptor FD is assumed to already be opened as read only
-// and the STAT structure is assumed to a valid pointer and already
-// containing valid data from a call to stat().
-//
-// Memory map FILE_LENGTH bytes in FILE starting FILE_OFFSET bytes into
-// the file. If FILE_LENGTH is set to SIZE_MAX, then map as many bytes
-// as possible.
-//
-// RETURNS
-// Number of bytes mapped starting from the requested offset.
-//----------------------------------------------------------------------
-size_t DataBufferMemoryMap::MemoryMapFromFileDescriptor(int fd,
- lldb::offset_t offset,
- size_t length,
- bool writeable,
- bool fd_is_file) {
- Clear();
- if (fd >= 0) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MMAP |
- LIBLLDB_LOG_VERBOSE));
- if (log) {
- log->Printf("DataBufferMemoryMap::MemoryMapFromFileDescriptor(fd=%i, "
- "offset=0x%" PRIx64 ", length=0x%" PRIx64
- ", writeable=%i, fd_is_file=%i)",
- fd, offset, (uint64_t)length, writeable, fd_is_file);
- }
-#ifdef _WIN32
- HANDLE handle = (HANDLE)_get_osfhandle(fd);
- DWORD file_size_low, file_size_high;
- file_size_low = GetFileSize(handle, &file_size_high);
- const lldb::offset_t file_size =
- llvm::Make_64(file_size_high, file_size_low);
- const lldb::offset_t max_bytes_available = file_size - offset;
- const size_t max_bytes_mappable =
- (size_t)std::min<lldb::offset_t>(SIZE_MAX, max_bytes_available);
- if (length == SIZE_MAX || length > max_bytes_mappable) {
- // Cap the length if too much data was requested
- length = max_bytes_mappable;
- }
-
- if (length > 0) {
- HANDLE fileMapping = CreateFileMapping(
- handle, nullptr, writeable ? PAGE_READWRITE : PAGE_READONLY,
- file_size_high, file_size_low, nullptr);
- if (fileMapping != nullptr) {
- if (win32memmapalignment == 0)
- LoadWin32MemMapAlignment();
- lldb::offset_t realoffset = offset;
- lldb::offset_t delta = 0;
- if (realoffset % win32memmapalignment != 0) {
- realoffset = realoffset / win32memmapalignment * win32memmapalignment;
- delta = offset - realoffset;
- }
-
- LPVOID data = MapViewOfFile(fileMapping,
- writeable ? FILE_MAP_WRITE : FILE_MAP_READ,
- 0, realoffset, length + delta);
- m_mmap_addr = (uint8_t *)data;
- if (!data) {
- Error error;
- error.SetErrorToErrno();
- } else {
- m_data = m_mmap_addr + delta;
- m_size = length;
- }
- CloseHandle(fileMapping);
- }
- }
-#else
- struct stat stat;
- if (::fstat(fd, &stat) == 0) {
- if (S_ISREG(stat.st_mode) &&
- (stat.st_size > static_cast<off_t>(offset))) {
- const size_t max_bytes_available = stat.st_size - offset;
- if (length == SIZE_MAX) {
- length = max_bytes_available;
- } else if (length > max_bytes_available) {
- // Cap the length if too much data was requested
- length = max_bytes_available;
- }
-
- if (length > 0) {
- int prot = PROT_READ;
- int flags = MAP_PRIVATE;
- if (writeable)
- prot |= PROT_WRITE;
- else
- flags |= MAP_EXTRA_HOST_READ_FLAGS;
-
- if (fd_is_file)
- flags |= MAP_FILE;
-
- m_mmap_addr =
- (uint8_t *)::mmap(nullptr, length, prot, flags, fd, offset);
- Error error;
-
- if (m_mmap_addr == (void *)-1) {
- error.SetErrorToErrno();
- if (error.GetError() == EINVAL) {
- // We may still have a shot at memory mapping if we align things
- // correctly
- size_t page_offset = offset % HostInfo::GetPageSize();
- if (page_offset != 0) {
- m_mmap_addr =
- (uint8_t *)::mmap(nullptr, length + page_offset, prot,
- flags, fd, offset - page_offset);
- if (m_mmap_addr == (void *)-1) {
- // Failed to map file
- m_mmap_addr = nullptr;
- } else if (m_mmap_addr != nullptr) {
- // We recovered and were able to memory map
- // after we aligned things to page boundaries
-
- // Save the actual mmap'ed size
- m_mmap_size = length + page_offset;
- // Our data is at an offset into the mapped data
- m_data = m_mmap_addr + page_offset;
- // Our pretend size is the size that was requested
- m_size = length;
- }
- }
- }
- if (error.GetError() == ENOMEM) {
- error.SetErrorStringWithFormat("could not allocate %" PRId64
- " bytes of memory to mmap in file",
- (uint64_t)length);
- }
- } else {
- // We were able to map the requested data in one chunk
- // where our mmap and actual data are the same.
- m_mmap_size = length;
- m_data = m_mmap_addr;
- m_size = length;
- }
-
- if (log) {
- log->Printf(
- "DataBufferMemoryMap::MemoryMapFromFileSpec() m_mmap_addr = "
- "%p, m_mmap_size = %" PRIu64 ", error = %s",
- (void *)m_mmap_addr, (uint64_t)m_mmap_size, error.AsCString());
- }
- }
- }
- }
-#endif
- }
- return GetByteSize();
-}
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 8f888a518d5b..751ceed13149 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -9,57 +9,70 @@
#include "lldb/Core/Debugger.h"
-// C Includes
-// C++ Includes
-#include <map>
-#include <mutex>
-
-// Other libraries and framework includes
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DynamicLibrary.h"
-
-// Project includes
+#include "lldb/Breakpoint/Breakpoint.h" // for Breakpoint, Brea...
+#include "lldb/Core/Event.h" // for Event, EventData...
#include "lldb/Core/FormatEntity.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Listener.h" // for Listener
+#include "lldb/Core/Mangled.h" // for Mangled
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamAsynchronousIO.h"
-#include "lldb/Core/StreamCallback.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Expression/REPL.h"
-#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/File.h" // for File, File::kInv...
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/OptionValue.h" // for OptionValue, Opt...
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
#include "lldb/Interpreter/OptionValueString.h"
-#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Interpreter/Property.h" // for PropertyDefinition
+#include "lldb/Interpreter/ScriptInterpreter.h" // for ScriptInterpreter
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
-#include "lldb/Symbol/VariableList.h"
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/SectionLoadList.h"
-#include "lldb/Target/StopInfo.h"
#include "lldb/Target/StructuredDataPlugin.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadList.h" // for ThreadList
#include "lldb/Utility/AnsiTerminal.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/Log.h" // for LLDB_LOG_OPTION_...
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamCallback.h"
+#include "lldb/Utility/StreamString.h"
+
+#if defined(LLVM_ON_WIN32)
+#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#endif
+
+#include "llvm/ADT/None.h" // for None
+#include "llvm/ADT/STLExtras.h" // for make_unique
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h" // for iterator_facade_...
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+#include "llvm/Support/raw_ostream.h" // for raw_fd_ostream
+
+#include <list> // for list
+#include <memory> // for make_shared
+#include <mutex>
+#include <set> // for set
+#include <stdio.h> // for size_t, NULL
+#include <stdlib.h> // for getenv
+#include <string.h> // for strcmp
+#include <string> // for string
+#include <system_error> // for error_code
+
+namespace lldb_private {
+class Address;
+}
using namespace lldb;
using namespace lldb_private;
@@ -125,7 +138,7 @@ OptionEnumValueElement g_language_enumerators[] = {
"\\n"
#define DEFAULT_FRAME_FORMAT \
- "frame #${frame.index}:{ ${frame.no-debug}${frame.pc}}" MODULE_WITH_FUNC FILE_AND_LINE \
+ "frame #${frame.index}: ${frame.pc}" MODULE_WITH_FUNC FILE_AND_LINE \
IS_OPTIMIZED "\\n"
// Three parts to this disassembly format specification:
@@ -296,9 +309,9 @@ Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
if (str.length())
new_prompt = str;
GetCommandInterpreter().UpdatePrompt(new_prompt);
- EventSP prompt_change_event_sp(
- new Event(CommandInterpreter::eBroadcastBitResetPrompt,
- new EventDataBytes(new_prompt)));
+ auto bytes = llvm::make_unique<EventDataBytes>(new_prompt);
+ auto prompt_change_event_sp = std::make_shared<Event>(
+ CommandInterpreter::eBroadcastBitResetPrompt, bytes.release());
GetCommandInterpreter().BroadcastEvent(prompt_change_event_sp);
} else if (property_path == g_properties[ePropertyUseColor].name) {
// use-color changed. Ping the prompt so it can reset the ansi terminal
@@ -555,7 +568,7 @@ bool Debugger::LoadPlugin(const FileSpec &spec, Error &error) {
}
static FileSpec::EnumerateDirectoryResult
-LoadPluginCallback(void *baton, FileSpec::FileType file_type,
+LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
Error error;
@@ -567,13 +580,13 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
Debugger *debugger = (Debugger *)baton;
+ namespace fs = llvm::sys::fs;
// If we have a regular file, a symbolic link or unknown file type, try
// and process the file. We must handle unknown as sometimes the directory
// enumeration might be enumerating a file system that doesn't have correct
// file type information.
- if (file_type == FileSpec::eFileTypeRegular ||
- file_type == FileSpec::eFileTypeSymbolicLink ||
- file_type == FileSpec::eFileTypeUnknown) {
+ if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -586,9 +599,9 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
debugger->LoadPlugin(plugin_file_spec, plugin_load_error);
return FileSpec::eEnumerateDirectoryResultNext;
- } else if (file_type == FileSpec::eFileTypeUnknown ||
- file_type == FileSpec::eFileTypeDirectory ||
- file_type == FileSpec::eFileTypeSymbolicLink) {
+ } else if (ft == fs::file_type::directory_file ||
+ ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
// Try and recurse into anything that a directory or symbolic link.
// We must also do this for unknown as sometimes the directory enumeration
// might be enumerating a file system that doesn't have correct file type
@@ -697,16 +710,16 @@ TargetSP Debugger::FindTargetWithProcess(Process *process) {
Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
: UserID(g_unique_id++),
- Properties(OptionValuePropertiesSP(new OptionValueProperties())),
- m_input_file_sp(new StreamFile(stdin, false)),
- m_output_file_sp(new StreamFile(stdout, false)),
- m_error_file_sp(new StreamFile(stderr, false)),
+ Properties(std::make_shared<OptionValueProperties>()),
+ m_input_file_sp(std::make_shared<StreamFile>(stdin, false)),
+ m_output_file_sp(std::make_shared<StreamFile>(stdout, false)),
+ m_error_file_sp(std::make_shared<StreamFile>(stderr, false)),
m_broadcaster_manager_sp(BroadcasterManager::MakeBroadcasterManager()),
m_terminal_state(), m_target_list(*this), m_platform_list(),
m_listener_sp(Listener::MakeListener("lldb.Debugger")),
m_source_manager_ap(), m_source_file_cache(),
- m_command_interpreter_ap(
- new CommandInterpreter(*this, eScriptLanguageDefault, false)),
+ m_command_interpreter_ap(llvm::make_unique<CommandInterpreter>(
+ *this, eScriptLanguageDefault, false)),
m_input_reader_stack(), m_instance_name(), m_loaded_plugins(),
m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
@@ -715,7 +728,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
snprintf(instance_cstr, sizeof(instance_cstr), "debugger_%d", (int)GetID());
m_instance_name.SetCString(instance_cstr);
if (log_callback)
- m_log_callback_stream_sp.reset(new StreamCallback(log_callback, baton));
+ m_log_callback_stream_sp =
+ std::make_shared<StreamCallback>(log_callback, baton);
m_command_interpreter_ap->Initialize();
// Always add our default platform to the platform list
PlatformSP default_platform_sp(Platform::GetHostPlatform());
@@ -762,7 +776,7 @@ void Debugger::Clear() {
// static void Debugger::Destroy(lldb::DebuggerSP &debugger_sp);
// static void Debugger::Terminate();
//----------------------------------------------------------------------
- std::call_once(m_clear_once, [this]() {
+ llvm::call_once(m_clear_once, [this]() {
ClearIOHandlers();
StopIOHandlerThread();
StopEventHandlerThread();
@@ -811,7 +825,7 @@ void Debugger::SetInputFileHandle(FILE *fh, bool tranfer_ownership) {
if (m_input_file_sp)
m_input_file_sp->GetFile().SetStream(fh, tranfer_ownership);
else
- m_input_file_sp.reset(new StreamFile(fh, tranfer_ownership));
+ m_input_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
File &in_file = m_input_file_sp->GetFile();
if (!in_file.IsValid())
@@ -826,7 +840,7 @@ void Debugger::SetOutputFileHandle(FILE *fh, bool tranfer_ownership) {
if (m_output_file_sp)
m_output_file_sp->GetFile().SetStream(fh, tranfer_ownership);
else
- m_output_file_sp.reset(new StreamFile(fh, tranfer_ownership));
+ m_output_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
File &out_file = m_output_file_sp->GetFile();
if (!out_file.IsValid())
@@ -845,7 +859,7 @@ void Debugger::SetErrorFileHandle(FILE *fh, bool tranfer_ownership) {
if (m_error_file_sp)
m_error_file_sp->GetFile().SetStream(fh, tranfer_ownership);
else
- m_error_file_sp.reset(new StreamFile(fh, tranfer_ownership));
+ m_error_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
File &err_file = m_error_file_sp->GetFile();
if (!err_file.IsValid())
@@ -996,7 +1010,7 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in,
// If there is nothing, use stdin
if (!in)
- in = StreamFileSP(new StreamFile(stdin, false));
+ in = std::make_shared<StreamFile>(stdin, false);
}
// If no STDOUT has been set, then set it appropriately
if (!out) {
@@ -1007,7 +1021,7 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in,
// If there is nothing, use stdout
if (!out)
- out = StreamFileSP(new StreamFile(stdout, false));
+ out = std::make_shared<StreamFile>(stdout, false);
}
// If no STDERR has been set, then set it appropriately
if (!err) {
@@ -1018,7 +1032,7 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in,
// If there is nothing, use stderr
if (!err)
- err = StreamFileSP(new StreamFile(stdout, false));
+ err = std::make_shared<StreamFile>(stdout, false);
}
}
@@ -1075,11 +1089,11 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
}
StreamSP Debugger::GetAsyncOutputStream() {
- return StreamSP(new StreamAsynchronousIO(*this, true));
+ return std::make_shared<StreamAsynchronousIO>(*this, true);
}
StreamSP Debugger::GetAsyncErrorStream() {
- return StreamSP(new StreamAsynchronousIO(*this, false));
+ return std::make_shared<StreamAsynchronousIO>(*this, false);
}
size_t Debugger::GetNumDebuggers() {
@@ -1234,31 +1248,42 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
// For simplicity's sake, I am not going to deal with how to close down any
// open logging streams, I just redirect everything from here on out to the
// callback.
- m_log_callback_stream_sp.reset(new StreamCallback(log_callback, baton));
+ m_log_callback_stream_sp =
+ std::make_shared<StreamCallback>(log_callback, baton);
}
-bool Debugger::EnableLog(const char *channel, const char **categories,
- const char *log_file, uint32_t log_options,
- Stream &error_stream) {
- StreamSP log_stream_sp;
+bool Debugger::EnableLog(llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ llvm::StringRef log_file, uint32_t log_options,
+ llvm::raw_ostream &error_stream) {
+ const bool should_close = true;
+ const bool unbuffered = true;
+
+ std::shared_ptr<llvm::raw_ostream> log_stream_sp;
if (m_log_callback_stream_sp) {
log_stream_sp = m_log_callback_stream_sp;
// For now when using the callback mode you always get thread & timestamp.
log_options |=
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
- } else if (log_file == nullptr || *log_file == '\0') {
- log_stream_sp = GetOutputFile();
+ } else if (log_file.empty()) {
+ log_stream_sp = std::make_shared<llvm::raw_fd_ostream>(
+ GetOutputFile()->GetFile().GetDescriptor(), !should_close, unbuffered);
} else {
- LogStreamMap::iterator pos = m_log_streams.find(log_file);
+ auto pos = m_log_streams.find(log_file);
if (pos != m_log_streams.end())
log_stream_sp = pos->second.lock();
if (!log_stream_sp) {
- uint32_t options = File::eOpenOptionWrite | File::eOpenOptionCanCreate |
- File::eOpenOptionCloseOnExec | File::eOpenOptionAppend;
- if (!(log_options & LLDB_LOG_OPTION_APPEND))
- options |= File::eOpenOptionTruncate;
-
- log_stream_sp.reset(new StreamFile(log_file, options));
+ llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_Text;
+ if (log_options & LLDB_LOG_OPTION_APPEND)
+ flags |= llvm::sys::fs::F_Append;
+ int FD;
+ if (std::error_code ec =
+ llvm::sys::fs::openFileForWrite(log_file, FD, flags)) {
+ error_stream << "Unable to open log file: " << ec.message();
+ return false;
+ }
+ log_stream_sp =
+ std::make_shared<llvm::raw_fd_ostream>(FD, should_close, unbuffered);
m_log_streams[log_file] = log_stream_sp;
}
}
@@ -1274,7 +1299,7 @@ bool Debugger::EnableLog(const char *channel, const char **categories,
SourceManager &Debugger::GetSourceManager() {
if (!m_source_manager_ap)
- m_source_manager_ap.reset(new SourceManager(shared_from_this()));
+ m_source_manager_ap = llvm::make_unique<SourceManager>(shared_from_this());
return *m_source_manager_ap;
}
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 7cac29491c8c..3880bfd16ecc 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -9,21 +9,14 @@
#include "lldb/Core/Disassembler.h"
-// C Includes
-// C++ Includes
-#include <cstdio>
-#include <cstring>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/AddressRange.h" // for AddressRange
#include "lldb/Core/Debugger.h"
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Core/Mangled.h" // for Mangled, Mangled...
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/SourceManager.h" // for SourceManager
#include "lldb/Core/Timer.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -33,13 +26,30 @@
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Symbol/Function.h"
-#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h" // for Symbol
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Target/Thread.h" // for Thread
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/lldb-private-enumerations.h" // for InstructionType:...
+#include "lldb/lldb-private-interfaces.h" // for DisassemblerCrea...
+#include "lldb/lldb-private-types.h" // for RegisterInfo
+#include "llvm/ADT/Triple.h" // for Triple, Triple::...
+#include "llvm/Support/Compiler.h" // for LLVM_PRETTY_FUNC...
+
+#include <cstdint> // for uint32_t, UINT32...
+#include <cstring>
+#include <utility> // for pair
+
+#include <assert.h> // for assert
#define DEFAULT_DISASM_BYTE_SIZE 32
@@ -759,7 +769,7 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
bool done = false;
char buffer[1024];
- OptionValueSP option_value_sp(new OptionValueArray(1u << data_type));
+ auto option_value_sp = std::make_shared<OptionValueArray>(1u << data_type);
int idx = 0;
while (!done) {
@@ -797,12 +807,12 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
OptionValueSP data_value_sp;
switch (data_type) {
case OptionValue::eTypeUInt64:
- data_value_sp.reset(new OptionValueUInt64(0, 0));
+ data_value_sp = std::make_shared<OptionValueUInt64>(0, 0);
data_value_sp->SetValueFromString(value);
break;
// Other types can be added later as needed.
default:
- data_value_sp.reset(new OptionValueString(value.c_str(), ""));
+ data_value_sp = std::make_shared<OptionValueString>(value.c_str(), "");
break;
}
@@ -818,7 +828,7 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
bool done = false;
char buffer[1024];
- OptionValueSP option_value_sp(new OptionValueDictionary());
+ auto option_value_sp = std::make_shared<OptionValueDictionary>();
static ConstString encoding_key("data_encoding");
OptionValue::Type data_type = OptionValue::eTypeInvalid;
@@ -891,13 +901,13 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
// We've used the data_type to read an array; re-set the type to Invalid
data_type = OptionValue::eTypeInvalid;
} else if ((value[0] == '0') && (value[1] == 'x')) {
- value_sp.reset(new OptionValueUInt64(0, 0));
+ value_sp = std::make_shared<OptionValueUInt64>(0, 0);
value_sp->SetValueFromString(value);
} else {
size_t len = value.size();
if ((value[0] == '"') && (value[len - 1] == '"'))
value = value.substr(1, len - 2);
- value_sp.reset(new OptionValueString(value.c_str(), ""));
+ value_sp = std::make_shared<OptionValueString>(value.c_str(), "");
}
if (const_key == encoding_key) {
@@ -1163,18 +1173,17 @@ size_t Disassembler::ParseInstructions(const ExecutionContext *exe_ctx,
!range.GetBaseAddress().IsValid())
return 0;
- DataBufferHeap *heap_buffer = new DataBufferHeap(byte_size, '\0');
- DataBufferSP data_sp(heap_buffer);
+ auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
Error error;
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
const size_t bytes_read = target->ReadMemory(
- range.GetBaseAddress(), prefer_file_cache, heap_buffer->GetBytes(),
- heap_buffer->GetByteSize(), error, &load_addr);
+ range.GetBaseAddress(), prefer_file_cache, data_sp->GetBytes(),
+ data_sp->GetByteSize(), error, &load_addr);
if (bytes_read > 0) {
- if (bytes_read != heap_buffer->GetByteSize())
- heap_buffer->SetByteSize(bytes_read);
+ if (bytes_read != data_sp->GetByteSize())
+ data_sp->SetByteSize(bytes_read);
DataExtractor data(data_sp, m_arch.GetByteOrder(),
m_arch.GetAddressByteSize());
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
diff --git a/source/Core/DumpDataExtractor.cpp b/source/Core/DumpDataExtractor.cpp
new file mode 100644
index 000000000000..2b7abd60f8bc
--- /dev/null
+++ b/source/Core/DumpDataExtractor.cpp
@@ -0,0 +1,824 @@
+//===-- DumpDataExtractor.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/DumpDataExtractor.h"
+
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for TargetSP, DisassemblerSP
+
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
+
+#include "clang/AST/ASTContext.h" // for ASTContext
+#include "clang/AST/CanonicalType.h" // for CanQualType
+
+#include "llvm/ADT/APFloat.h" // for APFloat, APFloatBase:...
+#include "llvm/ADT/APInt.h" // for APInt
+#include "llvm/ADT/ArrayRef.h" // for ArrayRef
+#include "llvm/ADT/SmallVector.h" // for SmallVector
+
+#include <limits> // for numeric_limits, numer...
+#include <memory> // for shared_ptr
+#include <string> // for string, basic_string
+
+#include <assert.h> // for assert
+#include <ctype.h> // for isprint
+#include <inttypes.h> // for PRIu64, PRIx64, PRIX64
+#include <math.h> // for ldexpf
+
+#include <bitset>
+#include <sstream>
+
+using namespace lldb_private;
+using namespace lldb;
+
+#define NON_PRINTABLE_CHAR '.'
+
+static float half2float(uint16_t half) {
+ union {
+ float f;
+ uint32_t u;
+ } u;
+ int32_t v = (int16_t)half;
+
+ if (0 == (v & 0x7c00)) {
+ u.u = v & 0x80007FFFU;
+ return u.f * ldexpf(1, 125);
+ }
+
+ v <<= 13;
+ u.u = v | 0x70000000U;
+ return u.f * ldexpf(1, -112);
+}
+
+static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
+ lldb::offset_t byte_size, llvm::APInt &result) {
+ llvm::SmallVector<uint64_t, 2> uint64_array;
+ lldb::offset_t bytes_left = byte_size;
+ uint64_t u64;
+ const lldb::ByteOrder byte_order = data.GetByteOrder();
+ if (byte_order == lldb::eByteOrderLittle) {
+ while (bytes_left > 0) {
+ if (bytes_left >= 8) {
+ u64 = data.GetU64(offset_ptr);
+ bytes_left -= 8;
+ } else {
+ u64 = data.GetMaxU64(offset_ptr, (uint32_t)bytes_left);
+ bytes_left = 0;
+ }
+ uint64_array.push_back(u64);
+ }
+ result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
+ return true;
+ } else if (byte_order == lldb::eByteOrderBig) {
+ lldb::offset_t be_offset = *offset_ptr + byte_size;
+ lldb::offset_t temp_offset;
+ while (bytes_left > 0) {
+ if (bytes_left >= 8) {
+ be_offset -= 8;
+ temp_offset = be_offset;
+ u64 = data.GetU64(&temp_offset);
+ bytes_left -= 8;
+ } else {
+ be_offset -= bytes_left;
+ temp_offset = be_offset;
+ u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
+ bytes_left = 0;
+ }
+ uint64_array.push_back(u64);
+ }
+ *offset_ptr += byte_size;
+ result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
+ return true;
+ }
+ return false;
+}
+
+static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data,
+ lldb::offset_t offset, lldb::offset_t byte_size,
+ bool is_signed, unsigned radix) {
+ llvm::APInt apint;
+ if (GetAPInt(data, &offset, byte_size, apint)) {
+ std::string apint_str(apint.toString(radix, is_signed));
+ switch (radix) {
+ case 2:
+ s->Write("0b", 2);
+ break;
+ case 8:
+ s->Write("0", 1);
+ break;
+ case 10:
+ break;
+ }
+ s->Write(apint_str.c_str(), apint_str.size());
+ }
+ return offset;
+}
+
+lldb::offset_t lldb_private::DumpDataExtractor(
+ const DataExtractor &DE, Stream *s, offset_t start_offset,
+ lldb::Format item_format, size_t item_byte_size, size_t item_count,
+ size_t num_per_line, uint64_t base_addr,
+ uint32_t item_bit_size, // If zero, this is not a bitfield value, if
+ // non-zero, the value is a bitfield
+ uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the
+ // shift amount to apply to a bitfield
+ ExecutionContextScope *exe_scope) {
+ if (s == nullptr)
+ return start_offset;
+
+ if (item_format == eFormatPointer) {
+ if (item_byte_size != 4 && item_byte_size != 8)
+ item_byte_size = s->GetAddressByteSize();
+ }
+
+ offset_t offset = start_offset;
+
+ if (item_format == eFormatInstruction) {
+ TargetSP target_sp;
+ if (exe_scope)
+ target_sp = exe_scope->CalculateTarget();
+ if (target_sp) {
+ DisassemblerSP disassembler_sp(Disassembler::FindPlugin(
+ target_sp->GetArchitecture(), nullptr, nullptr));
+ if (disassembler_sp) {
+ lldb::addr_t addr = base_addr + start_offset;
+ lldb_private::Address so_addr;
+ bool data_from_file = true;
+ if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) {
+ data_from_file = false;
+ } else {
+ if (target_sp->GetSectionLoadList().IsEmpty() ||
+ !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
+ so_addr.SetRawAddress(addr);
+ }
+
+ size_t bytes_consumed = disassembler_sp->DecodeInstructions(
+ so_addr, DE, start_offset, item_count, false, data_from_file);
+
+ if (bytes_consumed) {
+ offset += bytes_consumed;
+ const bool show_address = base_addr != LLDB_INVALID_ADDRESS;
+ const bool show_bytes = true;
+ ExecutionContext exe_ctx;
+ exe_scope->CalculateExecutionContext(exe_ctx);
+ disassembler_sp->GetInstructionList().Dump(s, show_address,
+ show_bytes, &exe_ctx);
+ }
+ }
+ } else
+ s->Printf("invalid target");
+
+ return offset;
+ }
+
+ if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) &&
+ item_byte_size > 8)
+ item_format = eFormatHex;
+
+ lldb::offset_t line_start_offset = start_offset;
+ for (uint32_t count = 0; DE.ValidOffset(offset) && count < item_count;
+ ++count) {
+ if ((count % num_per_line) == 0) {
+ if (count > 0) {
+ if (item_format == eFormatBytesWithASCII &&
+ offset > line_start_offset) {
+ s->Printf("%*s",
+ static_cast<int>(
+ (num_per_line - (offset - line_start_offset)) * 3 + 2),
+ "");
+ DumpDataExtractor(DE, s, line_start_offset, eFormatCharPrintable, 1,
+ offset - line_start_offset, SIZE_MAX,
+ LLDB_INVALID_ADDRESS, 0, 0);
+ }
+ s->EOL();
+ }
+ if (base_addr != LLDB_INVALID_ADDRESS)
+ s->Printf("0x%8.8" PRIx64 ": ",
+ (uint64_t)(base_addr +
+ (offset - start_offset) / DE.getTargetByteSize()));
+
+ line_start_offset = offset;
+ } else if (item_format != eFormatChar &&
+ item_format != eFormatCharPrintable &&
+ item_format != eFormatCharArray && count > 0) {
+ s->PutChar(' ');
+ }
+
+ switch (item_format) {
+ case eFormatBoolean:
+ if (item_byte_size <= 8)
+ s->Printf("%s", DE.GetMaxU64Bitfield(&offset, item_byte_size,
+ item_bit_size, item_bit_offset)
+ ? "true"
+ : "false");
+ else {
+ s->Printf("error: unsupported byte size (%" PRIu64
+ ") for boolean format",
+ (uint64_t)item_byte_size);
+ return offset;
+ }
+ break;
+
+ case eFormatBinary:
+ if (item_byte_size <= 8) {
+ uint64_t uval64 = DE.GetMaxU64Bitfield(&offset, item_byte_size,
+ item_bit_size, item_bit_offset);
+ // Avoid std::bitset<64>::to_string() since it is missing in
+ // earlier C++ libraries
+ std::string binary_value(64, '0');
+ std::bitset<64> bits(uval64);
+ for (uint32_t i = 0; i < 64; ++i)
+ if (bits[i])
+ binary_value[64 - 1 - i] = '1';
+ if (item_bit_size > 0)
+ s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size);
+ else if (item_byte_size > 0 && item_byte_size <= 8)
+ s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
+ } else {
+ const bool is_signed = false;
+ const unsigned radix = 2;
+ offset = DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
+ }
+ break;
+
+ case eFormatBytes:
+ case eFormatBytesWithASCII:
+ for (uint32_t i = 0; i < item_byte_size; ++i) {
+ s->Printf("%2.2x", DE.GetU8(&offset));
+ }
+
+ // Put an extra space between the groups of bytes if more than one
+ // is being dumped in a group (item_byte_size is more than 1).
+ if (item_byte_size > 1)
+ s->PutChar(' ');
+ break;
+
+ case eFormatChar:
+ case eFormatCharPrintable:
+ case eFormatCharArray: {
+ // If we are only printing one character surround it with single
+ // quotes
+ if (item_count == 1 && item_format == eFormatChar)
+ s->PutChar('\'');
+
+ const uint64_t ch = DE.GetMaxU64Bitfield(&offset, item_byte_size,
+ item_bit_size, item_bit_offset);
+ if (isprint(ch))
+ s->Printf("%c", (char)ch);
+ else if (item_format != eFormatCharPrintable) {
+ switch (ch) {
+ case '\033':
+ s->Printf("\\e");
+ break;
+ case '\a':
+ s->Printf("\\a");
+ break;
+ case '\b':
+ s->Printf("\\b");
+ break;
+ case '\f':
+ s->Printf("\\f");
+ break;
+ case '\n':
+ s->Printf("\\n");
+ break;
+ case '\r':
+ s->Printf("\\r");
+ break;
+ case '\t':
+ s->Printf("\\t");
+ break;
+ case '\v':
+ s->Printf("\\v");
+ break;
+ case '\0':
+ s->Printf("\\0");
+ break;
+ default:
+ if (item_byte_size == 1)
+ s->Printf("\\x%2.2x", (uint8_t)ch);
+ else
+ s->Printf("%" PRIu64, ch);
+ break;
+ }
+ } else {
+ s->PutChar(NON_PRINTABLE_CHAR);
+ }
+
+ // If we are only printing one character surround it with single quotes
+ if (item_count == 1 && item_format == eFormatChar)
+ s->PutChar('\'');
+ } break;
+
+ case eFormatEnum: // Print enum value as a signed integer when we don't get
+ // the enum type
+ case eFormatDecimal:
+ if (item_byte_size <= 8)
+ s->Printf("%" PRId64,
+ DE.GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset));
+ else {
+ const bool is_signed = true;
+ const unsigned radix = 10;
+ offset = DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
+ }
+ break;
+
+ case eFormatUnsigned:
+ if (item_byte_size <= 8)
+ s->Printf("%" PRIu64,
+ DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset));
+ else {
+ const bool is_signed = false;
+ const unsigned radix = 10;
+ offset = DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
+ }
+ break;
+
+ case eFormatOctal:
+ if (item_byte_size <= 8)
+ s->Printf("0%" PRIo64,
+ DE.GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset));
+ else {
+ const bool is_signed = false;
+ const unsigned radix = 8;
+ offset = DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
+ }
+ break;
+
+ case eFormatOSType: {
+ uint64_t uval64 = DE.GetMaxU64Bitfield(&offset, item_byte_size,
+ item_bit_size, item_bit_offset);
+ s->PutChar('\'');
+ for (uint32_t i = 0; i < item_byte_size; ++i) {
+ uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
+ if (isprint(ch))
+ s->Printf("%c", ch);
+ else {
+ switch (ch) {
+ case '\033':
+ s->Printf("\\e");
+ break;
+ case '\a':
+ s->Printf("\\a");
+ break;
+ case '\b':
+ s->Printf("\\b");
+ break;
+ case '\f':
+ s->Printf("\\f");
+ break;
+ case '\n':
+ s->Printf("\\n");
+ break;
+ case '\r':
+ s->Printf("\\r");
+ break;
+ case '\t':
+ s->Printf("\\t");
+ break;
+ case '\v':
+ s->Printf("\\v");
+ break;
+ case '\0':
+ s->Printf("\\0");
+ break;
+ default:
+ s->Printf("\\x%2.2x", ch);
+ break;
+ }
+ }
+ }
+ s->PutChar('\'');
+ } break;
+
+ case eFormatCString: {
+ const char *cstr = DE.GetCStr(&offset);
+
+ if (!cstr) {
+ s->Printf("NULL");
+ offset = LLDB_INVALID_OFFSET;
+ } else {
+ s->PutChar('\"');
+
+ while (const char c = *cstr) {
+ if (isprint(c)) {
+ s->PutChar(c);
+ } else {
+ switch (c) {
+ case '\033':
+ s->Printf("\\e");
+ break;
+ case '\a':
+ s->Printf("\\a");
+ break;
+ case '\b':
+ s->Printf("\\b");
+ break;
+ case '\f':
+ s->Printf("\\f");
+ break;
+ case '\n':
+ s->Printf("\\n");
+ break;
+ case '\r':
+ s->Printf("\\r");
+ break;
+ case '\t':
+ s->Printf("\\t");
+ break;
+ case '\v':
+ s->Printf("\\v");
+ break;
+ default:
+ s->Printf("\\x%2.2x", c);
+ break;
+ }
+ }
+
+ ++cstr;
+ }
+
+ s->PutChar('\"');
+ }
+ } break;
+
+ case eFormatPointer:
+ s->Address(DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset),
+ sizeof(addr_t));
+ break;
+
+ case eFormatComplexInteger: {
+ size_t complex_int_byte_size = item_byte_size / 2;
+
+ if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) {
+ s->Printf("%" PRIu64,
+ DE.GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+ s->Printf(" + %" PRIu64 "i",
+ DE.GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+ } else {
+ s->Printf("error: unsupported byte size (%" PRIu64
+ ") for complex integer format",
+ (uint64_t)item_byte_size);
+ return offset;
+ }
+ } break;
+
+ case eFormatComplex:
+ if (sizeof(float) * 2 == item_byte_size) {
+ float f32_1 = DE.GetFloat(&offset);
+ float f32_2 = DE.GetFloat(&offset);
+
+ s->Printf("%g + %gi", f32_1, f32_2);
+ break;
+ } else if (sizeof(double) * 2 == item_byte_size) {
+ double d64_1 = DE.GetDouble(&offset);
+ double d64_2 = DE.GetDouble(&offset);
+
+ s->Printf("%lg + %lgi", d64_1, d64_2);
+ break;
+ } else if (sizeof(long double) * 2 == item_byte_size) {
+ long double ld64_1 = DE.GetLongDouble(&offset);
+ long double ld64_2 = DE.GetLongDouble(&offset);
+ s->Printf("%Lg + %Lgi", ld64_1, ld64_2);
+ break;
+ } else {
+ s->Printf("error: unsupported byte size (%" PRIu64
+ ") for complex float format",
+ (uint64_t)item_byte_size);
+ return offset;
+ }
+ break;
+
+ default:
+ case eFormatDefault:
+ case eFormatHex:
+ case eFormatHexUppercase: {
+ bool wantsuppercase = (item_format == eFormatHexUppercase);
+ switch (item_byte_size) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
+ (int)(2 * item_byte_size), (int)(2 * item_byte_size),
+ DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset));
+ break;
+ default: {
+ assert(item_bit_size == 0 && item_bit_offset == 0);
+ const uint8_t *bytes =
+ (const uint8_t *)DE.GetData(&offset, item_byte_size);
+ if (bytes) {
+ s->PutCString("0x");
+ uint32_t idx;
+ if (DE.GetByteOrder() == eByteOrderBig) {
+ for (idx = 0; idx < item_byte_size; ++idx)
+ s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]);
+ } else {
+ for (idx = 0; idx < item_byte_size; ++idx)
+ s->Printf(wantsuppercase ? "%2.2X" : "%2.2x",
+ bytes[item_byte_size - 1 - idx]);
+ }
+ }
+ } break;
+ }
+ } break;
+
+ case eFormatFloat: {
+ TargetSP target_sp;
+ bool used_apfloat = false;
+ if (exe_scope)
+ target_sp = exe_scope->CalculateTarget();
+ if (target_sp) {
+ ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+ if (clang_ast) {
+ clang::ASTContext *ast = clang_ast->getASTContext();
+ if (ast) {
+ llvm::SmallVector<char, 256> sv;
+ // Show full precision when printing float values
+ const unsigned format_precision = 0;
+ const unsigned format_max_padding = 100;
+ size_t item_bit_size = item_byte_size * 8;
+
+ if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
+ llvm::APInt apint(item_bit_size,
+ DE.GetMaxU64(&offset, item_byte_size));
+ llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
+ apint);
+ apfloat.toString(sv, format_precision, format_max_padding);
+ } else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
+ llvm::APInt apint;
+ if (GetAPInt(DE, &offset, item_byte_size, apint)) {
+ llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy),
+ apint);
+ apfloat.toString(sv, format_precision, format_max_padding);
+ }
+ } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
+ const auto &semantics =
+ ast->getFloatTypeSemantics(ast->LongDoubleTy);
+ const auto byte_size =
+ (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
+
+ llvm::APInt apint;
+ if (GetAPInt(DE, &offset, byte_size, apint)) {
+ llvm::APFloat apfloat(semantics, apint);
+ apfloat.toString(sv, format_precision, format_max_padding);
+ }
+ } else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
+ llvm::APInt apint(item_bit_size, DE.GetU16(&offset));
+ llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
+ apint);
+ apfloat.toString(sv, format_precision, format_max_padding);
+ }
+
+ if (!sv.empty()) {
+ s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data());
+ used_apfloat = true;
+ }
+ }
+ }
+ }
+
+ if (!used_apfloat) {
+ std::ostringstream ss;
+ if (item_byte_size == sizeof(float) || item_byte_size == 2) {
+ float f;
+ if (item_byte_size == 2) {
+ uint16_t half = DE.GetU16(&offset);
+ f = half2float(half);
+ } else {
+ f = DE.GetFloat(&offset);
+ }
+ ss.precision(std::numeric_limits<float>::digits10);
+ ss << f;
+ } else if (item_byte_size == sizeof(double)) {
+ ss.precision(std::numeric_limits<double>::digits10);
+ ss << DE.GetDouble(&offset);
+ } else if (item_byte_size == sizeof(long double) ||
+ item_byte_size == 10) {
+ ss.precision(std::numeric_limits<long double>::digits10);
+ ss << DE.GetLongDouble(&offset);
+ } else {
+ s->Printf("error: unsupported byte size (%" PRIu64
+ ") for float format",
+ (uint64_t)item_byte_size);
+ return offset;
+ }
+ ss.flush();
+ s->Printf("%s", ss.str().c_str());
+ }
+ } break;
+
+ case eFormatUnicode16:
+ s->Printf("U+%4.4x", DE.GetU16(&offset));
+ break;
+
+ case eFormatUnicode32:
+ s->Printf("U+0x%8.8x", DE.GetU32(&offset));
+ break;
+
+ case eFormatAddressInfo: {
+ addr_t addr = DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
+ item_bit_offset);
+ s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size),
+ (int)(2 * item_byte_size), addr);
+ if (exe_scope) {
+ TargetSP target_sp(exe_scope->CalculateTarget());
+ lldb_private::Address so_addr;
+ if (target_sp) {
+ if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr,
+ so_addr)) {
+ s->PutChar(' ');
+ so_addr.Dump(s, exe_scope, Address::DumpStyleResolvedDescription,
+ Address::DumpStyleModuleWithFileAddress);
+ } else {
+ so_addr.SetOffset(addr);
+ so_addr.Dump(s, exe_scope,
+ Address::DumpStyleResolvedPointerDescription);
+ }
+ }
+ }
+ } break;
+
+ case eFormatHexFloat:
+ if (sizeof(float) == item_byte_size) {
+ char float_cstr[256];
+ llvm::APFloat ap_float(DE.GetFloat(&offset));
+ ap_float.convertToHexString(float_cstr, 0, false,
+ llvm::APFloat::rmNearestTiesToEven);
+ s->Printf("%s", float_cstr);
+ break;
+ } else if (sizeof(double) == item_byte_size) {
+ char float_cstr[256];
+ llvm::APFloat ap_float(DE.GetDouble(&offset));
+ ap_float.convertToHexString(float_cstr, 0, false,
+ llvm::APFloat::rmNearestTiesToEven);
+ s->Printf("%s", float_cstr);
+ break;
+ } else {
+ s->Printf("error: unsupported byte size (%" PRIu64
+ ") for hex float format",
+ (uint64_t)item_byte_size);
+ return offset;
+ }
+ break;
+
+ // please keep the single-item formats below in sync with
+ // FormatManager::GetSingleItemFormat
+ // if you fail to do so, users will start getting different outputs
+ // depending on internal
+ // implementation details they should not care about ||
+ case eFormatVectorOfChar: // ||
+ s->PutChar('{'); // \/
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatCharArray, 1, item_byte_size,
+ item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfSInt8:
+ s->PutChar('{');
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatDecimal, 1, item_byte_size,
+ item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfUInt8:
+ s->PutChar('{');
+ offset = DumpDataExtractor(DE, s, offset, eFormatHex, 1, item_byte_size,
+ item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfSInt16:
+ s->PutChar('{');
+ offset = DumpDataExtractor(
+ DE, s, offset, eFormatDecimal, sizeof(uint16_t),
+ item_byte_size / sizeof(uint16_t), item_byte_size / sizeof(uint16_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfUInt16:
+ s->PutChar('{');
+ offset = DumpDataExtractor(DE, s, offset, eFormatHex, sizeof(uint16_t),
+ item_byte_size / sizeof(uint16_t),
+ item_byte_size / sizeof(uint16_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfSInt32:
+ s->PutChar('{');
+ offset = DumpDataExtractor(
+ DE, s, offset, eFormatDecimal, sizeof(uint32_t),
+ item_byte_size / sizeof(uint32_t), item_byte_size / sizeof(uint32_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfUInt32:
+ s->PutChar('{');
+ offset = DumpDataExtractor(DE, s, offset, eFormatHex, sizeof(uint32_t),
+ item_byte_size / sizeof(uint32_t),
+ item_byte_size / sizeof(uint32_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfSInt64:
+ s->PutChar('{');
+ offset = DumpDataExtractor(
+ DE, s, offset, eFormatDecimal, sizeof(uint64_t),
+ item_byte_size / sizeof(uint64_t), item_byte_size / sizeof(uint64_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfUInt64:
+ s->PutChar('{');
+ offset = DumpDataExtractor(DE, s, offset, eFormatHex, sizeof(uint64_t),
+ item_byte_size / sizeof(uint64_t),
+ item_byte_size / sizeof(uint64_t),
+ LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfFloat16:
+ s->PutChar('{');
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatFloat, 2, item_byte_size / 2,
+ item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfFloat32:
+ s->PutChar('{');
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatFloat, 4, item_byte_size / 4,
+ item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfFloat64:
+ s->PutChar('{');
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatFloat, 8, item_byte_size / 8,
+ item_byte_size / 8, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+
+ case eFormatVectorOfUInt128:
+ s->PutChar('{');
+ offset =
+ DumpDataExtractor(DE, s, offset, eFormatHex, 16, item_byte_size / 16,
+ item_byte_size / 16, LLDB_INVALID_ADDRESS, 0, 0);
+ s->PutChar('}');
+ break;
+ }
+ }
+
+ if (item_format == eFormatBytesWithASCII && offset > line_start_offset) {
+ s->Printf("%*s", static_cast<int>(
+ (num_per_line - (offset - line_start_offset)) * 3 + 2),
+ "");
+ DumpDataExtractor(DE, s, line_start_offset, eFormatCharPrintable, 1,
+ offset - line_start_offset, SIZE_MAX,
+ LLDB_INVALID_ADDRESS, 0, 0);
+ }
+ return offset; // Return the offset at which we ended up
+}
+
+void lldb_private::DumpHexBytes(Stream *s, const void *src, size_t src_len,
+ uint32_t bytes_per_line,
+ lldb::addr_t base_addr) {
+ DataExtractor data(src, src_len, lldb::eByteOrderLittle, 4);
+ DumpDataExtractor(data, s,
+ 0, // Offset into "src"
+ lldb::eFormatBytes, // Dump as hex bytes
+ 1, // Size of each item is 1 for single bytes
+ src_len, // Number of bytes
+ bytes_per_line, // Num bytes per line
+ base_addr, // Base address
+ 0, 0); // Bitfield info
+}
diff --git a/source/Core/DynamicLoader.cpp b/source/Core/DynamicLoader.cpp
index 69c5ea30dad2..03fad244acfc 100644
--- a/source/Core/DynamicLoader.cpp
+++ b/source/Core/DynamicLoader.cpp
@@ -7,19 +7,25 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/DynamicLoader.h"
+
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
+#include "lldb/Symbol/ObjectFile.h" // for ObjectFile
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/lldb-private-interfaces.h" // for DynamicLoaderCreateInstance
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <memory> // for shared_ptr, unique_ptr
+
+#include <assert.h> // for assert
using namespace lldb;
using namespace lldb_private;
@@ -78,7 +84,7 @@ ModuleSP DynamicLoader::GetTargetExecutable() {
if (executable->GetFileSpec().Exists()) {
ModuleSpec module_spec(executable->GetFileSpec(),
executable->GetArchitecture());
- ModuleSP module_sp(new Module(module_spec));
+ auto module_sp = std::make_shared<Module>(module_spec);
// Check if the executable has changed and set it to the target executable
// if they differ.
@@ -189,7 +195,8 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
MemoryRegionInfo memory_info;
Error error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
if (error.Success() && memory_info.GetMapped() &&
- memory_info.GetRange().GetRangeBase() == base_addr) {
+ memory_info.GetRange().GetRangeBase() == base_addr &&
+ !(memory_info.GetName().IsEmpty())) {
ModuleSpec new_module_spec(
FileSpec(memory_info.GetName().AsCString(), false),
target.GetArchitecture());
@@ -233,3 +240,10 @@ addr_t DynamicLoader::ReadPointer(addr_t addr) {
else
return value;
}
+
+void DynamicLoader::LoadOperatingSystemPlugin(bool flush)
+{
+ if (m_process)
+ m_process->LoadOperatingSystemPlugin(flush);
+}
+
diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp
index bc32fb2f35eb..f18a4af67ef9 100644
--- a/source/Core/EmulateInstruction.cpp
+++ b/source/Core/EmulateInstruction.cpp
@@ -9,25 +9,33 @@
#include "lldb/Core/EmulateInstruction.h"
-// C Includes
-// C++ Includes
-#include <cstring>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Address.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/StackFrame.h" // for StackFrame
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h" // for Stream, Stream::::eBinary
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-forward.h" // for ProcessSP
+#include "lldb/lldb-private-interfaces.h" // for EmulateInstructionCreateIn...
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <cstring>
+#include <memory> // for shared_ptr
+
+#include <inttypes.h> // for PRIx64, PRId64, PRIu64
+#include <stdio.h> // for stdout
+
+namespace lldb_private {
+class Target;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/Event.cpp b/source/Core/Event.cpp
index bd57198f5487..8d351d8ba1a5 100644
--- a/source/Core/Event.cpp
+++ b/source/Core/Event.cpp
@@ -7,20 +7,19 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-#include <algorithm>
+#include "lldb/Core/Event.h"
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Event.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Core/DumpDataExtractor.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/lldb-enumerations.h" // for Format::eFormatBytes
+
+#include <algorithm>
+
+#include <ctype.h> // for isprint
using namespace lldb;
using namespace lldb_private;
@@ -140,8 +139,8 @@ void EventDataBytes::Dump(Stream *s) const {
} else if (!m_bytes.empty()) {
DataExtractor data;
data.SetData(m_bytes.data(), m_bytes.size(), endian::InlHostByteOrder());
- data.Dump(s, 0, eFormatBytes, 1, m_bytes.size(), 32, LLDB_INVALID_ADDRESS,
- 0, 0);
+ DumpDataExtractor(data, s, 0, eFormatBytes, 1, m_bytes.size(), 32,
+ LLDB_INVALID_ADDRESS, 0, 0);
}
}
diff --git a/source/Core/FileLineResolver.cpp b/source/Core/FileLineResolver.cpp
index db56cae9e9bc..36f37f4a14d5 100644
--- a/source/Core/FileLineResolver.cpp
+++ b/source/Core/FileLineResolver.cpp
@@ -10,10 +10,17 @@
#include "lldb/Core/FileLineResolver.h"
// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/FileSpecList.h" // for FileSpecList
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Stream.h" // for Stream
+
+#include <string> // for string
+
+namespace lldb_private {
+class Address;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/FileSpecList.cpp b/source/Core/FileSpecList.cpp
index d4ce4b787aad..a69f490f9aed 100644
--- a/source/Core/FileSpecList.cpp
+++ b/source/Core/FileSpecList.cpp
@@ -9,13 +9,12 @@
#include "lldb/Core/FileSpecList.h"
-// C Includes
-// C++ Includes
-#include <algorithm>
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Stream.h"
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Stream.h"
+#include <utility> // for find
+
+#include <stdint.h> // for UINT32_MAX
using namespace lldb_private;
using namespace std;
@@ -150,32 +149,23 @@ size_t FileSpecList::GetFilesMatchingPartialPath(const char *path,
FileSpecList &matches) {
#if 0 // FIXME: Just sketching...
matches.Clear();
- FileSpec path_spec = FileSpec (path);
- if (path_spec.Exists ())
- {
- FileSpec::FileType type = path_spec.GetFileType();
- if (type == FileSpec::eFileTypeSymbolicLink)
- // Shouldn't there be a Resolve on a file spec that real-path's it?
- {
- }
-
- if (type == FileSpec::eFileTypeRegular
- || (type == FileSpec::eFileTypeDirectory && dir_okay))
- {
- matches.Append (path_spec);
- return 1;
- }
- else if (type == FileSpec::eFileTypeDirectory)
- {
- // Fill the match list with all the files in the directory:
- }
- else
- {
- return 0;
- }
- }
- else
- {
+ using namespace llvm::sys::fs;
+ file_status stats;
+ if (status(path, stats, false))
+ return 0;
+ if (exists(stats)) {
+ if (is_symlink_file(stats)) {
+ // Shouldn't there be a method that realpath's a file?
+ }
+ if (is_regular_file(stats) || (is_directory(stats) && dir_okay)) {
+ matches.Append(FileSpec(path));
+ return 1;
+ } else if (is_directory(stats)) {
+ // Fill the match list with all the files in the directory:
+ } else {
+ return 0;
+ }
+ } else {
ConstString dir_name = path_spec.GetDirectory();
ConstString file_name = GetFilename();
if (dir_name == nullptr)
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp
index 08166d208aee..835a1c54a0e0 100644
--- a/source/Core/FormatEntity.cpp
+++ b/source/Core/FormatEntity.cpp
@@ -9,33 +9,31 @@
#include "lldb/Core/FormatEntity.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringRef.h"
-
-// Project includes
#include "lldb/Core/Address.h"
+#include "lldb/Core/AddressRange.h" // for AddressRange
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/RegisterValue.h" // for RegisterValue
+#include "lldb/Core/StructuredData.h" // for StructuredData::O...
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormatClasses.h" // for TypeNameSpecifier...
#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryImpl::...
#include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerType.h" // for CompilerType
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/Symbol.h"
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextS...
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -45,6 +43,36 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/ConstString.h" // for ConstString, oper...
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h" // for Log
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCatego...
+#include "lldb/Utility/SharingPtr.h" // for SharingPtr
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h" // for StringList
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for ValueObjectSP
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h" // for Triple, Triple::O...
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
+
+#include <ctype.h> // for isxdigit
+#include <inttypes.h> // for PRIu64, PRIx64
+#include <memory> // for shared_ptr, opera...
+#include <stdio.h> // for sprintf
+#include <stdlib.h> // for strtoul
+#include <string.h> // for size_t, strchr
+#include <type_traits> // for move
+#include <utility> // for pair
+
+namespace lldb_private {
+class ScriptInterpreter;
+}
+namespace lldb_private {
+struct RegisterInfo;
+}
using namespace lldb;
using namespace lldb_private;
@@ -64,14 +92,14 @@ enum FileKind { FileError = 0, Basename, Dirname, Fullpath };
#define ENTRY_CHILDREN(n, t, f, c) \
{ \
n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \
- false \
+ FormatEntity::Entry::FormatType::f, 0, \
+ static_cast<uint32_t>(llvm::array_lengthof(c)), c, false \
}
#define ENTRY_CHILDREN_KEEP_SEP(n, t, f, c) \
{ \
n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \
- true \
+ FormatEntity::Entry::FormatType::f, 0, \
+ static_cast<uint32_t>(llvm::array_lengthof(c)), c, true \
}
#define ENTRY_STRING(n, s) \
{ \
@@ -822,8 +850,8 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
StreamString bitfield_name;
bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(),
target->GetBitfieldBitSize());
- lldb::TypeNameSpecifierImplSP type_sp(
- new TypeNameSpecifierImpl(bitfield_name.GetString(), false));
+ auto type_sp = std::make_shared<TypeNameSpecifierImpl>(
+ bitfield_name.GetString(), false);
if (val_obj_display ==
ValueObject::eValueObjectRepresentationStyleSummary &&
!DataVisualization::GetSummaryForType(type_sp))
@@ -1187,7 +1215,8 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
? arch.GetTriple().getOS()
: llvm::Triple::UnknownOS;
if ((ostype == llvm::Triple::FreeBSD) ||
- (ostype == llvm::Triple::Linux)) {
+ (ostype == llvm::Triple::Linux) ||
+ (ostype == llvm::Triple::NetBSD)) {
format = "%" PRIu64;
}
} else {
diff --git a/source/Core/IOHandler.cpp b/source/Core/IOHandler.cpp
index 9c5e6ca80c20..b5dd0bd8a25f 100644
--- a/source/Core/IOHandler.cpp
+++ b/source/Core/IOHandler.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/Core/IOHandler.h"
+
// C Includes
#ifndef LLDB_DISABLE_CURSES
#include <curses.h>
@@ -21,36 +23,55 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/IOHandler.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Host/File.h" // for File
+#include "lldb/Host/Predicate.h" // for Predicate, ::eBroad...
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/StreamString.h" // for StreamString
+#include "lldb/Utility/StringList.h" // for StringList
+#include "lldb/lldb-forward.h" // for StreamFileSP
+
#ifndef LLDB_DISABLE_LIBEDIT
#include "lldb/Host/Editline.h"
#endif
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#ifndef LLDB_DISABLE_CURSES
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/State.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/ThreadPlan.h"
-#ifndef LLDB_DISABLE_CURSES
-#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#endif
+#include "llvm/ADT/StringRef.h" // for StringRef
+
#ifdef _MSC_VER
-#include <Windows.h>
+#include <windows.h>
#endif
+#include <memory> // for shared_ptr
+#include <mutex> // for recursive_mutex
+
+#include <assert.h> // for assert
+#include <ctype.h> // for isspace
+#include <errno.h> // for EINTR, errno
+#include <stdint.h> // for uint32_t, UINT32_MAX
+#include <stdio.h> // for size_t, fprintf, feof
+#include <string.h> // for strlen
+#include <type_traits> // for move
+
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/Listener.cpp b/source/Core/Listener.cpp
index 3adb677f53d1..1afa11649b59 100644
--- a/source/Core/Listener.cpp
+++ b/source/Core/Listener.cpp
@@ -9,16 +9,17 @@
#include "lldb/Core/Listener.h"
-// C Includes
-// C++ Includes
-#include <algorithm>
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIBL...
+
+#include "llvm/ADT/Optional.h" // for Optional
+
+#include <algorithm>
+#include <memory> // for make_shared
+#include <utility> // for pair, make_pair
using namespace lldb;
using namespace lldb_private;
@@ -352,11 +353,7 @@ bool Listener::GetEventInternal(
uint32_t num_broadcaster_names, uint32_t event_type_mask,
EventSP &event_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS));
- if (log != nullptr)
- log->Printf("%p Listener::GetEventInternal (timeout = %llu us) for %s",
- static_cast<void *>(this), static_cast<unsigned long long>(
- timeout ? timeout->count() : -1),
- m_name.c_str());
+ LLDB_LOG(log, "this = {0}, timeout = {1} for {2}", this, timeout, m_name);
std::unique_lock<std::mutex> lock(m_events_mutex);
diff --git a/source/Core/Log.cpp b/source/Core/Log.cpp
deleted file mode 100644
index b62df3c1fe97..000000000000
--- a/source/Core/Log.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-//===-- Log.cpp -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Utility/NameMatches.h"
-
-// Other libraries and framework includes
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/Chrono.h"
-#include "llvm/Support/Signals.h"
-#include "llvm/Support/raw_ostream.h"
-
-// C Includes
-// C++ Includes
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <map>
-#include <mutex>
-#include <string>
-
-using namespace lldb;
-using namespace lldb_private;
-
-Log::Log() : m_stream_sp(), m_options(0), m_mask_bits(0) {}
-
-Log::Log(const StreamSP &stream_sp)
- : m_stream_sp(stream_sp), m_options(0), m_mask_bits(0) {}
-
-Log::~Log() = default;
-
-Flags &Log::GetOptions() { return m_options; }
-
-const Flags &Log::GetOptions() const { return m_options; }
-
-Flags &Log::GetMask() { return m_mask_bits; }
-
-const Flags &Log::GetMask() const { return m_mask_bits; }
-
-void Log::PutCString(const char *cstr) { Printf("%s", cstr); }
-void Log::PutString(llvm::StringRef str) { PutCString(str.str().c_str()); }
-
-//----------------------------------------------------------------------
-// Simple variable argument logging with flags.
-//----------------------------------------------------------------------
-void Log::Printf(const char *format, ...) {
- va_list args;
- va_start(args, format);
- VAPrintf(format, args);
- va_end(args);
-}
-
-//----------------------------------------------------------------------
-// All logging eventually boils down to this function call. If we have
-// a callback registered, then we call the logging callback. If we have
-// a valid file handle, we also log to the file.
-//----------------------------------------------------------------------
-void Log::VAPrintf(const char *format, va_list args) {
- // Make a copy of our stream shared pointer in case someone disables our
- // log while we are logging and releases the stream
- StreamSP stream_sp(m_stream_sp);
- if (stream_sp) {
- static uint32_t g_sequence_id = 0;
- StreamString header;
-
- // Add a sequence ID if requested
- if (m_options.Test(LLDB_LOG_OPTION_PREPEND_SEQUENCE))
- header.Printf("%u ", ++g_sequence_id);
-
- // Timestamp if requested
- if (m_options.Test(LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) {
- auto now = std::chrono::duration<double>(
- std::chrono::system_clock::now().time_since_epoch());
- header.Printf("%.9f ", now.count());
- }
-
- // Add the process and thread if requested
- if (m_options.Test(LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
- header.Printf("[%4.4x/%4.4" PRIx64 "]: ", getpid(),
- Host::GetCurrentThreadID());
-
- // Add the thread name if requested
- if (m_options.Test(LLDB_LOG_OPTION_PREPEND_THREAD_NAME)) {
- llvm::SmallString<32> thread_name;
- ThisThread::GetName(thread_name);
- if (!thread_name.empty())
- header.Printf("%s ", thread_name.c_str());
- }
-
- header.PrintfVarArg(format, args);
- header.PutCString("\n");
-
- if (m_options.Test(LLDB_LOG_OPTION_BACKTRACE)) {
- std::string back_trace;
- llvm::raw_string_ostream stream(back_trace);
- llvm::sys::PrintStackTrace(stream);
- stream.flush();
- header.PutCString(back_trace);
- }
-
- if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) {
- static std::recursive_mutex g_LogThreadedMutex;
- std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
- stream_sp->PutCString(header.GetString());
- stream_sp->Flush();
- } else {
- stream_sp->PutCString(header.GetString());
- stream_sp->Flush();
- }
- }
-}
-
-//----------------------------------------------------------------------
-// Print debug strings if and only if the global debug option is set to
-// a non-zero value.
-//----------------------------------------------------------------------
-void Log::Debug(const char *format, ...) {
- if (!GetOptions().Test(LLDB_LOG_OPTION_DEBUG))
- return;
-
- va_list args;
- va_start(args, format);
- VAPrintf(format, args);
- va_end(args);
-}
-
-//----------------------------------------------------------------------
-// Log only if all of the bits are set
-//----------------------------------------------------------------------
-void Log::LogIf(uint32_t bits, const char *format, ...) {
- if (!m_options.AllSet(bits))
- return;
-
- va_list args;
- va_start(args, format);
- VAPrintf(format, args);
- va_end(args);
-}
-
-//----------------------------------------------------------------------
-// Printing of errors that are not fatal.
-//----------------------------------------------------------------------
-void Log::Error(const char *format, ...) {
- va_list args;
- va_start(args, format);
- VAError(format, args);
- va_end(args);
-}
-
-void Log::VAError(const char *format, va_list args) {
- char *arg_msg = nullptr;
- ::vasprintf(&arg_msg, format, args);
-
- if (arg_msg == nullptr)
- return;
-
- Printf("error: %s", arg_msg);
- free(arg_msg);
-}
-
-//----------------------------------------------------------------------
-// Printing of warnings that are not fatal only if verbose mode is
-// enabled.
-//----------------------------------------------------------------------
-void Log::Verbose(const char *format, ...) {
- if (!m_options.Test(LLDB_LOG_OPTION_VERBOSE))
- return;
-
- va_list args;
- va_start(args, format);
- VAPrintf(format, args);
- va_end(args);
-}
-
-//----------------------------------------------------------------------
-// Printing of warnings that are not fatal.
-//----------------------------------------------------------------------
-void Log::Warning(const char *format, ...) {
- char *arg_msg = nullptr;
- va_list args;
- va_start(args, format);
- ::vasprintf(&arg_msg, format, args);
- va_end(args);
-
- if (arg_msg == nullptr)
- return;
-
- Printf("warning: %s", arg_msg);
- free(arg_msg);
-}
-
-typedef std::map<ConstString, Log::Callbacks> CallbackMap;
-typedef CallbackMap::iterator CallbackMapIter;
-
-typedef std::map<ConstString, LogChannelSP> LogChannelMap;
-typedef LogChannelMap::iterator LogChannelMapIter;
-
-// Surround our callback map with a singleton function so we don't have any
-// global initializers.
-static CallbackMap &GetCallbackMap() {
- static CallbackMap g_callback_map;
- return g_callback_map;
-}
-
-static LogChannelMap &GetChannelMap() {
- static LogChannelMap g_channel_map;
- return g_channel_map;
-}
-
-void Log::RegisterLogChannel(const ConstString &channel,
- const Log::Callbacks &log_callbacks) {
- GetCallbackMap().insert(std::make_pair(channel, log_callbacks));
-}
-
-bool Log::UnregisterLogChannel(const ConstString &channel) {
- return GetCallbackMap().erase(channel) != 0;
-}
-
-bool Log::GetLogChannelCallbacks(const ConstString &channel,
- Log::Callbacks &log_callbacks) {
- CallbackMap &callback_map = GetCallbackMap();
- CallbackMapIter pos = callback_map.find(channel);
- if (pos != callback_map.end()) {
- log_callbacks = pos->second;
- return true;
- }
- ::memset(&log_callbacks, 0, sizeof(log_callbacks));
- return false;
-}
-
-bool Log::EnableLogChannel(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- const char *channel, const char **categories,
- Stream &error_stream) {
- Log::Callbacks log_callbacks;
- if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
- log_callbacks.enable(log_stream_sp, log_options, categories, &error_stream);
- return true;
- }
-
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(channel));
- if (log_channel_sp) {
- if (log_channel_sp->Enable(log_stream_sp, log_options, &error_stream,
- categories)) {
- return true;
- } else {
- error_stream.Printf("Invalid log channel '%s'.\n", channel);
- return false;
- }
- } else {
- error_stream.Printf("Invalid log channel '%s'.\n", channel);
- return false;
- }
-}
-
-void Log::EnableAllLogChannels(StreamSP &log_stream_sp, uint32_t log_options,
- const char **categories, Stream *feedback_strm) {
- CallbackMap &callback_map = GetCallbackMap();
- CallbackMapIter pos, end = callback_map.end();
-
- for (pos = callback_map.begin(); pos != end; ++pos)
- pos->second.enable(log_stream_sp, log_options, categories, feedback_strm);
-
- LogChannelMap &channel_map = GetChannelMap();
- LogChannelMapIter channel_pos, channel_end = channel_map.end();
- for (channel_pos = channel_map.begin(); channel_pos != channel_end;
- ++channel_pos) {
- channel_pos->second->Enable(log_stream_sp, log_options, feedback_strm,
- categories);
- }
-}
-
-void Log::AutoCompleteChannelName(const char *channel_name,
- StringList &matches) {
- LogChannelMap &map = GetChannelMap();
- LogChannelMapIter pos, end = map.end();
- for (pos = map.begin(); pos != end; ++pos) {
- const char *pos_channel_name = pos->first.GetCString();
- if (channel_name && channel_name[0]) {
- if (NameMatches(channel_name, eNameMatchStartsWith, pos_channel_name)) {
- matches.AppendString(pos_channel_name);
- }
- } else
- matches.AppendString(pos_channel_name);
- }
-}
-
-void Log::DisableAllLogChannels(Stream *feedback_strm) {
- CallbackMap &callback_map = GetCallbackMap();
- CallbackMapIter pos, end = callback_map.end();
- const char *categories[] = {"all", nullptr};
-
- for (pos = callback_map.begin(); pos != end; ++pos)
- pos->second.disable(categories, feedback_strm);
-
- LogChannelMap &channel_map = GetChannelMap();
- LogChannelMapIter channel_pos, channel_end = channel_map.end();
- for (channel_pos = channel_map.begin(); channel_pos != channel_end;
- ++channel_pos)
- channel_pos->second->Disable(categories, feedback_strm);
-}
-
-void Log::Initialize() {
- Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
- Log::RegisterLogChannel(ConstString("lldb"), log_callbacks);
-}
-
-void Log::Terminate() { DisableAllLogChannels(nullptr); }
-
-void Log::ListAllLogChannels(Stream *strm) {
- CallbackMap &callback_map = GetCallbackMap();
- LogChannelMap &channel_map = GetChannelMap();
-
- if (callback_map.empty() && channel_map.empty()) {
- strm->PutCString("No logging channels are currently registered.\n");
- return;
- }
-
- CallbackMapIter pos, end = callback_map.end();
- for (pos = callback_map.begin(); pos != end; ++pos)
- pos->second.list_categories(strm);
-
- uint32_t idx = 0;
- const char *name;
- for (idx = 0;
- (name = PluginManager::GetLogChannelCreateNameAtIndex(idx)) != nullptr;
- ++idx) {
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(name));
- if (log_channel_sp)
- log_channel_sp->ListCategories(strm);
- }
-}
-
-bool Log::GetVerbose() const {
- // FIXME: This has to be centralized between the stream and the log...
- if (m_options.Test(LLDB_LOG_OPTION_VERBOSE))
- return true;
-
- // Make a copy of our stream shared pointer in case someone disables our
- // log while we are logging and releases the stream
- StreamSP stream_sp(m_stream_sp);
- if (stream_sp)
- return stream_sp->GetVerbose();
- return false;
-}
-
-//------------------------------------------------------------------
-// Returns true if the debug flag bit is set in this stream.
-//------------------------------------------------------------------
-bool Log::GetDebug() const {
- // Make a copy of our stream shared pointer in case someone disables our
- // log while we are logging and releases the stream
- StreamSP stream_sp(m_stream_sp);
- if (stream_sp)
- return stream_sp->GetDebug();
- return false;
-}
-
-LogChannelSP LogChannel::FindPlugin(const char *plugin_name) {
- LogChannelSP log_channel_sp;
- LogChannelMap &channel_map = GetChannelMap();
- ConstString log_channel_name(plugin_name);
- LogChannelMapIter pos = channel_map.find(log_channel_name);
- if (pos == channel_map.end()) {
- ConstString const_plugin_name(plugin_name);
- LogChannelCreateInstance create_callback =
- PluginManager::GetLogChannelCreateCallbackForPluginName(
- const_plugin_name);
- if (create_callback) {
- log_channel_sp.reset(create_callback());
- if (log_channel_sp) {
- // Cache the one and only loaded instance of each log channel
- // plug-in after it has been loaded once.
- channel_map[log_channel_name] = log_channel_sp;
- }
- }
- } else {
- // We have already loaded an instance of this log channel class,
- // so just return the cached instance.
- log_channel_sp = pos->second;
- }
- return log_channel_sp;
-}
-
-LogChannel::LogChannel() : m_log_ap() {}
-
-LogChannel::~LogChannel() = default;
diff --git a/source/Core/Logging.cpp b/source/Core/Logging.cpp
deleted file mode 100644
index 4d63b60eeccd..000000000000
--- a/source/Core/Logging.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-//===-- Logging.cpp ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Logging.h"
-
-// C Includes
-// C++ Includes
-#include <atomic>
-#include <cstring>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.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_lob_sp the first time this function is
-// called.
-
-static std::atomic<bool> g_log_enabled{false};
-static Log *g_log = nullptr;
-
-static Log *GetLog() {
- if (!g_log_enabled)
- return nullptr;
- return g_log;
-}
-
-uint32_t lldb_private::GetLogMask() {
- Log *log(GetLog());
- if (log)
- return log->GetMask().Get();
- return 0;
-}
-
-bool lldb_private::IsLogVerbose() {
- uint32_t mask = GetLogMask();
- return (mask & LIBLLDB_LOG_VERBOSE);
-}
-
-Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) {
- Log *log(GetLog());
- if (log && mask) {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return nullptr;
- }
- return log;
-}
-
-void lldb_private::LogIfAllCategoriesSet(uint32_t mask, const char *format,
- ...) {
- Log *log(GetLogIfAllCategoriesSet(mask));
- if (log) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
-}
-
-void lldb_private::LogIfAnyCategoriesSet(uint32_t mask, const char *format,
- ...) {
- Log *log(GetLogIfAnyCategoriesSet(mask));
- if (log != nullptr) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
-}
-
-Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) {
- Log *log(GetLog());
- if (log != nullptr && mask && (mask & log->GetMask().Get()))
- return log;
- return nullptr;
-}
-
-void lldb_private::DisableLog(const char **categories, Stream *feedback_strm) {
- Log *log(GetLog());
-
- if (log != nullptr) {
- uint32_t flag_bits = 0;
- if (categories && categories[0]) {
- flag_bits = log->GetMask().Get();
- for (size_t i = 0; categories[i] != nullptr; ++i) {
- const char *arg = categories[i];
-
- if (0 == ::strcasecmp(arg, "all"))
- flag_bits &= ~LIBLLDB_LOG_ALL;
- else if (0 == ::strcasecmp(arg, "api"))
- flag_bits &= ~LIBLLDB_LOG_API;
- else if (0 == ::strncasecmp(arg, "break", 5))
- flag_bits &= ~LIBLLDB_LOG_BREAKPOINTS;
- else if (0 == ::strcasecmp(arg, "commands"))
- flag_bits &= ~LIBLLDB_LOG_COMMANDS;
- else if (0 == ::strcasecmp(arg, "default"))
- flag_bits &= ~LIBLLDB_LOG_DEFAULT;
- else if (0 == ::strcasecmp(arg, "dyld"))
- flag_bits &= ~LIBLLDB_LOG_DYNAMIC_LOADER;
- else if (0 == ::strncasecmp(arg, "event", 5))
- flag_bits &= ~LIBLLDB_LOG_EVENTS;
- else if (0 == ::strncasecmp(arg, "expr", 4))
- flag_bits &= ~LIBLLDB_LOG_EXPRESSIONS;
- else if (0 == ::strncasecmp(arg, "object", 6))
- flag_bits &= ~LIBLLDB_LOG_OBJECT;
- else if (0 == ::strcasecmp(arg, "process"))
- flag_bits &= ~LIBLLDB_LOG_PROCESS;
- else if (0 == ::strcasecmp(arg, "platform"))
- flag_bits &= ~LIBLLDB_LOG_PLATFORM;
- else if (0 == ::strcasecmp(arg, "script"))
- flag_bits &= ~LIBLLDB_LOG_SCRIPT;
- else if (0 == ::strcasecmp(arg, "state"))
- flag_bits &= ~LIBLLDB_LOG_STATE;
- else if (0 == ::strcasecmp(arg, "step"))
- flag_bits &= ~LIBLLDB_LOG_STEP;
- else if (0 == ::strcasecmp(arg, "thread"))
- flag_bits &= ~LIBLLDB_LOG_THREAD;
- else if (0 == ::strcasecmp(arg, "target"))
- flag_bits &= ~LIBLLDB_LOG_TARGET;
- else if (0 == ::strcasecmp(arg, "verbose"))
- flag_bits &= ~LIBLLDB_LOG_VERBOSE;
- else if (0 == ::strncasecmp(arg, "watch", 5))
- flag_bits &= ~LIBLLDB_LOG_WATCHPOINTS;
- else if (0 == ::strncasecmp(arg, "temp", 4))
- flag_bits &= ~LIBLLDB_LOG_TEMPORARY;
- else if (0 == ::strncasecmp(arg, "comm", 4))
- flag_bits &= ~LIBLLDB_LOG_COMMUNICATION;
- else if (0 == ::strncasecmp(arg, "conn", 4))
- flag_bits &= ~LIBLLDB_LOG_CONNECTION;
- else if (0 == ::strncasecmp(arg, "host", 4))
- flag_bits &= ~LIBLLDB_LOG_HOST;
- else if (0 == ::strncasecmp(arg, "unwind", 6))
- flag_bits &= ~LIBLLDB_LOG_UNWIND;
- else if (0 == ::strncasecmp(arg, "types", 5))
- flag_bits &= ~LIBLLDB_LOG_TYPES;
- else if (0 == ::strncasecmp(arg, "symbol", 6))
- flag_bits &= ~LIBLLDB_LOG_SYMBOLS;
- else if (0 == ::strcasecmp(arg, "system-runtime"))
- flag_bits &= ~LIBLLDB_LOG_SYSTEM_RUNTIME;
- else if (0 == ::strncasecmp(arg, "module", 6))
- flag_bits &= ~LIBLLDB_LOG_MODULES;
- else if (0 == ::strncasecmp(arg, "mmap", 4))
- flag_bits &= ~LIBLLDB_LOG_MMAP;
- else if (0 == ::strcasecmp(arg, "os"))
- flag_bits &= ~LIBLLDB_LOG_OS;
- else if (0 == ::strcasecmp(arg, "jit"))
- flag_bits &= ~LIBLLDB_LOG_JIT_LOADER;
- else if (0 == ::strcasecmp(arg, "language"))
- flag_bits &= ~LIBLLDB_LOG_LANGUAGE;
- else if (0 == ::strncasecmp(arg, "formatters", 10))
- flag_bits &= ~LIBLLDB_LOG_DATAFORMATTERS;
- else if (0 == ::strncasecmp(arg, "demangle", 8))
- flag_bits &= ~LIBLLDB_LOG_DEMANGLE;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n",
- arg);
- ListLogCategories(feedback_strm);
- return;
- }
- }
- }
- log->GetMask().Reset(flag_bits);
- if (flag_bits == 0) {
- log->SetStream(lldb::StreamSP());
- g_log_enabled = false;
- }
- }
-}
-
-Log *lldb_private::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;
- if (g_log != nullptr)
- flag_bits = g_log->GetMask().Get();
- else
- flag_bits = 0;
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp) {
- if (g_log != nullptr)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
-
- if (g_log != nullptr) {
- for (size_t i = 0; categories[i] != nullptr; ++i) {
- const char *arg = categories[i];
-
- if (0 == ::strcasecmp(arg, "all"))
- flag_bits |= LIBLLDB_LOG_ALL;
- else if (0 == ::strcasecmp(arg, "api"))
- flag_bits |= LIBLLDB_LOG_API;
- else if (0 == ::strncasecmp(arg, "break", 5))
- flag_bits |= LIBLLDB_LOG_BREAKPOINTS;
- else if (0 == ::strcasecmp(arg, "commands"))
- flag_bits |= LIBLLDB_LOG_COMMANDS;
- else if (0 == ::strncasecmp(arg, "commu", 5))
- flag_bits |= LIBLLDB_LOG_COMMUNICATION;
- else if (0 == ::strncasecmp(arg, "conn", 4))
- flag_bits |= LIBLLDB_LOG_CONNECTION;
- else if (0 == ::strcasecmp(arg, "default"))
- flag_bits |= LIBLLDB_LOG_DEFAULT;
- else if (0 == ::strcasecmp(arg, "dyld"))
- flag_bits |= LIBLLDB_LOG_DYNAMIC_LOADER;
- else if (0 == ::strncasecmp(arg, "event", 5))
- flag_bits |= LIBLLDB_LOG_EVENTS;
- else if (0 == ::strncasecmp(arg, "expr", 4))
- flag_bits |= LIBLLDB_LOG_EXPRESSIONS;
- else if (0 == ::strncasecmp(arg, "host", 4))
- flag_bits |= LIBLLDB_LOG_HOST;
- else if (0 == ::strncasecmp(arg, "mmap", 4))
- flag_bits |= LIBLLDB_LOG_MMAP;
- else if (0 == ::strncasecmp(arg, "module", 6))
- flag_bits |= LIBLLDB_LOG_MODULES;
- else if (0 == ::strncasecmp(arg, "object", 6))
- flag_bits |= LIBLLDB_LOG_OBJECT;
- else if (0 == ::strcasecmp(arg, "os"))
- flag_bits |= LIBLLDB_LOG_OS;
- else if (0 == ::strcasecmp(arg, "platform"))
- flag_bits |= LIBLLDB_LOG_PLATFORM;
- else if (0 == ::strcasecmp(arg, "process"))
- flag_bits |= LIBLLDB_LOG_PROCESS;
- else if (0 == ::strcasecmp(arg, "script"))
- flag_bits |= LIBLLDB_LOG_SCRIPT;
- else if (0 == ::strcasecmp(arg, "state"))
- flag_bits |= LIBLLDB_LOG_STATE;
- else if (0 == ::strcasecmp(arg, "step"))
- flag_bits |= LIBLLDB_LOG_STEP;
- else if (0 == ::strncasecmp(arg, "symbol", 6))
- flag_bits |= LIBLLDB_LOG_SYMBOLS;
- else if (0 == ::strcasecmp(arg, "system-runtime"))
- flag_bits |= LIBLLDB_LOG_SYSTEM_RUNTIME;
- else if (0 == ::strcasecmp(arg, "target"))
- flag_bits |= LIBLLDB_LOG_TARGET;
- else if (0 == ::strncasecmp(arg, "temp", 4))
- flag_bits |= LIBLLDB_LOG_TEMPORARY;
- else if (0 == ::strcasecmp(arg, "thread"))
- flag_bits |= LIBLLDB_LOG_THREAD;
- else if (0 == ::strncasecmp(arg, "types", 5))
- flag_bits |= LIBLLDB_LOG_TYPES;
- else if (0 == ::strncasecmp(arg, "unwind", 6))
- flag_bits |= LIBLLDB_LOG_UNWIND;
- else if (0 == ::strcasecmp(arg, "verbose"))
- flag_bits |= LIBLLDB_LOG_VERBOSE;
- else if (0 == ::strncasecmp(arg, "watch", 5))
- flag_bits |= LIBLLDB_LOG_WATCHPOINTS;
- else if (0 == ::strcasecmp(arg, "jit"))
- flag_bits |= LIBLLDB_LOG_JIT_LOADER;
- else if (0 == ::strcasecmp(arg, "language"))
- flag_bits |= LIBLLDB_LOG_LANGUAGE;
- else if (0 == ::strncasecmp(arg, "formatters", 10))
- flag_bits |= LIBLLDB_LOG_DATAFORMATTERS;
- else if (0 == ::strncasecmp(arg, "demangle", 8))
- flag_bits |= LIBLLDB_LOG_DEMANGLE;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- return g_log;
- }
- }
-
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- }
- g_log_enabled = true;
- return g_log;
-}
-
-void lldb_private::ListLogCategories(Stream *strm) {
- strm->Printf(
- "Logging categories for 'lldb':\n"
- " all - turn on all available logging categories\n"
- " api - enable logging of API calls and return values\n"
- " break - log breakpoints\n"
- " commands - log command argument parsing\n"
- " communication - log communication activities\n"
- " connection - log connection details\n"
- " default - enable the default set of logging categories for liblldb\n"
- " demangle - log mangled names to catch demangler crashes\n"
- " dyld - log shared library related activities\n"
- " events - log broadcaster, listener and event queue activities\n"
- " expr - log expressions\n"
- " formatters - log data formatters related activities\n"
- " host - log host activities\n"
- " jit - log JIT events in the target\n"
- " language - log language runtime events\n"
- " mmap - log mmap related activities\n"
- " module - log module activities such as when modules are created, "
- "destroyed, replaced, and more\n"
- " object - log object construction/destruction for important objects\n"
- " os - log OperatingSystem plugin related activities\n"
- " platform - log platform events and activities\n"
- " process - log process events and activities\n"
- " script - log events about the script interpreter\n"
- " state - log private and public process state changes\n"
- " step - log step related activities\n"
- " symbol - log symbol related issues and warnings\n"
- " system-runtime - log system runtime events\n"
- " target - log target events and activities\n"
- " thread - log thread events and activities\n"
- " types - log type system related activities\n"
- " unwind - log stack unwind activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n");
-}
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index c2c63b665639..3d96340b911c 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -7,10 +7,11 @@
//
//===----------------------------------------------------------------------===//
-// FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
-#include <cstddef>
+#include "lldb/Core/Mangled.h"
+
#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
+#include <windows.h>
+
#include <dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
#endif
@@ -18,29 +19,55 @@
#ifdef LLDB_USE_BUILTIN_DEMANGLER
// Provide a fast-path demangler implemented in FastDemangle.cpp until it can
// replace the existing C++ demangler with a complete implementation
+#include "lldb/Utility/FastDemangle.h"
#include "llvm/Demangle/Demangle.h"
-#include "lldb/Core/FastDemangle.h"
#else
+// FreeBSD9-STABLE requires this to know about size_t in cxxabi.
+#include <cstddef>
#include <cxxabi.h>
#endif
-#include "llvm/ADT/DenseMap.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-enumerations.h" // for LanguageType
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Logging.h"
-#include "lldb/Core/Mangled.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/Timer.h"
-#include <ctype.h>
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/Compiler.h" // for LLVM_PRETT...
+
+#include <mutex> // for mutex, loc...
+#include <string> // for string
+#include <utility> // for pair
+
#include <stdlib.h>
#include <string.h>
-
using namespace lldb_private;
+#if defined(_MSC_VER)
+static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
+ DWORD DemangledLength) {
+ static std::mutex M;
+ std::lock_guard<std::mutex> Lock(M);
+ return ::UnDecorateSymbolName(
+ Mangled, Demangled, DemangledLength,
+ UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
+ // keywords
+ UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
+ // etc keywords
+ UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
+ UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
+ // specifiers
+ UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords
+ );
+}
+#endif
+
static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
if (s) {
if (s[0] == '?')
@@ -253,17 +280,8 @@ Mangled::GetDemangledName(lldb::LanguageType language) const {
const size_t demangled_length = 2048;
demangled_name = static_cast<char *>(::malloc(demangled_length));
::ZeroMemory(demangled_name, demangled_length);
- DWORD result = ::UnDecorateSymbolName(
- mangled_name, demangled_name, demangled_length,
- UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
- // keywords
- UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
- // etc keywords
- UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
- UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
- // specifiers
- UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords
- );
+ DWORD result =
+ safeUndecorateName(mangled_name, demangled_name, demangled_length);
if (log) {
if (demangled_name && demangled_name[0])
log->Printf("demangled msvc: %s -> \"%s\"", mangled_name,
@@ -414,6 +432,14 @@ lldb::LanguageType Mangled::GuessLanguage() const {
else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name))
return lldb::eLanguageTypeObjC;
}
+ } else {
+ // ObjC names aren't really mangled, so they won't necessarily be in the
+ // mangled name slot.
+ ConstString demangled_name = GetDemangledName(lldb::eLanguageTypeUnknown);
+ if (demangled_name
+ && ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString()))
+ return lldb::eLanguageTypeObjC;
+
}
return lldb::eLanguageTypeUnknown;
}
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 28f140b41e1e..ddc9fca80671 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -9,46 +9,73 @@
#include "lldb/Core/Module.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/Support/Signals.h"
-#include "llvm/Support/raw_os_ostream.h"
-
-// Project includes
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "lldb/Core/AddressRange.h" // for AddressRange
#include "lldb/Core/AddressResolverFileLine.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/Debugger.h" // for Debugger
+#include "lldb/Core/FileSpecList.h" // for FileSpecList
+#include "lldb/Core/Mangled.h" // for Mangled
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/SearchFilter.h" // for SearchFilt...
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h" // for Function
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h" // for Symbol
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Symtab.h" // for Symtab
+#include "lldb/Symbol/Type.h" // for Type
+#include "lldb/Symbol/TypeList.h" // for TypeList
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Language.h"
+#include "lldb/Target/Platform.h" // for Platform
#include "lldb/Target/Process.h"
-#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAn...
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+
+#if defined(LLVM_ON_WIN32)
+#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#endif
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
+#include "llvm/ADT/STLExtras.h" // for make_unique
+#include "llvm/Support/Compiler.h" // for LLVM_PRETT...
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h" // for raw_string...
+
+#include <assert.h> // for assert
+#include <cstdint> // for uint32_t
+#include <inttypes.h> // for PRIx64
+#include <map> // for map
+#include <stdarg.h> // for va_end
+#include <string.h> // for size_t
+#include <type_traits> // for move
+#include <utility> // for find, pair
+
+namespace lldb_private {
+class CompilerDeclContext;
+}
+namespace lldb_private {
+class VariableList;
+}
+
using namespace lldb;
using namespace lldb_private;
@@ -303,8 +330,7 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (process_sp) {
m_did_load_objfile = true;
- std::unique_ptr<DataBufferHeap> data_ap(
- new DataBufferHeap(size_to_read, 0));
+ auto data_ap = llvm::make_unique<DataBufferHeap>(size_to_read, 0);
Error readmem_error;
const size_t bytes_read =
process_sp->ReadMemory(header_addr, data_ap->GetBytes(),
@@ -719,10 +745,10 @@ Module::LookupInfo::LookupInfo(const ConstString &name, uint32_t name_type_mask,
}
// Still try and get a basename in case someone specifies a name type mask
- // of
- // eFunctionNameTypeFull and a name like "A::func"
+ // of eFunctionNameTypeFull and a name like "A::func"
if (basename.empty()) {
- if (name_type_mask & eFunctionNameTypeFull) {
+ if (name_type_mask & eFunctionNameTypeFull &&
+ !CPlusPlusLanguage::IsCPPMangledName(name_cstr)) {
CPlusPlusLanguage::MethodName cpp_method(name);
basename = cpp_method.GetBasename();
if (basename.empty())
@@ -770,30 +796,39 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
// If we have only full name matches we might have tried to set breakpoint on
- // "func"
- // and specified eFunctionNameTypeFull, but we might have found "a::func()",
- // "a::b::func()", "c::func()", "func()" and "func". Only "func()" and "func"
- // should
- // end up matching.
+ // "func" and specified eFunctionNameTypeFull, but we might have found
+ // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
+ // "func()" and "func" should end up matching.
if (m_name_type_mask == eFunctionNameTypeFull) {
SymbolContext sc;
size_t i = start_idx;
while (i < sc_list.GetSize()) {
if (!sc_list.GetContextAtIndex(i, sc))
break;
+ // Make sure the mangled and demangled names don't match before we try
+ // to pull anything out
+ ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
ConstString full_name(sc.GetFunctionName());
- CPlusPlusLanguage::MethodName cpp_method(full_name);
- if (cpp_method.IsValid()) {
- if (cpp_method.GetContext().empty()) {
- if (cpp_method.GetBasename().compare(m_name.GetStringRef()) != 0) {
- sc_list.RemoveContextAtIndex(i);
- continue;
- }
- } else {
- std::string qualified_name = cpp_method.GetScopeQualifiedName();
- if (qualified_name.compare(m_name.GetCString()) != 0) {
- sc_list.RemoveContextAtIndex(i);
- continue;
+ if (mangled_name != m_name && full_name != m_name)
+ {
+ CPlusPlusLanguage::MethodName cpp_method(full_name);
+ if (cpp_method.IsValid()) {
+ if (cpp_method.GetContext().empty()) {
+ if (cpp_method.GetBasename().compare(m_name.GetStringRef()) != 0) {
+ sc_list.RemoveContextAtIndex(i);
+ continue;
+ }
+ } else {
+ std::string qualified_name;
+ llvm::StringRef anon_prefix("(anonymous namespace)");
+ if (cpp_method.GetContext() == anon_prefix)
+ qualified_name = cpp_method.GetBasename().str();
+ else
+ qualified_name = cpp_method.GetScopeQualifiedName();
+ if (qualified_name.compare(m_name.GetCString()) != 0) {
+ sc_list.RemoveContextAtIndex(i);
+ continue;
+ }
}
}
}
@@ -1022,7 +1057,7 @@ size_t Module::FindTypes(
// The "type_name_cstr" will have been modified if we have a valid type
// class
// prefix (like "struct", "class", "union", "typedef" etc).
- FindTypes_Impl(sc, ConstString(type_name_cstr), nullptr, append,
+ FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
max_matches, searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(type_class);
num_matches = typesmap.GetSize();
@@ -1297,7 +1332,7 @@ void Module::SectionFileAddressesChanged() {
SectionList *Module::GetUnifiedSectionList() {
// Populate m_unified_sections_ap with sections from objfile.
if (!m_sections_ap)
- m_sections_ap.reset(new SectionList());
+ m_sections_ap = llvm::make_unique<SectionList>();
return m_sections_ap.get();
}
@@ -1430,7 +1465,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
// check this
- if (file.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(file.GetPath())) {
std::string new_path(file.GetPath());
std::string old_path(obj_file->GetFileSpec().GetPath());
if (old_path.find(new_path) == 0) {
@@ -1644,7 +1679,8 @@ Module::CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp) {
// to the module, so we need to control the creation carefully in
// this static function
ModuleSP module_sp(new Module());
- module_sp->m_objfile_sp.reset(new ObjectFileJIT(module_sp, delegate_sp));
+ module_sp->m_objfile_sp =
+ std::make_shared<ObjectFileJIT>(module_sp, delegate_sp);
if (module_sp->m_objfile_sp) {
// Once we get the object file, update our module with the object file's
// architecture since it might differ in vendor/os if some parts were
@@ -1664,3 +1700,7 @@ bool Module::GetIsDynamicLinkEditor() {
return false;
}
+
+Error Module::LoadInMemory(Target &target, bool set_pc) {
+ return m_objfile_sp->LoadInMemory(target, set_pc);
+}
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index b980e15c0b37..da23329cc3b6 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -9,22 +9,54 @@
#include "lldb/Core/ModuleList.h"
-// C Includes
-// C++ Includes
-#include <cstdint>
-#include <mutex>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Log.h"
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
+#include "lldb/Core/FileSpecList.h" // for FileSpecList
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContextList, SymbolCon...
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAnyCategoriesSet
+#include "lldb/Utility/UUID.h" // for UUID, operator!=, operator==
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_INDEX32
+
+#if defined(LLVM_ON_WIN32)
+#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#endif
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+#include "llvm/Support/raw_ostream.h" // for fs
+
+#include <chrono> // for operator!=, time_point
+#include <memory> // for shared_ptr
+#include <mutex>
+#include <string> // for string
+#include <utility> // for distance
+
+namespace lldb_private {
+class Function;
+}
+namespace lldb_private {
+class RegularExpression;
+}
+namespace lldb_private {
+class Stream;
+}
+namespace lldb_private {
+class SymbolFile;
+}
+namespace lldb_private {
+class Target;
+}
+namespace lldb_private {
+class TypeList;
+}
using namespace lldb;
using namespace lldb_private;
@@ -644,8 +676,8 @@ size_t ModuleList::GetIndexForModule(const Module *module) const {
static ModuleList &GetSharedModuleList() {
static ModuleList *g_shared_module_list = nullptr;
- 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, []() {
// NOTE: Intentionally leak the module list so a program doesn't have to
// cleanup all modules and object files as it exits. This just wastes time
// doing a bunch of cleanup that isn't required.
@@ -764,7 +796,8 @@ Error ModuleList::GetSharedModule(const ModuleSpec &module_spec,
auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
if (!search_path_spec.ResolvePath())
continue;
- if (!search_path_spec.Exists() || !search_path_spec.IsDirectory())
+ namespace fs = llvm::sys::fs;
+ if (!fs::is_directory(search_path_spec.GetPath()))
continue;
search_path_spec.AppendPathComponent(
module_spec.GetFileSpec().GetFilename().AsCString());
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp
index 11b913841ecb..b4e691c1ddcd 100644
--- a/source/Core/Opcode.cpp
+++ b/source/Core/Opcode.cpp
@@ -9,17 +9,15 @@
#include "lldb/Core/Opcode.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/Triple.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-forward.h" // for DataBufferSP
-// Project includes
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/Endian.h"
+#include <memory> // for make_shared
+
+#include <inttypes.h> // for PRIx64
using namespace lldb;
using namespace lldb_private;
@@ -132,7 +130,7 @@ uint32_t Opcode::GetData(DataExtractor &data) const {
if (buf != nullptr) {
DataBufferSP buffer_sp;
- buffer_sp.reset(new DataBufferHeap(buf, byte_size));
+ buffer_sp = std::make_shared<DataBufferHeap>(buf, byte_size);
data.SetByteOrder(GetDataByteOrder());
data.SetData(buffer_sp);
return byte_size;
diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp
index b7b6b9a54efe..bd4ba5995204 100644
--- a/source/Core/PluginManager.cpp
+++ b/source/Core/PluginManager.cpp
@@ -9,24 +9,35 @@
#include "lldb/Core/PluginManager.h"
-// C Includes
-// C++ Includes
-#include <climits>
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StringList.h" // for StringList
+
+#if defined(LLVM_ON_WIN32)
+#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#endif
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/FileSystem.h" // for file_type, file_...
+#include "llvm/Support/raw_ostream.h" // for fs
+
+#include <map> // for map<>::const_ite...
+#include <memory> // for shared_ptr
#include <mutex>
#include <string>
+#include <utility> // for pair
#include <vector>
-// Other libraries and framework includes
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DynamicLibrary.h"
+#include <assert.h> // for assert
-// Project includes
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Interpreter/OptionValueProperties.h"
+namespace lldb_private {
+class CommandInterpreter;
+}
using namespace lldb;
using namespace lldb_private;
@@ -79,18 +90,18 @@ template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
}
static FileSpec::EnumerateDirectoryResult
-LoadPluginCallback(void *baton, FileSpec::FileType file_type,
+LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
// PluginManager *plugin_manager = (PluginManager *)baton;
Error error;
+ namespace fs = llvm::sys::fs;
// If we have a regular file, a symbolic link or unknown file type, try
// and process the file. We must handle unknown as sometimes the directory
// enumeration might be enumerating a file system that doesn't have correct
// file type information.
- if (file_type == FileSpec::eFileTypeRegular ||
- file_type == FileSpec::eFileTypeSymbolicLink ||
- file_type == FileSpec::eFileTypeUnknown) {
+ if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -135,9 +146,8 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
}
}
- if (file_type == FileSpec::eFileTypeUnknown ||
- file_type == FileSpec::eFileTypeDirectory ||
- file_type == FileSpec::eFileTypeSymbolicLink) {
+ if (ft == fs::file_type::directory_file ||
+ ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
// Try and recurse into anything that a directory or symbolic link.
// We must also do this for unknown as sometimes the directory enumeration
// might be enumerating a file system that doesn't have correct file type
@@ -1167,93 +1177,6 @@ PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(
return nullptr;
}
-#pragma mark LogChannel
-
-struct LogInstance {
- LogInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- LogChannelCreateInstance create_callback;
-};
-
-typedef std::vector<LogInstance> LogInstances;
-
-static std::recursive_mutex &GetLogMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
-
-static LogInstances &GetLogInstances() {
- static LogInstances g_instances;
- return g_instances;
-}
-
-bool PluginManager::RegisterPlugin(const ConstString &name,
- const char *description,
- LogChannelCreateInstance create_callback) {
- if (create_callback) {
- LogInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
- GetLogInstances().push_back(instance);
- }
- return false;
-}
-
-bool PluginManager::UnregisterPlugin(LogChannelCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
- LogInstances &instances = GetLogInstances();
-
- LogInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->create_callback == create_callback) {
- instances.erase(pos);
- return true;
- }
- }
- }
- return false;
-}
-
-const char *PluginManager::GetLogChannelCreateNameAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
- LogInstances &instances = GetLogInstances();
- if (idx < instances.size())
- return instances[idx].name.GetCString();
- return nullptr;
-}
-
-LogChannelCreateInstance
-PluginManager::GetLogChannelCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
- LogInstances &instances = GetLogInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-LogChannelCreateInstance
-PluginManager::GetLogChannelCreateCallbackForPluginName(
- const ConstString &name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> gard(GetLogMutex());
- LogInstances &instances = GetLogInstances();
-
- LogInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
-}
-
#pragma mark Platform
struct PlatformInstance {
@@ -2403,7 +2326,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(
OptionValuePropertiesSP plugin_properties_sp =
parent_properties_sp->GetSubProperty(nullptr, g_property_name);
if (!plugin_properties_sp && can_create) {
- plugin_properties_sp.reset(new OptionValueProperties(g_property_name));
+ plugin_properties_sp =
+ std::make_shared<OptionValueProperties>(g_property_name);
parent_properties_sp->AppendProperty(
g_property_name, ConstString("Settings specify to plugins."), true,
plugin_properties_sp);
@@ -2413,8 +2337,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(
lldb::OptionValuePropertiesSP plugin_type_properties_sp =
plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
if (!plugin_type_properties_sp && can_create) {
- plugin_type_properties_sp.reset(
- new OptionValueProperties(plugin_type_name));
+ plugin_type_properties_sp =
+ std::make_shared<OptionValueProperties>(plugin_type_name);
plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
true, plugin_type_properties_sp);
}
@@ -2437,7 +2361,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
OptionValuePropertiesSP plugin_properties_sp =
parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
if (!plugin_properties_sp && can_create) {
- plugin_properties_sp.reset(new OptionValueProperties(plugin_type_name));
+ plugin_properties_sp =
+ std::make_shared<OptionValueProperties>(plugin_type_name);
parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
true, plugin_properties_sp);
}
@@ -2446,8 +2371,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
lldb::OptionValuePropertiesSP plugin_type_properties_sp =
plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
if (!plugin_type_properties_sp && can_create) {
- plugin_type_properties_sp.reset(
- new OptionValueProperties(g_property_name));
+ plugin_type_properties_sp =
+ std::make_shared<OptionValueProperties>(g_property_name);
plugin_properties_sp->AppendProperty(
g_property_name, ConstString("Settings specific to plugins"), true,
plugin_type_properties_sp);
diff --git a/source/Core/RegisterValue.cpp b/source/Core/RegisterValue.cpp
index 2bc0b9dd4743..26a7515febc3 100644
--- a/source/Core/RegisterValue.cpp
+++ b/source/Core/RegisterValue.cpp
@@ -9,22 +9,27 @@
#include "lldb/Core/RegisterValue.h"
-// C Includes
-// C++ Includes
-#include <vector>
+#include "lldb/Core/DumpDataExtractor.h"
+#include "lldb/Core/Scalar.h"
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-private-types.h" // for RegisterInfo, type128
-// Other libraries and framework includes
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
-// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Scalar.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/StringConvert.h"
-#include "lldb/Interpreter/Args.h"
+#include <cstdint> // for uint8_t, uint32_t, uint64_t
+#include <string> // for string
+#include <tuple> // for tie, tuple
+#include <vector>
+
+#include <assert.h> // for assert
+#include <inttypes.h> // for PRIx64
+#include <stdio.h> // for sscanf
using namespace lldb;
using namespace lldb_private;
@@ -76,15 +81,15 @@ bool RegisterValue::Dump(Stream *s, const RegisterInfo *reg_info,
if (format == eFormatDefault)
format = reg_info->format;
- data.Dump(s,
- 0, // Offset in "data"
- format, // Format to use when dumping
- reg_info->byte_size, // item_byte_size
- 1, // item_count
- UINT32_MAX, // num_per_line
- LLDB_INVALID_ADDRESS, // base_addr
- 0, // item_bit_size
- 0); // item_bit_offset
+ DumpDataExtractor(data, s,
+ 0, // Offset in "data"
+ format, // Format to use when dumping
+ reg_info->byte_size, // item_byte_size
+ 1, // item_count
+ UINT32_MAX, // num_per_line
+ LLDB_INVALID_ADDRESS, // base_addr
+ 0, // item_bit_size
+ 0); // item_bit_offset
return true;
}
return false;
diff --git a/source/Core/Scalar.cpp b/source/Core/Scalar.cpp
index 2b99ec17b0a0..88ad430ddbae 100644
--- a/source/Core/Scalar.cpp
+++ b/source/Core/Scalar.cpp
@@ -9,24 +9,17 @@
#include "lldb/Core/Scalar.h"
-// C Includes
-// C++ Includes
-#include <cinttypes>
-#include <cmath>
-#include <cstdio>
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-types.h" // for offset_t
-// Other libraries and framework includes
#include "llvm/ADT/SmallString.h"
-// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/StringConvert.h"
-#include "lldb/Interpreter/Args.h"
-
-#include "Plugins/Process/Utility/InstructionUtils.h"
+#include <cinttypes>
+#include <cstdio>
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/SearchFilter.cpp b/source/Core/SearchFilter.cpp
index 2dfb26910ee0..6d29e21c310e 100644
--- a/source/Core/SearchFilter.cpp
+++ b/source/Core/SearchFilter.cpp
@@ -7,16 +7,35 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/SearchFilter.h"
+
+#include "lldb/Breakpoint/Breakpoint.h" // for Breakpoint
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Target/Target.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/lldb-enumerations.h" // for SymbolContextItem::eSymbolCo...
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable
+
+#include <memory> // for shared_ptr
+#include <mutex> // for recursive_mutex, lock_guard
+#include <string> // for string
+
+#include <inttypes.h> // for PRIu64
+#include <string.h> // for size_t, strcmp
+
+namespace lldb_private {
+class Address;
+}
+namespace lldb_private {
+class Function;
+}
using namespace lldb;
using namespace lldb_private;
@@ -153,7 +172,7 @@ SearchFilter::WrapOptionsDict(StructuredData::DictionarySP options_dict_sp) {
if (!options_dict_sp || !options_dict_sp->IsValid())
return StructuredData::DictionarySP();
- StructuredData::DictionarySP type_dict_sp(new StructuredData::Dictionary());
+ auto type_dict_sp = std::make_shared<StructuredData::Dictionary>();
type_dict_sp->AddStringItem(GetSerializationSubclassKey(), GetFilterName());
type_dict_sp->AddItem(GetSerializationSubclassOptionsKey(), options_dict_sp);
@@ -169,10 +188,10 @@ void SearchFilter::SerializeFileSpecList(
if (num_modules == 0)
return;
- StructuredData::ArraySP module_array_sp(new StructuredData::Array());
+ auto module_array_sp = std::make_shared<StructuredData::Array>();
for (size_t i = 0; i < num_modules; i++) {
- module_array_sp->AddItem(StructuredData::StringSP(
- new StructuredData::String(file_list.GetFileSpecAtIndex(i).GetPath())));
+ module_array_sp->AddItem(std::make_shared<StructuredData::String>(
+ file_list.GetFileSpecAtIndex(i).GetPath()));
}
options_dict_sp->AddItem(GetKey(name), module_array_sp);
}
@@ -321,14 +340,14 @@ Searcher::CallbackReturn SearchFilter::DoFunctionIteration(
SearchFilterSP SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
Target &target, const StructuredData::Dictionary &data_dict, Error &error) {
// No options for an unconstrained search.
- return SearchFilterSP(
- new SearchFilterForUnconstrainedSearches(target.shared_from_this()));
+ return std::make_shared<SearchFilterForUnconstrainedSearches>(
+ target.shared_from_this());
}
StructuredData::ObjectSP
SearchFilterForUnconstrainedSearches::SerializeToStructuredData() {
// The options dictionary is an empty dictionary:
- StructuredData::DictionarySP result_sp(new StructuredData::Dictionary());
+ auto result_sp = std::make_shared<StructuredData::Dictionary>();
return WrapOptionsDict(result_sp);
}
@@ -352,8 +371,7 @@ bool SearchFilterForUnconstrainedSearches::ModulePasses(
lldb::SearchFilterSP SearchFilterForUnconstrainedSearches::DoCopyForBreakpoint(
Breakpoint &breakpoint) {
- SearchFilterSP ret_sp(new SearchFilterForUnconstrainedSearches(*this));
- return ret_sp;
+ return std::make_shared<SearchFilterForUnconstrainedSearches>(*this);
}
//----------------------------------------------------------------------
@@ -433,13 +451,7 @@ void SearchFilterByModule::Search(Searcher &searcher) {
void SearchFilterByModule::GetDescription(Stream *s) {
s->PutCString(", module = ");
- if (s->GetVerbose()) {
- char buffer[2048];
- m_module_spec.GetPath(buffer, 2047);
- s->PutCString(buffer);
- } else {
- s->PutCString(m_module_spec.GetFilename().AsCString("<Unknown>"));
- }
+ s->PutCString(m_module_spec.GetFilename().AsCString("<Unknown>"));
}
uint32_t SearchFilterByModule::GetFilterRequiredItems() {
@@ -450,8 +462,7 @@ void SearchFilterByModule::Dump(Stream *s) const {}
lldb::SearchFilterSP
SearchFilterByModule::DoCopyForBreakpoint(Breakpoint &breakpoint) {
- SearchFilterSP ret_sp(new SearchFilterByModule(*this));
- return ret_sp;
+ return std::make_shared<SearchFilterByModule>(*this);
}
SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
@@ -479,16 +490,15 @@ SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
}
FileSpec module_spec(module, false);
- return SearchFilterSP(
- new SearchFilterByModule(target.shared_from_this(), module_spec));
+ return std::make_shared<SearchFilterByModule>(target.shared_from_this(),
+ module_spec);
}
StructuredData::ObjectSP SearchFilterByModule::SerializeToStructuredData() {
- StructuredData::DictionarySP options_dict_sp(
- new StructuredData::Dictionary());
- StructuredData::ArraySP module_array_sp(new StructuredData::Array());
- module_array_sp->AddItem(StructuredData::StringSP(
- new StructuredData::String(m_module_spec.GetPath())));
+ auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
+ auto module_array_sp = std::make_shared<StructuredData::Array>();
+ module_array_sp->AddItem(
+ std::make_shared<StructuredData::String>(m_module_spec.GetPath()));
options_dict_sp->AddItem(GetKey(OptionNames::ModList), module_array_sp);
return WrapOptionsDict(options_dict_sp);
}
@@ -591,27 +601,15 @@ void SearchFilterByModuleList::GetDescription(Stream *s) {
size_t num_modules = m_module_spec_list.GetSize();
if (num_modules == 1) {
s->Printf(", module = ");
- if (s->GetVerbose()) {
- char buffer[2048];
- m_module_spec_list.GetFileSpecAtIndex(0).GetPath(buffer, 2047);
- s->PutCString(buffer);
- } else {
- s->PutCString(
- m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
- "<Unknown>"));
- }
+ s->PutCString(
+ m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
+ "<Unknown>"));
} else {
s->Printf(", modules(%" PRIu64 ") = ", (uint64_t)num_modules);
for (size_t i = 0; i < num_modules; i++) {
- if (s->GetVerbose()) {
- char buffer[2048];
- m_module_spec_list.GetFileSpecAtIndex(i).GetPath(buffer, 2047);
- s->PutCString(buffer);
- } else {
- s->PutCString(
- m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
- "<Unknown>"));
- }
+ s->PutCString(
+ m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
+ "<Unknown>"));
if (i != num_modules - 1)
s->PutCString(", ");
}
@@ -626,8 +624,7 @@ void SearchFilterByModuleList::Dump(Stream *s) const {}
lldb::SearchFilterSP
SearchFilterByModuleList::DoCopyForBreakpoint(Breakpoint &breakpoint) {
- SearchFilterSP ret_sp(new SearchFilterByModuleList(*this));
- return ret_sp;
+ return std::make_shared<SearchFilterByModuleList>(*this);
}
SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
@@ -650,8 +647,8 @@ SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
}
}
- return SearchFilterSP(
- new SearchFilterByModuleList(target.shared_from_this(), modules));
+ return std::make_shared<SearchFilterByModuleList>(target.shared_from_this(),
+ modules);
}
void SearchFilterByModuleList::SerializeUnwrapped(
@@ -661,8 +658,7 @@ void SearchFilterByModuleList::SerializeUnwrapped(
}
StructuredData::ObjectSP SearchFilterByModuleList::SerializeToStructuredData() {
- StructuredData::DictionarySP options_dict_sp(
- new StructuredData::Dictionary());
+ auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
SerializeUnwrapped(options_dict_sp);
return WrapOptionsDict(options_dict_sp);
}
@@ -736,14 +732,13 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
cus.Append(FileSpec(cu, false));
}
- return SearchFilterSP(new SearchFilterByModuleListAndCU(
- target.shared_from_this(), modules, cus));
+ return std::make_shared<SearchFilterByModuleListAndCU>(
+ target.shared_from_this(), modules, cus);
}
StructuredData::ObjectSP
SearchFilterByModuleListAndCU::SerializeToStructuredData() {
- StructuredData::DictionarySP options_dict_sp(
- new StructuredData::Dictionary());
+ auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
SearchFilterByModuleList::SerializeUnwrapped(options_dict_sp);
SerializeFileSpecList(options_dict_sp, OptionNames::CUList, m_cu_spec_list);
return WrapOptionsDict(options_dict_sp);
@@ -827,27 +822,15 @@ void SearchFilterByModuleListAndCU::GetDescription(Stream *s) {
size_t num_modules = m_module_spec_list.GetSize();
if (num_modules == 1) {
s->Printf(", module = ");
- if (s->GetVerbose()) {
- char buffer[2048];
- m_module_spec_list.GetFileSpecAtIndex(0).GetPath(buffer, 2047);
- s->PutCString(buffer);
- } else {
- s->PutCString(
- m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
- "<Unknown>"));
- }
+ s->PutCString(
+ m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
+ "<Unknown>"));
} else if (num_modules > 0) {
s->Printf(", modules(%" PRIu64 ") = ", static_cast<uint64_t>(num_modules));
for (size_t i = 0; i < num_modules; i++) {
- if (s->GetVerbose()) {
- char buffer[2048];
- m_module_spec_list.GetFileSpecAtIndex(i).GetPath(buffer, 2047);
- s->PutCString(buffer);
- } else {
- s->PutCString(
- m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
- "<Unknown>"));
- }
+ s->PutCString(
+ m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
+ "<Unknown>"));
if (i != num_modules - 1)
s->PutCString(", ");
}
@@ -862,6 +845,5 @@ void SearchFilterByModuleListAndCU::Dump(Stream *s) const {}
lldb::SearchFilterSP
SearchFilterByModuleListAndCU::DoCopyForBreakpoint(Breakpoint &breakpoint) {
- SearchFilterSP ret_sp(new SearchFilterByModuleListAndCU(*this));
- return ret_sp;
+ return std::make_shared<SearchFilterByModuleListAndCU>(*this);
}
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index 95bcdada5377..f6428ced0164 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -8,15 +8,119 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/Section.h"
+#include "lldb/Core/Address.h" // for Address
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/ConvertEnum.h"
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/VMRange.h" // for VMRange
+#include <inttypes.h> // for PRIx64
+#include <limits> // for numeric_limits
+#include <utility> // for distance
+
+namespace lldb_private {
+class DataExtractor;
+}
using namespace lldb;
using namespace lldb_private;
+static const char *GetSectionTypeAsCString(lldb::SectionType sect_type) {
+ switch (sect_type) {
+ case eSectionTypeInvalid:
+ return "invalid";
+ case eSectionTypeCode:
+ return "code";
+ case eSectionTypeContainer:
+ return "container";
+ case eSectionTypeData:
+ return "data";
+ case eSectionTypeDataCString:
+ return "data-cstr";
+ case eSectionTypeDataCStringPointers:
+ return "data-cstr-ptr";
+ case eSectionTypeDataSymbolAddress:
+ return "data-symbol-addr";
+ case eSectionTypeData4:
+ return "data-4-byte";
+ case eSectionTypeData8:
+ return "data-8-byte";
+ case eSectionTypeData16:
+ return "data-16-byte";
+ case eSectionTypeDataPointers:
+ return "data-ptrs";
+ case eSectionTypeDebug:
+ return "debug";
+ case eSectionTypeZeroFill:
+ return "zero-fill";
+ case eSectionTypeDataObjCMessageRefs:
+ return "objc-message-refs";
+ case eSectionTypeDataObjCCFStrings:
+ return "objc-cfstrings";
+ case eSectionTypeDWARFDebugAbbrev:
+ return "dwarf-abbrev";
+ case eSectionTypeDWARFDebugAddr:
+ return "dwarf-addr";
+ case eSectionTypeDWARFDebugAranges:
+ return "dwarf-aranges";
+ case eSectionTypeDWARFDebugFrame:
+ return "dwarf-frame";
+ case eSectionTypeDWARFDebugInfo:
+ return "dwarf-info";
+ case eSectionTypeDWARFDebugLine:
+ return "dwarf-line";
+ case eSectionTypeDWARFDebugLoc:
+ return "dwarf-loc";
+ case eSectionTypeDWARFDebugMacInfo:
+ return "dwarf-macinfo";
+ case eSectionTypeDWARFDebugMacro:
+ return "dwarf-macro";
+ case eSectionTypeDWARFDebugPubNames:
+ return "dwarf-pubnames";
+ case eSectionTypeDWARFDebugPubTypes:
+ return "dwarf-pubtypes";
+ case eSectionTypeDWARFDebugRanges:
+ return "dwarf-ranges";
+ case eSectionTypeDWARFDebugStr:
+ return "dwarf-str";
+ case eSectionTypeDWARFDebugStrOffsets:
+ return "dwarf-str-offsets";
+ case eSectionTypeELFSymbolTable:
+ return "elf-symbol-table";
+ case eSectionTypeELFDynamicSymbols:
+ return "elf-dynamic-symbols";
+ case eSectionTypeELFRelocationEntries:
+ return "elf-relocation-entries";
+ case eSectionTypeELFDynamicLinkInfo:
+ return "elf-dynamic-link-info";
+ case eSectionTypeDWARFAppleNames:
+ return "apple-names";
+ case eSectionTypeDWARFAppleTypes:
+ return "apple-types";
+ case eSectionTypeDWARFAppleNamespaces:
+ return "apple-namespaces";
+ case eSectionTypeDWARFAppleObjC:
+ return "apple-objc";
+ case eSectionTypeEHFrame:
+ return "eh-frame";
+ case eSectionTypeARMexidx:
+ return "ARM.exidx";
+ case eSectionTypeARMextab:
+ return "ARM.extab";
+ case eSectionTypeCompactUnwind:
+ return "compact-unwind";
+ case eSectionTypeGoSymtab:
+ return "go-symtab";
+ case eSectionTypeAbsoluteAddress:
+ return "absolute";
+ case eSectionTypeOther:
+ return "regular";
+ }
+ return "unknown";
+}
+
Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
user_id_t sect_id, const ConstString &name,
SectionType sect_type, addr_t file_addr, addr_t byte_size,
diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp
index 603fe5711498..b284ff1dbaaa 100644
--- a/source/Core/SourceManager.cpp
+++ b/source/Core/SourceManager.cpp
@@ -9,21 +9,40 @@
#include "lldb/Core/SourceManager.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/DataBuffer.h"
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/AddressRange.h" // for AddressRange
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h" // for FormatEntity
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/ModuleList.h" // for ModuleList
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/LineEntry.h" // for LineEntry
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/PathMappingList.h" // for PathMappingList
#include "lldb/Target/Target.h"
-#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-enumerations.h" // for StopShowColumn::eStopSho...
+
+#include "llvm/ADT/Twine.h" // for Twine
+
+#include <memory>
+#include <utility> // for pair
+
+#include <assert.h> // for assert
+#include <stdio.h> // for size_t, NULL, snprintf
+
+namespace lldb_private {
+class ExecutionContext;
+}
+namespace lldb_private {
+class ValueObject;
+}
using namespace lldb;
using namespace lldb_private;
@@ -74,9 +93,9 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
// If file_sp is no good or it points to a non-existent file, reset it.
if (!file_sp || !file_sp->GetFileSpec().Exists()) {
if (target_sp)
- file_sp.reset(new File(file_spec, target_sp.get()));
+ file_sp = std::make_shared<File>(file_spec, target_sp.get());
else
- file_sp.reset(new File(file_spec, debugger_sp));
+ file_sp = std::make_shared<File>(file_spec, debugger_sp);
if (debugger_sp)
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
@@ -404,7 +423,7 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
}
if (m_mod_time != llvm::sys::TimePoint<>())
- m_data_sp = m_file_spec.ReadFileContents();
+ m_data_sp = DataBufferLLVM::CreateFromPath(m_file_spec.GetPath());
}
uint32_t SourceManager::File::GetLineOffset(uint32_t line) {
@@ -482,7 +501,7 @@ void SourceManager::File::UpdateIfNeeded() {
if (curr_mod_time != llvm::sys::TimePoint<>() &&
m_mod_time != curr_mod_time) {
m_mod_time = curr_mod_time;
- m_data_sp = m_file_spec.ReadFileContents();
+ m_data_sp = DataBufferLLVM::CreateFromPath(m_file_spec.GetPath());
m_offsets.clear();
}
}
diff --git a/source/Core/State.cpp b/source/Core/State.cpp
index 80497dd77b87..4697ca4b5f17 100644
--- a/source/Core/State.cpp
+++ b/source/Core/State.cpp
@@ -12,7 +12,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/State.h"
-#include <stdio.h>
using namespace lldb;
using namespace lldb_private;
@@ -44,10 +43,7 @@ const char *lldb_private::StateAsCString(StateType state) {
case eStateSuspended:
return "suspended";
}
- static char unknown_state_string[64];
- snprintf(unknown_state_string, sizeof(unknown_state_string), "StateType = %i",
- state);
- return unknown_state_string;
+ return "unknown";
}
const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) {
diff --git a/source/Core/StreamAsynchronousIO.cpp b/source/Core/StreamAsynchronousIO.cpp
index 1f7e634dfe33..aae8636bff09 100644
--- a/source/Core/StreamAsynchronousIO.cpp
+++ b/source/Core/StreamAsynchronousIO.cpp
@@ -10,7 +10,7 @@
#include "lldb/Core/StreamAsynchronousIO.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/lldb-private.h"
+#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderBig
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/StreamCallback.cpp b/source/Core/StreamCallback.cpp
deleted file mode 100644
index de784101e969..000000000000
--- a/source/Core/StreamCallback.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- StreamCallback.cpp -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdio.h>
-
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Event.h"
-#include "lldb/Core/StreamCallback.h"
-#include "lldb/Host/Host.h"
-#include "lldb/lldb-private.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-StreamCallback::StreamCallback(lldb::LogOutputCallback callback, void *baton)
- : Stream(0, 4, eByteOrderBig), m_callback(callback), m_baton(baton),
- m_accumulated_data(), m_collection_mutex() {}
-
-StreamCallback::~StreamCallback() {}
-
-StreamString &StreamCallback::FindStreamForThread(lldb::tid_t cur_tid) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator iter = m_accumulated_data.find(cur_tid);
- if (iter == m_accumulated_data.end()) {
- std::pair<collection::iterator, bool> ret;
- ret = m_accumulated_data.insert(
- std::pair<lldb::tid_t, StreamString>(cur_tid, StreamString()));
- iter = ret.first;
- }
- return (*iter).second;
-}
-
-void StreamCallback::Flush() {
- lldb::tid_t cur_tid = Host::GetCurrentThreadID();
- StreamString &out_stream = FindStreamForThread(cur_tid);
- m_callback(out_stream.GetData(), m_baton);
- out_stream.Clear();
-}
-
-size_t StreamCallback::Write(const void *s, size_t length) {
- lldb::tid_t cur_tid = Host::GetCurrentThreadID();
- FindStreamForThread(cur_tid).Write(s, length);
- return length;
-}
diff --git a/source/Core/StreamFile.cpp b/source/Core/StreamFile.cpp
index f8c7fb9a84dc..f59415485021 100644
--- a/source/Core/StreamFile.cpp
+++ b/source/Core/StreamFile.cpp
@@ -9,12 +9,7 @@
#include "lldb/Core/StreamFile.h"
-// C Includes
#include <stdio.h>
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/StructuredData.cpp b/source/Core/StructuredData.cpp
index 1e190f52314e..649c4615ad4f 100644
--- a/source/Core/StructuredData.cpp
+++ b/source/Core/StructuredData.cpp
@@ -9,17 +9,26 @@
#include "lldb/Core/StructuredData.h"
-#include <errno.h>
-#include <inttypes.h>
-#include <stdlib.h>
-
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/File.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/JSON.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermiss...
+#include "lldb/lldb-forward.h" // for DataBufferSP
+
+#include "llvm/ADT/STLExtras.h" // for make_unique
+
+#include <limits> // for numeric_limits
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdio.h> // for printf
+#include <stdlib.h>
+#include <sys/types.h> // for off_t
using namespace lldb_private;
@@ -70,10 +79,8 @@ StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Error &error) {
static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser) {
// The "JSONParser::Token::ObjectStart" token should have already been
- // consumed
- // by the time this function is called
- std::unique_ptr<StructuredData::Dictionary> dict_up(
- new StructuredData::Dictionary());
+ // consumed by the time this function is called
+ auto dict_up = llvm::make_unique<StructuredData::Dictionary>();
std::string value;
std::string key;
@@ -105,7 +112,7 @@ static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser) {
// The "JSONParser::Token::ObjectStart" token should have already been
// consumed
// by the time this function is called
- std::unique_ptr<StructuredData::Array> array_up(new StructuredData::Array());
+ auto array_up = llvm::make_unique<StructuredData::Array>();
std::string value;
std::string key;
@@ -142,26 +149,26 @@ static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser) {
bool success = false;
uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
if (success)
- return StructuredData::ObjectSP(new StructuredData::Integer(uval));
+ return std::make_shared<StructuredData::Integer>(uval);
} break;
case JSONParser::Token::Float: {
bool success = false;
double val = StringConvert::ToDouble(value.c_str(), 0.0, &success);
if (success)
- return StructuredData::ObjectSP(new StructuredData::Float(val));
+ return std::make_shared<StructuredData::Float>(val);
} break;
case JSONParser::Token::String:
- return StructuredData::ObjectSP(new StructuredData::String(value));
+ return std::make_shared<StructuredData::String>(value);
case JSONParser::Token::True:
case JSONParser::Token::False:
- return StructuredData::ObjectSP(
- new StructuredData::Boolean(token == JSONParser::Token::True));
+ return std::make_shared<StructuredData::Boolean>(token ==
+ JSONParser::Token::True);
case JSONParser::Token::Null:
- return StructuredData::ObjectSP(new StructuredData::Null());
+ return std::make_shared<StructuredData::Null>();
default:
break;
diff --git a/source/Core/Timer.cpp b/source/Core/Timer.cpp
index ca1a2b749ec3..60da39b7f199 100644
--- a/source/Core/Timer.cpp
+++ b/source/Core/Timer.cpp
@@ -8,14 +8,18 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/Timer.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-types.h" // for thread_key_t
+
#include <algorithm>
#include <map>
#include <mutex>
+#include <utility> // for pair
#include <vector>
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/Host.h"
-
+#include <assert.h> // for assert
+#include <stdarg.h> // for va_end, va_list, va_start
#include <stdio.h>
using namespace lldb_private;
diff --git a/source/Core/UserSettingsController.cpp b/source/Core/UserSettingsController.cpp
index 92c3c8440d15..59a88ccdb931 100644
--- a/source/Core/UserSettingsController.cpp
+++ b/source/Core/UserSettingsController.cpp
@@ -1,5 +1,4 @@
-//====-- UserSettingsController.cpp ------------------------------*- C++
-//-*-===//
+//====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,17 +7,26 @@
//
//===----------------------------------------------------------------------===//
-#include <algorithm>
-#include <string.h>
-
-#include "lldb/Core/Error.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/UserSettingsController.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
+
#include "lldb/Interpreter/OptionValueProperties.h"
-#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+
+#include <memory> // for shared_ptr
+
+namespace lldb_private {
+class CommandInterpreter;
+}
+namespace lldb_private {
+class ConstString;
+}
+namespace lldb_private {
+class ExecutionContext;
+}
+namespace lldb_private {
+class Property;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index a480c3cf375a..9aaddf77021c 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -9,16 +9,10 @@
#include "lldb/Core/Value.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -28,6 +22,20 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h" // for InlHostByteOrder
+#include "lldb/Utility/FileSpec.h" // for FileSpec
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-forward.h" // for DataBufferSP, ModuleSP
+#include "lldb/lldb-types.h" // for addr_t
+
+#include <memory> // for make_shared
+#include <string> // for string
+
+#include <inttypes.h> // for PRIx64
using namespace lldb;
using namespace lldb_private;
@@ -538,7 +546,8 @@ Error Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
// Make sure we have enough room within "data", and if we don't make
// something large enough that does
if (!data.ValidOffsetForDataOfSize(data_offset, byte_size)) {
- DataBufferSP data_sp(new DataBufferHeap(data_offset + byte_size, '\0'));
+ auto data_sp =
+ std::make_shared<DataBufferHeap>(data_offset + byte_size, '\0');
data.SetData(data_sp);
}
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index fc2312d60d57..381763dab8e1 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -9,52 +9,67 @@
#include "lldb/Core/ValueObject.h"
-// C Includes
-#include <stdlib.h>
-
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/Support/raw_ostream.h"
-
-// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/Address.h" // for Address
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/Scalar.h" // for Scalar
#include "lldb/Core/ValueObjectCast.h"
#include "lldb/Core/ValueObjectChild.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectDynamicValue.h"
-#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectSyntheticFilter.h"
-
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormatManager.h" // for FormatManager
#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/TypeFormat.h" // for TypeFormatImpl_F...
+#include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryOptions
+#include "lldb/DataFormatters/TypeValidator.h" // for TypeValidatorImp...
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-
-#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
-
-#include "lldb/Host/Endian.h"
-
-#include "lldb/Interpreter/CommandInterpreter.h"
-
+#include "lldb/Expression/ExpressionVariable.h" // for ExpressionVariable
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Symbol/Declaration.h" // for Declaration
+#include "lldb/Symbol/SymbolContext.h" // for SymbolContext
#include "lldb/Symbol/Type.h"
-
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/StackFrame.h" // for StackFrame
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadList.h" // for ThreadList
+#include "lldb/Utility/DataBuffer.h" // for DataBuffer
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Flags.h" // for Flags
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCateg...
+#include "lldb/Utility/SharingPtr.h" // for SharingPtr
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-private-types.h" // for RegisterInfo
+
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
+
+#include <algorithm> // for min
+#include <cstdint> // for uint32_t, uint64_t
+#include <cstdlib> // for size_t, NULL
+#include <memory> // for shared_ptr, oper...
+#include <tuple> // for tie, tuple
+
+#include <assert.h> // for assert
+#include <inttypes.h> // for PRIu64, PRIx64
+#include <stdio.h> // for snprintf
+#include <string.h> // for memcpy, memcmp
+
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class SymbolContextScope;
+}
using namespace lldb;
using namespace lldb_private;
@@ -2889,6 +2904,11 @@ ValueObjectSP ValueObject::Dereference(Error &error) {
child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
language_flags);
}
+ } else if (HasSyntheticValue()) {
+ m_deref_valobj =
+ GetSyntheticValue()
+ ->GetChildMemberWithName(ConstString("$$dereference$$"), true)
+ .get();
}
if (m_deref_valobj) {
@@ -2957,6 +2977,10 @@ ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
return ValueObjectCast::Create(*this, GetName(), compiler_type);
}
+lldb::ValueObjectSP ValueObject::Clone(const ConstString &new_name) {
+ return ValueObjectCast::Create(*this, new_name, GetCompilerType());
+}
+
ValueObjectSP ValueObject::CastPointerType(const char *name,
CompilerType &compiler_type) {
ValueObjectSP valobj_sp;
diff --git a/source/Core/ValueObjectCast.cpp b/source/Core/ValueObjectCast.cpp
index 300aeae3b33a..aa4cf60c1f9e 100644
--- a/source/Core/ValueObjectCast.cpp
+++ b/source/Core/ValueObjectCast.cpp
@@ -9,27 +9,16 @@
#include "lldb/Core/ValueObjectCast.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
+#include "lldb/Core/Scalar.h" // for operator!=, Scalar
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectList.h"
-
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Error.h" // for Error
+
+namespace lldb_private {
+class ConstString;
+}
using namespace lldb_private;
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index 9b2bdd1e468c..eeb28c960a3a 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -9,18 +9,21 @@
#include "lldb/Core/ValueObjectChild.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ValueObjectList.h"
-
+#include "lldb/Core/Scalar.h" // for Scalar
+#include "lldb/Core/Value.h" // for Value, Value::ValueType::e...
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Flags.h" // for Flags
+#include "lldb/lldb-forward.h" // for ProcessSP, ModuleSP
+
+#include <functional> // for _Func_impl<>::_Mybase
+#include <memory> // for shared_ptr
+#include <vector> // for vector
+
+#include <stdio.h> // for snprintf, size_t
+#include <string.h> // for strlen
using namespace lldb_private;
diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp
index f78574ef7ee3..cf437ce6f7d5 100644
--- a/source/Core/ValueObjectConstResult.cpp
+++ b/source/Core/ValueObjectConstResult.cpp
@@ -9,22 +9,19 @@
#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ValueObjectChild.h"
-#include "lldb/Core/ValueObjectConstResultChild.h"
+#include "lldb/Core/Scalar.h" // for Scalar
#include "lldb/Core/ValueObjectDynamicValue.h"
-#include "lldb/Core/ValueObjectList.h"
-
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextScope
#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBuffer.h" // for DataBuffer
+#include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap
+#include "lldb/Utility/DataExtractor.h"
+
+namespace lldb_private {
+class Module;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ValueObjectConstResultCast.cpp b/source/Core/ValueObjectConstResultCast.cpp
index 32451468c183..f575bebd7110 100644
--- a/source/Core/ValueObjectConstResultCast.cpp
+++ b/source/Core/ValueObjectConstResultCast.cpp
@@ -9,10 +9,15 @@
#include "lldb/Core/ValueObjectConstResultCast.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Core/ValueObjectList.h"
-
-#include "lldb/Symbol/ClangASTContext.h"
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ValueObject;
+}
using namespace lldb_private;
diff --git a/source/Core/ValueObjectConstResultChild.cpp b/source/Core/ValueObjectConstResultChild.cpp
index c4c9c63c765d..9c6ad8becf3b 100644
--- a/source/Core/ValueObjectConstResultChild.cpp
+++ b/source/Core/ValueObjectConstResultChild.cpp
@@ -1,5 +1,4 @@
-//===-- ValueObjectConstResultChild.cpp ------------------------------*- C++
-//-*-===//
+//===-- ValueObjectConstResultChild.cpp --------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,10 +9,16 @@
#include "lldb/Core/ValueObjectConstResultChild.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Core/ValueObjectList.h"
-
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/lldb-private-enumerations.h" // for AddressType::eAddressType
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
+namespace lldb_private {
+class ValueObject;
+}
using namespace lldb_private;
diff --git a/source/Core/ValueObjectConstResultImpl.cpp b/source/Core/ValueObjectConstResultImpl.cpp
index 0e4f73f13b52..ed25ea8071a2 100644
--- a/source/Core/ValueObjectConstResultImpl.cpp
+++ b/source/Core/ValueObjectConstResultImpl.cpp
@@ -1,5 +1,4 @@
-//===-- ValueObjectConstResultImpl.cpp ---------------------------*- C++
-//-*-===//
+//===-- ValueObjectConstResultImpl.cpp ---------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,24 +9,26 @@
#include "lldb/Core/ValueObjectConstResultImpl.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ValueObjectChild.h"
+#include "lldb/Core/Scalar.h" // for Scalar
+#include "lldb/Core/Value.h" // for Value, Value::Val...
+#include "lldb/Core/ValueObject.h" // for ValueObject
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectConstResultCast.h"
#include "lldb/Core/ValueObjectConstResultChild.h"
-#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Core/ValueObjectMemory.h"
-
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap
+#include "lldb/Utility/Endian.h" // for InlHostByteOrder
+#include "lldb/Utility/SharingPtr.h" // for SharingPtr
+
+#include <string> // for string
+
+namespace lldb_private {
+class DataExtractor;
+}
+namespace lldb_private {
+class Error;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp
index 1fb32d4e86a3..59bbc025f994 100644
--- a/source/Core/ValueObjectDynamicValue.cpp
+++ b/source/Core/ValueObjectDynamicValue.cpp
@@ -1,5 +1,4 @@
-//===-- ValueObjectDynamicValue.cpp ---------------------------------*- C++
-//-*-===//
+//===-- ValueObjectDynamicValue.cpp ------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,28 +9,26 @@
#include "lldb/Core/ValueObjectDynamicValue.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
+#include "lldb/Core/Scalar.h" // for Scalar, operator!=
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectList.h"
-
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h" // for DataExtractor
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet
+#include "lldb/lldb-types.h" // for addr_t, offset_t
+
+#include <string.h> // for strcmp, size_t
+namespace lldb_private {
+class Declaration;
+}
using namespace lldb_private;
diff --git a/source/Core/ValueObjectList.cpp b/source/Core/ValueObjectList.cpp
index 7eae49744413..00aee798c0e3 100644
--- a/source/Core/ValueObjectList.cpp
+++ b/source/Core/ValueObjectList.cpp
@@ -9,15 +9,11 @@
#include "lldb/Core/ValueObjectList.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ValueObjectChild.h"
-#include "lldb/Core/ValueObjectRegister.h"
-#include "lldb/Core/ValueObjectVariable.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Core/ValueObject.h" // for ValueObject
+#include "lldb/Utility/ConstString.h" // for ConstString
+#include "lldb/Utility/SharingPtr.h" // for SharingPtr
+
+#include <utility> // for back_insert_iterator, back_ins...
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp
index 18f3c94c522b..0fb8f0d2de03 100644
--- a/source/Core/ValueObjectMemory.cpp
+++ b/source/Core/ValueObjectMemory.cpp
@@ -9,25 +9,24 @@
#include "lldb/Core/ValueObjectMemory.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Module.h"
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
+#include "lldb/Core/Scalar.h" // for Scalar, operator!=
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectList.h"
-
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h" // for DataExtractor
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-types.h" // for addr_t
+#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable
+
+#include <assert.h> // for assert
+#include <memory> // for shared_ptr
+
+namespace lldb_private {
+class ExecutionContextScope;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 80e00e4007c4..6469340201e5 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/source/Core/ValueObjectRegister.cpp
@@ -9,19 +9,28 @@
#include "lldb/Core/ValueObjectRegister.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Core/Scalar.h" // for Scalar
+#include "lldb/Core/Value.h" // for Value, Value::ContextType:...
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/TypeSystem.h" // for TypeSystem
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrame.h" // for StackFrame
#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h" // for DataExtractor
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Stream.h" // for Stream
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <assert.h> // for assert
+#include <memory> // for shared_ptr
+
+namespace lldb_private {
+class ExecutionContextScope;
+}
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/ValueObjectSyntheticFilter.cpp b/source/Core/ValueObjectSyntheticFilter.cpp
index 592f1ea56bdf..f0fd76ed09fc 100644
--- a/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/source/Core/ValueObjectSyntheticFilter.cpp
@@ -7,15 +7,22 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ValueObjectSyntheticFilter.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/Value.h" // for Value
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Target/ExecutionContext.h" // for ExecutionContext
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet
+#include "lldb/Utility/SharingPtr.h" // for SharingPtr
+
+#include "llvm/ADT/STLExtras.h"
+
+namespace lldb_private {
+class Declaration;
+}
using namespace lldb_private;
@@ -124,7 +131,7 @@ lldb::ValueType ValueObjectSynthetic::GetValueType() const {
void ValueObjectSynthetic::CreateSynthFilter() {
m_synth_filter_ap = (m_synth_sp->GetFrontEnd(*m_parent));
if (!m_synth_filter_ap.get())
- m_synth_filter_ap.reset(new DummySyntheticFrontEnd(*m_parent));
+ m_synth_filter_ap = llvm::make_unique<DummySyntheticFrontEnd>(*m_parent);
}
bool ValueObjectSynthetic::UpdateValue() {
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index f8eedc30e709..169f8f0f6c28 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -9,28 +9,44 @@
#include "lldb/Core/ValueObjectVariable.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Core/Address.h" // for Address
+#include "lldb/Core/AddressRange.h" // for AddressRange
+#include "lldb/Core/ArchSpec.h" // for ArchSpec
#include "lldb/Core/Module.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/Scalar.h" // for Scalar, operator!=
#include "lldb/Core/Value.h"
-#include "lldb/Core/ValueObjectList.h"
-
+#include "lldb/Expression/DWARFExpression.h" // for DWARFExpression
+#include "lldb/Symbol/Declaration.h" // for Declaration
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
-
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h" // for DataExtractor
+#include "lldb/Utility/Error.h" // for Error
+#include "lldb/lldb-private-enumerations.h" // for AddressType::eAddressTy...
+#include "lldb/lldb-types.h" // for addr_t
+
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <assert.h> // for assert
+#include <memory> // for shared_ptr
+namespace lldb_private {
+class ExecutionContextScope;
+}
+namespace lldb_private {
+class StackFrame;
+}
+namespace lldb_private {
+struct RegisterInfo;
+}
using namespace lldb_private;
lldb::ValueObjectSP
diff --git a/source/DataFormatters/CMakeLists.txt b/source/DataFormatters/CMakeLists.txt
index bfb5c8b9f68b..b8596779005d 100644
--- a/source/DataFormatters/CMakeLists.txt
+++ b/source/DataFormatters/CMakeLists.txt
@@ -16,4 +16,14 @@ add_lldb_library(lldbDataFormatters
TypeValidator.cpp
ValueObjectPrinter.cpp
VectorType.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/DataFormatters/CXXFunctionPointer.cpp b/source/DataFormatters/CXXFunctionPointer.cpp
index 41e9d4b382b3..fad67a9d5b7a 100644
--- a/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/source/DataFormatters/CXXFunctionPointer.cpp
@@ -9,10 +9,10 @@
#include "lldb/DataFormatters/CXXFunctionPointer.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
#include <string>
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp
index 6e5fdf92305f..7619b6f6f82b 100644
--- a/source/DataFormatters/FormatManager.cpp
+++ b/source/DataFormatters/FormatManager.cpp
@@ -17,11 +17,11 @@
// Project includes
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/LanguageCategory.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -660,11 +660,9 @@ FormatManager::GetFormat(ValueObject &valobj,
if (log) {
log->Printf(
"[FormatManager::GetFormat] Cache search success. Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -705,10 +703,8 @@ FormatManager::GetFormat(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetFormat(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
@@ -742,11 +738,9 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
if (log) {
log->Printf("[FormatManager::GetSummaryFormat] Cache search success. "
"Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -787,10 +781,8 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSummary(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
@@ -825,11 +817,9 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
if (log) {
log->Printf("[FormatManager::GetSyntheticChildren] Cache search "
"success. Returning.");
- if (log->GetDebug())
- log->Printf(
- "[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -871,10 +861,8 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
#endif
@@ -895,11 +883,9 @@ FormatManager::GetValidator(ValueObject &valobj,
if (log) {
log->Printf(
"[FormatManager::GetValidator] Cache search success. Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -940,10 +926,8 @@ FormatManager::GetValidator(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetValidator(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp
index 68802b902a23..460a49690d3d 100644
--- a/source/DataFormatters/FormattersHelpers.cpp
+++ b/source/DataFormatters/FormattersHelpers.cpp
@@ -17,11 +17,11 @@
// Project includes
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp
index 4021bd5d9284..7ca3744a247a 100644
--- a/source/DataFormatters/StringPrinter.cpp
+++ b/source/DataFormatters/StringPrinter.cpp
@@ -11,11 +11,11 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
#include "llvm/Support/ConvertUTF.h"
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index cc85288c23fc..d2da672f13dc 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -10,8 +10,8 @@
#include "lldb/DataFormatters/TypeCategoryMap.h"
-#include "lldb/Core/Log.h"
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/Utility/Log.h"
// C Includes
// C++ Includes
diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp
index 8bd369b3532e..4d1a0096bb68 100644
--- a/source/DataFormatters/TypeFormat.cpp
+++ b/source/DataFormatters/TypeFormat.cpp
@@ -19,13 +19,15 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-public.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -60,9 +62,9 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
return false;
StreamString reg_sstr;
- data.Dump(&reg_sstr, 0, GetFormat(), reg_info->byte_size, 1, UINT32_MAX,
- LLDB_INVALID_ADDRESS, 0, 0,
- exe_ctx.GetBestExecutionContextScope());
+ DumpDataExtractor(data, &reg_sstr, 0, GetFormat(), reg_info->byte_size,
+ 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0,
+ exe_ctx.GetBestExecutionContextScope());
dest = reg_sstr.GetString();
}
} else {
diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp
index 610d2fe7998a..09a7ff8d7d36 100644
--- a/source/DataFormatters/TypeSummary.cpp
+++ b/source/DataFormatters/TypeSummary.cpp
@@ -20,13 +20,13 @@
#include "lldb/lldb-public.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp
index 0f7bd9aa7951..28a51dae6b20 100644
--- a/source/DataFormatters/TypeSynthetic.cpp
+++ b/source/DataFormatters/TypeSynthetic.cpp
@@ -19,12 +19,12 @@
#include "lldb/lldb-public.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/DataFormatters/TypeValidator.cpp b/source/DataFormatters/TypeValidator.cpp
index 2affd7311e07..7a5b8d565292 100644
--- a/source/DataFormatters/TypeValidator.cpp
+++ b/source/DataFormatters/TypeValidator.cpp
@@ -15,7 +15,7 @@
// Project includes
#include "lldb/DataFormatters/TypeValidator.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp
index d6efe78e49a8..863ff3af12e8 100644
--- a/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/source/DataFormatters/ValueObjectPrinter.cpp
@@ -13,12 +13,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -457,7 +457,12 @@ bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
else
object_desc = GetDescriptionForDisplay();
if (object_desc && *object_desc) {
- m_stream->Printf("%s\n", object_desc);
+ // If the description already ends with a \n don't add another one.
+ size_t object_end = strlen(object_desc) - 1;
+ if (object_desc[object_end] == '\n')
+ m_stream->Printf("%s", object_desc);
+ else
+ m_stream->Printf("%s\n", object_desc);
return true;
} else if (value_printed == false && summary_printed == false)
return true;
@@ -468,32 +473,11 @@ bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
return true;
}
-bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion(
- bool is_root, TypeSummaryImpl *entry, ValueObject *valobj,
- const std::string &summary) {
- switch (m_mode) {
- case Mode::Always:
- return (m_count > 0);
- case Mode::Never:
- return false;
- case Mode::Default:
- if (is_root)
- m_count = std::min<decltype(m_count)>(m_count, 1);
- return m_count > 0;
- case Mode::Formatters:
- if (!entry || entry->DoesPrintChildren(valobj) || summary.empty())
- return m_count > 0;
- return false;
- }
- return false;
-}
-
bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
switch (m_mode) {
case Mode::Always:
case Mode::Default:
- case Mode::Formatters:
- return (m_count > 0);
+ return m_count > 0;
case Mode::Never:
return false;
}
@@ -546,8 +530,7 @@ bool ValueObjectPrinter::ShouldPrintChildren(
return true;
}
- return curr_ptr_depth.CanAllowExpansion(false, entry, m_valobj,
- m_summary);
+ return curr_ptr_depth.CanAllowExpansion();
}
return (!entry || entry->DoesPrintChildren(m_valobj) || m_summary.empty());
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
index 652bde792ab4..4fb92cad3988 100644
--- a/source/DataFormatters/VectorType.cpp
+++ b/source/DataFormatters/VectorType.cpp
@@ -204,14 +204,12 @@ public:
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
auto offset = idx * m_child_type.GetByteSize(nullptr);
- ValueObjectSP child_sp(
- m_backend.GetSyntheticChildAtOffset(offset, m_child_type, true));
- if (!child_sp)
- return child_sp;
-
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- child_sp->SetName(ConstString(idx_name.GetString()));
+ ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset(
+ offset, m_child_type, true, ConstString(idx_name.GetString())));
+ if (!child_sp)
+ return child_sp;
child_sp->SetFormat(m_item_format);
diff --git a/source/Expression/CMakeLists.txt b/source/Expression/CMakeLists.txt
index f8faa6df0267..7d9643a45dd5 100644
--- a/source/Expression/CMakeLists.txt
+++ b/source/Expression/CMakeLists.txt
@@ -21,4 +21,18 @@ add_lldb_library(lldbExpression
DEPENDS
${tablegen_deps}
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginExpressionParserClang
+
+ LINK_COMPONENTS
+ Core
+ ExecutionEngine
+ Support
)
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index c8b0b5944e8b..928577cd7ee4 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -15,20 +15,20 @@
// C++ Includes
#include <vector>
-#include "lldb/Core/DataEncoder.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/VMRange.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/DataEncoder.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/VMRange.h"
#include "Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h"
#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
+#include "lldb/Utility/Endian.h"
#include "lldb/Symbol/Function.h"
diff --git a/source/Expression/DiagnosticManager.cpp b/source/Expression/DiagnosticManager.cpp
index ad06600e098a..5ade0817b1e2 100644
--- a/source/Expression/DiagnosticManager.cpp
+++ b/source/Expression/DiagnosticManager.cpp
@@ -11,8 +11,8 @@
#include "llvm/Support/ErrorHandling.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
diff --git a/source/Expression/ExpressionSourceCode.cpp b/source/Expression/ExpressionSourceCode.cpp
index 90a9ff2ffa06..d60a12888065 100644
--- a/source/Expression/ExpressionSourceCode.cpp
+++ b/source/Expression/ExpressionSourceCode.cpp
@@ -11,7 +11,6 @@
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/DebugMacros.h"
@@ -22,6 +21,7 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
diff --git a/source/Expression/ExpressionVariable.cpp b/source/Expression/ExpressionVariable.cpp
index 00e689622949..a97180029a84 100644
--- a/source/Expression/ExpressionVariable.cpp
+++ b/source/Expression/ExpressionVariable.cpp
@@ -8,8 +8,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Core/Log.h"
#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
diff --git a/source/Expression/FunctionCaller.cpp b/source/Expression/FunctionCaller.cpp
index f218ccb047a7..e2f38a9f50bb 100644
--- a/source/Expression/FunctionCaller.cpp
+++ b/source/Expression/FunctionCaller.cpp
@@ -13,8 +13,6 @@
// Project includes
#include "lldb/Expression/FunctionCaller.h"
-#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"
@@ -31,6 +29,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/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index b337ea2cb275..44ff6295ca18 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -21,14 +21,14 @@
// Project includes
#include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
using namespace llvm;
using namespace lldb_private;
diff --git a/source/Expression/IRExecutionUnit.cpp b/source/Expression/IRExecutionUnit.cpp
index f18d96bd9e23..4309caefbd44 100644
--- a/source/Expression/IRExecutionUnit.cpp
+++ b/source/Expression/IRExecutionUnit.cpp
@@ -15,11 +15,8 @@
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Expression/IRExecutionUnit.h"
@@ -30,7 +27,10 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "lldb/../../source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp
index e5705984eb87..6867443cdf5e 100644
--- a/source/Expression/IRInterpreter.cpp
+++ b/source/Expression/IRInterpreter.cpp
@@ -8,19 +8,19 @@
//===----------------------------------------------------------------------===//
#include "lldb/Expression/IRInterpreter.h"
-#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/ModuleSpec.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRMemoryMap.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
diff --git a/source/Expression/IRMemoryMap.cpp b/source/Expression/IRMemoryMap.cpp
index 7b9d26667389..66510ac978ae 100644
--- a/source/Expression/IRMemoryMap.cpp
+++ b/source/Expression/IRMemoryMap.cpp
@@ -8,15 +8,15 @@
//===----------------------------------------------------------------------===//
#include "lldb/Expression/IRMemoryMap.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
diff --git a/source/Expression/LLVMUserExpression.cpp b/source/Expression/LLVMUserExpression.cpp
index c5df7812ba43..396a7e295033 100644
--- a/source/Expression/LLVMUserExpression.cpp
+++ b/source/Expression/LLVMUserExpression.cpp
@@ -12,11 +12,8 @@
// Project includes
#include "lldb/Expression/LLVMUserExpression.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/ExpressionSourceCode.h"
@@ -38,6 +35,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"
using namespace lldb_private;
@@ -49,7 +49,10 @@ LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
const EvaluateExpressionOptions &options)
: UserExpression(exe_scope, expr, prefix, language, desired_type, options),
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
- m_stack_frame_top(LLDB_INVALID_ADDRESS), m_transformed_text(),
+ m_stack_frame_top(LLDB_INVALID_ADDRESS),
+ m_allow_cxx(false),
+ m_allow_objc(false),
+ m_transformed_text(),
m_execution_unit_sp(), m_materializer_ap(), m_jit_module_wp(),
m_enforce_valid_object(true), m_in_cplusplus_method(false),
m_in_objectivec_method(false), m_in_static_method(false),
diff --git a/source/Expression/Materializer.cpp b/source/Expression/Materializer.cpp
index 6ddd4a4d8fb0..8a22daa5acdd 100644
--- a/source/Expression/Materializer.cpp
+++ b/source/Expression/Materializer.cpp
@@ -12,7 +12,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Expression/Materializer.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
@@ -26,6 +26,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
@@ -370,11 +371,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
dump_stream.PutChar('\n');
}
@@ -398,11 +396,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, target_address);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ target_address);
dump_stream.PutChar('\n');
}
@@ -711,8 +706,8 @@ public:
DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
map.GetByteOrder(), map.GetAddressByteSize());
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
lldb::offset_t offset;
@@ -739,11 +734,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
dump_stream.PutChar('\n');
}
@@ -981,8 +973,8 @@ public:
DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
map.GetByteOrder(), map.GetAddressByteSize());
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
lldb::offset_t offset;
@@ -1009,11 +1001,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
dump_stream.PutChar('\n');
}
@@ -1146,11 +1135,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
dump_stream.PutChar('\n');
}
@@ -1322,11 +1308,8 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
- DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
- map.GetByteOrder(), map.GetAddressByteSize());
-
- extractor.DumpHexBytes(&dump_stream, data.GetBytes(),
- data.GetByteSize(), 16, load_addr);
+ DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16,
+ load_addr);
dump_stream.PutChar('\n');
}
diff --git a/source/Expression/UserExpression.cpp b/source/Expression/UserExpression.cpp
index 041caf57bd31..c7cf106e19df 100644
--- a/source/Expression/UserExpression.cpp
+++ b/source/Expression/UserExpression.cpp
@@ -17,11 +17,8 @@
#include <string>
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/ExpressionSourceCode.h"
@@ -43,6 +40,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"
using namespace lldb_private;
diff --git a/source/Expression/UtilityFunction.cpp b/source/Expression/UtilityFunction.cpp
index fdb21ba372bd..6772fd18ac5b 100644
--- a/source/Expression/UtilityFunction.cpp
+++ b/source/Expression/UtilityFunction.cpp
@@ -15,10 +15,7 @@
// 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/DiagnosticManager.h"
#include "lldb/Expression/ExpressionSourceCode.h"
@@ -29,6 +26,9 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.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;
using namespace lldb;
diff --git a/source/Host/CMakeLists.txt b/source/Host/CMakeLists.txt
index 0e4a8a533e5f..f00d67420fa3 100644
--- a/source/Host/CMakeLists.txt
+++ b/source/Host/CMakeLists.txt
@@ -6,7 +6,6 @@ endmacro()
add_host_subdirectory(common
common/File.cpp
common/FileCache.cpp
- common/FileSpec.cpp
common/FileSystem.cpp
common/GetOptInc.cpp
common/Host.cpp
@@ -22,11 +21,11 @@ add_host_subdirectory(common
common/NativeWatchpointList.cpp
common/NativeProcessProtocol.cpp
common/NativeRegisterContext.cpp
- common/NativeRegisterContextRegisterInfo.cpp
common/NativeThreadProtocol.cpp
common/OptionParser.cpp
common/PipeBase.cpp
common/ProcessRunLock.cpp
+ common/PseudoTerminal.cpp
common/Socket.cpp
common/SocketAddress.cpp
common/SoftwareBreakpoint.cpp
@@ -34,7 +33,6 @@ add_host_subdirectory(common
common/Symbols.cpp
common/TCPSocket.cpp
common/Terminal.cpp
- common/ThisThread.cpp
common/ThreadLauncher.cpp
common/XML.cpp
common/UDPSocket.cpp
@@ -55,6 +53,10 @@ add_host_subdirectory(posix
posix/ConnectionFileDescriptorPosix.cpp
)
+if(NOT LLDB_DISABLE_PYTHON)
+ list(APPEND LLDB_PLUGINS lldbPluginScriptInterpreterPython)
+endif()
+
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_host_subdirectory(windows
windows/ConnectionGenericFileWindows.cpp
@@ -68,7 +70,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
windows/PipeWindows.cpp
windows/ProcessLauncherWindows.cpp
windows/ProcessRunLock.cpp
- windows/ThisThread.cpp
windows/Windows.cpp
)
else()
@@ -86,9 +87,10 @@ else()
posix/LockFilePosix.cpp
posix/MainLoopPosix.cpp
posix/PipePosix.cpp
+ posix/ProcessLauncherPosixFork.cpp
)
- if (NOT __ANDROID_NDK__)
+ if (NOT (CMAKE_SYSTEM_NAME MATCHES "Android"))
add_host_subdirectory(posix
posix/ProcessLauncherPosix.cpp
)
@@ -101,7 +103,6 @@ else()
macosx/HostInfoMacOSX.mm
macosx/HostThreadMacOSX.mm
macosx/Symbols.cpp
- macosx/ThisThread.cpp
macosx/cfcpp/CFCBundle.cpp
macosx/cfcpp/CFCData.cpp
macosx/cfcpp/CFCMutableArray.cpp
@@ -110,37 +111,37 @@ else()
macosx/cfcpp/CFCString.cpp
)
- elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
- if (__ANDROID_NDK__)
- add_host_subdirectory(android
- android/HostInfoAndroid.cpp
- android/LibcGlue.cpp
- )
- endif()
+
+ elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
add_host_subdirectory(linux
linux/AbstractSocket.cpp
linux/Host.cpp
linux/HostInfoLinux.cpp
- linux/HostThreadLinux.cpp
linux/LibcGlue.cpp
- linux/ProcessLauncherLinux.cpp
- linux/ThisThread.cpp
+ linux/Support.cpp
)
-
+ if (CMAKE_SYSTEM_NAME MATCHES "Android")
+ add_host_subdirectory(android
+ android/HostInfoAndroid.cpp
+ android/LibcGlue.cpp
+ )
+ endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_host_subdirectory(freebsd
freebsd/Host.cpp
freebsd/HostInfoFreeBSD.cpp
- freebsd/HostThreadFreeBSD.cpp
- freebsd/ThisThread.cpp
)
elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_host_subdirectory(netbsd
netbsd/Host.cpp
netbsd/HostInfoNetBSD.cpp
- netbsd/HostThreadNetBSD.cpp
- netbsd/ThisThread.cpp
+ )
+
+ elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
+ add_host_subdirectory(openbsd
+ openbsd/Host.cpp
+ openbsd/HostInfoOpenBSD.cpp
)
endif()
endif()
@@ -158,8 +159,22 @@ if (${get_python_libdir})
endif()
endif()
-add_lldb_library(lldbHost ${HOST_SOURCES})
-
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-target_link_libraries(lldbHost kvm)
+ set(EXTRA_LIBS kvm)
endif ()
+
+add_lldb_library(lldbHost
+ ${HOST_SOURCES}
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ ${LLDB_PLUGINS}
+ ${EXTRA_LIBS}
+
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/source/Host/common/Editline.cpp b/source/Host/common/Editline.cpp
index 1c5c0ffe902b..b157cdb7c110 100644
--- a/source/Host/common/Editline.cpp
+++ b/source/Host/common/Editline.cpp
@@ -11,16 +11,19 @@
#include <iostream>
#include <limits.h>
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Editline.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/SelectHelper.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
+#include "lldb/Utility/Timeout.h"
+
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
using namespace lldb_private;
using namespace lldb_private::line_editor;
@@ -176,9 +179,7 @@ private:
if (m_path.empty() && m_history && !m_prefix.empty()) {
FileSpec parent_path{"~/.lldb", true};
char history_path[PATH_MAX];
- if (FileSystem::MakeDirectory(parent_path,
- lldb::eFilePermissionsDirectoryDefault)
- .Success()) {
+ if (!llvm::sys::fs::create_directory(parent_path.GetPath())) {
snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history",
m_prefix.c_str());
} else {
@@ -1151,8 +1152,8 @@ Editline::Editline(const char *editline_name, FILE *input_file,
if (term_fd != -1) {
static std::mutex *g_init_terminal_fds_mutex_ptr = nullptr;
static std::set<int> *g_init_terminal_fds_ptr = nullptr;
- 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, [&]() {
g_init_terminal_fds_mutex_ptr =
new std::mutex(); // NOTE: Leak to avoid C++ destructor chain issues
g_init_terminal_fds_ptr = new std::set<int>(); // NOTE: Leak to avoid
diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp
index 4eb9ae15f069..1869a6db49c9 100644
--- a/source/Host/common/File.cpp
+++ b/source/Host/common/File.cpp
@@ -19,17 +19,18 @@
#include "lldb/Host/windows/windows.h"
#else
#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <termios.h>
#endif
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors()
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/Config.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -247,14 +248,12 @@ Error File::Open(const char *path, uint32_t options, uint32_t permissions) {
uint32_t File::GetPermissions(const FileSpec &file_spec, Error &error) {
if (file_spec) {
- struct stat file_stats;
- int stat_result = FileSystem::Stat(file_spec.GetCString(), &file_stats);
- if (stat_result == -1)
- error.SetErrorToErrno();
- else {
- error.Clear();
- return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
- }
+ error.Clear();
+ auto Perms = llvm::sys::fs::getPermissions(file_spec.GetPath());
+ if (Perms)
+ return *Perms;
+ error = Error(Perms.getError());
+ return 0;
} else
error.SetErrorString("empty file spec");
return 0;
@@ -308,7 +307,7 @@ void File::Clear() {
Error File::GetFileSpec(FileSpec &file_spec) const {
Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
if (IsValid()) {
char path[PATH_MAX];
if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
diff --git a/source/Host/common/FileSystem.cpp b/source/Host/common/FileSystem.cpp
index 88f29b46f360..4472aece1daa 100644
--- a/source/Host/common/FileSystem.cpp
+++ b/source/Host/common/FileSystem.cpp
@@ -10,7 +10,6 @@
#include "lldb/Host/FileSystem.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MD5.h"
#include <algorithm>
#include <fstream>
@@ -19,79 +18,6 @@
using namespace lldb;
using namespace lldb_private;
-namespace {
-
-bool CalcMD5(const FileSpec &file_spec, uint64_t offset, uint64_t length,
- llvm::MD5::MD5Result &md5_result) {
- llvm::MD5 md5_hash;
- std::ifstream file(file_spec.GetPath(), std::ios::binary);
- if (!file.is_open())
- return false;
-
- if (offset > 0)
- file.seekg(offset, file.beg);
-
- std::vector<char> read_buf(4096);
- uint64_t total_read_bytes = 0;
- while (!file.eof()) {
- const uint64_t to_read =
- (length > 0) ? std::min(static_cast<uint64_t>(read_buf.size()),
- length - total_read_bytes)
- : read_buf.size();
- if (to_read == 0)
- break;
-
- file.read(&read_buf[0], to_read);
- const auto read_bytes = file.gcount();
- if (read_bytes == 0)
- break;
-
- md5_hash.update(llvm::StringRef(&read_buf[0], read_bytes));
- total_read_bytes += read_bytes;
- }
-
- md5_hash.final(md5_result);
- return true;
-}
-
-} // namespace
-
-bool FileSystem::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
- uint64_t &high) {
- return CalculateMD5(file_spec, 0, 0, low, high);
-}
-
-bool FileSystem::CalculateMD5(const FileSpec &file_spec, uint64_t offset,
- uint64_t length, uint64_t &low, uint64_t &high) {
- llvm::MD5::MD5Result md5_result;
- if (!CalcMD5(file_spec, offset, length, md5_result))
- return false;
-
- const auto uint64_res = reinterpret_cast<const uint64_t *>(md5_result);
- high = uint64_res[0];
- low = uint64_res[1];
-
- return true;
-}
-
-bool FileSystem::CalculateMD5AsString(const FileSpec &file_spec,
- std::string &digest_str) {
- return CalculateMD5AsString(file_spec, 0, 0, digest_str);
-}
-
-bool FileSystem::CalculateMD5AsString(const FileSpec &file_spec,
- uint64_t offset, uint64_t length,
- std::string &digest_str) {
- llvm::MD5::MD5Result md5_result;
- if (!CalcMD5(file_spec, offset, length, md5_result))
- return false;
-
- llvm::SmallString<32> result_str;
- llvm::MD5::stringifyResult(md5_result, result_str);
- digest_str = result_str.c_str();
- return true;
-}
-
llvm::sys::TimePoint<>
FileSystem::GetModificationTime(const FileSpec &file_spec) {
llvm::sys::fs::file_status status;
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 6d0ad0175fd8..7754d96ad331 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -28,7 +28,8 @@
#endif
#if defined(__linux__) || defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
+ defined(__FreeBSD_kernel__) || defined(__APPLE__) || \
+ defined(__NetBSD__) || defined(__OpenBSD__)
#if !defined(__ANDROID__)
#include <spawn.h>
#endif
@@ -40,16 +41,16 @@
#include <pthread_np.h>
#endif
+#if defined(__NetBSD__)
+#include <lwp.h>
+#endif
+
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostProcess.h"
@@ -61,14 +62,18 @@
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-private-forward.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#if defined(_WIN32)
#include "lldb/Host/windows/ProcessLauncherWindows.h"
-#elif defined(__linux__)
-#include "lldb/Host/linux/ProcessLauncherLinux.h"
+#elif defined(__linux__) || defined(__NetBSD__)
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
#else
#include "lldb/Host/posix/ProcessLauncherPosix.h"
#endif
@@ -180,7 +185,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) {
delete info;
int status = -1;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
#define __WALL 0
#endif
const int options = __WALL;
@@ -310,25 +315,6 @@ lldb::pid_t Host::GetCurrentProcessID() { return ::getpid(); }
#ifndef _WIN32
-lldb::tid_t Host::GetCurrentThreadID() {
-#if defined(__APPLE__)
- // Calling "mach_thread_self()" bumps the reference count on the thread
- // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
- // count.
- thread_port_t thread_self = mach_thread_self();
- mach_port_deallocate(mach_task_self(), thread_self);
- return thread_self;
-#elif defined(__FreeBSD__)
- return lldb::tid_t(pthread_getthreadid_np());
-#elif defined(__ANDROID__)
- return lldb::tid_t(gettid());
-#elif defined(__linux__)
- return lldb::tid_t(syscall(SYS_gettid));
-#else
- return lldb::tid_t(pthread_self());
-#endif
-}
-
lldb::thread_t Host::GetCurrentThread() {
return lldb::thread_t(pthread_self());
}
@@ -601,23 +587,22 @@ Error Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
error.SetErrorStringWithFormat(
"shell command output is too large to fit into a std::string");
} else {
- std::vector<char> command_output(file_size);
- output_file_spec.ReadFileContents(0, command_output.data(),
- file_size, &error);
+ auto Buffer =
+ DataBufferLLVM::CreateFromPath(output_file_spec.GetPath());
if (error.Success())
- command_output_ptr->assign(command_output.data(), file_size);
+ command_output_ptr->assign(Buffer->GetChars(),
+ Buffer->GetByteSize());
}
}
}
}
}
- if (FileSystem::GetFileExists(output_file_spec))
- FileSystem::Unlink(output_file_spec);
+ llvm::sys::fs::remove(output_file_spec.GetPath());
return error;
}
-// LaunchProcessPosixSpawn for Apple, Linux, FreeBSD and other GLIBC
+// LaunchProcessPosixSpawn for Apple, Linux, FreeBSD, NetBSD and other GLIBC
// systems
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || \
@@ -679,10 +664,10 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
posix_spawnattr_t attr;
error.SetError(::posix_spawnattr_init(&attr), eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log, "::posix_spawnattr_init ( &attr )");
- if (error.Fail())
+ if (error.Fail()) {
+ LLDB_LOG(log, "error: {0}, ::posix_spawnattr_init ( &attr )", error);
return error;
+ }
// Make a quick class that will cleanup the posix spawn attributes in case
// we return in the middle of this function.
@@ -694,7 +679,7 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
sigemptyset(&no_signals);
sigfillset(&all_signals);
::posix_spawnattr_setsigmask(&attr, &no_signals);
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
::posix_spawnattr_setsigdefault(&attr, &no_signals);
#else
::posix_spawnattr_setsigdefault(&attr, &all_signals);
@@ -703,11 +688,12 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
short flags = GetPosixspawnFlags(launch_info);
error.SetError(::posix_spawnattr_setflags(&attr, flags), eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log, "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )",
- flags);
- if (error.Fail())
+ if (error.Fail()) {
+ LLDB_LOG(log,
+ "error: {0}, ::posix_spawnattr_setflags ( &attr, flags={1:x} )",
+ error, flags);
return error;
+ }
// posix_spawnattr_setbinpref_np appears to be an Apple extension per:
// http://www.unix.com/man-page/OSX/3/posix_spawnattr_setbinpref_np/
@@ -734,10 +720,10 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
size_t ocount = 0;
error.SetError(::posix_spawnattr_setbinpref_np(&attr, 1, &cpu, &ocount),
eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, "
- "cpu_type = 0x%8.8x, count => %llu )",
- cpu, (uint64_t)ocount);
+ if (error.Fail())
+ LLDB_LOG(log, "error: {0}, ::posix_spawnattr_setbinpref_np ( &attr, 1, "
+ "cpu_type = {1:x}, count => {2} )",
+ error, cpu, ocount);
if (error.Fail() || ocount != 1)
return error;
@@ -788,14 +774,14 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
#else
if (::getcwd(current_dir, sizeof(current_dir)) == NULL) {
error.SetError(errno, eErrorTypePOSIX);
- error.LogIfError(log, "unable to save the current directory");
+ LLDB_LOG(log, "error: {0}, unable to save the current directory", error);
return error;
}
if (::chdir(working_dir.GetCString()) == -1) {
error.SetError(errno, eErrorTypePOSIX);
- error.LogIfError(log, "unable to change working directory to %s",
- working_dir.GetCString());
+ LLDB_LOG(log, "error: {0}, unable to change working directory to {1}",
+ error, working_dir);
return error;
}
#endif
@@ -807,10 +793,12 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
posix_spawn_file_actions_t file_actions;
error.SetError(::posix_spawn_file_actions_init(&file_actions),
eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log, "::posix_spawn_file_actions_init ( &file_actions )");
- if (error.Fail())
+ if (error.Fail()) {
+ LLDB_LOG(log,
+ "error: {0}, ::posix_spawn_file_actions_init ( &file_actions )",
+ error);
return error;
+ }
// Make a quick class that will cleanup the posix spawn attributes in case
// we return in the middle of this function.
@@ -832,16 +820,14 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
::posix_spawnp(&result_pid, exe_path, &file_actions, &attr, argv, envp),
eErrorTypePOSIX);
- if (error.Fail() || log) {
- error.PutToLog(
- log, "::posix_spawnp ( pid => %i, path = '%s', file_actions = %p, "
- "attr = %p, argv = %p, envp = %p )",
- result_pid, exe_path, static_cast<void *>(&file_actions),
- static_cast<void *>(&attr), reinterpret_cast<const void *>(argv),
- reinterpret_cast<const void *>(envp));
+ if (error.Fail()) {
+ LLDB_LOG(log, "error: {0}, ::posix_spawnp(pid => {1}, path = '{2}', "
+ "file_actions = {3}, "
+ "attr = {4}, argv = {5}, envp = {6} )",
+ error, result_pid, exe_path, &file_actions, &attr, argv, envp);
if (log) {
for (int ii = 0; argv[ii]; ++ii)
- log->Printf("argv[%i] = '%s'", ii, argv[ii]);
+ LLDB_LOG(log, "argv[{0}] = '{1}'", ii, argv[ii]);
}
}
@@ -850,16 +836,13 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
::posix_spawnp(&result_pid, exe_path, NULL, &attr, argv, envp),
eErrorTypePOSIX);
- if (error.Fail() || log) {
- error.PutToLog(log, "::posix_spawnp ( pid => %i, path = '%s', "
- "file_actions = NULL, attr = %p, argv = %p, envp = "
- "%p )",
- result_pid, exe_path, static_cast<void *>(&attr),
- reinterpret_cast<const void *>(argv),
- reinterpret_cast<const void *>(envp));
+ if (error.Fail()) {
+ LLDB_LOG(log, "error: {0}, ::posix_spawnp ( pid => {1}, path = '{2}', "
+ "file_actions = NULL, attr = {3}, argv = {4}, envp = {5} )",
+ error, result_pid, exe_path, &attr, argv, envp);
if (log) {
for (int ii = 0; argv[ii]; ++ii)
- log->Printf("argv[%i] = '%s'", ii, argv[ii]);
+ LLDB_LOG(log, "argv[{0}] = '{1}'", ii, argv[ii]);
}
}
}
@@ -872,8 +855,9 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path,
#else
if (::chdir(current_dir) == -1 && error.Success()) {
error.SetError(errno, eErrorTypePOSIX);
- error.LogIfError(log, "unable to change current directory back to %s",
- current_dir);
+ LLDB_LOG(log,
+ "error: {0}, unable to change current directory back to {1}",
+ error, current_dir);
}
#endif
}
@@ -902,10 +886,10 @@ bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
error.SetError(
::posix_spawn_file_actions_addclose(file_actions, info->GetFD()),
eErrorTypePOSIX);
- if (log && (error.Fail() || log))
- error.PutToLog(log,
- "posix_spawn_file_actions_addclose (action=%p, fd=%i)",
- static_cast<void *>(file_actions), info->GetFD());
+ if (error.Fail())
+ LLDB_LOG(log, "error: {0}, posix_spawn_file_actions_addclose "
+ "(action={1}, fd={2})",
+ error, file_actions, info->GetFD());
}
break;
@@ -921,12 +905,10 @@ bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
::posix_spawn_file_actions_adddup2(file_actions, info->GetFD(),
info->GetActionArgument()),
eErrorTypePOSIX);
- if (log && (error.Fail() || log))
- error.PutToLog(
- log,
- "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)",
- static_cast<void *>(file_actions), info->GetFD(),
- info->GetActionArgument());
+ if (error.Fail())
+ LLDB_LOG(log, "error: {0}, posix_spawn_file_actions_adddup2 "
+ "(action={1}, fd={2}, dup_fd={3})",
+ error, file_actions, info->GetFD(), info->GetActionArgument());
}
break;
@@ -946,11 +928,11 @@ bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
file_actions, info->GetFD(),
info->GetPath().str().c_str(), oflag, mode),
eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log, "posix_spawn_file_actions_addopen (action=%p, "
- "fd=%i, path='%s', oflag=%i, mode=%i)",
- static_cast<void *>(file_actions), info->GetFD(),
- info->GetPath().str().c_str(), oflag, mode);
+ if (error.Fail())
+ LLDB_LOG(
+ log, "error: {0}, posix_spawn_file_actions_addopen (action={1}, "
+ "fd={2}, path='{3}', oflag={4}, mode={5})",
+ error, file_actions, info->GetFD(), info->GetPath(), oflag, mode);
}
break;
}
@@ -969,8 +951,8 @@ Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
std::unique_ptr<ProcessLauncher> delegate_launcher;
#if defined(_WIN32)
delegate_launcher.reset(new ProcessLauncherWindows());
-#elif defined(__linux__)
- delegate_launcher.reset(new ProcessLauncherLinux());
+#elif defined(__linux__) || defined(__NetBSD__)
+ delegate_launcher.reset(new ProcessLauncherPosixFork());
#else
delegate_launcher.reset(new ProcessLauncherPosix());
#endif
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index 01ac87047c5d..a6c9e91a98e8 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -10,21 +10,22 @@
#include "lldb/Host/Config.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostInfoBase.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
-#include <mutex> // std::once
+#include <mutex>
#include <thread>
using namespace lldb;
@@ -45,13 +46,10 @@ struct HostInfoBaseFields {
// Remove the LLDB temporary directory if we have one. Set "recurse" to
// true to all files that were created for the LLDB process can be cleaned
// up.
- FileSystem::DeleteDirectory(m_lldb_process_tmp_dir, true);
+ llvm::sys::fs::remove_directories(m_lldb_process_tmp_dir.GetPath());
}
}
- uint32_t m_number_cpus;
- std::string m_vendor_string;
- std::string m_os_string;
std::string m_host_triple;
ArchSpec m_host_arch_32;
@@ -78,37 +76,9 @@ void HostInfoBase::Terminate() {
g_fields = nullptr;
}
-uint32_t HostInfoBase::GetNumberCPUS() {
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
- g_fields->m_number_cpus = std::thread::hardware_concurrency();
- });
- return g_fields->m_number_cpus;
-}
-
-uint32_t HostInfoBase::GetMaxThreadNameLength() { return 0; }
-
-llvm::StringRef HostInfoBase::GetVendorString() {
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
- g_fields->m_vendor_string =
- HostInfo::GetArchitecture().GetTriple().getVendorName().str();
- });
- return g_fields->m_vendor_string;
-}
-
-llvm::StringRef HostInfoBase::GetOSString() {
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
- g_fields->m_os_string =
- std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
- });
- return g_fields->m_os_string;
-}
-
llvm::StringRef HostInfoBase::GetTargetTriple() {
- 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, []() {
g_fields->m_host_triple =
HostInfo::GetArchitecture().GetTriple().getTriple();
});
@@ -116,8 +86,8 @@ llvm::StringRef HostInfoBase::GetTargetTriple() {
}
const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) {
- 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, []() {
HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32,
g_fields->m_host_arch_64);
});
@@ -144,9 +114,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
FileSpec *result = nullptr;
switch (type) {
case lldb::ePathTypeLLDBShlibDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success =
HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -158,9 +128,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_so_dir;
} break;
case lldb::ePathTypeSupportExecutableDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeSupportExeDirectory(
g_fields->m_lldb_support_exe_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -173,9 +143,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_support_exe_dir;
} break;
case lldb::ePathTypeHeaderDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
@@ -186,9 +156,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_headers_dir;
} break;
case lldb::ePathTypePythonDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputePythonDirectory(g_fields->m_lldb_python_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
@@ -199,9 +169,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_python_dir;
} break;
case lldb::ePathTypeClangDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success =
HostInfo::ComputeClangDirectory(g_fields->m_lldb_clang_resource_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -214,9 +184,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_clang_resource_dir;
} break;
case lldb::ePathTypeLLDBSystemPlugins: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeSystemPluginsDirectory(
g_fields->m_lldb_system_plugin_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -229,9 +199,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_system_plugin_dir;
} break;
case lldb::ePathTypeLLDBUserPlugins: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeUserPluginsDirectory(
g_fields->m_lldb_user_plugin_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -244,9 +214,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_user_plugin_dir;
} break;
case lldb::ePathTypeLLDBTempSystemDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeProcessTempFileDirectory(
g_fields->m_lldb_process_tmp_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -259,9 +229,9 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
result = &g_fields->m_lldb_process_tmp_dir;
} break;
case lldb::ePathTypeGlobalLLDBTempSystemDir: {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
static bool success = false;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
success = HostInfo::ComputeGlobalTempFileDirectory(
g_fields->m_lldb_global_tmp_dir);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
@@ -313,9 +283,7 @@ bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) {
std::string pid_str{llvm::to_string(Host::GetCurrentProcessID())};
temp_file_spec.AppendPathComponent(pid_str);
- if (!FileSystem::MakeDirectory(temp_file_spec,
- eFilePermissionsDirectoryDefault)
- .Success())
+ if (llvm::sys::fs::create_directory(temp_file_spec.GetPath()))
return false;
file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
@@ -337,9 +305,7 @@ bool HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) {
return false;
temp_file_spec.AppendPathComponent("lldb");
- if (!FileSystem::MakeDirectory(temp_file_spec,
- eFilePermissionsDirectoryDefault)
- .Success())
+ if (llvm::sys::fs::create_directory(temp_file_spec.GetPath()))
return false;
file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
diff --git a/source/Host/common/HostNativeThreadBase.cpp b/source/Host/common/HostNativeThreadBase.cpp
index fd39e0d1e2fe..402d3caacfcb 100644
--- a/source/Host/common/HostNativeThreadBase.cpp
+++ b/source/Host/common/HostNativeThreadBase.cpp
@@ -8,11 +8,12 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/HostNativeThreadBase.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/ThisThread.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/Log.h"
+
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Threading.h"
using namespace lldb;
using namespace lldb_private;
@@ -52,7 +53,7 @@ lldb::thread_result_t
HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) {
ThreadLauncher::HostThreadCreateInfo *info =
(ThreadLauncher::HostThreadCreateInfo *)arg;
- ThisThread::SetName(info->thread_name, HostInfo::GetMaxThreadNameLength());
+ llvm::set_thread_name(info->thread_name);
thread_func_t thread_fptr = info->thread_fptr;
thread_arg_t thread_arg = info->thread_arg;
diff --git a/source/Host/common/MonitoringProcessLauncher.cpp b/source/Host/common/MonitoringProcessLauncher.cpp
index ae98cc83379d..2aa6c7f50b66 100644
--- a/source/Host/common/MonitoringProcessLauncher.cpp
+++ b/source/Host/common/MonitoringProcessLauncher.cpp
@@ -8,14 +8,16 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/MonitoringProcessLauncher.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
@@ -38,8 +40,9 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info,
FileSpec exe_spec(resolved_info.GetExecutableFile());
- FileSpec::FileType file_type = exe_spec.GetFileType();
- if (file_type != FileSpec::eFileTypeRegular) {
+ llvm::sys::fs::file_status stats;
+ status(exe_spec.GetPath(), stats);
+ if (!is_regular_file(stats)) {
ModuleSpec module_spec(exe_spec, arch_spec);
lldb::ModuleSP exe_module_sp;
error =
@@ -48,11 +51,13 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info,
if (error.Fail())
return HostProcess();
- if (exe_module_sp)
+ if (exe_module_sp) {
exe_spec = exe_module_sp->GetFileSpec();
+ status(exe_spec.GetPath(), stats);
+ }
}
- if (exe_spec.Exists()) {
+ if (exists(stats)) {
exe_spec.GetPath(exe_path, sizeof(exe_path));
} else {
resolved_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
diff --git a/source/Host/common/NativeBreakpoint.cpp b/source/Host/common/NativeBreakpoint.cpp
index d61a2f531ac3..8a3ee72179c3 100644
--- a/source/Host/common/NativeBreakpoint.cpp
+++ b/source/Host/common/NativeBreakpoint.cpp
@@ -9,8 +9,8 @@
#include "lldb/Host/common/NativeBreakpoint.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-defines.h"
using namespace lldb_private;
diff --git a/source/Host/common/NativeBreakpointList.cpp b/source/Host/common/NativeBreakpointList.cpp
index df5bce8079e0..60608a0bbc55 100644
--- a/source/Host/common/NativeBreakpointList.cpp
+++ b/source/Host/common/NativeBreakpointList.cpp
@@ -9,7 +9,7 @@
#include "lldb/Host/common/NativeBreakpointList.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Host/common/NativeBreakpoint.h"
#include "lldb/Host/common/SoftwareBreakpoint.h"
diff --git a/source/Host/common/NativeProcessProtocol.cpp b/source/Host/common/NativeProcessProtocol.cpp
index d77b8b2e9746..9d4149d700ba 100644
--- a/source/Host/common/NativeProcessProtocol.cpp
+++ b/source/Host/common/NativeProcessProtocol.cpp
@@ -10,7 +10,6 @@
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
@@ -20,6 +19,7 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-enumerations.h"
using namespace lldb;
@@ -46,6 +46,12 @@ lldb_private::Error NativeProcessProtocol::Interrupt() {
#endif
}
+Error NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef<int> signals) {
+ m_signals_to_ignore.clear();
+ m_signals_to_ignore.insert(signals.begin(), signals.end());
+ return Error();
+}
+
lldb_private::Error
NativeProcessProtocol::GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
@@ -139,11 +145,8 @@ NativeProcessProtocol::GetWatchpointMap() const {
return m_watchpoint_list.GetWatchpointMap();
}
-uint32_t NativeProcessProtocol::GetMaxWatchpoints() const {
- // This default implementation will return the number of
- // *hardware* breakpoints available. MacOSX and other OS
- // implementations that support software breakpoints will want to
- // override this correctly for their implementation.
+llvm::Optional<std::pair<uint32_t, uint32_t>>
+NativeProcessProtocol::GetHardwareDebugSupportInfo() const {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
// get any thread
@@ -154,7 +157,7 @@ uint32_t NativeProcessProtocol::GetMaxWatchpoints() const {
log->Warning("NativeProcessProtocol::%s (): failed to find a thread to "
"grab a NativeRegisterContext!",
__FUNCTION__);
- return 0;
+ return llvm::None;
}
NativeRegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
@@ -163,10 +166,11 @@ uint32_t NativeProcessProtocol::GetMaxWatchpoints() const {
log->Warning("NativeProcessProtocol::%s (): failed to get a "
"RegisterContextNativeProcess from the first thread!",
__FUNCTION__);
- return 0;
+ return llvm::None;
}
- return reg_ctx_sp->NumSupportedHardwareWatchpoints();
+ return std::make_pair(reg_ctx_sp->NumSupportedHardwareBreakpoints(),
+ reg_ctx_sp->NumSupportedHardwareWatchpoints());
}
Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size,
@@ -263,6 +267,92 @@ Error NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) {
return overall_error.Fail() ? overall_error : error;
}
+const HardwareBreakpointMap &
+NativeProcessProtocol::GetHardwareBreakpointMap() const {
+ return m_hw_breakpoints_map;
+}
+
+Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr,
+ size_t size) {
+ // This default implementation assumes setting a hardware breakpoint for
+ // this process will require setting same hardware breakpoint for each
+ // of its existing threads. New thread will do the same once created.
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+ // Update the thread list
+ UpdateThreads();
+
+ // Exit here if target does not have required hardware breakpoint capability.
+ auto hw_debug_cap = GetHardwareDebugSupportInfo();
+
+ if (hw_debug_cap == llvm::None || hw_debug_cap->first == 0 ||
+ hw_debug_cap->first <= m_hw_breakpoints_map.size())
+ return Error("Target does not have required no of hardware breakpoints");
+
+ // Vector below stores all thread pointer for which we have we successfully
+ // set this hardware breakpoint. If any of the current process threads fails
+ // to set this hardware breakpoint then roll back and remove this breakpoint
+ // for all the threads that had already set it successfully.
+ std::vector<NativeThreadProtocolSP> breakpoint_established_threads;
+
+ // Request to set a hardware breakpoint for each of current process threads.
+ std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+ for (auto thread_sp : m_threads) {
+ assert(thread_sp && "thread list should not have a NULL thread!");
+ if (!thread_sp)
+ continue;
+
+ Error thread_error = thread_sp->SetHardwareBreakpoint(addr, size);
+ if (thread_error.Success()) {
+ // Remember that we set this breakpoint successfully in
+ // case we need to clear it later.
+ breakpoint_established_threads.push_back(thread_sp);
+ } else {
+ // Unset the breakpoint for each thread we successfully
+ // set so that we get back to a consistent state of "not
+ // set" for this hardware breakpoint.
+ for (auto rollback_thread_sp : breakpoint_established_threads) {
+ Error remove_error = rollback_thread_sp->RemoveHardwareBreakpoint(addr);
+ if (remove_error.Fail() && log) {
+ log->Warning("NativeProcessProtocol::%s (): RemoveHardwareBreakpoint"
+ " failed for pid=%" PRIu64 ", tid=%" PRIu64 ": %s",
+ __FUNCTION__, GetID(), rollback_thread_sp->GetID(),
+ remove_error.AsCString());
+ }
+ }
+
+ return thread_error;
+ }
+ }
+
+ // Register new hardware breakpoint into hardware breakpoints map of current
+ // process.
+ m_hw_breakpoints_map[addr] = {addr, size};
+
+ return Error();
+}
+
+Error NativeProcessProtocol::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+ // Update the thread list
+ UpdateThreads();
+
+ Error error;
+
+ std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+ for (auto thread_sp : m_threads) {
+ assert(thread_sp && "thread list should not have a NULL thread!");
+ if (!thread_sp)
+ continue;
+
+ error = thread_sp->RemoveHardwareBreakpoint(addr);
+ }
+
+ // Also remove from hardware breakpoint map of current process.
+ m_hw_breakpoints_map.erase(addr);
+
+ return error;
+}
+
bool NativeProcessProtocol::RegisterNativeDelegate(
NativeDelegate &native_delegate) {
std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
@@ -339,8 +429,12 @@ Error NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr,
});
}
-Error NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr) {
- return m_breakpoint_list.DecRef(addr);
+Error NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr,
+ bool hardware) {
+ if (hardware)
+ return RemoveHardwareBreakpoint(addr);
+ else
+ return m_breakpoint_list.DecRef(addr);
}
Error NativeProcessProtocol::EnableBreakpoint(lldb::addr_t addr) {
@@ -410,7 +504,7 @@ Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
return Error("failed to retrieve a valid architecture from the exe module");
}
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__NetBSD__)
// These need to be implemented to support lldb-gdb-server on a given platform.
// Stubs are
// provided to make the rest of the code link on non-supported platforms.
diff --git a/source/Host/common/NativeRegisterContext.cpp b/source/Host/common/NativeRegisterContext.cpp
index 73b2629c57c1..3bc0a0d9705c 100644
--- a/source/Host/common/NativeRegisterContext.cpp
+++ b/source/Host/common/NativeRegisterContext.cpp
@@ -9,8 +9,8 @@
#include "lldb/Host/common/NativeRegisterContext.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
@@ -246,10 +246,20 @@ uint32_t NativeRegisterContext::SetHardwareBreakpoint(lldb::addr_t addr,
return LLDB_INVALID_INDEX32;
}
+Error NativeRegisterContext::ClearAllHardwareBreakpoints() {
+ return Error("not implemented");
+}
+
bool NativeRegisterContext::ClearHardwareBreakpoint(uint32_t hw_idx) {
return false;
}
+Error NativeRegisterContext::GetHardwareBreakHitIndex(uint32_t &bp_index,
+ lldb::addr_t trap_addr) {
+ bp_index = LLDB_INVALID_INDEX32;
+ return Error("not implemented");
+}
+
uint32_t NativeRegisterContext::NumSupportedHardwareWatchpoints() { return 0; }
uint32_t NativeRegisterContext::SetHardwareWatchpoint(lldb::addr_t addr,
diff --git a/source/Host/common/NativeWatchpointList.cpp b/source/Host/common/NativeWatchpointList.cpp
index 5948adf3c8d1..168e5b42b961 100644
--- a/source/Host/common/NativeWatchpointList.cpp
+++ b/source/Host/common/NativeWatchpointList.cpp
@@ -9,7 +9,7 @@
#include "lldb/Host/common/NativeWatchpointList.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Utility/PseudoTerminal.cpp b/source/Host/common/PseudoTerminal.cpp
index 4d99a568b65e..58c32e4a1c4b 100644
--- a/source/Utility/PseudoTerminal.cpp
+++ b/source/Host/common/PseudoTerminal.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/Config.h"
#include <errno.h>
@@ -112,8 +112,7 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
return true;
#else
if (error_str)
- ::snprintf(error_str, error_len, "%s",
- "pseudo terminal not supported");
+ ::snprintf(error_str, error_len, "%s", "pseudo terminal not supported");
return false;
#endif
}
diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp
index 79777c88fa46..2a665ddacb64 100644
--- a/source/Host/common/Socket.cpp
+++ b/source/Host/common/Socket.cpp
@@ -9,14 +9,14 @@
#include "lldb/Host/Socket.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/SocketAddress.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Host/common/UDPSocket.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#ifndef LLDB_DISABLE_POSIX
#include "lldb/Host/posix/DomainSocket.h"
@@ -38,11 +38,9 @@
#include <asm-generic/errno-base.h>
#include <errno.h>
#include <linux/tcp.h>
-#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
#include <fcntl.h>
#include <sys/syscall.h>
#include <unistd.h>
-#endif // ANDROID_ARM_BUILD_STATIC || ANDROID_MIPS_BUILD_STATIC
#endif // __ANDROID__
using namespace lldb;
@@ -174,15 +172,13 @@ Error Socket::TcpListen(llvm::StringRef host_and_port,
}
Error Socket::UdpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&send_socket,
- Socket *&recv_socket) {
+ bool child_processes_inherit, Socket *&socket) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
host_and_port.data());
- return UDPSocket::Connect(host_and_port, child_processes_inherit, send_socket,
- recv_socket);
+ return UDPSocket::Connect(host_and_port, child_processes_inherit, socket);
}
Error Socket::UnixDomainConnect(llvm::StringRef name,
@@ -424,9 +420,13 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
socklen_t *addrlen,
bool child_processes_inherit, Error &error) {
error.Clear();
-#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
- // Temporary workaround for statically linking Android lldb-server with the
- // latest API.
+#if defined(ANDROID_USE_ACCEPT_WORKAROUND)
+ // Hack:
+ // This enables static linking lldb-server to an API 21 libc, but still having
+ // it run on older devices. It is necessary because API 21 libc's
+ // implementation of accept() uses the accept4 syscall(), which is not
+ // available in older kernels. Using an older libc would fix this issue, but
+ // introduce other ones, as the old libraries were quite buggy.
int fd = syscall(__NR_accept, sockfd, addr, addrlen);
if (fd >= 0 && !child_processes_inherit) {
int flags = ::fcntl(fd, F_GETFD);
@@ -441,11 +441,7 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
if (!child_processes_inherit) {
flags |= SOCK_CLOEXEC;
}
-#if defined(__NetBSD__)
- NativeSocket fd = ::paccept(sockfd, addr, addrlen, nullptr, flags);
-#else
NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags);
-#endif
#else
NativeSocket fd = ::accept(sockfd, addr, addrlen);
#endif
diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp
index 1f5de2e5df18..48c3ec1c48ed 100644
--- a/source/Host/common/SocketAddress.cpp
+++ b/source/Host/common/SocketAddress.cpp
@@ -89,6 +89,10 @@ SocketAddress::SocketAddress(const struct sockaddr_storage &s) {
m_socket_addr.sa_storage = s;
}
+SocketAddress::SocketAddress(const struct addrinfo *addr_info) {
+ *this = addr_info;
+}
+
//----------------------------------------------------------------------
// SocketAddress copy constructor
//----------------------------------------------------------------------
@@ -244,6 +248,24 @@ bool SocketAddress::getaddrinfo(const char *host, const char *service,
return result;
}
+std::vector<SocketAddress> SocketAddress::GetAddressInfo(const char *hostname,
+ const char *servname) {
+ std::vector<SocketAddress> addr_list;
+
+ struct addrinfo *service_info_list = NULL;
+ int err = ::getaddrinfo(hostname, servname, NULL, &service_info_list);
+ if (err == 0 && service_info_list) {
+ for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL;
+ service_ptr = service_ptr->ai_next) {
+ addr_list.emplace_back(SocketAddress(service_ptr));
+ }
+ }
+
+ if (service_info_list)
+ ::freeaddrinfo(service_info_list);
+ return addr_list;
+}
+
bool SocketAddress::SetToLocalhost(sa_family_t family, uint16_t port) {
switch (family) {
case AF_INET:
@@ -287,3 +309,29 @@ bool SocketAddress::SetToAnyAddress(sa_family_t family, uint16_t port) {
Clear();
return false;
}
+
+bool SocketAddress::IsAnyAddr() const {
+ return (GetFamily() == AF_INET)
+ ? m_socket_addr.sa_ipv4.sin_addr.s_addr == htonl(INADDR_ANY)
+ : 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_any, 16);
+}
+
+bool SocketAddress::operator==(const SocketAddress &rhs) const {
+ if (GetFamily() != rhs.GetFamily())
+ return false;
+ if (GetLength() != rhs.GetLength())
+ return false;
+ switch (GetFamily()) {
+ case AF_INET:
+ return m_socket_addr.sa_ipv4.sin_addr.s_addr ==
+ rhs.m_socket_addr.sa_ipv4.sin_addr.s_addr;
+ case AF_INET6:
+ return 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr,
+ &rhs.m_socket_addr.sa_ipv6.sin6_addr, 16);
+ }
+ return false;
+}
+
+bool SocketAddress::operator!=(const SocketAddress &rhs) const {
+ return !(*this == rhs);
+}
diff --git a/source/Host/common/SoftwareBreakpoint.cpp b/source/Host/common/SoftwareBreakpoint.cpp
index 3d57b7dd6b88..436cb2bb112e 100644
--- a/source/Host/common/SoftwareBreakpoint.cpp
+++ b/source/Host/common/SoftwareBreakpoint.cpp
@@ -9,9 +9,9 @@
#include "lldb/Host/common/SoftwareBreakpoint.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/Debug.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
diff --git a/source/Host/common/Symbols.cpp b/source/Host/common/Symbols.cpp
index 461b15a07f84..9e0a3b5bf4df 100644
--- a/source/Host/common/Symbols.cpp
+++ b/source/Host/common/Symbols.cpp
@@ -9,17 +9,17 @@
#include "lldb/Host/Symbols.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Core/UUID.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
#include "llvm/Support/FileSystem.h"
@@ -54,7 +54,9 @@ static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
if (ObjectFile::GetModuleSpecifications(file_fspec, 0, 0, module_specs)) {
ModuleSpec spec;
for (size_t i = 0; i < module_specs.GetSize(); ++i) {
- assert(module_specs.GetModuleSpecAtIndex(i, spec));
+ bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
+ UNUSED_IF_ASSERT_DISABLED(got_spec);
+ assert(got_spec);
if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
(arch == NULL || (spec.GetArchitecturePtr() &&
spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
@@ -210,8 +212,13 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
debug_file_search_paths.AppendIfUnique(FileSpec(".", true));
#ifndef LLVM_ON_WIN32
+#if defined(__NetBSD__)
+ // Add /usr/libdata/debug directory.
+ debug_file_search_paths.AppendIfUnique(FileSpec("/usr/libdata/debug", true));
+#else
// Add /usr/lib/debug directory.
debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true));
+#endif
#endif // LLVM_ON_WIN32
std::string uuid_str;
@@ -228,7 +235,7 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
for (size_t idx = 0; idx < num_directories; ++idx) {
FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
dirspec.ResolvePath();
- if (!dirspec.Exists() || !dirspec.IsDirectory())
+ if (!llvm::sys::fs::is_directory(dirspec.GetPath()))
continue;
std::vector<std::string> files;
diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp
index 9685ceeeadf1..9a009280a904 100644
--- a/source/Host/common/TCPSocket.cpp
+++ b/source/Host/common/TCPSocket.cpp
@@ -13,8 +13,8 @@
#include "lldb/Host/common/TCPSocket.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
#ifndef LLDB_DISABLE_POSIX
#include <arpa/inet.h>
diff --git a/source/Host/common/ThisThread.cpp b/source/Host/common/ThisThread.cpp
deleted file mode 100644
index b3f9edee2e16..000000000000
--- a/source/Host/common/ThisThread.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Host/HostInfo.h"
-
-#include "llvm/ADT/STLExtras.h"
-
-#include <algorithm>
-
-using namespace lldb;
-using namespace lldb_private;
-
-void ThisThread::SetName(llvm::StringRef name, int max_length) {
- std::string truncated_name(name.data());
-
- // Thread names are coming in like '<lldb.comm.debugger.edit>' and
- // '<lldb.comm.debugger.editline>'. So just chopping the end of the string
- // off leads to a lot of similar named threads. Go through the thread name
- // and search for the last dot and use that.
-
- if (max_length > 0 &&
- truncated_name.length() > static_cast<size_t>(max_length)) {
- // First see if we can get lucky by removing any initial or final braces.
- std::string::size_type begin = truncated_name.find_first_not_of("(<");
- std::string::size_type end = truncated_name.find_last_not_of(")>.");
- if (end - begin > static_cast<size_t>(max_length)) {
- // We're still too long. Since this is a dotted component, use everything
- // after the last
- // dot, up to a maximum of |length| characters.
- std::string::size_type last_dot = truncated_name.rfind('.');
- if (last_dot != std::string::npos)
- begin = last_dot + 1;
-
- end = std::min(end, begin + max_length);
- }
-
- std::string::size_type count = end - begin + 1;
- truncated_name = truncated_name.substr(begin, count);
- }
-
- SetName(truncated_name);
-}
diff --git a/source/Host/common/ThreadLauncher.cpp b/source/Host/common/ThreadLauncher.cpp
index b91c2fe9baab..32641efe408a 100644
--- a/source/Host/common/ThreadLauncher.cpp
+++ b/source/Host/common/ThreadLauncher.cpp
@@ -10,10 +10,9 @@
// lldb Includes
#include "lldb/Host/ThreadLauncher.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/HostThread.h"
-#include "lldb/Host/ThisThread.h"
+#include "lldb/Utility/Log.h"
#if defined(_WIN32)
#include "lldb/Host/windows/windows.h"
diff --git a/source/Host/common/UDPSocket.cpp b/source/Host/common/UDPSocket.cpp
index 972f87eb73d8..7ca62e7496ba 100644
--- a/source/Host/common/UDPSocket.cpp
+++ b/source/Host/common/UDPSocket.cpp
@@ -9,8 +9,8 @@
#include "lldb/Host/common/UDPSocket.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
#ifndef LLDB_DISABLE_POSIX
#include <arpa/inet.h>
@@ -38,7 +38,7 @@ UDPSocket::UDPSocket(bool child_processes_inherit, Error &error)
size_t UDPSocket::Send(const void *buf, const size_t num_bytes) {
return ::sendto(m_socket, static_cast<const char *>(buf), num_bytes, 0,
- m_send_sockaddr, m_send_sockaddr.GetLength());
+ m_sockaddr, m_sockaddr.GetLength());
}
Error UDPSocket::Connect(llvm::StringRef name) {
@@ -55,9 +55,8 @@ Error UDPSocket::Accept(llvm::StringRef name, bool child_processes_inherit,
}
Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
- Socket *&send_socket, Socket *&recv_socket) {
- std::unique_ptr<UDPSocket> final_send_socket;
- std::unique_ptr<UDPSocket> final_recv_socket;
+ Socket *&socket) {
+ std::unique_ptr<UDPSocket> final_socket;
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
@@ -70,25 +69,6 @@ Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
return error;
- // Setup the receiving end of the UDP connection on this localhost
- // on port zero. After we bind to port zero we can read the port.
- final_recv_socket.reset(new UDPSocket(child_processes_inherit, error));
- if (error.Success()) {
- // Socket was created, now lets bind to the requested port
- SocketAddress addr;
- addr.SetToAnyAddress(AF_INET, 0);
-
- if (::bind(final_recv_socket->GetNativeSocket(), addr, addr.GetLength()) ==
- -1) {
- // Bind failed...
- SetLastError(error);
- }
- }
-
- assert(error.Fail() == !(final_recv_socket && final_recv_socket->IsValid()));
- if (error.Fail())
- return error;
-
// At this point we have setup the receive port, now we need to
// setup the UDP send socket
@@ -118,8 +98,8 @@ Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
service_info_ptr->ai_family, service_info_ptr->ai_socktype,
service_info_ptr->ai_protocol, child_processes_inherit, error);
if (error.Success()) {
- final_send_socket.reset(new UDPSocket(send_fd));
- final_send_socket->m_send_sockaddr = service_info_ptr;
+ final_socket.reset(new UDPSocket(send_fd));
+ final_socket->m_sockaddr = service_info_ptr;
break;
} else
continue;
@@ -127,11 +107,31 @@ Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
::freeaddrinfo(service_info_list);
- if (!final_send_socket)
+ if (!final_socket)
+ return error;
+
+ SocketAddress bind_addr;
+
+ // Only bind to the loopback address if we are expecting a connection from
+ // localhost to avoid any firewall issues.
+ const bool bind_addr_success = (host_str == "127.0.0.1" || host_str == "localhost")
+ ? bind_addr.SetToLocalhost(kDomain, port)
+ : bind_addr.SetToAnyAddress(kDomain, port);
+
+ if (!bind_addr_success) {
+ error.SetErrorString("Failed to get hostspec to bind for");
return error;
+ }
+
+ bind_addr.SetPort(0); // Let the source port # be determined dynamically
+
+ err = ::bind(final_socket->GetNativeSocket(), bind_addr, bind_addr.GetLength());
+
+ struct sockaddr_in source_info;
+ socklen_t address_len = sizeof (struct sockaddr_in);
+ err = ::getsockname(final_socket->GetNativeSocket(), (struct sockaddr *) &source_info, &address_len);
- send_socket = final_send_socket.release();
- recv_socket = final_recv_socket.release();
+ socket = final_socket.release();
error.Clear();
return error;
}
diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp
index aeab780ac453..9415b2bb3fd0 100644
--- a/source/Host/freebsd/Host.cpp
+++ b/source/Host/freebsd/Host.cpp
@@ -26,21 +26,21 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/NameMatches.h"
#include "llvm/Support/Host.h"
@@ -52,18 +52,6 @@ extern char **environ;
using namespace lldb;
using namespace lldb_private;
-size_t Host::GetEnvironment(StringList &env) {
- char *v;
- char **var = environ;
- for (; var != NULL && *var != NULL; ++var) {
- v = strchr(*var, (int)'-');
- if (v == NULL)
- continue;
- env.AppendString(v);
- }
- return env.GetSize();
-}
-
static bool
GetFreeBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
ProcessInstanceInfo &process_info) {
@@ -243,21 +231,13 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
return false;
}
-lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
- int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, 0};
- size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo);
- DataBufferSP buf_sp;
-
- std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(auxv_size, 0));
-
- mib[3] = process->GetID();
- if (::sysctl(mib, 4, buf_ap->GetBytes(), &auxv_size, NULL, 0) == 0) {
- buf_sp.reset(buf_ap.release());
- } else {
- perror("sysctl failed on auxv");
- }
-
- return buf_sp;
+size_t Host::GetEnvironment(StringList &env) {
+ char **host_env = environ;
+ char *env_entry;
+ size_t i;
+ for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+ env.AppendString(env_entry);
+ return i;
}
Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
diff --git a/source/Host/freebsd/HostInfoFreeBSD.cpp b/source/Host/freebsd/HostInfoFreeBSD.cpp
index fb9d86678dbb..9c82fcca7563 100644
--- a/source/Host/freebsd/HostInfoFreeBSD.cpp
+++ b/source/Host/freebsd/HostInfoFreeBSD.cpp
@@ -14,11 +14,10 @@
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/utsname.h>
+#include <unistd.h>
using namespace lldb_private;
-uint32_t HostInfoFreeBSD::GetMaxThreadNameLength() { return 16; }
-
bool HostInfoFreeBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
uint32_t &update) {
struct utsname un;
diff --git a/source/Host/freebsd/HostThreadFreeBSD.cpp b/source/Host/freebsd/HostThreadFreeBSD.cpp
deleted file mode 100644
index 97d4d9d05b66..000000000000
--- a/source/Host/freebsd/HostThreadFreeBSD.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-//===-- HostThreadFreeBSD.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// lldb Includes
-#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
-#include "lldb/Host/Host.h"
-
-// C includes
-#include <errno.h>
-#include <pthread.h>
-#if defined(__FreeBSD__)
-#include <pthread_np.h>
-#endif
-#include <stdlib.h>
-#include <sys/sysctl.h>
-#include <sys/user.h>
-
-// C++ includes
-#include <string>
-
-using namespace lldb_private;
-
-HostThreadFreeBSD::HostThreadFreeBSD() {}
-
-HostThreadFreeBSD::HostThreadFreeBSD(lldb::thread_t thread)
- : HostThreadPosix(thread) {}
-
-void HostThreadFreeBSD::GetName(lldb::tid_t tid,
- llvm::SmallVectorImpl<char> &name) {
- name.clear();
- int pid = Host::GetCurrentProcessID();
-
- 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,
- (int)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;
- }
- 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)tid) {
- name.append(kp[i].ki_tdname, kp[i].ki_tdname + strlen(kp[i].ki_tdname));
- break;
- }
- }
- free(kp);
-}
diff --git a/source/Host/freebsd/ThisThread.cpp b/source/Host/freebsd/ThisThread.cpp
deleted file mode 100644
index da0f2379a870..000000000000
--- a/source/Host/freebsd/ThisThread.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Host/HostNativeThread.h"
-
-#include "llvm/ADT/SmallVector.h"
-
-#include <pthread.h>
-#if defined(__FreeBSD__)
-#include <pthread_np.h>
-#endif
-
-using namespace lldb_private;
-
-void ThisThread::SetName(llvm::StringRef name) {
-#if defined(__FreeBSD__) // Kfreebsd does not have a simple alternative
- ::pthread_set_name_np(::pthread_self(), name.data());
-#endif
-}
-
-void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
-#if defined(__FreeBSD__)
- HostNativeThread::GetName(::pthread_getthreadid_np(), name);
-#else
- // Kfreebsd
- HostNativeThread::GetName((unsigned)pthread_self(), name);
-#endif
-}
diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp
index 8acf4a94e5bf..810222cbbf2f 100644
--- a/source/Host/linux/Host.cpp
+++ b/source/Host/linux/Host.cpp
@@ -21,150 +21,195 @@
// Other libraries and framework includes
#include "llvm/Support/ScopedPrinter.h"
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
-#include "Plugins/Process/Linux/ProcFileReader.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Symbol/ObjectFile.h"
using namespace lldb;
using namespace lldb_private;
-typedef enum ProcessStateFlags {
- eProcessStateRunning = (1u << 0), // Running
- eProcessStateSleeping = (1u << 1), // Sleeping in an interruptible wait
- eProcessStateWaiting = (1u << 2), // Waiting in an uninterruptible disk sleep
- eProcessStateZombie = (1u << 3), // Zombie
- eProcessStateTracedOrStopped = (1u << 4), // Traced or stopped (on a signal)
- eProcessStatePaging = (1u << 5) // Paging
-} ProcessStateFlags;
-
-typedef struct ProcessStatInfo {
- lldb::pid_t ppid; // Parent Process ID
- uint32_t fProcessState; // ProcessStateFlags
-} ProcessStatInfo;
-
-// Get the process info with additional information from /proc/$PID/stat (like
-// process state, and tracer pid).
-static bool GetProcessAndStatInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info,
- ProcessStatInfo &stat_info,
- lldb::pid_t &tracerpid);
-
-static bool ReadProcPseudoFileStat(lldb::pid_t pid,
- ProcessStatInfo &stat_info) {
- // Read the /proc/$PID/stat file.
- lldb::DataBufferSP buf_sp =
- process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "stat");
-
- // The filename of the executable is stored in parenthesis right after the
- // pid. We look for the closing
- // parenthesis for the filename and work from there in case the name has
- // something funky like ')' in it.
- const char *filename_end = strrchr((const char *)buf_sp->GetBytes(), ')');
- if (filename_end) {
- char state = '\0';
- int ppid = LLDB_INVALID_PROCESS_ID;
-
- // Read state and ppid.
- sscanf(filename_end + 1, " %c %d", &state, &ppid);
-
- stat_info.ppid = ppid;
-
- switch (state) {
- case 'R':
- stat_info.fProcessState |= eProcessStateRunning;
- break;
- case 'S':
- stat_info.fProcessState |= eProcessStateSleeping;
- break;
- case 'D':
- stat_info.fProcessState |= eProcessStateWaiting;
- break;
- case 'Z':
- stat_info.fProcessState |= eProcessStateZombie;
- break;
- case 'T':
- stat_info.fProcessState |= eProcessStateTracedOrStopped;
- break;
- case 'W':
- stat_info.fProcessState |= eProcessStatePaging;
- break;
+namespace {
+enum class ProcessState {
+ Unknown,
+ DiskSleep,
+ Paging,
+ Running,
+ Sleeping,
+ TracedOrStopped,
+ Zombie,
+};
+}
+
+static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo &ProcessInfo,
+ ProcessState &State, ::pid_t &TracerPid) {
+ auto BufferOrError = getProcFile(Pid, "status");
+ if (!BufferOrError)
+ return false;
+
+ llvm::StringRef Rest = BufferOrError.get()->getBuffer();
+ while(!Rest.empty()) {
+ llvm::StringRef Line;
+ std::tie(Line, Rest) = Rest.split('\n');
+
+ if (Line.consume_front("Gid:")) {
+ // Real, effective, saved set, and file system GIDs. Read the first two.
+ Line = Line.ltrim();
+ uint32_t RGid, EGid;
+ Line.consumeInteger(10, RGid);
+ Line = Line.ltrim();
+ Line.consumeInteger(10, EGid);
+
+ ProcessInfo.SetGroupID(RGid);
+ ProcessInfo.SetEffectiveGroupID(EGid);
+ } else if (Line.consume_front("Uid:")) {
+ // Real, effective, saved set, and file system UIDs. Read the first two.
+ Line = Line.ltrim();
+ uint32_t RUid, EUid;
+ Line.consumeInteger(10, RUid);
+ Line = Line.ltrim();
+ Line.consumeInteger(10, EUid);
+
+ ProcessInfo.SetUserID(RUid);
+ ProcessInfo.SetEffectiveUserID(EUid);
+ } else if (Line.consume_front("PPid:")) {
+ ::pid_t PPid;
+ Line.ltrim().consumeInteger(10, PPid);
+ ProcessInfo.SetParentProcessID(PPid);
+ } else if (Line.consume_front("State:")) {
+ char S = Line.ltrim().front();
+ switch (S) {
+ case 'R':
+ State = ProcessState::Running;
+ break;
+ case 'S':
+ State = ProcessState::Sleeping;
+ break;
+ case 'D':
+ State = ProcessState::DiskSleep;
+ break;
+ case 'Z':
+ State = ProcessState::Zombie;
+ break;
+ case 'T':
+ State = ProcessState::TracedOrStopped;
+ break;
+ case 'W':
+ State = ProcessState::Paging;
+ break;
+ }
+ } else if (Line.consume_front("TracerPid:")) {
+ Line = Line.ltrim();
+ Line.consumeInteger(10, TracerPid);
}
+ }
+ return true;
+}
- return true;
+static bool IsDirNumeric(const char *dname) {
+ for (; *dname; dname++) {
+ if (!isdigit(*dname))
+ return false;
}
+ return true;
+}
+static bool GetELFProcessCPUType(llvm::StringRef exe_path,
+ ProcessInstanceInfo &process_info) {
+ // Clear the architecture.
+ process_info.GetArchitecture().Clear();
+
+ ModuleSpecList specs;
+ FileSpec filespec(exe_path, false);
+ const size_t num_specs =
+ ObjectFile::GetModuleSpecifications(filespec, 0, 0, specs);
+ // GetModuleSpecifications() could fail if the executable has been deleted or
+ // is locked.
+ // But it shouldn't return more than 1 architecture.
+ assert(num_specs <= 1 && "Linux plugin supports only a single architecture");
+ if (num_specs == 1) {
+ ModuleSpec module_spec;
+ if (specs.GetModuleSpecAtIndex(0, module_spec) &&
+ module_spec.GetArchitecture().IsValid()) {
+ process_info.GetArchitecture() = module_spec.GetArchitecture();
+ return true;
+ }
+ }
return false;
}
-static void GetLinuxProcessUserAndGroup(lldb::pid_t pid,
- ProcessInstanceInfo &process_info,
- lldb::pid_t &tracerpid) {
+static bool GetProcessAndStatInfo(::pid_t pid,
+ ProcessInstanceInfo &process_info,
+ ProcessState &State, ::pid_t &tracerpid) {
tracerpid = 0;
- uint32_t rUid = UINT32_MAX; // Real User ID
- uint32_t eUid = UINT32_MAX; // Effective User ID
- uint32_t rGid = UINT32_MAX; // Real Group ID
- uint32_t eGid = UINT32_MAX; // Effective Group ID
-
- // Read the /proc/$PID/status file and parse the Uid:, Gid:, and TracerPid:
- // fields.
- lldb::DataBufferSP buf_sp =
- process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "status");
-
- static const char uid_token[] = "Uid:";
- char *buf_uid = strstr((char *)buf_sp->GetBytes(), uid_token);
- if (buf_uid) {
- // Real, effective, saved set, and file system UIDs. Read the first two.
- buf_uid += sizeof(uid_token);
- rUid = strtol(buf_uid, &buf_uid, 10);
- eUid = strtol(buf_uid, &buf_uid, 10);
- }
+ process_info.Clear();
- static const char gid_token[] = "Gid:";
- char *buf_gid = strstr((char *)buf_sp->GetBytes(), gid_token);
- if (buf_gid) {
- // Real, effective, saved set, and file system GIDs. Read the first two.
- buf_gid += sizeof(gid_token);
- rGid = strtol(buf_gid, &buf_gid, 10);
- eGid = strtol(buf_gid, &buf_gid, 10);
- }
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+ // We can't use getProcFile here because proc/[pid]/exe is a symbolic link.
+ llvm::SmallString<64> ProcExe;
+ (llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe);
+ std::string ExePath(PATH_MAX, '\0');
- static const char tracerpid_token[] = "TracerPid:";
- char *buf_tracerpid = strstr((char *)buf_sp->GetBytes(), tracerpid_token);
- if (buf_tracerpid) {
- // Tracer PID. 0 if we're not being debugged.
- buf_tracerpid += sizeof(tracerpid_token);
- tracerpid = strtol(buf_tracerpid, &buf_tracerpid, 10);
+ ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX);
+ if (len <= 0) {
+ LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid,
+ Error(errno, eErrorTypePOSIX));
+ return false;
}
+ ExePath.resize(len);
- process_info.SetUserID(rUid);
- process_info.SetEffectiveUserID(eUid);
- process_info.SetGroupID(rGid);
- process_info.SetEffectiveGroupID(eGid);
-}
+ // If the binary has been deleted, the link name has " (deleted)" appended.
+ // Remove if there.
+ llvm::StringRef PathRef = ExePath;
+ PathRef.consume_back(" (deleted)");
-lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
- return process_linux::ProcFileReader::ReadIntoDataBuffer(process->GetID(),
- "auxv");
-}
+ GetELFProcessCPUType(PathRef, process_info);
-lldb::DataBufferSP Host::GetAuxvData(lldb::pid_t pid) {
- return process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "auxv");
-}
+ // Get the process environment.
+ auto BufferOrError = getProcFile(pid, "environ");
+ if (!BufferOrError)
+ return false;
+ std::unique_ptr<llvm::MemoryBuffer> Environ = std::move(*BufferOrError);
-static bool IsDirNumeric(const char *dname) {
- for (; *dname; dname++) {
- if (!isdigit(*dname))
- return false;
+ // Get the command line used to start the process.
+ BufferOrError = getProcFile(pid, "cmdline");
+ if (!BufferOrError)
+ return false;
+ std::unique_ptr<llvm::MemoryBuffer> Cmdline = std::move(*BufferOrError);
+
+ // Get User and Group IDs and get tracer pid.
+ if (!GetStatusInfo(pid, process_info, State, tracerpid))
+ return false;
+
+ process_info.SetProcessID(pid);
+ process_info.GetExecutableFile().SetFile(PathRef, false);
+ process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());
+
+ llvm::StringRef Rest = Environ->getBuffer();
+ while (!Rest.empty()) {
+ llvm::StringRef Var;
+ std::tie(Var, Rest) = Rest.split('\0');
+ process_info.GetEnvironmentEntries().AppendArgument(Var);
}
+
+ llvm::StringRef Arg0;
+ std::tie(Arg0, Rest) = Cmdline->getBuffer().split('\0');
+ process_info.SetArg0(Arg0);
+ while (!Rest.empty()) {
+ llvm::StringRef Arg;
+ std::tie(Arg, Rest) = Rest.split('\0');
+ process_info.GetArguments().AppendArgument(Arg);
+ }
+
return true;
}
@@ -189,19 +234,18 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
if (pid == our_pid)
continue;
- lldb::pid_t tracerpid;
- ProcessStatInfo stat_info;
+ ::pid_t tracerpid;
+ ProcessState State;
ProcessInstanceInfo process_info;
- if (!GetProcessAndStatInfo(pid, process_info, stat_info, tracerpid))
+ if (!GetProcessAndStatInfo(pid, process_info, State, tracerpid))
continue;
// Skip if process is being debugged.
if (tracerpid != 0)
continue;
- // Skip zombies.
- if (stat_info.fProcessState & eProcessStateZombie)
+ if (State == ProcessState::Zombie)
continue;
// Check for user match if we're not matching all users and not running as
@@ -246,121 +290,10 @@ bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
return tids_changed;
}
-static bool GetELFProcessCPUType(const char *exe_path,
- ProcessInstanceInfo &process_info) {
- // Clear the architecture.
- process_info.GetArchitecture().Clear();
-
- ModuleSpecList specs;
- FileSpec filespec(exe_path, false);
- const size_t num_specs =
- ObjectFile::GetModuleSpecifications(filespec, 0, 0, specs);
- // GetModuleSpecifications() could fail if the executable has been deleted or
- // is locked.
- // But it shouldn't return more than 1 architecture.
- assert(num_specs <= 1 && "Linux plugin supports only a single architecture");
- if (num_specs == 1) {
- ModuleSpec module_spec;
- if (specs.GetModuleSpecAtIndex(0, module_spec) &&
- module_spec.GetArchitecture().IsValid()) {
- process_info.GetArchitecture() = module_spec.GetArchitecture();
- return true;
- }
- }
- return false;
-}
-
-static bool GetProcessAndStatInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info,
- ProcessStatInfo &stat_info,
- lldb::pid_t &tracerpid) {
- tracerpid = 0;
- process_info.Clear();
- ::memset(&stat_info, 0, sizeof(stat_info));
- stat_info.ppid = LLDB_INVALID_PROCESS_ID;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- // Use special code here because proc/[pid]/exe is a symbolic link.
- char link_path[PATH_MAX];
- char exe_path[PATH_MAX] = "";
- if (snprintf(link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", pid) <= 0) {
- if (log)
- log->Printf("%s: failed to sprintf pid %" PRIu64, __FUNCTION__, pid);
- return false;
- }
-
- ssize_t len = readlink(link_path, exe_path, sizeof(exe_path) - 1);
- if (len <= 0) {
- if (log)
- log->Printf("%s: failed to read link %s: %s", __FUNCTION__, link_path,
- strerror(errno));
- return false;
- }
-
- // readlink does not append a null byte.
- exe_path[len] = 0;
-
- // If the binary has been deleted, the link name has " (deleted)" appended.
- // Remove if there.
- static const ssize_t deleted_len = strlen(" (deleted)");
- if (len > deleted_len &&
- !strcmp(exe_path + len - deleted_len, " (deleted)")) {
- exe_path[len - deleted_len] = 0;
- } else {
- GetELFProcessCPUType(exe_path, process_info);
- }
-
- process_info.SetProcessID(pid);
- process_info.GetExecutableFile().SetFile(exe_path, false);
- process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());
-
- lldb::DataBufferSP buf_sp;
-
- // Get the process environment.
- buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "environ");
- Args &info_env = process_info.GetEnvironmentEntries();
- char *next_var = (char *)buf_sp->GetBytes();
- char *end_buf = next_var + buf_sp->GetByteSize();
- while (next_var < end_buf && 0 != *next_var) {
- info_env.AppendArgument(llvm::StringRef(next_var));
- next_var += strlen(next_var) + 1;
- }
-
- // Get the command line used to start the process.
- buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "cmdline");
-
- // Grab Arg0 first, if there is one.
- char *cmd = (char *)buf_sp->GetBytes();
- if (cmd) {
- process_info.SetArg0(cmd);
-
- // Now process any remaining arguments.
- Args &info_args = process_info.GetArguments();
- char *next_arg = cmd + strlen(cmd) + 1;
- end_buf = cmd + buf_sp->GetByteSize();
- while (next_arg < end_buf && 0 != *next_arg) {
- info_args.AppendArgument(llvm::StringRef(next_arg));
- next_arg += strlen(next_arg) + 1;
- }
- }
-
- // Read /proc/$PID/stat to get our parent pid.
- if (ReadProcPseudoFileStat(pid, stat_info)) {
- process_info.SetParentProcessID(stat_info.ppid);
- }
-
- // Get User and Group IDs and get tracer pid.
- GetLinuxProcessUserAndGroup(pid, process_info, tracerpid);
-
- return true;
-}
-
bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
- lldb::pid_t tracerpid;
- ProcessStatInfo stat_info;
-
- return GetProcessAndStatInfo(pid, process_info, stat_info, tracerpid);
+ ::pid_t tracerpid;
+ ProcessState State;
+ return GetProcessAndStatInfo(pid, process_info, State, tracerpid);
}
size_t Host::GetEnvironment(StringList &env) {
diff --git a/source/Host/linux/HostInfoLinux.cpp b/source/Host/linux/HostInfoLinux.cpp
index 2a01f0676142..3ff722d5c109 100644
--- a/source/Host/linux/HostInfoLinux.cpp
+++ b/source/Host/linux/HostInfoLinux.cpp
@@ -8,7 +8,9 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/linux/HostInfoLinux.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/Threading.h"
#include <limits.h>
#include <stdio.h>
@@ -39,13 +41,11 @@ void HostInfoLinux::Initialize() {
g_fields = new HostInfoLinuxFields();
}
-uint32_t HostInfoLinux::GetMaxThreadNameLength() { return 16; }
-
bool HostInfoLinux::GetOSVersion(uint32_t &major, uint32_t &minor,
uint32_t &update) {
static bool success = false;
- 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, []() {
struct utsname un;
if (uname(&un) == 0) {
@@ -100,8 +100,8 @@ bool HostInfoLinux::GetOSKernelDescription(std::string &s) {
llvm::StringRef HostInfoLinux::GetDistributionId() {
// Try to run 'lbs_release -i', and use that response
// for the distribution id.
- 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, []() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST));
if (log)
diff --git a/source/Host/linux/HostThreadLinux.cpp b/source/Host/linux/HostThreadLinux.cpp
deleted file mode 100644
index 625f05d0e9d8..000000000000
--- a/source/Host/linux/HostThreadLinux.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//===-- HostThreadLinux.cpp -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/linux/HostThreadLinux.h"
-#include "Plugins/Process/Linux/ProcFileReader.h"
-#include "lldb/Core/DataBuffer.h"
-
-#include "llvm/ADT/SmallVector.h"
-
-#include <pthread.h>
-
-using namespace lldb_private;
-
-HostThreadLinux::HostThreadLinux() : HostThreadPosix() {}
-
-HostThreadLinux::HostThreadLinux(lldb::thread_t thread)
- : HostThreadPosix(thread) {}
-
-void HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name) {
-#if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__)
- ::pthread_setname_np(thread, name.data());
-#else
- (void)thread;
- (void)name;
-#endif
-}
-
-void HostThreadLinux::GetName(lldb::thread_t thread,
- llvm::SmallVectorImpl<char> &name) {
- // Read /proc/$TID/comm file.
- lldb::DataBufferSP buf_sp =
- process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm");
- const char *comm_str = (const char *)buf_sp->GetBytes();
- const char *cr_str = ::strchr(comm_str, '\n');
- size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
-
- name.clear();
- name.append(comm_str, comm_str + length);
-}
diff --git a/source/Host/linux/ProcessLauncherLinux.cpp b/source/Host/linux/ProcessLauncherLinux.cpp
index 27a6329da067..e69de29bb2d1 100644
--- a/source/Host/linux/ProcessLauncherLinux.cpp
+++ b/source/Host/linux/ProcessLauncherLinux.cpp
@@ -1,216 +0,0 @@
-//===-- ProcessLauncherLinux.cpp --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/linux/ProcessLauncherLinux.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostProcess.h"
-#include "lldb/Host/Pipe.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
-
-#include <limits.h>
-#include <sys/personality.h>
-#include <sys/ptrace.h>
-#include <sys/wait.h>
-
-#include <sstream>
-
-using namespace lldb;
-using namespace lldb_private;
-
-static void FixupEnvironment(Args &env) {
-#ifdef __ANDROID__
- // If there is no PATH variable specified inside the environment then set the
- // path to /system/bin. It is required because the default path used by
- // execve() is wrong on android.
- static const char *path = "PATH=";
- for (auto &entry : env.entries()) {
- if (entry.ref.startswith(path))
- return;
- }
- env.AppendArgument(llvm::StringRef("PATH=/system/bin"));
-#endif
-}
-
-static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
- const char *operation) {
- std::ostringstream os;
- os << operation << " failed: " << strerror(errno);
- write(error_fd, os.str().data(), os.str().size());
- close(error_fd);
- _exit(1);
-}
-
-static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
- int flags) {
- int target_fd = ::open(file_spec.GetCString(), flags, 0666);
-
- if (target_fd == -1)
- ExitWithError(error_fd, "DupDescriptor-open");
-
- if (target_fd == fd)
- return;
-
- if (::dup2(target_fd, fd) == -1)
- ExitWithError(error_fd, "DupDescriptor-dup2");
-
- ::close(target_fd);
- return;
-}
-
-static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
- const ProcessLaunchInfo &info) {
- // First, make sure we disable all logging. If we are logging to stdout, our
- // logs can be
- // mistaken for inferior output.
- Log::DisableAllLogChannels(nullptr);
-
- // Do not inherit setgid powers.
- if (setgid(getgid()) != 0)
- ExitWithError(error_fd, "setgid");
-
- if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
- if (setpgid(0, 0) != 0)
- ExitWithError(error_fd, "setpgid");
- }
-
- for (size_t i = 0; i < info.GetNumFileActions(); ++i) {
- const FileAction &action = *info.GetFileActionAtIndex(i);
- switch (action.GetAction()) {
- case FileAction::eFileActionClose:
- if (close(action.GetFD()) != 0)
- ExitWithError(error_fd, "close");
- break;
- case FileAction::eFileActionDuplicate:
- if (dup2(action.GetFD(), action.GetActionArgument()) == -1)
- ExitWithError(error_fd, "dup2");
- break;
- case FileAction::eFileActionOpen:
- DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(),
- action.GetActionArgument());
- break;
- case FileAction::eFileActionNone:
- break;
- }
- }
-
- const char **argv = info.GetArguments().GetConstArgumentVector();
-
- // Change working directory
- if (info.GetWorkingDirectory() &&
- 0 != ::chdir(info.GetWorkingDirectory().GetCString()))
- ExitWithError(error_fd, "chdir");
-
- // Disable ASLR if requested.
- if (info.GetFlags().Test(lldb::eLaunchFlagDisableASLR)) {
- const unsigned long personality_get_current = 0xffffffff;
- int value = personality(personality_get_current);
- if (value == -1)
- ExitWithError(error_fd, "personality get");
-
- value = personality(ADDR_NO_RANDOMIZE | value);
- if (value == -1)
- ExitWithError(error_fd, "personality set");
- }
-
- Args env = info.GetEnvironmentEntries();
- FixupEnvironment(env);
- const char **envp = env.GetConstArgumentVector();
-
- // Clear the signal mask to prevent the child from being affected by
- // any masking done by the parent.
- sigset_t set;
- if (sigemptyset(&set) != 0 ||
- pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0)
- ExitWithError(error_fd, "pthread_sigmask");
-
- if (info.GetFlags().Test(eLaunchFlagDebug)) {
- // HACK:
- // Close everything besides stdin, stdout, and stderr that has no file
- // action to avoid leaking. Only do this when debugging, as elsewhere we
- // actually rely on
- // passing open descriptors to child processes.
- for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd)
- if (!info.GetFileActionForFD(fd) && fd != error_fd)
- close(fd);
-
- // Start tracing this child that is about to exec.
- if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
- ExitWithError(error_fd, "ptrace");
- }
-
- // Execute. We should never return...
- execve(argv[0], const_cast<char *const *>(argv),
- const_cast<char *const *>(envp));
-
- if (errno == ETXTBSY) {
- // On android M and earlier we can get this error because the adb deamon can
- // hold a write
- // handle on the executable even after it has finished uploading it. This
- // state lasts
- // only a short time and happens only when there are many concurrent adb
- // commands being
- // issued, such as when running the test suite. (The file remains open when
- // someone does
- // an "adb shell" command in the fork() child before it has had a chance to
- // exec.) Since
- // this state should clear up quickly, wait a while and then give it one
- // more go.
- usleep(50000);
- execve(argv[0], const_cast<char *const *>(argv),
- const_cast<char *const *>(envp));
- }
-
- // ...unless exec fails. In which case we definitely need to end the child
- // here.
- ExitWithError(error_fd, "execve");
-}
-
-HostProcess
-ProcessLauncherLinux::LaunchProcess(const ProcessLaunchInfo &launch_info,
- Error &error) {
- char exe_path[PATH_MAX];
- launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
-
- // A pipe used by the child process to report errors.
- PipePosix pipe;
- const bool child_processes_inherit = false;
- error = pipe.CreateNew(child_processes_inherit);
- if (error.Fail())
- return HostProcess();
-
- ::pid_t pid = ::fork();
- if (pid == -1) {
- // Fork failed
- error.SetErrorStringWithFormat("Fork failed with error message: %s",
- strerror(errno));
- return HostProcess(LLDB_INVALID_PROCESS_ID);
- }
- if (pid == 0) {
- // child process
- pipe.CloseReadFileDescriptor();
- ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
- }
-
- // parent process
-
- pipe.CloseWriteFileDescriptor();
- char buf[1000];
- int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
-
- if (r == 0)
- return HostProcess(pid); // No error. We're done.
-
- error.SetErrorString(buf);
-
- waitpid(pid, nullptr, 0);
-
- return HostProcess();
-}
diff --git a/source/Host/linux/Support.cpp b/source/Host/linux/Support.cpp
new file mode 100644
index 000000000000..8fbb60052e3f
--- /dev/null
+++ b/source/Host/linux/Support.cpp
@@ -0,0 +1,34 @@
+//===-- Support.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/linux/Support.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ std::string File =
+ ("/proc/" + llvm::Twine(pid) + "/task/" + llvm::Twine(tid) + "/" + file)
+ .str();
+ auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
+ if (!Ret)
+ LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
+ return Ret;
+}
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+lldb_private::getProcFile(::pid_t pid, const llvm::Twine &file) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ std::string File = ("/proc/" + llvm::Twine(pid) + "/" + file).str();
+ auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
+ if (!Ret)
+ LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
+ return Ret;
+}
diff --git a/source/Host/linux/ThisThread.cpp b/source/Host/linux/ThisThread.cpp
deleted file mode 100644
index f65440b9d778..000000000000
--- a/source/Host/linux/ThisThread.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Host/HostNativeThread.h"
-
-#include "llvm/ADT/SmallVector.h"
-
-#include <pthread.h>
-
-using namespace lldb_private;
-
-void ThisThread::SetName(llvm::StringRef name) {
- HostNativeThread::SetName(::pthread_self(), name);
-}
-
-void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
- HostNativeThread::GetName(::pthread_self(), name);
-}
diff --git a/source/Host/macosx/Host.mm b/source/Host/macosx/Host.mm
index 99bc7ec8ff15..4c51e8ff154b 100644
--- a/source/Host/macosx/Host.mm
+++ b/source/Host/macosx/Host.mm
@@ -56,24 +56,25 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Communication.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/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/FileSystem.h"
#include "cfcpp/CFCBundle.h"
#include "cfcpp/CFCMutableArray.h"
@@ -101,7 +102,7 @@ using namespace lldb_private;
bool Host::GetBundleDirectory(const FileSpec &file,
FileSpec &bundle_directory) {
#if defined(__APPLE__)
- if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
+ if (llvm::sys::fs::is_directory(file.GetPath())) {
char path[PATH_MAX];
if (file.GetPath(path, sizeof(path))) {
CFCBundle bundle(path);
@@ -118,7 +119,7 @@ bool Host::GetBundleDirectory(const FileSpec &file,
bool Host::ResolveExecutableInBundle(FileSpec &file) {
#if defined(__APPLE__)
- if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
+ if (llvm::sys::fs::is_directory(file.GetPath())) {
char path[PATH_MAX];
if (file.GetPath(path, sizeof(path))) {
CFCBundle bundle(path);
@@ -528,7 +529,7 @@ LaunchInNewTerminalWithAppleScript(const char *exe_path,
WaitForProcessToSIGSTOP(pid, 5);
}
- FileSystem::Unlink(FileSpec{unix_socket_name, false});
+ llvm::sys::fs::remove(unix_socket_name);
[applescript release];
if (pid != LLDB_INVALID_PROCESS_ID)
launch_info.SetProcessID(pid);
@@ -957,9 +958,7 @@ static Error getXPCAuthorization(ProcessLaunchInfo &launch_info) {
if (createStatus != errAuthorizationSuccess) {
error.SetError(1, eErrorTypeGeneric);
error.SetErrorString("Can't create authorizationRef.");
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
@@ -1012,9 +1011,7 @@ static Error getXPCAuthorization(ProcessLaunchInfo &launch_info) {
error.SetError(2, eErrorTypeGeneric);
error.SetErrorStringWithFormat(
"Launching as root needs root authorization.");
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
if (authorizationRef) {
AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
@@ -1050,9 +1047,7 @@ static Error LaunchProcessXPC(const char *exe_path,
error.SetError(3, eErrorTypeGeneric);
error.SetErrorStringWithFormat("Launching root via XPC needs to "
"externalize authorization reference.");
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
xpc_service = LaunchUsingXPCRightName;
@@ -1060,9 +1055,7 @@ static Error LaunchProcessXPC(const char *exe_path,
error.SetError(4, eErrorTypeGeneric);
error.SetErrorStringWithFormat(
"Launching via XPC is only currently available for root.");
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
@@ -1146,9 +1139,7 @@ static Error LaunchProcessXPC(const char *exe_path,
error.SetErrorStringWithFormat(
"Problems with launching via XPC. Error type : %i, code : %i",
errorType, errorCode);
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
if (authorizationRef) {
AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
@@ -1160,9 +1151,7 @@ static Error LaunchProcessXPC(const char *exe_path,
error.SetErrorStringWithFormat(
"Problems with launching via XPC. XPC error : %s",
xpc_dictionary_get_string(reply, XPC_ERROR_KEY_DESCRIPTION));
- if (log) {
- error.PutToLog(log, "%s", error.AsCString());
- }
+ LLDB_LOG(log, "error: {0}", error);
}
return error;
@@ -1196,8 +1185,8 @@ Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
ModuleSpec exe_module_spec(launch_info.GetExecutableFile(),
launch_info.GetArchitecture());
- FileSpec::FileType file_type = exe_module_spec.GetFileSpec().GetFileType();
- if (file_type != FileSpec::eFileTypeRegular) {
+ if (!llvm::sys::fs::is_regular_file(
+ exe_module_spec.GetFileSpec().GetPath())) {
lldb::ModuleSP exe_module_sp;
error = host_platform_sp->ResolveExecutable(exe_module_spec, exe_module_sp,
NULL);
@@ -1458,7 +1447,3 @@ void Host::SystemLog(SystemLogType type, const char *format, va_list args) {
::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
}
}
-
-lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
- return lldb::DataBufferSP();
-}
diff --git a/source/Host/macosx/HostInfoMacOSX.mm b/source/Host/macosx/HostInfoMacOSX.mm
index 1c526c6ecccb..8774c76ef2da 100644
--- a/source/Host/macosx/HostInfoMacOSX.mm
+++ b/source/Host/macosx/HostInfoMacOSX.mm
@@ -11,13 +11,14 @@
#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#endif
-#include "lldb/Core/Log.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/macosx/HostInfoMacOSX.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/SafeMachO.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
// C++ Includes
@@ -152,7 +153,7 @@ bool HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) {
// the lldb driver.
raw_path.append("/../bin");
FileSpec support_dir_spec(raw_path, true);
- if (!support_dir_spec.Exists() || !support_dir_spec.IsDirectory()) {
+ if (!llvm::sys::fs::is_directory(support_dir_spec.GetPath())) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("HostInfoMacOSX::%s(): failed to find support directory",
@@ -334,5 +335,3 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32,
}
}
}
-
-uint32_t HostInfoMacOSX::GetMaxThreadNameLength() { return 64; }
diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp
index c428377eb7d2..a5085681495d 100644
--- a/source/Host/macosx/Symbols.cpp
+++ b/source/Host/macosx/Symbols.cpp
@@ -24,20 +24,22 @@
#include "Host/macosx/cfcpp/CFCReleaser.h"
#include "Host/macosx/cfcpp/CFCString.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
#include "mach/machine.h"
+#include "llvm/Support/FileSystem.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace llvm::MachO;
@@ -101,7 +103,7 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
}
FileSpec dsym_filespec(path, path[0] == '~');
- if (dsym_filespec.GetFileType() == FileSpec::eFileTypeDirectory) {
+ if (llvm::sys::fs::is_directory(dsym_filespec.GetPath())) {
dsym_filespec =
Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch);
++items_found;
@@ -164,8 +166,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
FileSpec file_spec(path, true);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
- switch (file_spec.GetFileType()) {
- case FileSpec::eFileTypeDirectory: // Bundle directory?
+ using namespace llvm::sys::fs;
+ switch (get_file_type(file_spec.GetPath())) {
+
+ case file_type::directory_file: // Bundle directory?
{
CFCBundle bundle(path);
CFCReleaser<CFURLRef> bundle_exe_url(
@@ -193,15 +197,17 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
}
} break;
- case FileSpec::eFileTypePipe: // Forget pipes
- case FileSpec::eFileTypeSocket: // We can't process socket files
- case FileSpec::eFileTypeInvalid: // File doesn't exist...
+ case file_type::fifo_file: // Forget pipes
+ case file_type::socket_file: // We can't process socket files
+ case file_type::file_not_found: // File doesn't exist...
+ case file_type::status_error:
break;
- case FileSpec::eFileTypeUnknown:
- case FileSpec::eFileTypeRegular:
- case FileSpec::eFileTypeSymbolicLink:
- case FileSpec::eFileTypeOther:
+ case file_type::type_unknown:
+ case file_type::regular_file:
+ case file_type::symlink_file:
+ case file_type::block_file:
+ case file_type::character_file:
if (ObjectFile::GetModuleSpecifications(file_spec, 0, 0,
module_specs) &&
module_specs.FindMatchingModuleSpec(module_spec,
@@ -263,7 +269,9 @@ FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
module_specs)) {
ModuleSpec spec;
for (size_t i = 0; i < module_specs.GetSize(); ++i) {
- assert(module_specs.GetModuleSpecAtIndex(i, spec));
+ bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
+ UNUSED_IF_ASSERT_DISABLED(got_spec);
+ assert(got_spec);
if ((uuid == NULL ||
(spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
(arch == NULL ||
diff --git a/source/Host/macosx/ThisThread.cpp b/source/Host/macosx/ThisThread.cpp
deleted file mode 100644
index 5244ba014121..000000000000
--- a/source/Host/macosx/ThisThread.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/ThisThread.h"
-
-#include "llvm/ADT/SmallVector.h"
-#include <pthread.h>
-
-using namespace lldb_private;
-
-void ThisThread::SetName(llvm::StringRef name) {
-#if defined(__APPLE__)
- ::pthread_setname_np(name.str().c_str());
-#endif
-}
-
-void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
- // FIXME - implement this.
-}
diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp
index 717af9b20aeb..6a6b8ab51a17 100644
--- a/source/Host/netbsd/Host.cpp
+++ b/source/Host/netbsd/Host.cpp
@@ -1,5 +1,4 @@
-//===-- source/Host/netbsd/Host.cpp ------------------------------*- C++
-//-*-===//
+//===-- source/Host/netbsd/Host.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,7 +14,6 @@
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/types.h>
-#include <sys/user.h>
#include <limits.h>
@@ -27,21 +25,21 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/NameMatches.h"
#include "llvm/Support/Host.h"
@@ -54,15 +52,12 @@ using namespace lldb;
using namespace lldb_private;
size_t Host::GetEnvironment(StringList &env) {
- char *v;
- char **var = environ;
- for (; var != NULL && *var != NULL; ++var) {
- v = ::strchr(*var, (int)'-');
- if (v == NULL)
- continue;
- env.AppendString(v);
- }
- return env.GetSize();
+ char **host_env = environ;
+ char *env_entry;
+ size_t i;
+ for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+ env.AppendString(env_entry);
+ return i;
}
static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
@@ -259,10 +254,6 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
return false;
}
-lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
- return lldb::DataBufferSP();
-}
-
Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
return Error("unimplemented");
}
diff --git a/source/Host/netbsd/HostInfoNetBSD.cpp b/source/Host/netbsd/HostInfoNetBSD.cpp
index 3c1385ab562f..428183bbe2c3 100644
--- a/source/Host/netbsd/HostInfoNetBSD.cpp
+++ b/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -21,10 +21,6 @@
using namespace lldb_private;
-uint32_t HostInfoNetBSD::GetMaxThreadNameLength() {
- return PTHREAD_MAX_NAMELEN_NP;
-}
-
bool HostInfoNetBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
uint32_t &update) {
struct utsname un;
@@ -85,15 +81,15 @@ FileSpec HostInfoNetBSD::GetProgramFileSpec() {
static FileSpec g_program_filespec;
if (!g_program_filespec) {
- ssize_t len;
- static char buf[PATH_MAX];
- char name[PATH_MAX];
-
- ::snprintf(name, PATH_MAX, "/proc/%d/exe", ::getpid());
- len = ::readlink(name, buf, PATH_MAX - 1);
- if (len != -1) {
- buf[len] = '\0';
- g_program_filespec.SetFile(buf, false);
+ static const int name[] = {
+ CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
+ };
+ char path[MAXPATHLEN];
+ size_t len;
+
+ len = sizeof(path);
+ if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) {
+ g_program_filespec.SetFile(path, false);
}
}
return g_program_filespec;
diff --git a/source/Host/netbsd/HostThreadNetBSD.cpp b/source/Host/netbsd/HostThreadNetBSD.cpp
deleted file mode 100644
index e8c106b7f229..000000000000
--- a/source/Host/netbsd/HostThreadNetBSD.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- HostThreadNetBSD.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// lldb Includes
-#include "lldb/Host/netbsd/HostThreadNetBSD.h"
-#include "lldb/Host/Host.h"
-
-// C includes
-#include <errno.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/sysctl.h>
-#include <sys/user.h>
-
-// C++ includes
-#include <string>
-
-using namespace lldb_private;
-
-HostThreadNetBSD::HostThreadNetBSD() {}
-
-HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread)
- : HostThreadPosix(thread) {}
-
-void HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name) {
- ::pthread_setname_np(thread, "%s", const_cast<char *>(name.data()));
-}
-
-void HostThreadNetBSD::GetName(lldb::thread_t thread,
- llvm::SmallVectorImpl<char> &name) {
- char buf[PTHREAD_MAX_NAMELEN_NP];
- ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);
-
- name.clear();
- name.append(buf, buf + strlen(buf));
-}
diff --git a/source/Host/netbsd/ThisThread.cpp b/source/Host/netbsd/ThisThread.cpp
deleted file mode 100644
index ea16981ef257..000000000000
--- a/source/Host/netbsd/ThisThread.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Host/HostNativeThread.h"
-
-#include "llvm/ADT/SmallVector.h"
-
-#include <pthread.h>
-#include <string.h>
-
-using namespace lldb_private;
-
-void ThisThread::SetName(llvm::StringRef name) {
- HostNativeThread::SetName(::pthread_self(), name);
-}
-
-void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
- HostNativeThread::GetName(::pthread_self(), name);
-}
diff --git a/source/Host/openbsd/Host.cpp b/source/Host/openbsd/Host.cpp
new file mode 100644
index 000000000000..c9ff69366c2f
--- /dev/null
+++ b/source/Host/openbsd/Host.cpp
@@ -0,0 +1,225 @@
+//===-- source/Host/openbsd/Host.cpp ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <sys/types.h>
+
+#include <sys/signal.h>
+#include <sys/exec.h>
+#include <sys/proc.h>
+#include <sys/ptrace.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+
+#include <stdio.h>
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/NameMatches.h"
+
+#include "llvm/Support/Host.h"
+
+extern "C" {
+extern char **environ;
+}
+
+using namespace lldb;
+using namespace lldb_private;
+
+size_t Host::GetEnvironment(StringList &env) {
+ char *v;
+ char **var = environ;
+ for (; var != NULL && *var != NULL; ++var) {
+ v = strchr(*var, (int)'-');
+ if (v == NULL)
+ continue;
+ env.AppendString(v);
+ }
+ return env.GetSize();
+}
+
+static bool
+GetOpenBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
+ ProcessInstanceInfo &process_info) {
+ if (process_info.ProcessIDIsValid()) {
+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS,
+ (int)process_info.GetProcessID()};
+
+ char arg_data[8192];
+ size_t arg_data_size = sizeof(arg_data);
+ if (::sysctl(mib, 4, arg_data, &arg_data_size, NULL, 0) == 0) {
+ DataExtractor data(arg_data, arg_data_size, endian::InlHostByteOrder(),
+ sizeof(void *));
+ lldb::offset_t offset = 0;
+ const char *cstr;
+
+ cstr = data.GetCStr(&offset);
+ if (cstr) {
+ process_info.GetExecutableFile().SetFile(cstr, false);
+
+ if (!(match_info_ptr == NULL ||
+ NameMatches(
+ process_info.GetExecutableFile().GetFilename().GetCString(),
+ match_info_ptr->GetNameMatchType(),
+ match_info_ptr->GetProcessInfo().GetName())))
+ return false;
+
+ Args &proc_args = process_info.GetArguments();
+ while (1) {
+ const uint8_t *p = data.PeekData(offset, 1);
+ while ((p != NULL) && (*p == '\0') && offset < arg_data_size) {
+ ++offset;
+ p = data.PeekData(offset, 1);
+ }
+ if (p == NULL || offset >= arg_data_size)
+ return true;
+
+ cstr = data.GetCStr(&offset);
+ if (cstr)
+ proc_args.AppendArgument(llvm::StringRef(cstr));
+ else
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+static bool GetOpenBSDProcessCPUType(ProcessInstanceInfo &process_info) {
+ if (process_info.ProcessIDIsValid()) {
+ process_info.GetArchitecture() =
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ return true;
+ }
+ process_info.GetArchitecture().Clear();
+ return false;
+}
+
+static bool GetOpenBSDProcessUserAndGroup(ProcessInstanceInfo &process_info) {
+ struct kinfo_proc proc_kinfo;
+ size_t proc_kinfo_size;
+
+ if (process_info.ProcessIDIsValid()) {
+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ (int)process_info.GetProcessID()};
+ proc_kinfo_size = sizeof(struct kinfo_proc);
+
+ if (::sysctl(mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0) {
+ if (proc_kinfo_size > 0) {
+ process_info.SetParentProcessID(proc_kinfo.p_ppid);
+ process_info.SetUserID(proc_kinfo.p_ruid);
+ process_info.SetGroupID(proc_kinfo.p_rgid);
+ process_info.SetEffectiveUserID(proc_kinfo.p_uid);
+ process_info.SetEffectiveGroupID(proc_kinfo.p_gid);
+ return true;
+ }
+ }
+ }
+ process_info.SetParentProcessID(LLDB_INVALID_PROCESS_ID);
+ process_info.SetUserID(UINT32_MAX);
+ process_info.SetGroupID(UINT32_MAX);
+ process_info.SetEffectiveUserID(UINT32_MAX);
+ process_info.SetEffectiveGroupID(UINT32_MAX);
+ return false;
+}
+
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ std::vector<struct kinfo_proc> kinfos;
+
+ int mib[3] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
+
+ size_t pid_data_size = 0;
+ if (::sysctl(mib, 3, NULL, &pid_data_size, NULL, 0) != 0)
+ return 0;
+
+ // Add a few extra in case a few more show up
+ const size_t estimated_pid_count =
+ (pid_data_size / sizeof(struct kinfo_proc)) + 10;
+
+ kinfos.resize(estimated_pid_count);
+ pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
+
+ if (::sysctl(mib, 3, &kinfos[0], &pid_data_size, NULL, 0) != 0)
+ return 0;
+
+ const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));
+
+ bool all_users = match_info.GetMatchAllUsers();
+ const ::pid_t our_pid = getpid();
+ const uid_t our_uid = getuid();
+ for (size_t i = 0; i < actual_pid_count; i++) {
+ const struct kinfo_proc &kinfo = kinfos[i];
+ const bool kinfo_user_matches = (all_users || (kinfo.p_ruid == our_uid) ||
+ // Special case, if lldb is being run as
+ // root we can attach to anything.
+ (our_uid == 0));
+
+ if (kinfo_user_matches == false || // Make sure the user is acceptable
+ kinfo.p_pid == our_pid || // Skip this process
+ kinfo.p_pid == 0 || // Skip kernel (kernel pid is zero)
+ kinfo.p_stat == SZOMB || // Zombies are bad, they like brains...
+ kinfo.p_psflags & PS_TRACED || // Being debugged?
+ kinfo.p_flag & P_WEXIT) // Working on exiting
+ continue;
+
+ ProcessInstanceInfo process_info;
+ process_info.SetProcessID(kinfo.p_pid);
+ process_info.SetParentProcessID(kinfo.p_ppid);
+ process_info.SetUserID(kinfo.p_ruid);
+ process_info.SetGroupID(kinfo.p_rgid);
+ process_info.SetEffectiveUserID(kinfo.p_svuid);
+ process_info.SetEffectiveGroupID(kinfo.p_svgid);
+
+ // Make sure our info matches before we go fetch the name and cpu type
+ if (match_info.Matches(process_info) &&
+ GetOpenBSDProcessArgs(&match_info, process_info)) {
+ GetOpenBSDProcessCPUType(process_info);
+ if (match_info.Matches(process_info))
+ process_infos.Append(process_info);
+ }
+ }
+
+ return process_infos.GetSize();
+}
+
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+ process_info.SetProcessID(pid);
+
+ if (GetOpenBSDProcessArgs(NULL, process_info)) {
+ // should use libprocstat instead of going right into sysctl?
+ GetOpenBSDProcessCPUType(process_info);
+ GetOpenBSDProcessUserAndGroup(process_info);
+ return true;
+ }
+
+ process_info.Clear();
+ return false;
+}
+
+Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+ return Error("unimplemented");
+}
diff --git a/source/Host/openbsd/HostInfoOpenBSD.cpp b/source/Host/openbsd/HostInfoOpenBSD.cpp
new file mode 100644
index 000000000000..548958899322
--- /dev/null
+++ b/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -0,0 +1,65 @@
+//===-- HostInfoOpenBSD.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/openbsd/HostInfoOpenBSD.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/utsname.h>
+
+using namespace lldb_private;
+
+bool HostInfoOpenBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
+ uint32_t &update) {
+ struct utsname un;
+
+ ::memset(&un, 0, sizeof(utsname));
+ if (uname(&un) < 0)
+ return false;
+
+ int status = sscanf(un.release, "%u.%u", &major, &minor);
+ return status == 2;
+}
+
+bool HostInfoOpenBSD::GetOSBuildString(std::string &s) {
+ int mib[2] = {CTL_KERN, KERN_OSREV};
+ char osrev_str[12];
+ uint32_t osrev = 0;
+ size_t osrev_len = sizeof(osrev);
+
+ if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0) {
+ ::snprintf(osrev_str, sizeof(osrev_str), "%-8.8u", osrev);
+ s.assign(osrev_str);
+ return true;
+ }
+
+ s.clear();
+ return false;
+}
+
+bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
+ struct utsname un;
+
+ ::memset(&un, 0, sizeof(utsname));
+ s.clear();
+
+ if (uname(&un) < 0)
+ return false;
+
+ s.assign(un.version);
+
+ return true;
+}
+
+FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
+ static FileSpec g_program_filespec;
+ return g_program_filespec;
+}
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 64101fdc4267..a3ac36558e32 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -19,7 +19,6 @@
#include "lldb/Host/IOObject.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/SocketAddress.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Utility/SelectHelper.h"
// C Includes
@@ -43,13 +42,12 @@
#endif
// Project includes
#include "lldb/Core/Communication.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/common/TCPSocket.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -561,10 +559,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout,
// ever get used more generally we will need to lock here as well.
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_CONNECTION));
- if (log)
- log->Printf(
- "%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %lu)",
- static_cast<void *>(this), long(timeout ? timeout->count() : -1));
+ LLDB_LOG(log, "this = {0}, timeout = {1}", this, timeout);
// Make a copy of the file descriptors to make sure we don't
// have another thread change these values out from under us
@@ -753,14 +748,12 @@ ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s,
ConnectionStatus ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s,
Error *error_ptr) {
- Socket *send_socket = nullptr;
- Socket *recv_socket = nullptr;
- Error error = Socket::UdpConnect(s, m_child_processes_inherit, send_socket,
- recv_socket);
+ Socket *socket = nullptr;
+ Error error = Socket::UdpConnect(s, m_child_processes_inherit, socket);
if (error_ptr)
*error_ptr = error;
- m_write_sp.reset(send_socket);
- m_read_sp.reset(recv_socket);
+ m_write_sp.reset(socket);
+ m_read_sp = m_write_sp;
if (error.Fail()) {
return eConnectionStatusError;
}
diff --git a/source/Host/posix/DomainSocket.cpp b/source/Host/posix/DomainSocket.cpp
index cb0a1d057506..538979df2b6b 100644
--- a/source/Host/posix/DomainSocket.cpp
+++ b/source/Host/posix/DomainSocket.cpp
@@ -9,7 +9,7 @@
#include "lldb/Host/posix/DomainSocket.h"
-#include "lldb/Host/FileSystem.h"
+#include "llvm/Support/FileSystem.h"
#include <stddef.h>
#include <sys/socket.h>
@@ -116,5 +116,5 @@ Error DomainSocket::Accept(llvm::StringRef name, bool child_processes_inherit,
size_t DomainSocket::GetNameOffset() const { return 0; }
void DomainSocket::DeleteSocketFile(llvm::StringRef name) {
- FileSystem::Unlink(FileSpec{name, true});
+ llvm::sys::fs::remove(name);
}
diff --git a/source/Host/posix/FileSystem.cpp b/source/Host/posix/FileSystem.cpp
index aaa53ce07723..22f337fcfec5 100644
--- a/source/Host/posix/FileSystem.cpp
+++ b/source/Host/posix/FileSystem.cpp
@@ -25,149 +25,17 @@
#endif
// lldb Includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/Host.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
const char *FileSystem::DEV_NULL = "/dev/null";
-FileSpec::PathSyntax FileSystem::GetNativePathSyntax() {
- return FileSpec::ePathSyntaxPosix;
-}
-
-Error FileSystem::MakeDirectory(const FileSpec &file_spec,
- uint32_t file_permissions) {
- if (file_spec) {
- Error error;
- if (::mkdir(file_spec.GetCString(), file_permissions) == -1) {
- error.SetErrorToErrno();
- errno = 0;
- switch (error.GetError()) {
- case ENOENT: {
- // Parent directory doesn't exist, so lets make it if we can
- // Make the parent directory and try again
- FileSpec parent_file_spec{file_spec.GetDirectory().GetCString(), false};
- error = MakeDirectory(parent_file_spec, file_permissions);
- if (error.Fail())
- return error;
- // Try and make the directory again now that the parent directory was
- // made successfully
- if (::mkdir(file_spec.GetCString(), file_permissions) == -1) {
- error.SetErrorToErrno();
- }
- return error;
- } break;
- case EEXIST: {
- if (file_spec.IsDirectory())
- return Error(); // It is a directory and it already exists
- } break;
- }
- }
- return error;
- }
- return Error("empty path");
-}
-
-Error FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse) {
- Error error;
- if (file_spec) {
- if (recurse) {
- // Save all sub directories in a list so we don't recursively call this
- // function
- // and possibly run out of file descriptors if the directory is too deep.
- std::vector<FileSpec> sub_directories;
-
- FileSpec::ForEachItemInDirectory(
- file_spec.GetCString(),
- [&error, &sub_directories](
- FileSpec::FileType file_type,
- const FileSpec &spec) -> FileSpec::EnumerateDirectoryResult {
- if (file_type == FileSpec::eFileTypeDirectory) {
- // Save all directorires and process them after iterating through
- // this directory
- sub_directories.push_back(spec);
- } else {
- // Update sub_spec to point to the current file and delete it
- error = FileSystem::Unlink(spec);
- }
- // If anything went wrong, stop iterating, else process the next
- // file
- if (error.Fail())
- return FileSpec::eEnumerateDirectoryResultQuit;
- else
- return FileSpec::eEnumerateDirectoryResultNext;
- });
-
- if (error.Success()) {
- // Now delete all sub directories with separate calls that aren't
- // recursively calling into this function _while_ this function is
- // iterating through the current directory.
- for (const auto &sub_directory : sub_directories) {
- error = DeleteDirectory(sub_directory, recurse);
- if (error.Fail())
- break;
- }
- }
- }
-
- if (error.Success()) {
- if (::rmdir(file_spec.GetCString()) != 0)
- error.SetErrorToErrno();
- }
- } else {
- error.SetErrorString("empty path");
- }
- return error;
-}
-
-Error FileSystem::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions) {
- Error error;
- struct stat file_stats;
- if (::stat(file_spec.GetCString(), &file_stats) == 0) {
- // The bits in "st_mode" currently match the definitions
- // for the file mode bits in unix.
- file_permissions = file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
- } else {
- error.SetErrorToErrno();
- }
- return error;
-}
-
-Error FileSystem::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions) {
- Error error;
- if (::chmod(file_spec.GetCString(), file_permissions) != 0)
- error.SetErrorToErrno();
- return error;
-}
-
-lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) {
- return file_spec.GetByteSize();
-}
-
-bool FileSystem::GetFileExists(const FileSpec &file_spec) {
- return file_spec.Exists();
-}
-
-Error FileSystem::Hardlink(const FileSpec &src, const FileSpec &dst) {
- Error error;
- if (::link(dst.GetCString(), src.GetCString()) == -1)
- error.SetErrorToErrno();
- return error;
-}
-
-int FileSystem::GetHardlinkCount(const FileSpec &file_spec) {
- struct stat file_stat;
- if (::stat(file_spec.GetCString(), &file_stat) == 0)
- return file_stat.st_nlink;
-
- return -1;
-}
-
Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
Error error;
if (::symlink(dst.GetCString(), src.GetCString()) == -1)
@@ -175,13 +43,6 @@ Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
return error;
}
-Error FileSystem::Unlink(const FileSpec &file_spec) {
- Error error;
- if (::unlink(file_spec.GetCString()) == -1)
- error.SetErrorToErrno();
- return error;
-}
-
Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
Error error;
char buf[PATH_MAX];
@@ -213,50 +74,6 @@ Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
return Error();
}
-#if defined(__NetBSD__)
-static bool IsLocal(const struct statvfs &info) {
- return (info.f_flag & MNT_LOCAL) != 0;
-}
-#else
-static bool IsLocal(const struct statfs &info) {
-#ifdef __linux__
-#define CIFS_MAGIC_NUMBER 0xFF534D42
- switch ((uint32_t)info.f_type) {
- case NFS_SUPER_MAGIC:
- case SMB_SUPER_MAGIC:
- case CIFS_MAGIC_NUMBER:
- return false;
- default:
- return true;
- }
-#else
- return (info.f_flags & MNT_LOCAL) != 0;
-#endif
-}
-#endif
-
-#if defined(__NetBSD__)
-bool FileSystem::IsLocal(const FileSpec &spec) {
- struct statvfs statfs_info;
- std::string path(spec.GetPath());
- if (statvfs(path.c_str(), &statfs_info) == 0)
- return ::IsLocal(statfs_info);
- return false;
-}
-#else
-bool FileSystem::IsLocal(const FileSpec &spec) {
- struct statfs statfs_info;
- std::string path(spec.GetPath());
- if (statfs(path.c_str(), &statfs_info) == 0)
- return ::IsLocal(statfs_info);
- return false;
-}
-#endif
-
FILE *FileSystem::Fopen(const char *path, const char *mode) {
return ::fopen(path, mode);
}
-
-int FileSystem::Stat(const char *path, struct stat *stats) {
- return ::stat(path, stats);
-}
diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp
index 38aac59ecc40..da9e1fb366cc 100644
--- a/source/Host/posix/HostInfoPosix.cpp
+++ b/source/Host/posix/HostInfoPosix.cpp
@@ -11,8 +11,8 @@
#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#endif
-#include "lldb/Core/Log.h"
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/Log.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
diff --git a/source/Host/posix/HostThreadPosix.cpp b/source/Host/posix/HostThreadPosix.cpp
index ac398998c20f..073b7b0b11e8 100644
--- a/source/Host/posix/HostThreadPosix.cpp
+++ b/source/Host/posix/HostThreadPosix.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/HostThreadPosix.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include <errno.h>
#include <pthread.h>
diff --git a/source/Host/posix/MainLoopPosix.cpp b/source/Host/posix/MainLoopPosix.cpp
index 08c969e72a26..a73187e730f0 100644
--- a/source/Host/posix/MainLoopPosix.cpp
+++ b/source/Host/posix/MainLoopPosix.cpp
@@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/MainLoopPosix.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <csignal>
-#include <vector>
#include <sys/select.h>
+#include <vector>
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp
index 4e0810c1a9b3..3ac5d480de89 100644
--- a/source/Host/posix/PipePosix.cpp
+++ b/source/Host/posix/PipePosix.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/PipePosix.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/SelectHelper.h"
#include "llvm/ADT/SmallString.h"
@@ -231,7 +230,7 @@ void PipePosix::Close() {
}
Error PipePosix::Delete(llvm::StringRef name) {
- return FileSystem::Unlink(FileSpec{name.data(), true});
+ return llvm::sys::fs::remove(name);
}
bool PipePosix::CanRead() const {
diff --git a/source/Host/posix/ProcessLauncherPosixFork.cpp b/source/Host/posix/ProcessLauncherPosixFork.cpp
new file mode 100644
index 000000000000..91c32d6e6426
--- /dev/null
+++ b/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -0,0 +1,231 @@
+//===-- ProcessLauncherLinux.cpp --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/Pipe.h"
+#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+
+#include <limits.h>
+#include <sys/ptrace.h>
+#include <sys/wait.h>
+
+#include <sstream>
+
+#ifdef __ANDROID__
+#include <android/api-level.h>
+#define PT_TRACE_ME PTRACE_TRACEME
+#endif
+
+#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
+#include <linux/personality.h>
+#elif defined(__linux__)
+#include <sys/personality.h>
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+
+static void FixupEnvironment(Args &env) {
+#ifdef __ANDROID__
+ // If there is no PATH variable specified inside the environment then set the
+ // path to /system/bin. It is required because the default path used by
+ // execve() is wrong on android.
+ static const char *path = "PATH=";
+ for (auto &entry : env.entries()) {
+ if (entry.ref.startswith(path))
+ return;
+ }
+ env.AppendArgument(llvm::StringRef("PATH=/system/bin"));
+#endif
+}
+
+static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
+ const char *operation) {
+ std::ostringstream os;
+ os << operation << " failed: " << strerror(errno);
+ write(error_fd, os.str().data(), os.str().size());
+ close(error_fd);
+ _exit(1);
+}
+
+static void DisableASLRIfRequested(int error_fd, const ProcessLaunchInfo &info) {
+#if defined(__linux__)
+ if (info.GetFlags().Test(lldb::eLaunchFlagDisableASLR)) {
+ const unsigned long personality_get_current = 0xffffffff;
+ int value = personality(personality_get_current);
+ if (value == -1)
+ ExitWithError(error_fd, "personality get");
+
+ value = personality(ADDR_NO_RANDOMIZE | value);
+ if (value == -1)
+ ExitWithError(error_fd, "personality set");
+ }
+#endif
+}
+
+static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
+ int flags) {
+ int target_fd = ::open(file_spec.GetCString(), flags, 0666);
+
+ if (target_fd == -1)
+ ExitWithError(error_fd, "DupDescriptor-open");
+
+ if (target_fd == fd)
+ return;
+
+ if (::dup2(target_fd, fd) == -1)
+ ExitWithError(error_fd, "DupDescriptor-dup2");
+
+ ::close(target_fd);
+ return;
+}
+
+static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
+ const ProcessLaunchInfo &info) {
+ // First, make sure we disable all logging. If we are logging to stdout, our
+ // logs can be mistaken for inferior output.
+ Log::DisableAllLogChannels();
+
+ // Do not inherit setgid powers.
+ if (setgid(getgid()) != 0)
+ ExitWithError(error_fd, "setgid");
+
+ if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
+ if (setpgid(0, 0) != 0)
+ ExitWithError(error_fd, "setpgid");
+ }
+
+ for (size_t i = 0; i < info.GetNumFileActions(); ++i) {
+ const FileAction &action = *info.GetFileActionAtIndex(i);
+ switch (action.GetAction()) {
+ case FileAction::eFileActionClose:
+ if (close(action.GetFD()) != 0)
+ ExitWithError(error_fd, "close");
+ break;
+ case FileAction::eFileActionDuplicate:
+ if (dup2(action.GetFD(), action.GetActionArgument()) == -1)
+ ExitWithError(error_fd, "dup2");
+ break;
+ case FileAction::eFileActionOpen:
+ DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(),
+ action.GetActionArgument());
+ break;
+ case FileAction::eFileActionNone:
+ break;
+ }
+ }
+
+ const char **argv = info.GetArguments().GetConstArgumentVector();
+
+ // Change working directory
+ if (info.GetWorkingDirectory() &&
+ 0 != ::chdir(info.GetWorkingDirectory().GetCString()))
+ ExitWithError(error_fd, "chdir");
+
+ DisableASLRIfRequested(error_fd, info);
+ Args env = info.GetEnvironmentEntries();
+ FixupEnvironment(env);
+ const char **envp = env.GetConstArgumentVector();
+
+ // Clear the signal mask to prevent the child from being affected by
+ // any masking done by the parent.
+ sigset_t set;
+ if (sigemptyset(&set) != 0 ||
+ pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0)
+ ExitWithError(error_fd, "pthread_sigmask");
+
+ if (info.GetFlags().Test(eLaunchFlagDebug)) {
+ // HACK:
+ // Close everything besides stdin, stdout, and stderr that has no file
+ // action to avoid leaking. Only do this when debugging, as elsewhere we
+ // actually rely on
+ // passing open descriptors to child processes.
+ for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd)
+ if (!info.GetFileActionForFD(fd) && fd != error_fd)
+ close(fd);
+
+ // Start tracing this child that is about to exec.
+ if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1)
+ ExitWithError(error_fd, "ptrace");
+ }
+
+ // Execute. We should never return...
+ execve(argv[0], const_cast<char *const *>(argv),
+ const_cast<char *const *>(envp));
+
+#if defined(__linux__)
+ if (errno == ETXTBSY) {
+ // On android M and earlier we can get this error because the adb deamon can
+ // hold a write
+ // handle on the executable even after it has finished uploading it. This
+ // state lasts
+ // only a short time and happens only when there are many concurrent adb
+ // commands being
+ // issued, such as when running the test suite. (The file remains open when
+ // someone does
+ // an "adb shell" command in the fork() child before it has had a chance to
+ // exec.) Since
+ // this state should clear up quickly, wait a while and then give it one
+ // more go.
+ usleep(50000);
+ execve(argv[0], const_cast<char *const *>(argv),
+ const_cast<char *const *>(envp));
+ }
+#endif
+
+ // ...unless exec fails. In which case we definitely need to end the child
+ // here.
+ ExitWithError(error_fd, "execve");
+}
+
+HostProcess
+ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info,
+ Error &error) {
+ char exe_path[PATH_MAX];
+ launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
+
+ // A pipe used by the child process to report errors.
+ PipePosix pipe;
+ const bool child_processes_inherit = false;
+ error = pipe.CreateNew(child_processes_inherit);
+ if (error.Fail())
+ return HostProcess();
+
+ ::pid_t pid = ::fork();
+ if (pid == -1) {
+ // Fork failed
+ error.SetErrorStringWithFormat("Fork failed with error message: %s",
+ strerror(errno));
+ return HostProcess(LLDB_INVALID_PROCESS_ID);
+ }
+ if (pid == 0) {
+ // child process
+ pipe.CloseReadFileDescriptor();
+ ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
+ }
+
+ // parent process
+
+ pipe.CloseWriteFileDescriptor();
+ char buf[1000];
+ int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
+
+ if (r == 0)
+ return HostProcess(pid); // No error. We're done.
+
+ error.SetErrorString(buf);
+
+ waitpid(pid, nullptr, 0);
+
+ return HostProcess();
+}
diff --git a/source/Host/windows/ConnectionGenericFileWindows.cpp b/source/Host/windows/ConnectionGenericFileWindows.cpp
index 5d48a1c867ad..8fc038f3f9b6 100644
--- a/source/Host/windows/ConnectionGenericFileWindows.cpp
+++ b/source/Host/windows/ConnectionGenericFileWindows.cpp
@@ -8,8 +8,9 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Timeout.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
diff --git a/source/Host/windows/FileSystem.cpp b/source/Host/windows/FileSystem.cpp
index f0ba7376876d..092b70b1f4dc 100644
--- a/source/Host/windows/FileSystem.cpp
+++ b/source/Host/windows/FileSystem.cpp
@@ -15,6 +15,7 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/windows/AutoHandle.h"
+#include "lldb/Host/windows/PosixApi.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
@@ -26,126 +27,6 @@ const char *FileSystem::DEV_NULL = "nul";
const char *FileSystem::PATH_CONVERSION_ERROR =
"Error converting path between UTF-8 and native encoding";
-FileSpec::PathSyntax FileSystem::GetNativePathSyntax() {
- return FileSpec::ePathSyntaxWindows;
-}
-
-Error FileSystem::MakeDirectory(const FileSpec &file_spec,
- uint32_t file_permissions) {
- // On Win32, the mode parameter is ignored, as Windows files and directories
- // support a
- // different permission model than POSIX.
- Error error;
- const auto err_code =
- llvm::sys::fs::create_directories(file_spec.GetPath(), true);
- if (err_code) {
- error.SetErrorString(err_code.message().c_str());
- }
-
- return error;
-}
-
-Error FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse) {
- Error error;
- std::wstring path_buffer;
- if (!llvm::ConvertUTF8toWide(file_spec.GetPath(), path_buffer)) {
- error.SetErrorString(PATH_CONVERSION_ERROR);
- return error;
- }
- if (!recurse) {
- BOOL result = ::RemoveDirectoryW(path_buffer.c_str());
- if (!result)
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- } else {
- // SHFileOperation() accepts a list of paths, and so must be
- // double-null-terminated to
- // indicate the end of the list. The first null terminator is there only in
- // the backing
- // store but not the actual vector contents, and so we need to push twice.
- path_buffer.push_back(0);
- path_buffer.push_back(0);
-
- SHFILEOPSTRUCTW shfos = {};
- shfos.wFunc = FO_DELETE;
- shfos.pFrom = (LPCWSTR)path_buffer.data();
- shfos.fFlags = FOF_NO_UI;
-
- int result = ::SHFileOperationW(&shfos);
- // TODO(zturner): Correctly handle the intricacies of SHFileOperation return
- // values.
- if (result != 0)
- error.SetErrorStringWithFormat("SHFileOperation failed");
- }
- return error;
-}
-
-Error FileSystem::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions) {
- Error error;
- // Beware that Windows's permission model is different from Unix's, and it's
- // not clear if this API is supposed to check ACLs. To match the caller's
- // expectations as closely as possible, we'll use Microsoft's _stat, which
- // attempts to emulate POSIX stat. This should be good enough for basic
- // checks like FileSpec::Readable.
- struct _stat file_stats;
- if (::_stat(file_spec.GetCString(), &file_stats) == 0) {
- // The owner permission bits in "st_mode" currently match the definitions
- // for the owner file mode bits.
- file_permissions = file_stats.st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC);
- } else {
- error.SetErrorToErrno();
- }
-
- return error;
-}
-
-Error FileSystem::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions) {
- Error error;
- error.SetErrorStringWithFormat("%s is not supported on this host",
- LLVM_PRETTY_FUNCTION);
- return error;
-}
-
-lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) {
- return file_spec.GetByteSize();
-}
-
-bool FileSystem::GetFileExists(const FileSpec &file_spec) {
- return file_spec.Exists();
-}
-
-Error FileSystem::Hardlink(const FileSpec &src, const FileSpec &dst) {
- Error error;
- std::wstring wsrc, wdst;
- if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc) ||
- !llvm::ConvertUTF8toWide(dst.GetCString(), wdst))
- error.SetErrorString(PATH_CONVERSION_ERROR);
- else if (!::CreateHardLinkW(wsrc.c_str(), wdst.c_str(), nullptr))
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- return error;
-}
-
-int FileSystem::GetHardlinkCount(const FileSpec &file_spec) {
- std::wstring path;
- if (!llvm::ConvertUTF8toWide(file_spec.GetCString(), path))
- return -1;
-
- HANDLE file_handle =
- ::CreateFileW(path.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ,
- nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
-
- if (file_handle == INVALID_HANDLE_VALUE)
- return -1;
-
- AutoHandle auto_file_handle(file_handle);
- BY_HANDLE_FILE_INFORMATION file_info;
- if (::GetFileInformationByHandle(file_handle, &file_info))
- return file_info.nNumberOfLinks;
-
- return -1;
-}
-
Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
Error error;
std::wstring wsrc, wdst;
@@ -167,19 +48,6 @@ Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
return error;
}
-Error FileSystem::Unlink(const FileSpec &file_spec) {
- Error error;
- std::wstring path;
- if (!llvm::ConvertUTF8toWide(file_spec.GetCString(), path)) {
- error.SetErrorString(PATH_CONVERSION_ERROR);
- return error;
- }
- BOOL result = ::DeleteFileW(path.c_str());
- if (!result)
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- return error;
-}
-
Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
Error error;
std::wstring wsrc;
@@ -217,15 +85,6 @@ Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
return Error("ResolveSymbolicLink() isn't implemented on Windows");
}
-bool FileSystem::IsLocal(const FileSpec &spec) {
- if (spec) {
- // TODO: return true if the file is on a locally mounted file system
- return true;
- }
-
- return false;
-}
-
FILE *FileSystem::Fopen(const char *path, const char *mode) {
std::wstring wpath, wmode;
if (!llvm::ConvertUTF8toWide(path, wpath))
@@ -237,25 +96,3 @@ FILE *FileSystem::Fopen(const char *path, const char *mode) {
return nullptr;
return file;
}
-
-int FileSystem::Stat(const char *path, struct stat *stats) {
- std::wstring wpath;
- if (!llvm::ConvertUTF8toWide(path, wpath)) {
- errno = EINVAL;
- return -EINVAL;
- }
- int stat_result;
-#ifdef _USE_32BIT_TIME_T
- struct _stat32 file_stats;
- stat_result = ::_wstat32(wpath.c_str(), &file_stats);
-#else
- struct _stat64i32 file_stats;
- stat_result = ::_wstat64i32(wpath.c_str(), &file_stats);
-#endif
- if (stat_result == 0) {
- static_assert(sizeof(struct stat) == sizeof(file_stats),
- "stat and _stat32/_stat64i32 must have the same layout");
- *stats = *reinterpret_cast<struct stat *>(&file_stats);
- }
- return stat_result;
-}
diff --git a/source/Host/windows/Host.cpp b/source/Host/windows/Host.cpp
index 3da073605dcb..9a6957b2a1ff 100644
--- a/source/Host/windows/Host.cpp
+++ b/source/Host/windows/Host.cpp
@@ -15,16 +15,16 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
#include "llvm/Support/ConvertUTF.h"
@@ -97,14 +97,6 @@ void GetProcessExecutableAndTriple(const AutoHandle &handle,
}
}
-lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
- return 0;
-}
-
-lldb::tid_t Host::GetCurrentThreadID() {
- return lldb::tid_t(::GetCurrentThreadId());
-}
-
lldb::thread_t Host::GetCurrentThread() {
return lldb::thread_t(::GetCurrentThread());
}
diff --git a/source/Host/windows/HostInfoWindows.cpp b/source/Host/windows/HostInfoWindows.cpp
index a965ec0ea4e2..53a24ad1893e 100644
--- a/source/Host/windows/HostInfoWindows.cpp
+++ b/source/Host/windows/HostInfoWindows.cpp
@@ -14,10 +14,12 @@
#include <mutex> // std::once
#include "lldb/Host/windows/HostInfoWindows.h"
+#include "lldb/Host/windows/PosixApi.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
using namespace lldb_private;
@@ -90,8 +92,8 @@ bool HostInfoWindows::GetHostname(std::string &s) {
}
FileSpec HostInfoWindows::GetProgramFileSpec() {
- 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, []() {
std::vector<wchar_t> buffer(PATH_MAX);
::GetModuleFileNameW(NULL, buffer.data(), buffer.size());
std::string path;
diff --git a/source/Host/windows/HostProcessWindows.cpp b/source/Host/windows/HostProcessWindows.cpp
index 8201d53bd27c..3bbc84a4ca59 100644
--- a/source/Host/windows/HostProcessWindows.cpp
+++ b/source/Host/windows/HostProcessWindows.cpp
@@ -8,10 +8,10 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/windows/HostProcessWindows.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ConvertUTF.h"
diff --git a/source/Host/windows/HostThreadWindows.cpp b/source/Host/windows/HostThreadWindows.cpp
index 41be21bfa304..aa791714c338 100644
--- a/source/Host/windows/HostThreadWindows.cpp
+++ b/source/Host/windows/HostThreadWindows.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
diff --git a/source/Host/windows/ThisThread.cpp b/source/Host/windows/ThisThread.cpp
deleted file mode 100644
index 8db12f05b0ba..000000000000
--- a/source/Host/windows/ThisThread.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/Error.h"
-
-#include "lldb/Host/ThisThread.h"
-#include "lldb/Host/windows/windows.h"
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-#if defined(_MSC_VER) && !defined(__clang__)
-
-namespace {
-static const DWORD MS_VC_EXCEPTION = 0x406D1388;
-
-#pragma pack(push, 8)
-struct THREADNAME_INFO {
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to thread name
- DWORD dwThreadId; // Thread ID (-1 == current thread)
- DWORD dwFlags; // Reserved. Do not use.
-};
-#pragma pack(pop)
-}
-
-#endif
-
-void ThisThread::SetName(llvm::StringRef name) {
-// Other compilers don't yet support SEH, so we can only set the thread if
-// compiling with MSVC.
-// TODO(zturner): Once clang-cl supports SEH, relax this conditional.
-#if defined(_MSC_VER) && !defined(__clang__)
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = name.data();
- info.dwThreadId = ::GetCurrentThreadId();
- info.dwFlags = 0;
-
- __try {
- ::RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),
- (ULONG_PTR *)&info);
- } __except (EXCEPTION_EXECUTE_HANDLER) {
- }
-#endif
-}
-
-void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
- // Getting the thread name is not supported on Windows.
- // TODO(zturner): In SetName(), make a TLS entry that contains the thread's
- // name, and in this function
- // try to extract that TLS entry.
- name.clear();
-}
diff --git a/source/Host/windows/Windows.cpp b/source/Host/windows/Windows.cpp
index 21afc6d85da5..9d0e70e6d126 100644
--- a/source/Host/windows/Windows.cpp
+++ b/source/Host/windows/Windows.cpp
@@ -23,13 +23,6 @@
#include <stdlib.h>
#include <string.h>
-// These prototypes are defined in <direct.h>, but it also defines chdir() and
-// getcwd(), giving multiply defined errors
-extern "C" {
-char *_getcwd(char *buffer, int maxlen);
-int _chdir(const char *path);
-}
-
namespace {
bool utf8ToWide(const char *utf8, wchar_t *buf, size_t bufSize) {
const llvm::UTF8 *sourceStart = reinterpret_cast<const llvm::UTF8 *>(utf8);
@@ -190,31 +183,6 @@ char *basename(char *path) {
return &l1[1];
}
-// use _getcwd() instead of GetCurrentDirectory() because it updates errno
-char *getcwd(char *path, int max) {
- assert(path == NULL || max <= PATH_MAX);
- wchar_t wpath[PATH_MAX];
- if (wchar_t *wresult = _wgetcwd(wpath, PATH_MAX)) {
- // Caller is allowed to pass in NULL for `path`.
- // In that case, we're supposed to allocate a
- // buffer on the caller's behalf.
- if (path == NULL) {
- max = UNI_MAX_UTF8_BYTES_PER_CODE_POINT * wcslen(wresult) + 1;
- path = (char *)malloc(max);
- if (path == NULL) {
- errno = ENOMEM;
- return NULL;
- }
- }
- if (wideToUtf8(wresult, path, max))
- return path;
- }
- return NULL;
-}
-
-// use _chdir() instead of SetCurrentDirectory() because it updates errno
-int chdir(const char *path) { return _chdir(path); }
-
char *dirname(char *path) {
char *l1 = strrchr(path, '\\');
char *l2 = strrchr(path, '/');
diff --git a/source/Initialization/CMakeLists.txt b/source/Initialization/CMakeLists.txt
index f23a2b4339b8..7a100588e009 100644
--- a/source/Initialization/CMakeLists.txt
+++ b/source/Initialization/CMakeLists.txt
@@ -1,5 +1,33 @@
+if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
+ list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
+endif()
+
+if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
+ list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
+endif()
+
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+ list(APPEND EXTRA_PLUGINS lldbPluginProcessWindowsCommon)
+endif ()
+
add_lldb_library(lldbInitialization
SystemInitializerCommon.cpp
SystemInitializer.cpp
SystemLifetimeManager.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbPluginInstructionARM
+ lldbPluginInstructionMIPS
+ lldbPluginInstructionMIPS64
+ lldbPluginObjectContainerBSDArchive
+ lldbPluginObjectContainerMachOArchive
+ lldbPluginObjectFileELF
+ lldbPluginObjectFilePECOFF
+ lldbPluginProcessGDBRemote
+ ${EXTRA_PLUGINS}
+ ${LLDB_SYSTEM_LIBS}
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp
index 1139955b18a5..805e6091e68a 100644
--- a/source/Initialization/SystemInitializerCommon.cpp
+++ b/source/Initialization/SystemInitializerCommon.cpp
@@ -17,16 +17,16 @@
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Log.h"
#if defined(__APPLE__)
#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
#endif
-#if defined(__linux__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#endif
@@ -70,7 +70,7 @@ void SystemInitializerCommon::Initialize() {
#endif
llvm::EnablePrettyStackTrace();
- Log::Initialize();
+ InitializeLog();
HostInfo::Initialize();
Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
@@ -93,9 +93,8 @@ void SystemInitializerCommon::Initialize() {
#if defined(__APPLE__)
ObjectFileMachO::Initialize();
#endif
-#if defined(__linux__)
- static ConstString g_linux_log_name("linux");
- ProcessPOSIXLog::Initialize(g_linux_log_name);
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+ ProcessPOSIXLog::Initialize();
#endif
#if defined(_MSC_VER)
ProcessWindowsLog::Initialize();
@@ -122,5 +121,5 @@ void SystemInitializerCommon::Terminate() {
#endif
HostInfo::Terminate();
- Log::Terminate();
+ Log::DisableAllLogChannels();
}
diff --git a/source/Interpreter/Args.cpp b/source/Interpreter/Args.cpp
index 698432885d9b..5bfe13f55e49 100644
--- a/source/Interpreter/Args.cpp
+++ b/source/Interpreter/Args.cpp
@@ -12,18 +12,15 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
@@ -632,9 +629,7 @@ lldb::addr_t Args::StringToAddress(const ExecutionContext *exe_ctx,
add = str[0] == '+';
if (regex_match.GetMatchAtIndex(s, 3, str)) {
- offset = StringConvert::ToUInt64(str.c_str(), 0, 0, &success);
-
- if (success) {
+ if (!llvm::StringRef(str).getAsInteger(0, offset)) {
Error error;
addr = StringToAddress(exe_ctx, name.c_str(),
LLDB_INVALID_ADDRESS, &error);
@@ -931,12 +926,12 @@ bool Args::ContainsEnvironmentVariable(llvm::StringRef env_var_name,
// Check each arg to see if it matches the env var name.
for (auto arg : llvm::enumerate(m_entries)) {
llvm::StringRef name, value;
- std::tie(name, value) = arg.Value.ref.split('=');
+ std::tie(name, value) = arg.value().ref.split('=');
if (name != env_var_name)
continue;
if (argument_index)
- *argument_index = arg.Index;
+ *argument_index = arg.index();
return true;
}
@@ -954,9 +949,9 @@ size_t Args::FindArgumentIndexForOption(Option *long_options,
long_options[long_options_index].definition->long_option);
for (auto entry : llvm::enumerate(m_entries)) {
- if (entry.Value.ref.startswith(short_buffer) ||
- entry.Value.ref.startswith(long_buffer))
- return entry.Index;
+ if (entry.value().ref.startswith(short_buffer) ||
+ entry.value().ref.startswith(long_buffer))
+ return entry.index();
}
return size_t(-1);
diff --git a/source/Interpreter/CMakeLists.txt b/source/Interpreter/CMakeLists.txt
index 76d046f7d802..0ab25f17144b 100644
--- a/source/Interpreter/CMakeLists.txt
+++ b/source/Interpreter/CMakeLists.txt
@@ -43,4 +43,15 @@ add_lldb_library(lldbInterpreter
Options.cpp
Property.cpp
ScriptInterpreter.cpp
+
+ LINK_LIBS
+ lldbCommands
+ lldbCore
+ lldbDataFormatters
+ lldbHost
+ lldbTarget
+ lldbUtility
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Interpreter/CommandAlias.cpp b/source/Interpreter/CommandAlias.cpp
index a8f5343701d5..2db7460611ca 100644
--- a/source/Interpreter/CommandAlias.cpp
+++ b/source/Interpreter/CommandAlias.cpp
@@ -11,11 +11,11 @@
#include "llvm/Support/ErrorHandling.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/CommandHistory.cpp b/source/Interpreter/CommandHistory.cpp
index c16f71374c7e..0fa25ed806ff 100644
--- a/source/Interpreter/CommandHistory.cpp
+++ b/source/Interpreter/CommandHistory.cpp
@@ -9,7 +9,6 @@
#include <inttypes.h>
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandHistory.h"
using namespace lldb;
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index d44eb25848dc..de27f7be30d3 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -42,12 +42,12 @@
#include "../Commands/CommandObjectWatchpoint.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#ifndef LLDB_DISABLE_LIBEDIT
#include "lldb/Host/Editline.h"
@@ -2018,8 +2018,8 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
}
for (auto entry : llvm::enumerate(cmd_args.entries())) {
- if (!used[entry.Index] && !wants_raw_input)
- new_args.AppendArgument(entry.Value.ref);
+ if (!used[entry.index()] && !wants_raw_input)
+ new_args.AppendArgument(entry.value().ref);
}
cmd_args.Clear();
@@ -2542,14 +2542,6 @@ void CommandInterpreter::OutputFormattedHelpText(Stream &strm,
OutputFormattedHelpText(strm, prefix_stream.GetString(), help_text);
}
-LLVM_ATTRIBUTE_ALWAYS_INLINE
-static size_t nextWordLength(llvm::StringRef S) {
- size_t pos = S.find_first_of(' ');
- if (pos == llvm::StringRef::npos)
- return S.size();
- return pos;
-}
-
void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
llvm::StringRef separator,
llvm::StringRef help_text,
@@ -2568,6 +2560,11 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
uint32_t chars_left = max_columns;
+ auto nextWordLength = [](llvm::StringRef S) {
+ size_t pos = S.find_first_of(' ');
+ return pos == llvm::StringRef::npos ? S.size() : pos;
+ };
+
while (!text.empty()) {
if (text.front() == '\n' ||
(text.front() == ' ' && nextWordLength(text.ltrim(' ')) < chars_left)) {
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 944d40823ed2..2a6c77d7deba 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -24,9 +24,9 @@
// FIXME: Make a separate file for the completers.
#include "lldb/Core/FileSpecList.h"
#include "lldb/DataFormatters/FormatManager.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Target/Language.h"
@@ -977,10 +977,10 @@ bool CommandObjectParsed::Execute(const char *args_string,
}
if (!handled) {
for (auto entry : llvm::enumerate(cmd_args.entries())) {
- if (!entry.Value.ref.empty() && entry.Value.ref.front() == '`') {
+ if (!entry.value().ref.empty() && entry.value().ref.front() == '`') {
cmd_args.ReplaceArgumentAtIndex(
- entry.Index,
- m_interpreter.ProcessEmbeddedScriptCommands(entry.Value.c_str()));
+ entry.index(),
+ m_interpreter.ProcessEmbeddedScriptCommands(entry.value().c_str()));
}
}
diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp
index 72e66aa082e3..00fcff510cff 100644
--- a/source/Interpreter/CommandReturnObject.cpp
+++ b/source/Interpreter/CommandReturnObject.cpp
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp
index 51245a851c57..4a6bf48a24d4 100644
--- a/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/source/Interpreter/OptionGroupArchitecture.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Utility/Utils.h"
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp
index 10b97463842d..4956b83c8f7a 100644
--- a/source/Interpreter/OptionGroupBoolean.cpp
+++ b/source/Interpreter/OptionGroupBoolean.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp
index 0c0b068c42a3..995a6a46e48e 100644
--- a/source/Interpreter/OptionGroupFile.cpp
+++ b/source/Interpreter/OptionGroupFile.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp
index c97d16ad9865..df5e2b3cd346 100644
--- a/source/Interpreter/OptionGroupFormat.cpp
+++ b/source/Interpreter/OptionGroupFormat.cpp
@@ -14,10 +14,10 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
@@ -235,32 +235,36 @@ bool OptionGroupFormat::ParserGDBFormatLetter(
m_prev_gdb_format = format_letter;
return true;
- // Size isn't used for printing instructions, so if a size is specified, and
- // the previous format was
- // 'i', then we should reset it to the default ('x'). Otherwise we'll
- // continue to print as instructions,
- // which isn't expected.
case 'b':
- byte_size = 1;
- LLVM_FALLTHROUGH;
case 'h':
- byte_size = 2;
- LLVM_FALLTHROUGH;
case 'w':
- byte_size = 4;
- LLVM_FALLTHROUGH;
case 'g':
- byte_size = 8;
-
- m_prev_gdb_size = format_letter;
- if (m_prev_gdb_format == 'i')
- m_prev_gdb_format = 'x';
- return true;
+ {
+ // Size isn't used for printing instructions, so if a size is specified, and
+ // the previous format was
+ // 'i', then we should reset it to the default ('x'). Otherwise we'll
+ // continue to print as instructions,
+ // which isn't expected.
+ if (format_letter == 'b')
+ byte_size = 1;
+ else if (format_letter == 'h')
+ byte_size = 2;
+ else if (format_letter == 'w')
+ byte_size = 4;
+ else if (format_letter == 'g')
+ byte_size = 8;
+ m_prev_gdb_size = format_letter;
+ if (m_prev_gdb_format == 'i')
+ m_prev_gdb_format = 'x';
+ return true;
+ }
break;
default:
break;
}
+
+
return false;
}
diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp
index b9538fb14ddf..7b0ee61dd7eb 100644
--- a/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/source/Interpreter/OptionGroupOutputFile.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Utility/Utils.h"
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupPlatform.cpp b/source/Interpreter/OptionGroupPlatform.cpp
index 62311626f109..f6edca82a142 100644
--- a/source/Interpreter/OptionGroupPlatform.cpp
+++ b/source/Interpreter/OptionGroupPlatform.cpp
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Platform.h"
-#include "lldb/Utility/Utils.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupString.cpp b/source/Interpreter/OptionGroupString.cpp
index 48a9ff1a9eb0..5705264dba20 100644
--- a/source/Interpreter/OptionGroupString.cpp
+++ b/source/Interpreter/OptionGroupString.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp
index a8501fab42f4..a6a0d49232c1 100644
--- a/source/Interpreter/OptionGroupUInt64.cpp
+++ b/source/Interpreter/OptionGroupUInt64.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp
index cd6c02a7c730..32a9962b5b97 100644
--- a/source/Interpreter/OptionGroupUUID.cpp
+++ b/source/Interpreter/OptionGroupUUID.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Utility/Utils.h"
+#include "lldb/Host/OptionParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 6d331326dec6..89acf3f0d3f9 100644
--- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -14,10 +14,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/DataFormatters/ValueObjectPrinter.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Utils.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/source/Interpreter/OptionGroupVariable.cpp b/source/Interpreter/OptionGroupVariable.cpp
index c257506135fa..760563071d7d 100644
--- a/source/Interpreter/OptionGroupVariable.cpp
+++ b/source/Interpreter/OptionGroupVariable.cpp
@@ -13,11 +13,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Utils.h"
+#include "lldb/Utility/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp
index cda934bd3943..1e6fab929ca7 100644
--- a/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
-#include "lldb/Utility/Utils.h"
#include "lldb/lldb-enumerations.h"
using namespace lldb;
diff --git a/source/Interpreter/OptionValue.cpp b/source/Interpreter/OptionValue.cpp
index 58de32cc6e1a..5f42f7f7056a 100644
--- a/source/Interpreter/OptionValue.cpp
+++ b/source/Interpreter/OptionValue.cpp
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/OptionValues.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueArray.cpp b/source/Interpreter/OptionValueArray.cpp
index 9dc463390ee3..0d1825cec28b 100644
--- a/source/Interpreter/OptionValueArray.cpp
+++ b/source/Interpreter/OptionValueArray.cpp
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueBoolean.cpp b/source/Interpreter/OptionValueBoolean.cpp
index 85799fe3cd4c..92e4d891c1a8 100644
--- a/source/Interpreter/OptionValueBoolean.cpp
+++ b/source/Interpreter/OptionValueBoolean.cpp
@@ -13,10 +13,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
diff --git a/source/Interpreter/OptionValueChar.cpp b/source/Interpreter/OptionValueChar.cpp
index 6423185a33f4..1f6acf61c68c 100644
--- a/source/Interpreter/OptionValueChar.cpp
+++ b/source/Interpreter/OptionValueChar.cpp
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
diff --git a/source/Interpreter/OptionValueEnumeration.cpp b/source/Interpreter/OptionValueEnumeration.cpp
index 679b5ccbaa6a..d3899677ba53 100644
--- a/source/Interpreter/OptionValueEnumeration.cpp
+++ b/source/Interpreter/OptionValueEnumeration.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueFileSpec.cpp b/source/Interpreter/OptionValueFileSpec.cpp
index a6eb5375851d..0df581af5d67 100644
--- a/source/Interpreter/OptionValueFileSpec.cpp
+++ b/source/Interpreter/OptionValueFileSpec.cpp
@@ -15,6 +15,7 @@
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Utility/DataBufferLLVM.h"
using namespace lldb;
using namespace lldb_private;
@@ -118,10 +119,8 @@ OptionValueFileSpec::GetFileContents(bool null_terminate) {
const auto file_mod_time = FileSystem::GetModificationTime(m_current_value);
if (m_data_sp && m_data_mod_time == file_mod_time)
return m_data_sp;
- if (null_terminate)
- m_data_sp = m_current_value.ReadFileContentsAsCString();
- else
- m_data_sp = m_current_value.ReadFileContents();
+ m_data_sp = DataBufferLLVM::CreateFromPath(m_current_value.GetPath(),
+ null_terminate);
m_data_mod_time = file_mod_time;
}
return m_data_sp;
diff --git a/source/Interpreter/OptionValueFileSpecLIst.cpp b/source/Interpreter/OptionValueFileSpecLIst.cpp
index e4bd4ba189e7..9cddf32206e4 100644
--- a/source/Interpreter/OptionValueFileSpecLIst.cpp
+++ b/source/Interpreter/OptionValueFileSpecLIst.cpp
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueFormat.cpp b/source/Interpreter/OptionValueFormat.cpp
index 041d8a500a87..7d58f63a381e 100644
--- a/source/Interpreter/OptionValueFormat.cpp
+++ b/source/Interpreter/OptionValueFormat.cpp
@@ -13,9 +13,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueFormatEntity.cpp b/source/Interpreter/OptionValueFormatEntity.cpp
index 03f077cf9e87..5259398dcd33 100644
--- a/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/source/Interpreter/OptionValueFormatEntity.cpp
@@ -14,9 +14,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueLanguage.cpp b/source/Interpreter/OptionValueLanguage.cpp
index b3da6d3ec4a3..2ea152c436c7 100644
--- a/source/Interpreter/OptionValueLanguage.cpp
+++ b/source/Interpreter/OptionValueLanguage.cpp
@@ -13,10 +13,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValuePathMappings.cpp b/source/Interpreter/OptionValuePathMappings.cpp
index 5b9850d45216..54797422cba3 100644
--- a/source/Interpreter/OptionValuePathMappings.cpp
+++ b/source/Interpreter/OptionValuePathMappings.cpp
@@ -13,10 +13,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueProperties.cpp b/source/Interpreter/OptionValueProperties.cpp
index 7e4df3a3e1d2..10370c2f667f 100644
--- a/source/Interpreter/OptionValueProperties.cpp
+++ b/source/Interpreter/OptionValueProperties.cpp
@@ -13,13 +13,14 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Interpreter/Property.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueRegex.cpp b/source/Interpreter/OptionValueRegex.cpp
index 86ef102a7588..6823300c515a 100644
--- a/source/Interpreter/OptionValueRegex.cpp
+++ b/source/Interpreter/OptionValueRegex.cpp
@@ -13,7 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueSInt64.cpp b/source/Interpreter/OptionValueSInt64.cpp
index 3f3844ae402a..3bdbfb9e2fae 100644
--- a/source/Interpreter/OptionValueSInt64.cpp
+++ b/source/Interpreter/OptionValueSInt64.cpp
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueString.cpp b/source/Interpreter/OptionValueString.cpp
index e61ead081b89..149ccbc7b518 100644
--- a/source/Interpreter/OptionValueString.cpp
+++ b/source/Interpreter/OptionValueString.cpp
@@ -14,8 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueUInt64.cpp b/source/Interpreter/OptionValueUInt64.cpp
index 8986080bbd22..826c9e5ba887 100644
--- a/source/Interpreter/OptionValueUInt64.cpp
+++ b/source/Interpreter/OptionValueUInt64.cpp
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp
index 3519334b8a0f..7378195a2f94 100644
--- a/source/Interpreter/OptionValueUUID.cpp
+++ b/source/Interpreter/OptionValueUUID.cpp
@@ -14,9 +14,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index d26e53f121c4..b8b9bdf54a0d 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -18,12 +18,13 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/StreamString.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Interpreter/ScriptInterpreter.cpp b/source/Interpreter/ScriptInterpreter.cpp
index d87d24e46db7..0f7e1f8d74f4 100644
--- a/source/Interpreter/ScriptInterpreter.cpp
+++ b/source/Interpreter/ScriptInterpreter.cpp
@@ -13,11 +13,11 @@
#include <stdlib.h>
#include <string>
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StringList.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
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();
+
+ 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);
+ }
- 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 (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));
-
- // 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;
-
- 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));
-
- 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
+ if (!object_name)
+ return nullptr;
+
+ 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));
+
+ // 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;
+
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);
-
- 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);
- }
+ 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);
}
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 (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformFreeBSD::CreateInstance);
}
}
- 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());
- }
- }
- }
- }
-
- 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
-
-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;
-}
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
-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;
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
- if (IsHost()) {
- error.SetErrorStringWithFormat(
- "can't disconnect from the host platform '%s', always connected",
- GetPluginName().GetCString());
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote();
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
-bool PlatformNetBSD::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else if (m_remote_platform_sp) {
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformNetBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
-const char *PlatformNetBSD::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *PlatformNetBSD::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
-Error PlatformNetBSD::GetSharedModule(
- const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) {
- Error error;
- module_sp.reset();
-
- if (IsRemote()) {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp) {
- error = m_remote_platform_sp->GetSharedModule(
- module_spec, process, module_sp, module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- }
-
- if (!module_sp) {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule(module_spec, process, module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
-}
+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) {
+ Platform::GetStatus(strm);
+
#ifndef LLDB_DISABLE_POSIX
- struct ::utsname un;
+ // 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;
- strm << " Host: ";
+ if (uname(&un))
+ return;
- ::memset(&un, 0, sizeof(utsname));
- if (::uname(&un) == -1) {
- strm << "NetBSD" << '\n';
- } else {
- strm << un.sysname << ' ' << un.release;
- if (un.nodename[0] != '\0')
- strm << " (" << un.nodename << ')';
- strm << '\n';
-
- // Dump a common information about the platform status.
- strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version
- << '\n';
+ 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;
-
- error = debugger.GetTargetList().CreateTarget(debugger, "", emptyArchSpec,
- false, m_remote_platform_sp,
- new_target_sp);
- target = new_target_sp.get();
- } else
- error.Clear();
-
- if (target && error.Success()) {
- debugger.GetTargetList().SetSelectedTarget(target);
- // The netbsd always currently uses the GDB remote debugger plug-in
- // so even when debugging locally we are debugging remotely!
- // Just like the darwin plugin.
- process_sp = target->CreateProcess(
- attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
-
- if (process_sp)
- error = process_sp->Attach(attach_info);
+// 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);
+
+ //
+ // For local debugging, we'll insist on having ProcessGDBRemote create the
+ // process.
+ //
+
+ 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;
+ }
+
+ 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);
-
- // 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();
+ 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;
+}
+
+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>";
-
- // 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();
+ NativeProcessLinux &process = GetProcess();
+
+ 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.
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- Error error;
+ // 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 = 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;
-}
-
-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());
-}
-
-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);
- }
-}
+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},
+};
+
+Log::Channel ProcessKDPLog::g_channel(g_categories, KDP_LOG_DEFAULT);
+
+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/Host/common/NativeRegisterContextRegisterInfo.cpp b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
index 5ff596b57693..0b1814362425 100644
--- a/source/Host/common/NativeRegisterContextRegisterInfo.cpp
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Host/common/NativeRegisterContextRegisterInfo.h"
+#include "NativeRegisterContextRegisterInfo.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h"
diff --git a/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
index 908989a0624e..c1b597462b60 100644
--- a/include/lldb/Host/common/NativeRegisterContextRegisterInfo.h
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
@@ -1,5 +1,4 @@
-//===-- NativeRegisterContextRegisterInfo.h ----------------------*- C++
-//-*-===//
+//===-- NativeRegisterContextRegisterInfo.h ---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_NativeRegisterContextRegisterInfo_h
-#define lldb_NativeRegisterContextRegisterInfo_h
+#ifndef LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
+#define LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
#include <memory>
-#include "NativeRegisterContext.h"
-#include "Plugins/Process/Utility/RegisterInfoInterface.h"
+#include "RegisterInfoInterface.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
namespace lldb_private {
class NativeRegisterContextRegisterInfo : public NativeRegisterContext {
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},
+};
+
+Log::Channel ProcessGDBRemoteLog::g_channel(g_categories, GDBR_LOG_DEFAULT);
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::RegisterLogChannel(g_name, log_callbacks);
+ 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() {}
-
-LogChannelDWARF::~LogChannelDWARF() {}
+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},
+};
+
+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();
+ Log::Register("dwarf", g_channel);
}
-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 *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>
diff --git a/source/Symbol/ArmUnwindInfo.cpp b/source/Symbol/ArmUnwindInfo.cpp
index 19951498c1d7..742c057e10e3 100644
--- a/source/Symbol/ArmUnwindInfo.cpp
+++ b/source/Symbol/ArmUnwindInfo.cpp
@@ -12,10 +12,10 @@
#include "Utility/ARM_DWARF_Registers.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ArmUnwindInfo.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/Endian.h"
/*
* Unwind information reader and parser for the ARM exception handling ABI
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index 6c4c28d1f7f7..648d8ee48bf5 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -9,13 +9,13 @@
#include "lldb/Symbol/Block.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Symbol/CMakeLists.txt b/source/Symbol/CMakeLists.txt
index c5f7be73f4bf..69a2b5a1699c 100644
--- a/source/Symbol/CMakeLists.txt
+++ b/source/Symbol/CMakeLists.txt
@@ -36,4 +36,24 @@ add_lldb_library(lldbSymbol
Variable.cpp
VariableList.cpp
VerifyDecl.cpp
+
+ LINK_LIBS
+ clangAST
+ clangBasic
+ clangFrontend
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbTarget
+ lldbUtility
+ lldbPluginExpressionParserClang
+ lldbPluginExpressionParserGo
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFilePDB
+ lldbPluginObjectContainerBSDArchive
+ lldbPluginCPlusPlusLanguage
+ lldbPluginObjCLanguage
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 49b28349fd15..482a08322663 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -14,7 +14,7 @@
// C Includes
// C++ Includes
-#include <mutex> // std::once
+#include <mutex>
#include <string>
#include <vector>
@@ -65,16 +65,17 @@
#endif
#include "llvm/Support/Signals.h"
+#include "llvm/Support/Threading.h"
#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Flags.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Flags.h"
+
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
@@ -92,7 +93,10 @@
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
@@ -127,8 +131,8 @@ typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, ClangASTContext *>
static ClangASTMap &GetASTMap() {
static ClangASTMap *g_map_ptr = nullptr;
- 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, []() {
g_map_ptr = new ClangASTMap(); // leaked on purpose to avoid spins
});
return *g_map_ptr;
@@ -954,8 +958,8 @@ ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) {
if (name) {
typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
static TypeNameToBasicTypeMap g_type_map;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
// "void"
g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid);
@@ -4314,6 +4318,8 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::TemplateSpecialization:
break;
+ case clang::Type::DeducedTemplateSpecialization:
+ break;
case clang::Type::Atomic:
break;
case clang::Type::Pipe:
@@ -5039,7 +5045,6 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::Kind::OCLImage3dWO:
case clang::BuiltinType::Kind::OCLImage3dRW:
case clang::BuiltinType::Kind::OCLQueue:
- case clang::BuiltinType::Kind::OCLNDRange:
case clang::BuiltinType::Kind::OCLReserveID:
case clang::BuiltinType::Kind::OCLSampler:
case clang::BuiltinType::Kind::OMPArraySection:
@@ -5123,6 +5128,7 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::Type::TypeOf:
case clang::Type::Decltype:
case clang::Type::TemplateSpecialization:
+ case clang::Type::DeducedTemplateSpecialization:
case clang::Type::Atomic:
case clang::Type::Adjusted:
case clang::Type::Pipe:
@@ -5272,6 +5278,7 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::TypeOf:
case clang::Type::Decltype:
case clang::Type::TemplateSpecialization:
+ case clang::Type::DeducedTemplateSpecialization:
case clang::Type::Atomic:
case clang::Type::Adjusted:
case clang::Type::Pipe:
@@ -8821,7 +8828,7 @@ ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
void ClangASTContext::DumpValue(
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s,
- lldb::Format format, const lldb_private::DataExtractor &data,
+ lldb::Format format, const DataExtractor &data,
lldb::offset_t data_byte_offset, size_t data_byte_size,
uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types,
bool show_summary, bool verbose, uint32_t depth) {
@@ -9029,8 +9036,9 @@ void ClangASTContext::DumpValue(
if (is_array_of_characters) {
s->PutChar('"');
- data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size,
- element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ DumpDataExtractor(data, s, data_byte_offset, lldb::eFormatChar,
+ element_byte_size, element_count, UINT32_MAX,
+ LLDB_INVALID_ADDRESS, 0, 0);
s->PutChar('"');
return;
} else {
@@ -9186,8 +9194,9 @@ void ClangASTContext::DumpValue(
default:
// We are down to a scalar type that we just need to display.
- data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX,
- LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset);
+ DumpDataExtractor(data, s, data_byte_offset, format, data_byte_size, 1,
+ UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size,
+ bitfield_bit_offset);
if (show_summary)
DumpSummary(type, exe_ctx, s, data, data_byte_offset, data_byte_size);
@@ -9197,8 +9206,8 @@ void ClangASTContext::DumpValue(
bool ClangASTContext::DumpTypeValue(
lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format,
- const lldb_private::DataExtractor &data, lldb::offset_t byte_offset,
- size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
+ const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size,
+ uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
ExecutionContextScope *exe_scope) {
if (!type)
return false;
@@ -9336,9 +9345,10 @@ bool ClangASTContext::DumpTypeValue(
byte_size = 4;
break;
}
- return data.Dump(s, byte_offset, format, byte_size, item_count,
- UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size,
- bitfield_bit_offset, exe_scope);
+ return DumpDataExtractor(data, s, byte_offset, format, byte_size,
+ item_count, UINT32_MAX, LLDB_INVALID_ADDRESS,
+ bitfield_bit_size, bitfield_bit_offset,
+ exe_scope);
}
break;
}
@@ -9364,8 +9374,8 @@ void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
else
buf.resize(256);
- lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(),
- process->GetByteOrder(), 4);
+ DataExtractor cstr_data(&buf.front(), buf.size(),
+ process->GetByteOrder(), 4);
buf.back() = '\0';
size_t bytes_read;
size_t total_cstr_len = 0;
@@ -9377,8 +9387,8 @@ void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
break;
if (total_cstr_len == 0)
s->PutCString(" \"");
- cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX,
- LLDB_INVALID_ADDRESS, 0, 0);
+ DumpDataExtractor(cstr_data, s, 0, lldb::eFormatChar, 1, len,
+ UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
total_cstr_len += len;
if (len < buf.size())
break;
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index c0e8fea1f3bf..72ccaed43eaa 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -8,12 +8,12 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
diff --git a/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
index e39baea8ead2..c88119bc9a4c 100644
--- a/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
@@ -40,7 +40,7 @@
#include <assert.h>
#endif
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
#include "clang/AST/Decl.h"
using namespace clang;
@@ -61,93 +61,6 @@ bool ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(
}
std::string decl_name(clang_decl_name.getAsString());
-
- switch (clang_decl_name.getNameKind()) {
- // Normal identifiers.
- case clang::DeclarationName::Identifier:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"Identifier\", name = \"%s\")\n", decl_ctx,
- // decl_name.c_str());
- if (clang_decl_name.getAsIdentifierInfo()->getBuiltinID() != 0) {
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
- }
- break;
-
- case clang::DeclarationName::ObjCZeroArgSelector:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"ObjCZeroArgSelector\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::ObjCOneArgSelector:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"ObjCOneArgSelector\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::ObjCMultiArgSelector:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"ObjCMultiArgSelector\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXConstructorName:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXConstructorName\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXDestructorName:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXDestructorName\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXConversionFunctionName:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXConversionFunctionName\", name =
- // \"%s\")\n", decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXOperatorName:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXOperatorName\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXLiteralOperatorName:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXLiteralOperatorName\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
-
- case clang::DeclarationName::CXXUsingDirective:
- // printf
- // ("ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(decl_ctx
- // = %p, decl_name = { kind = \"CXXUsingDirective\", name = \"%s\")\n",
- // decl_ctx, decl_name.c_str());
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
- }
-
SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
return false;
}
diff --git a/source/Symbol/ClangExternalASTSourceCommon.cpp b/source/Symbol/ClangExternalASTSourceCommon.cpp
index 69263fa67da0..7a1a0f23a7ce 100644
--- a/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp
index e3da6f17cfa4..77fcd33bbb3b 100644
--- a/source/Symbol/CompactUnwindInfo.cpp
+++ b/source/Symbol/CompactUnwindInfo.cpp
@@ -12,17 +12,17 @@
#include <algorithm>
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompactUnwindInfo.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/Support/MathExtras.h"
diff --git a/source/Symbol/CompilerType.cpp b/source/Symbol/CompilerType.cpp
index 2684db980aac..cc33dc196226 100644
--- a/source/Symbol/CompilerType.cpp
+++ b/source/Symbol/CompilerType.cpp
@@ -9,19 +9,19 @@
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include <iterator>
#include <mutex>
@@ -744,8 +744,7 @@ size_t CompilerType::ConvertStringToFloatValue(const char *s, uint8_t *dst,
#define DEPTH_INCREMENT 2
void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
- lldb::Format format,
- const lldb_private::DataExtractor &data,
+ lldb::Format format, const DataExtractor &data,
lldb::offset_t data_byte_offset,
size_t data_byte_size, uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset, bool show_types,
@@ -759,7 +758,7 @@ void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
}
bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format,
- const lldb_private::DataExtractor &data,
+ const DataExtractor &data,
lldb::offset_t byte_offset, size_t byte_size,
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset,
@@ -772,7 +771,7 @@ bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format,
}
void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s,
- const lldb_private::DataExtractor &data,
+ const DataExtractor &data,
lldb::offset_t data_byte_offset,
size_t data_byte_size) {
if (IsValid())
diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp
index 9504ea184236..d229e880d97d 100644
--- a/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/source/Symbol/DWARFCallFrameInfo.cpp
@@ -12,21 +12,144 @@
#include <list>
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Section.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Core/dwarf.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
+//----------------------------------------------------------------------
+// GetDwarfEHPtr
+//
+// Used for calls when the value type is specified by a DWARF EH Frame
+// pointer encoding.
+//----------------------------------------------------------------------
+static uint64_t
+GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr,
+ uint32_t eh_ptr_enc, addr_t pc_rel_addr, addr_t text_addr,
+ addr_t data_addr) //, BSDRelocs *data_relocs) const
+{
+ if (eh_ptr_enc == DW_EH_PE_omit)
+ return ULLONG_MAX; // Value isn't in the buffer...
+
+ uint64_t baseAddress = 0;
+ uint64_t addressValue = 0;
+ const uint32_t addr_size = DE.GetAddressByteSize();
+#ifdef LLDB_CONFIGURATION_DEBUG
+ assert(addr_size == 4 || addr_size == 8);
+#endif
+
+ bool signExtendValue = false;
+ // Decode the base part or adjust our offset
+ switch (eh_ptr_enc & 0x70) {
+ case DW_EH_PE_pcrel:
+ signExtendValue = true;
+ baseAddress = *offset_ptr;
+ if (pc_rel_addr != LLDB_INVALID_ADDRESS)
+ baseAddress += pc_rel_addr;
+ // else
+ // Log::GlobalWarning ("PC relative pointer encoding found with
+ // invalid pc relative address.");
+ break;
+
+ case DW_EH_PE_textrel:
+ signExtendValue = true;
+ if (text_addr != LLDB_INVALID_ADDRESS)
+ baseAddress = text_addr;
+ // else
+ // Log::GlobalWarning ("text relative pointer encoding being
+ // decoded with invalid text section address, setting base address
+ // to zero.");
+ break;
+
+ case DW_EH_PE_datarel:
+ signExtendValue = true;
+ if (data_addr != LLDB_INVALID_ADDRESS)
+ baseAddress = data_addr;
+ // else
+ // Log::GlobalWarning ("data relative pointer encoding being
+ // decoded with invalid data section address, setting base address
+ // to zero.");
+ break;
+
+ case DW_EH_PE_funcrel:
+ signExtendValue = true;
+ break;
+
+ case DW_EH_PE_aligned: {
+ // SetPointerSize should be called prior to extracting these so the
+ // pointer size is cached
+ assert(addr_size != 0);
+ if (addr_size) {
+ // Align to a address size boundary first
+ uint32_t alignOffset = *offset_ptr % addr_size;
+ if (alignOffset)
+ offset_ptr += addr_size - alignOffset;
+ }
+ } break;
+
+ default:
+ break;
+ }
+
+ // Decode the value part
+ switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING) {
+ case DW_EH_PE_absptr: {
+ addressValue = DE.GetAddress(offset_ptr);
+ // if (data_relocs)
+ // addressValue = data_relocs->Relocate(*offset_ptr -
+ // addr_size, *this, addressValue);
+ } break;
+ case DW_EH_PE_uleb128:
+ addressValue = DE.GetULEB128(offset_ptr);
+ break;
+ case DW_EH_PE_udata2:
+ addressValue = DE.GetU16(offset_ptr);
+ break;
+ case DW_EH_PE_udata4:
+ addressValue = DE.GetU32(offset_ptr);
+ break;
+ case DW_EH_PE_udata8:
+ addressValue = DE.GetU64(offset_ptr);
+ break;
+ case DW_EH_PE_sleb128:
+ addressValue = DE.GetSLEB128(offset_ptr);
+ break;
+ case DW_EH_PE_sdata2:
+ addressValue = (int16_t)DE.GetU16(offset_ptr);
+ break;
+ case DW_EH_PE_sdata4:
+ addressValue = (int32_t)DE.GetU32(offset_ptr);
+ break;
+ case DW_EH_PE_sdata8:
+ addressValue = (int64_t)DE.GetU64(offset_ptr);
+ break;
+ default:
+ // Unhandled encoding type
+ assert(eh_ptr_enc);
+ break;
+ }
+
+ // Since we promote everything to 64 bit, we may need to sign extend
+ if (signExtendValue && addr_size < sizeof(baseAddress)) {
+ uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull);
+ if (sign_bit & addressValue) {
+ uint64_t mask = ~sign_bit + 1;
+ addressValue |= mask;
+ }
+ }
+ return baseAddress + addressValue;
+}
+
DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile &objfile,
SectionSP &section_sp,
lldb::RegisterKind reg_kind,
@@ -223,9 +346,9 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) {
{
uint8_t arg_ptr_encoding = m_cfi_data.GetU8(&offset);
const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
- cie_sp->personality_loc = m_cfi_data.GetGNUEHPointer(
- &offset, arg_ptr_encoding, pc_rel_addr, LLDB_INVALID_ADDRESS,
- LLDB_INVALID_ADDRESS);
+ cie_sp->personality_loc = GetGNUEHPointer(
+ m_cfi_data, &offset, arg_ptr_encoding, pc_rel_addr,
+ LLDB_INVALID_ADDRESS, LLDB_INVALID_ADDRESS);
}
break;
@@ -361,14 +484,15 @@ void DWARFCallFrameInfo::GetFDEIndex() {
const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS;
const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
- lldb::addr_t addr = m_cfi_data.GetGNUEHPointer(
- &offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr);
+ lldb::addr_t addr =
+ GetGNUEHPointer(m_cfi_data, &offset, cie->ptr_encoding, pc_rel_addr,
+ text_addr, data_addr);
if (clear_address_zeroth_bit)
addr &= ~1ull;
- lldb::addr_t length = m_cfi_data.GetGNUEHPointer(
- &offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr,
- text_addr, data_addr);
+ lldb::addr_t length = GetGNUEHPointer(
+ m_cfi_data, &offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING,
+ pc_rel_addr, text_addr, data_addr);
FDEEntryMap::Entry fde(addr, length, current_entry);
m_fde_index.Append(fde);
} else {
@@ -434,11 +558,12 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS;
const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
- lldb::addr_t range_base = m_cfi_data.GetGNUEHPointer(
- &offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr);
- lldb::addr_t range_len = m_cfi_data.GetGNUEHPointer(
- &offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr,
- text_addr, data_addr);
+ lldb::addr_t range_base =
+ GetGNUEHPointer(m_cfi_data, &offset, cie->ptr_encoding, pc_rel_addr,
+ text_addr, data_addr);
+ lldb::addr_t range_len = GetGNUEHPointer(
+ m_cfi_data, &offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING,
+ pc_rel_addr, text_addr, data_addr);
AddressRange range(range_base, m_objfile.GetAddressByteSize(),
m_objfile.GetSectionList());
range.SetByteSize(range_len);
@@ -449,8 +574,9 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
uint32_t aug_data_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
if (aug_data_len != 0 && cie->lsda_addr_encoding != DW_EH_PE_omit) {
offset_t saved_offset = offset;
- lsda_data_file_address = m_cfi_data.GetGNUEHPointer(
- &offset, cie->lsda_addr_encoding, pc_rel_addr, text_addr, data_addr);
+ lsda_data_file_address =
+ GetGNUEHPointer(m_cfi_data, &offset, cie->lsda_addr_encoding,
+ pc_rel_addr, text_addr, data_addr);
if (offset - saved_offset != aug_data_len) {
// There is more in the augmentation region than we know how to process;
// don't read anything.
diff --git a/source/Symbol/Declaration.cpp b/source/Symbol/Declaration.cpp
index 5d1dbdee1430..7cee6c5a3ef3 100644
--- a/source/Symbol/Declaration.cpp
+++ b/source/Symbol/Declaration.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/Declaration.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
@@ -42,7 +42,7 @@ void Declaration::Dump(Stream *s, bool show_fullpaths) const {
bool Declaration::DumpStopContext(Stream *s, bool show_fullpaths) const {
if (m_file) {
- if (show_fullpaths || s->GetVerbose())
+ if (show_fullpaths)
*s << m_file;
else
m_file.GetFilename().Dump(s);
diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp
index 0abd8a25b5d7..3b94e250dac7 100644
--- a/source/Symbol/FuncUnwinders.cpp
+++ b/source/Symbol/FuncUnwinders.cpp
@@ -19,10 +19,10 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.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"
using namespace lldb;
using namespace lldb_private;
@@ -73,13 +73,13 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target,
UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
int current_offset) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_compact_unwind.size() > 0)
return m_unwind_plan_compact_unwind[0]; // FIXME support multiple compact
// unwind plans for one func
if (m_tried_unwind_plan_compact_unwind)
return UnwindPlanSP();
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_plan_compact_unwind = true;
if (m_range.GetBaseAddress().IsValid()) {
Address current_pc(m_range.GetBaseAddress());
@@ -101,10 +101,10 @@ UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target,
int current_offset) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_eh_frame_sp.get() || m_tried_unwind_plan_eh_frame)
return m_unwind_plan_eh_frame_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_plan_eh_frame = true;
if (m_range.GetBaseAddress().IsValid()) {
Address current_pc(m_range.GetBaseAddress());
@@ -123,10 +123,10 @@ UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target,
UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target,
int current_offset) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_arm_unwind_sp.get() || m_tried_unwind_plan_arm_unwind)
return m_unwind_plan_arm_unwind_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_plan_arm_unwind = true;
if (m_range.GetBaseAddress().IsValid()) {
Address current_pc(m_range.GetBaseAddress());
@@ -147,6 +147,7 @@ UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target,
UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
Thread &thread,
int current_offset) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_eh_frame_augmented_sp.get() ||
m_tried_unwind_plan_eh_frame_augmented)
return m_unwind_plan_eh_frame_augmented_sp;
@@ -162,7 +163,6 @@ UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
return m_unwind_plan_eh_frame_augmented_sp;
}
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_plan_eh_frame_augmented = true;
UnwindPlanSP eh_frame_plan = GetEHFrameUnwindPlan(target, current_offset);
@@ -190,12 +190,12 @@ UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target,
Thread &thread,
int current_offset) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_assembly_sp.get() || m_tried_unwind_plan_assembly ||
m_unwind_table.GetAllowAssemblyEmulationUnwindPlans() == false) {
return m_unwind_plan_assembly_sp;
}
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_plan_assembly = true;
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
@@ -298,10 +298,10 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target,
UnwindPlanSP FuncUnwinders::GetUnwindPlanFastUnwind(Target &target,
Thread &thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_fast_sp.get() || m_tried_unwind_fast)
return m_unwind_plan_fast_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_fast = true;
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
@@ -316,10 +316,10 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanFastUnwind(Target &target,
}
UnwindPlanSP FuncUnwinders::GetUnwindPlanArchitectureDefault(Thread &thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_arch_default_sp.get() || m_tried_unwind_arch_default)
return m_unwind_plan_arch_default_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_arch_default = true;
Address current_pc;
@@ -340,11 +340,11 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanArchitectureDefault(Thread &thread) {
UnwindPlanSP
FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry(Thread &thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_arch_default_at_func_entry_sp.get() ||
m_tried_unwind_arch_default_at_func_entry)
return m_unwind_plan_arch_default_at_func_entry_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_tried_unwind_arch_default_at_func_entry = true;
Address current_pc;
@@ -365,10 +365,10 @@ FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry(Thread &thread) {
}
Address &FuncUnwinders::GetFirstNonPrologueInsn(Target &target) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_first_non_prologue_insn.IsValid())
return m_first_non_prologue_insn;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
ExecutionContext exe_ctx(target.shared_from_this(), false);
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
if (assembly_profiler_sp)
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 8fde0a423883..9464cef0bc73 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -228,12 +228,15 @@ const CompileUnit *Function::GetCompileUnit() const { return m_comp_unit; }
void Function::GetDescription(Stream *s, lldb::DescriptionLevel level,
Target *target) {
- Type *func_type = GetType();
- const char *name = func_type ? func_type->GetName().AsCString() : "<unknown>";
-
- *s << "id = " << (const UserID &)*this << ", name = \"" << name
- << "\", range = ";
-
+ ConstString name = GetName();
+ ConstString mangled = m_mangled.GetMangledName();
+
+ *s << "id = " << (const UserID &)*this;
+ if (name)
+ *s << ", name = \"" << name.GetCString() << '"';
+ if (mangled)
+ *s << ", mangled = \"" << mangled.GetCString() << '"';
+ *s << ", range = ";
Address::DumpStyle fallback_style;
if (level == eDescriptionLevelVerbose)
fallback_style = Address::DumpStyleModuleWithFileAddress;
diff --git a/source/Symbol/GoASTContext.cpp b/source/Symbol/GoASTContext.cpp
index a28a6d756846..5ca173ae113c 100644
--- a/source/Symbol/GoASTContext.cpp
+++ b/source/Symbol/GoASTContext.cpp
@@ -11,12 +11,12 @@
#include <utility>
#include <vector>
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/GoASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -25,6 +25,8 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "llvm/Support/Threading.h"
+
#include "Plugins/ExpressionParser/Go/GoUserExpression.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserGo.h"
@@ -593,8 +595,8 @@ GoASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
if (name) {
typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
static TypeNameToBasicTypeMap g_type_map;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
// "void"
g_type_map.Append(ConstString("void").GetStringRef(), eBasicTypeVoid);
// "int"
@@ -1261,9 +1263,9 @@ bool GoASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
byte_size = 4;
break;
}
- return data.Dump(s, byte_offset, format, byte_size, item_count, UINT32_MAX,
- LLDB_INVALID_ADDRESS, bitfield_bit_size,
- bitfield_bit_offset, exe_scope);
+ return DumpDataExtractor(data, s, byte_offset, format, byte_size,
+ item_count, UINT32_MAX, LLDB_INVALID_ADDRESS,
+ bitfield_bit_size, bitfield_bit_offset, exe_scope);
}
return 0;
}
diff --git a/source/Symbol/JavaASTContext.cpp b/source/Symbol/JavaASTContext.cpp
index 79073a653676..ac029dfe5dc8 100644
--- a/source/Symbol/JavaASTContext.cpp
+++ b/source/Symbol/JavaASTContext.cpp
@@ -10,10 +10,9 @@
#include <sstream>
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DWARFExpression.h"
@@ -22,6 +21,7 @@
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserJava.h"
@@ -1004,10 +1004,10 @@ bool JavaASTContext::DumpTypeValue(
size_t data_byte_size, uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) {
if (IsScalarType(type)) {
- return data.Dump(s, data_offset, format, data_byte_size,
- 1, // count
- UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size,
- bitfield_bit_offset, exe_scope);
+ return DumpDataExtractor(data, s, data_offset, format, data_byte_size,
+ 1, // count
+ UINT32_MAX, LLDB_INVALID_ADDRESS,
+ bitfield_bit_size, bitfield_bit_offset, exe_scope);
}
return false;
}
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp
index 02ab0c126117..3cb305302927 100644
--- a/source/Symbol/LineTable.cpp
+++ b/source/Symbol/LineTable.cpp
@@ -11,8 +11,8 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Utility/Stream.h"
#include <algorithm>
using namespace lldb;
@@ -230,6 +230,14 @@ bool LineTable::FindLineEntryByAddress(const Address &so_addr,
}
}
}
+ else
+ {
+ // There might be code in the containing objfile before the first line
+ // table entry. Make sure that does not get considered part of the first
+ // line table entry.
+ if (pos->file_addr > so_addr.GetFileAddress())
+ return false;
+ }
// Make sure we have a valid match and that the match isn't a
// terminating
@@ -501,6 +509,7 @@ LineTable *LineTable::LinkLineTable(const FileRangeMap &file_range_map) {
if (terminate_previous_entry && !sequence.m_entries.empty()) {
assert(prev_file_addr != LLDB_INVALID_ADDRESS);
+ UNUSED_IF_ASSERT_DISABLED(prev_file_addr);
sequence.m_entries.push_back(sequence.m_entries.back());
if (prev_end_entry_linked_file_addr == LLDB_INVALID_ADDRESS)
prev_end_entry_linked_file_addr =
diff --git a/source/Symbol/OCamlASTContext.cpp b/source/Symbol/OCamlASTContext.cpp
index d459be3c23d2..1456ebfa9dce 100644
--- a/source/Symbol/OCamlASTContext.cpp
+++ b/source/Symbol/OCamlASTContext.cpp
@@ -9,7 +9,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/OCamlASTContext.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
@@ -19,6 +19,7 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h"
@@ -621,9 +622,9 @@ bool OCamlASTContext::DumpTypeValue(
}
if (IsScalarType(type)) {
- return data.Dump(s, byte_offset, format, byte_size, 1, SIZE_MAX,
- LLDB_INVALID_ADDRESS, bitfield_bit_size,
- bitfield_bit_offset, exe_scope);
+ return DumpDataExtractor(data, s, byte_offset, format, byte_size, 1,
+ SIZE_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size,
+ bitfield_bit_offset, exe_scope);
}
return false;
diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp
index 0b1d6b29983b..483a315defbd 100644
--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -9,18 +9,22 @@
#include "lldb/Symbol/ObjectFile.h"
#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "lldb/Core/DataBuffer.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/RegularExpression.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/ObjectContainer.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/lldb-private.h"
using namespace lldb;
@@ -73,8 +77,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
// and object container plug-ins can use these bytes to see if they
// can parse this file.
if (file_size > 0) {
- data_sp = file->ReadFileContents(file_offset,
- std::min<size_t>(512, file_size));
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), 512, file_offset);
data_offset = 0;
}
}
@@ -117,7 +121,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
}
// We failed to find any cached object files in the container
// plug-ins, so lets read the first 512 bytes and try again below...
- data_sp = archive_file.ReadFileContents(file_offset, 512);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(archive_file.GetPath(),
+ 512, file_offset);
}
}
}
@@ -203,7 +208,7 @@ size_t ObjectFile::GetModuleSpecifications(const FileSpec &file,
lldb::offset_t file_offset,
lldb::offset_t file_size,
ModuleSpecList &specs) {
- DataBufferSP data_sp(file.ReadFileContents(file_offset, 512));
+ DataBufferSP data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), 512, file_offset);
if (data_sp) {
if (file_size == 0) {
const lldb::offset_t actual_file_size = file.GetByteSize();
@@ -648,3 +653,40 @@ ConstString ObjectFile::GetNextSyntheticSymbolName() {
file_name.GetCString());
return ConstString(ss.GetString());
}
+
+Error ObjectFile::LoadInMemory(Target &target, bool set_pc) {
+ Error error;
+ ProcessSP process = target.CalculateProcess();
+ if (!process)
+ return Error("No Process");
+ if (set_pc && !GetEntryPointAddress().IsValid())
+ return Error("No entry address in object file");
+
+ SectionList *section_list = GetSectionList();
+ if (!section_list)
+ return Error("No section in object file");
+ size_t section_count = section_list->GetNumSections(0);
+ for (size_t i = 0; i < section_count; ++i) {
+ SectionSP section_sp = section_list->GetSectionAtIndex(i);
+ addr_t addr = target.GetSectionLoadList().GetSectionLoadAddress(section_sp);
+ if (addr != LLDB_INVALID_ADDRESS) {
+ DataExtractor section_data;
+ // We can skip sections like bss
+ if (section_sp->GetFileSize() == 0)
+ continue;
+ section_sp->GetSectionData(section_data);
+ lldb::offset_t written = process->WriteMemory(
+ addr, section_data.GetDataStart(), section_data.GetByteSize(), error);
+ if (written != section_data.GetByteSize())
+ return error;
+ }
+ }
+ if (set_pc) {
+ ThreadList &thread_list = process->GetThreadList();
+ ThreadSP curr_thread(thread_list.GetSelectedThread());
+ RegisterContextSP reg_context(curr_thread->GetRegisterContext());
+ Address file_entry = GetEntryPointAddress();
+ reg_context->SetPC(file_entry.GetLoadAddress(&target));
+ }
+ return error;
+}
diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp
index d24365720f56..ab297ef330f2 100644
--- a/source/Symbol/Symbol.cpp
+++ b/source/Symbol/Symbol.cpp
@@ -12,13 +12,13 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index e43a70f78e42..d99bfc609261 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -9,7 +9,6 @@
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Host.h"
@@ -23,6 +22,7 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index 8d8b606b5729..d7898919f45e 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -9,14 +9,14 @@
#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private.h"
using namespace lldb_private;
diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp
index a0a40efd0c06..f5a08739f24d 100644
--- a/source/Symbol/SymbolVendor.cpp
+++ b/source/Symbol/SymbolVendor.cpp
@@ -15,10 +15,10 @@
// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index 09cfd8ead88c..427029802634 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -13,14 +13,15 @@
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/STLUtils.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symtab.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -328,6 +329,11 @@ void Symtab::InitNameIndexes() {
} else {
// No context for this function so this has to be a basename
m_basename_to_index.Append(entry);
+ // If there is no context (no namespaces or class scopes that
+ // come before the function name) then this also could be a
+ // fullname.
+ if (cxx_method.GetContext().empty())
+ m_name_to_index.Append(entry);
}
}
}
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 80d08bf742fc..89fc9f974c67 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -13,11 +13,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
diff --git a/source/Symbol/UnwindPlan.cpp b/source/Symbol/UnwindPlan.cpp
index 8a20ef8cce27..4c0014348c42 100644
--- a/source/Symbol/UnwindPlan.cpp
+++ b/source/Symbol/UnwindPlan.cpp
@@ -9,11 +9,11 @@
#include "lldb/Symbol/UnwindPlan.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index e17685e83e2a..0d1db1cdeac0 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -10,8 +10,6 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/Block.h"
@@ -30,6 +28,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/Twine.h"
diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp
index a81b95b7937f..e7a482e158b1 100644
--- a/source/Symbol/VariableList.cpp
+++ b/source/Symbol/VariableList.cpp
@@ -9,10 +9,10 @@
#include "lldb/Symbol/VariableList.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Utility/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/CMakeLists.txt b/source/Target/CMakeLists.txt
index cdb047a66400..1d858ae584d9 100644
--- a/source/Target/CMakeLists.txt
+++ b/source/Target/CMakeLists.txt
@@ -13,6 +13,7 @@ add_lldb_library(lldbTarget
LanguageRuntime.cpp
Memory.cpp
MemoryHistory.cpp
+ ModuleCache.cpp
ObjCLanguageRuntime.cpp
OperatingSystem.cpp
PathMappingList.cpp
@@ -24,6 +25,7 @@ add_lldb_library(lldbTarget
QueueItem.cpp
QueueList.cpp
RegisterContext.cpp
+ RegisterNumber.cpp
SectionLoadHistory.cpp
SectionLoadList.cpp
StackFrame.cpp
@@ -58,4 +60,19 @@ add_lldb_library(lldbTarget
ThreadSpec.cpp
UnixSignals.cpp
UnwindAssembly.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbUtility
+ lldbPluginExpressionParserClang
+ lldbPluginObjCLanguage
+ lldbPluginProcessUtility
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Target/FileAction.cpp b/source/Target/FileAction.cpp
index 7c2567ebea2d..c9cc325b5a53 100644
--- a/source/Target/FileAction.cpp
+++ b/source/Target/FileAction.cpp
@@ -9,9 +9,9 @@
#include <fcntl.h>
-#include "lldb/Core/Stream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Target/FileAction.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/source/Target/InstrumentationRuntime.cpp b/source/Target/InstrumentationRuntime.cpp
index f3bc145f8b4e..ac8b5dfe4599 100644
--- a/source/Target/InstrumentationRuntime.cpp
+++ b/source/Target/InstrumentationRuntime.cpp
@@ -15,8 +15,8 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/lldb-private.h"
using namespace lldb;
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
index 938d80ac1758..8fef32a3b186 100644
--- a/source/Target/Language.cpp
+++ b/source/Target/Language.cpp
@@ -15,10 +15,12 @@
#include "lldb/Target/Language.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Stream.h"
+
+#include "llvm/Support/Threading.h"
using namespace lldb;
using namespace lldb_private;
@@ -29,9 +31,9 @@ typedef std::map<lldb::LanguageType, LanguageUP> LanguagesMap;
static LanguagesMap &GetLanguagesMap() {
static LanguagesMap *g_map = nullptr;
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
- std::call_once(g_initialize, [] {
+ llvm::call_once(g_initialize, [] {
g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global
// destructor chain
});
@@ -40,9 +42,9 @@ static LanguagesMap &GetLanguagesMap() {
}
static std::mutex &GetLanguagesMutex() {
static std::mutex *g_mutex = nullptr;
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
- std::call_once(g_initialize, [] {
+ llvm::call_once(g_initialize, [] {
g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global
// destructor chain
});
diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp
index cacb491392f7..d0018b6df114 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -12,7 +12,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/LanguageRuntime.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/SearchFilter.h"
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index 775d0b305f26..c78bd7ad7b34 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -13,11 +13,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/State.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -252,146 +252,78 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, Error &error) {
AllocatedBlock::AllocatedBlock(lldb::addr_t addr, uint32_t byte_size,
uint32_t permissions, uint32_t chunk_size)
- : m_addr(addr), m_byte_size(byte_size), m_permissions(permissions),
- m_chunk_size(chunk_size), m_offset_to_chunk_size()
-// m_allocated (byte_size / chunk_size)
+ : m_range(addr, byte_size), m_permissions(permissions),
+ m_chunk_size(chunk_size)
{
+ // The entire address range is free to start with.
+ m_free_blocks.Append(m_range);
assert(byte_size > chunk_size);
}
AllocatedBlock::~AllocatedBlock() {}
lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
- addr_t addr = LLDB_INVALID_ADDRESS;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (size <= m_byte_size) {
- const uint32_t needed_chunks = CalculateChunksNeededForSize(size);
-
- if (m_offset_to_chunk_size.empty()) {
- m_offset_to_chunk_size[0] = needed_chunks;
- if (log)
- log->Printf("[1] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) "
- "=> offset = 0x%x, %u %u bit chunks",
- (void *)this, size, size, 0, needed_chunks, m_chunk_size);
- addr = m_addr;
- } else {
- uint32_t last_offset = 0;
- OffsetToChunkSize::const_iterator pos = m_offset_to_chunk_size.begin();
- OffsetToChunkSize::const_iterator end = m_offset_to_chunk_size.end();
- while (pos != end) {
- if (pos->first > last_offset) {
- const uint32_t bytes_available = pos->first - last_offset;
- const uint32_t num_chunks =
- CalculateChunksNeededForSize(bytes_available);
- if (num_chunks >= needed_chunks) {
- m_offset_to_chunk_size[last_offset] = needed_chunks;
- if (log)
- log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u "
- "(0x%x)) => offset = 0x%x, %u %u bit chunks - "
- "num_chunks %zu",
- (void *)this, size, size, last_offset, needed_chunks,
- m_chunk_size, m_offset_to_chunk_size.size());
- addr = m_addr + last_offset;
- break;
- }
- }
-
- last_offset = pos->first + pos->second * m_chunk_size;
-
- if (++pos == end) {
- // Last entry...
- const uint32_t chunks_left =
- CalculateChunksNeededForSize(m_byte_size - last_offset);
- if (chunks_left >= needed_chunks) {
- m_offset_to_chunk_size[last_offset] = needed_chunks;
- if (log)
- log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u "
- "(0x%x)) => offset = 0x%x, %u %u bit chunks - "
- "num_chunks %zu",
- (void *)this, size, size, last_offset, needed_chunks,
- m_chunk_size, m_offset_to_chunk_size.size());
- addr = m_addr + last_offset;
- break;
- }
- }
+ // We must return something valid for zero bytes.
+ if (size == 0)
+ size = 1;
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+ const size_t free_count = m_free_blocks.GetSize();
+ for (size_t i=0; i<free_count; ++i)
+ {
+ auto &free_block = m_free_blocks.GetEntryRef(i);
+ const lldb::addr_t range_size = free_block.GetByteSize();
+ if (range_size >= size)
+ {
+ // We found a free block that is big enough for our data. Figure out how
+ // many chunks we will need and calculate the resulting block size we will
+ // reserve.
+ addr_t addr = free_block.GetRangeBase();
+ size_t num_chunks = CalculateChunksNeededForSize(size);
+ lldb::addr_t block_size = num_chunks * m_chunk_size;
+ lldb::addr_t bytes_left = range_size - block_size;
+ if (bytes_left == 0)
+ {
+ // The newly allocated block will take all of the bytes in this
+ // available block, so we can just add it to the allocated ranges and
+ // remove the range from the free ranges.
+ m_reserved_blocks.Insert(free_block, false);
+ m_free_blocks.RemoveEntryAtIndex(i);
+ }
+ else
+ {
+ // Make the new allocated range and add it to the allocated ranges.
+ Range<lldb::addr_t, uint32_t> reserved_block(free_block);
+ reserved_block.SetByteSize(block_size);
+ // Insert the reserved range and don't combine it with other blocks
+ // in the reserved blocks list.
+ m_reserved_blocks.Insert(reserved_block, false);
+ // Adjust the free range in place since we won't change the sorted
+ // ordering of the m_free_blocks list.
+ free_block.SetRangeBase(reserved_block.GetRangeEnd());
+ free_block.SetByteSize(bytes_left);
}
+ LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size, addr);
+ return addr;
}
- // const uint32_t total_chunks = m_allocated.size ();
- // uint32_t unallocated_idx = 0;
- // uint32_t allocated_idx = m_allocated.find_first();
- // uint32_t first_chunk_idx = UINT32_MAX;
- // uint32_t num_chunks;
- // while (1)
- // {
- // if (allocated_idx == UINT32_MAX)
- // {
- // // No more bits are set starting from unallocated_idx, so
- // we
- // // either have enough chunks for the request, or we don't.
- // // Either way we break out of the while loop...
- // num_chunks = total_chunks - unallocated_idx;
- // if (needed_chunks <= num_chunks)
- // first_chunk_idx = unallocated_idx;
- // break;
- // }
- // else if (allocated_idx > unallocated_idx)
- // {
- // // We have some allocated chunks, check if there are
- // enough
- // // free chunks to satisfy the request?
- // num_chunks = allocated_idx - unallocated_idx;
- // if (needed_chunks <= num_chunks)
- // {
- // // Yep, we have enough!
- // first_chunk_idx = unallocated_idx;
- // break;
- // }
- // }
- //
- // while (unallocated_idx < total_chunks)
- // {
- // if (m_allocated[unallocated_idx])
- // ++unallocated_idx;
- // else
- // break;
- // }
- //
- // if (unallocated_idx >= total_chunks)
- // break;
- //
- // allocated_idx = m_allocated.find_next(unallocated_idx);
- // }
- //
- // if (first_chunk_idx != UINT32_MAX)
- // {
- // const uint32_t end_bit_idx = unallocated_idx + needed_chunks;
- // for (uint32_t idx = first_chunk_idx; idx < end_bit_idx; ++idx)
- // m_allocated.set(idx);
- // return m_addr + m_chunk_size * first_chunk_idx;
- // }
}
- if (log)
- log->Printf("AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => "
- "0x%16.16" PRIx64,
- (void *)this, size, size, (uint64_t)addr);
- return addr;
+ LLDB_LOGV(log, "({0}) (size = {1} ({1:x})) => {2:x}", this, size,
+ LLDB_INVALID_ADDRESS);
+ return LLDB_INVALID_ADDRESS;
}
bool AllocatedBlock::FreeBlock(addr_t addr) {
- uint32_t offset = addr - m_addr;
- OffsetToChunkSize::iterator pos = m_offset_to_chunk_size.find(offset);
bool success = false;
- if (pos != m_offset_to_chunk_size.end()) {
- m_offset_to_chunk_size.erase(pos);
+ auto entry_idx = m_reserved_blocks.FindEntryIndexThatContains(addr);
+ if (entry_idx != UINT32_MAX)
+ {
+ m_free_blocks.Insert(m_reserved_blocks.GetEntryRef(entry_idx), true);
+ m_reserved_blocks.RemoveEntryAtIndex(entry_idx);
success = true;
}
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (log)
- log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64
- ") => %i, num_chunks: %zu",
- (void *)this, (uint64_t)addr, success,
- m_offset_to_chunk_size.size());
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ LLDB_LOGV(log, "({0}) (addr = {1:x}) => {2}", this, addr, success);
return success;
}
diff --git a/source/Utility/ModuleCache.cpp b/source/Target/ModuleCache.cpp
index 889cd8f94667..a4aa26a0e480 100644
--- a/source/Utility/ModuleCache.cpp
+++ b/source/Target/ModuleCache.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "ModuleCache.h"
+#include "lldb/Target/ModuleCache.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/File.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/LockFile.h"
+#include "lldb/Utility/Log.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
@@ -59,21 +58,16 @@ public:
void Delete();
};
-FileSpec JoinPath(const FileSpec &path1, const char *path2) {
+static FileSpec JoinPath(const FileSpec &path1, const char *path2) {
FileSpec result_spec(path1);
result_spec.AppendPathComponent(path2);
return result_spec;
}
-Error MakeDirectory(const FileSpec &dir_path) {
- if (dir_path.Exists()) {
- if (!dir_path.IsDirectory())
- return Error("Invalid existing path");
+static Error MakeDirectory(const FileSpec &dir_path) {
+ namespace fs = llvm::sys::fs;
- return Error();
- }
-
- return FileSystem::MakeDirectory(dir_path, eFilePermissionsDirectoryDefault);
+ return fs::create_directories(dir_path.GetPath(), true, fs::perms::owner_all);
}
FileSpec GetModuleDirectory(const FileSpec &root_dir_spec, const UUID &uuid) {
@@ -106,15 +100,16 @@ void DeleteExistingModule(const FileSpec &root_dir_spec,
module_uuid.GetAsString().c_str(), error.AsCString());
}
- auto link_count = FileSystem::GetHardlinkCount(sysroot_module_path_spec);
- if (link_count == -1)
+ namespace fs = llvm::sys::fs;
+ fs::file_status st;
+ if (status(sysroot_module_path_spec.GetPath(), st))
return;
- if (link_count > 2) // module is referred by other hosts.
+ if (st.getLinkCount() > 2) // module is referred by other hosts.
return;
const auto module_spec_dir = GetModuleDirectory(root_dir_spec, module_uuid);
- FileSystem::DeleteDirectory(module_spec_dir, true);
+ llvm::sys::fs::remove_directories(module_spec_dir.GetPath());
lock.Delete();
}
@@ -124,11 +119,10 @@ void DecrementRefExistingModule(const FileSpec &root_dir_spec,
DeleteExistingModule(root_dir_spec, sysroot_module_path_spec);
// Remove sysroot link.
- FileSystem::Unlink(sysroot_module_path_spec);
+ llvm::sys::fs::remove(sysroot_module_path_spec.GetPath());
FileSpec symfile_spec = GetSymbolFileSpec(sysroot_module_path_spec);
- if (symfile_spec.Exists()) // delete module's symbol file if exists.
- FileSystem::Unlink(symfile_spec);
+ llvm::sys::fs::remove(symfile_spec.GetPath());
}
Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec,
@@ -151,7 +145,8 @@ Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec,
if (error.Fail())
return error;
- return FileSystem::Hardlink(sysroot_module_path_spec, local_module_spec);
+ return llvm::sys::fs::create_hard_link(local_module_spec.GetPath(),
+ sysroot_module_path_spec.GetPath());
}
} // namespace
@@ -184,7 +179,7 @@ void ModuleLock::Delete() {
return;
m_file.Close();
- FileSystem::Unlink(m_file_spec);
+ llvm::sys::fs::remove(m_file_spec.GetPath());
}
/////////////////////////////////////////////////////////////////////////
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
index 3ee4dd3ad57a..6aeb4c46df48 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Target/ObjCLanguageRuntime.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/Type.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/MappedHash.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -21,6 +20,7 @@
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/StringRef.h"
diff --git a/source/Target/PathMappingList.cpp b/source/Target/PathMappingList.cpp
index 90fff57d59bd..4fbaee98da61 100644
--- a/source/Target/PathMappingList.cpp
+++ b/source/Target/PathMappingList.cpp
@@ -14,11 +14,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index d8db53663f14..fd909075a240 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -18,30 +18,32 @@
#include "llvm/Support/Path.h"
// Project includes
-#include "Utility/ModuleCache.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/DataBufferHeap.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/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/ModuleCache.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
-#include "lldb/Utility/Utils.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/FileSystem.h"
// Define these constants from POSIX mman.h rather than include the file
// so that they will be correct even when compiled on Linux.
@@ -523,11 +525,11 @@ void Platform::AddClangModuleCompilationOptions(
FileSpec Platform::GetWorkingDirectory() {
if (IsHost()) {
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd)))
- return FileSpec{cwd, true};
- else
+ llvm::SmallString<64> cwd;
+ if (llvm::sys::fs::current_path(cwd))
return FileSpec{};
+ else
+ return FileSpec(cwd, true);
} else {
if (!m_working_dir)
m_working_dir = GetRemoteWorkingDirectory();
@@ -542,17 +544,18 @@ struct RecurseCopyBaton {
};
static FileSpec::EnumerateDirectoryResult
-RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
+RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &src) {
RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton;
- switch (file_type) {
- case FileSpec::eFileTypePipe:
- case FileSpec::eFileTypeSocket:
+ namespace fs = llvm::sys::fs;
+ switch (ft) {
+ case fs::file_type::fifo_file:
+ case fs::file_type::socket_file:
// we have no way to copy pipes and sockets - ignore them and continue
return FileSpec::eEnumerateDirectoryResultNext;
break;
- case FileSpec::eFileTypeDirectory: {
+ case fs::file_type::directory_file: {
// make the new directory and get in there
FileSpec dst_dir = rc_baton->dst;
if (!dst_dir.GetFilename())
@@ -582,7 +585,7 @@ RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
return FileSpec::eEnumerateDirectoryResultNext;
} break;
- case FileSpec::eFileTypeSymbolicLink: {
+ case fs::file_type::symlink_file: {
// copy the file and keep going
FileSpec dst_file = rc_baton->dst;
if (!dst_file.GetFilename())
@@ -604,7 +607,7 @@ RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
return FileSpec::eEnumerateDirectoryResultNext;
} break;
- case FileSpec::eFileTypeRegular: {
+ case fs::file_type::regular_file: {
// copy the file and keep going
FileSpec dst_file = rc_baton->dst;
if (!dst_file.GetFilename())
@@ -617,15 +620,13 @@ RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
return FileSpec::eEnumerateDirectoryResultNext;
} break;
- case FileSpec::eFileTypeInvalid:
- case FileSpec::eFileTypeOther:
- case FileSpec::eFileTypeUnknown:
+ default:
rc_baton->error.SetErrorStringWithFormat(
"invalid file detected during copy: %s", src.GetPath().c_str());
return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
break;
}
- llvm_unreachable("Unhandled FileSpec::FileType!");
+ llvm_unreachable("Unhandled file_type!");
}
Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
@@ -693,10 +694,10 @@ Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
if (GetSupportsRSync()) {
error = PutFile(src, dst);
} else {
- switch (src.GetFileType()) {
- case FileSpec::eFileTypeDirectory: {
- if (GetFileExists(fixed_dst))
- Unlink(fixed_dst);
+ namespace fs = llvm::sys::fs;
+ switch (fs::get_file_type(src.GetPath(), false)) {
+ case fs::file_type::directory_file: {
+ llvm::sys::fs::remove(fixed_dst.GetPath());
uint32_t permissions = src.GetPermissions();
if (permissions == 0)
permissions = eFilePermissionsDirectoryDefault;
@@ -714,29 +715,25 @@ Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
}
} break;
- case FileSpec::eFileTypeRegular:
- if (GetFileExists(fixed_dst))
- Unlink(fixed_dst);
+ case fs::file_type::regular_file:
+ llvm::sys::fs::remove(fixed_dst.GetPath());
error = PutFile(src, fixed_dst);
break;
- case FileSpec::eFileTypeSymbolicLink: {
- if (GetFileExists(fixed_dst))
- Unlink(fixed_dst);
+ case fs::file_type::symlink_file: {
+ llvm::sys::fs::remove(fixed_dst.GetPath());
FileSpec src_resolved;
error = FileSystem::Readlink(src, src_resolved);
if (error.Success())
error = CreateSymlink(dst, src_resolved);
} break;
- case FileSpec::eFileTypePipe:
+ case fs::file_type::fifo_file:
error.SetErrorString("platform install doesn't handle pipes");
break;
- case FileSpec::eFileTypeSocket:
+ case fs::file_type::socket_file:
error.SetErrorString("platform install doesn't handle sockets");
break;
- case FileSpec::eFileTypeInvalid:
- case FileSpec::eFileTypeUnknown:
- case FileSpec::eFileTypeOther:
+ default:
error.SetErrorString(
"platform install doesn't handle non file or directory items");
break;
@@ -748,14 +745,12 @@ Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
bool Platform::SetWorkingDirectory(const FileSpec &file_spec) {
if (IsHost()) {
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf("Platform::SetWorkingDirectory('%s')",
- file_spec.GetCString());
- if (file_spec) {
- if (::chdir(file_spec.GetCString()) == 0)
- return true;
+ LLDB_LOG(log, "{0}", file_spec);
+ if (std::error_code ec = llvm::sys::fs::set_current_path(file_spec.GetPath())) {
+ LLDB_LOG(log, "error: {0}", ec.message());
+ return false;
}
- return false;
+ return true;
} else {
m_working_dir.Clear();
return SetRemoteWorkingDirectory(file_spec);
@@ -764,7 +759,7 @@ bool Platform::SetWorkingDirectory(const FileSpec &file_spec) {
Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) {
if (IsHost())
- return FileSystem::MakeDirectory(file_spec, permissions);
+ return llvm::sys::fs::create_directory(file_spec.GetPath(), permissions);
else {
Error error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
@@ -776,9 +771,12 @@ Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) {
Error Platform::GetFilePermissions(const FileSpec &file_spec,
uint32_t &file_permissions) {
- if (IsHost())
- return FileSystem::GetFilePermissions(file_spec, file_permissions);
- else {
+ if (IsHost()) {
+ auto Value = llvm::sys::fs::getPermissions(file_spec.GetPath());
+ if (Value)
+ file_permissions = Value.get();
+ return Error(Value.getError());
+ } else {
Error error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
GetPluginName().GetCString(),
@@ -789,9 +787,10 @@ Error Platform::GetFilePermissions(const FileSpec &file_spec,
Error Platform::SetFilePermissions(const FileSpec &file_spec,
uint32_t file_permissions) {
- if (IsHost())
- return FileSystem::SetFilePermissions(file_spec, file_permissions);
- else {
+ if (IsHost()) {
+ auto Perms = static_cast<llvm::sys::fs::perms>(file_permissions);
+ return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms);
+ } else {
Error error;
error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
GetPluginName().GetCString(),
@@ -1239,7 +1238,8 @@ Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
uint32_t source_open_options =
File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
- if (source.GetFileType() == FileSpec::eFileTypeSymbolicLink)
+ namespace fs = llvm::sys::fs;
+ if (fs::is_symlink_file(source.GetPath()))
source_open_options |= File::eOpenOptionDontFollowSymlinks;
File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
@@ -1344,10 +1344,13 @@ lldb_private::Error Platform::RunShellCommand(
bool Platform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
uint64_t &high) {
- if (IsHost())
- return FileSystem::CalculateMD5(file_spec, low, high);
- else
+ if (!IsHost())
return false;
+ auto Result = llvm::sys::fs::md5_contents(file_spec.GetPath());
+ if (!Result)
+ return false;
+ std::tie(high, low) = Result->words();
+ return true;
}
void Platform::SetLocalCacheDirectory(const char *local) {
@@ -1643,8 +1646,9 @@ Error Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
const FileSpec &dst_file_spec) {
Error error;
- std::ofstream dst(dst_file_spec.GetPath(), std::ios::out | std::ios::binary);
- if (!dst.is_open()) {
+ std::error_code EC;
+ llvm::raw_fd_ostream dst(dst_file_spec.GetPath(), EC, llvm::sys::fs::F_None);
+ if (EC) {
error.SetErrorStringWithFormat("unable to open destination file: %s",
dst_file_spec.GetPath().c_str());
return error;
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index c72662e4e343..0bc58f073bf1 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -14,13 +14,14 @@
// Other libraries and framework includes
#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/Threading.h"
+
// Project includes
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -33,6 +34,7 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
@@ -63,6 +65,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanBase.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
#include "lldb/Utility/SelectHelper.h"
@@ -581,7 +584,7 @@ llvm::ArrayRef<OptionDefinition> ProcessLaunchCommandOptions::GetDefinitions() {
}
bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
- if (m_name_match_type == eNameMatchIgnore || process_name == nullptr)
+ if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
return true;
const char *match_name = m_match_info.GetName();
if (!match_name)
@@ -627,7 +630,7 @@ bool ProcessInstanceInfoMatch::Matches(
}
bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
- if (m_name_match_type != eNameMatchIgnore)
+ if (m_name_match_type != NameMatch::Ignore)
return false;
if (m_match_info.ProcessIDIsValid())
@@ -659,7 +662,7 @@ bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
void ProcessInstanceInfoMatch::Clear() {
m_match_info.Clear();
- m_name_match_type = eNameMatchIgnore;
+ m_name_match_type = NameMatch::Ignore;
m_match_all_users = false;
}
@@ -982,10 +985,7 @@ StateType Process::WaitForProcessToStop(const Timeout<std::micro> &timeout,
return state;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu)", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1));
+ LLDB_LOG(log, "timeout = {0}", timeout);
if (!wait_always && StateIsStoppedState(state, true) &&
StateIsStoppedState(GetPrivateState(), true)) {
@@ -1261,11 +1261,7 @@ StateType Process::GetStateChangedEvents(EventSP &event_sp,
const Timeout<std::micro> &timeout,
ListenerSP hijack_listener_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1));
+ LLDB_LOG(log, "timeout = {0}, event_sp)...", timeout);
ListenerSP listener_sp = hijack_listener_sp;
if (!listener_sp)
@@ -1277,15 +1273,11 @@ StateType Process::GetStateChangedEvents(EventSP &event_sp,
timeout)) {
if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
- else if (log)
- log->Printf("Process::%s got no event or was interrupted.", __FUNCTION__);
+ else
+ LLDB_LOG(log, "got no event or was interrupted.");
}
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1),
- StateAsCString(state));
+ LLDB_LOG(log, "timeout = {0}, event_sp) => {1}", timeout, state);
return state;
}
@@ -1314,11 +1306,7 @@ StateType
Process::GetStateChangedEventsPrivate(EventSP &event_sp,
const Timeout<std::micro> &timeout) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1));
+ LLDB_LOG(log, "timeout = {0}, event_sp)...", timeout);
StateType state = eStateInvalid;
if (m_private_state_listener_sp->GetEventForBroadcasterWithType(
@@ -1328,14 +1316,8 @@ Process::GetStateChangedEventsPrivate(EventSP &event_sp,
if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
- // This is a bit of a hack, but when we wait here we could very well return
- // to the command-line, and that could disable the log, which would render the
- // log we got above invalid.
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1),
- state == eStateInvalid ? "TIMEOUT" : StateAsCString(state));
+ LLDB_LOG(log, "timeout = {0}, event_sp) => {1}", timeout,
+ state == eStateInvalid ? "TIMEOUT" : StateAsCString(state));
return state;
}
@@ -1343,11 +1325,7 @@ bool Process::GetEventsPrivate(EventSP &event_sp,
const Timeout<std::micro> &timeout,
bool control_only) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (log)
- log->Printf(
- "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout ? timeout->count() : -1));
+ LLDB_LOG(log, "timeout = {0}, event_sp)...", timeout);
if (control_only)
return m_private_state_listener_sp->GetEventForBroadcaster(
@@ -1981,8 +1959,8 @@ size_t Process::RemoveBreakpointOpcodesFromBuffer(addr_t bp_addr, size_t size,
if (m_breakpoint_site_list.FindInRange(bp_addr, bp_addr + size,
bp_sites_in_range)) {
- bp_sites_in_range.ForEach([bp_addr, size, buf, &bytes_removed](
- BreakpointSite *bp_site) -> void {
+ bp_sites_in_range.ForEach([bp_addr, size,
+ buf](BreakpointSite *bp_site) -> void {
if (bp_site->GetType() == BreakpointSite::eSoftware) {
addr_t intersect_addr;
size_t intersect_size;
@@ -2798,7 +2776,12 @@ Error Process::Launch(ProcessLaunchInfo &launch_info) {
if (system_runtime)
system_runtime->DidLaunch();
- LoadOperatingSystemPlugin(false);
+ if (!m_os_ap)
+ LoadOperatingSystemPlugin(false);
+
+ // We successfully launched the process and stopped,
+ // now it the right time to set up signal filters before resuming.
+ UpdateAutomaticSignalFiltering();
// Note, the stop event was consumed above, but not handled. This
// was done
@@ -2862,7 +2845,9 @@ Error Process::LoadCore() {
if (system_runtime)
system_runtime->DidAttach();
- m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr));
+ if (!m_os_ap)
+ LoadOperatingSystemPlugin(false);
+
// We successfully loaded a core file, now pretend we stopped so we can
// show all of the threads in the core file and explore the crashed
// state.
@@ -3046,7 +3031,7 @@ Error Process::Attach(ProcessAttachInfo &attach_info) {
if (platform_sp) {
ProcessInstanceInfoMatch match_info;
match_info.GetProcessInfo() = attach_info;
- match_info.SetNameMatchType(eNameMatchEquals);
+ match_info.SetNameMatchType(NameMatch::Equals);
platform_sp->FindProcesses(match_info, process_infos);
const uint32_t num_matches = process_infos.GetSize();
if (num_matches == 1) {
@@ -3205,7 +3190,8 @@ void Process::CompleteAttach() {
}
}
- m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr));
+ if (!m_os_ap)
+ LoadOperatingSystemPlugin(false);
// Figure out which one is the executable, and set that in our target:
const ModuleList &target_modules = GetTarget().GetImages();
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
@@ -3276,6 +3262,10 @@ Error Process::PrivateResume() {
m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()),
StateAsCString(m_private_state.GetValue()));
+ // If signals handing status changed we might want to update
+ // our signal filters before resuming.
+ UpdateAutomaticSignalFiltering();
+
Error error(WillResume());
// Tell the process it is about to resume before the thread list
if (error.Success()) {
@@ -3754,8 +3744,8 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) {
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
char thread_name[1024];
-
- if (HostInfo::GetMaxThreadNameLength() <= 30) {
+ uint32_t max_len = llvm::get_max_thread_name_length();
+ if (max_len > 0 && max_len <= 30) {
// On platforms with abbreviated thread name lengths, choose thread names
// that fit within the limit.
if (already_running)
@@ -5248,15 +5238,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
do_resume = false;
handle_running_event = true;
} else {
- StopInfoSP stop_info_sp(thread_sp->GetStopInfo());
- StopReason stop_reason = eStopReasonInvalid;
- if (stop_info_sp)
- stop_reason = stop_info_sp->GetStopReason();
-
- // FIXME: We only check if the stop reason is plan complete,
- // should we make sure that
- // it is OUR plan that is complete?
- if (stop_reason == eStopReasonPlanComplete) {
+ ThreadPlanSP plan = thread->GetCompletedPlan();
+ if (plan == thread_plan_sp && plan->PlanSucceeded()) {
+
if (log)
log->PutCString("Process::RunThreadPlan(): execution "
"completed successfully.");
@@ -5267,9 +5251,11 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
return_value = eExpressionCompleted;
} else {
+ StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
// Something restarted the target, so just wait for it to
// stop for real.
- if (stop_reason == eStopReasonBreakpoint) {
+ if (stop_info_sp &&
+ stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
if (log)
log->Printf("Process::RunThreadPlan() stopped for "
"breakpoint: %s.",
@@ -5348,19 +5334,16 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
if (log) {
if (options.GetTryAllThreads()) {
if (before_first_timeout) {
- log->Printf("Process::RunThreadPlan(): Running function with "
- "one thread timeout timed out.");
+ LLDB_LOG(log,
+ "Running function with one thread timeout timed out.");
} else
- log->Printf("Process::RunThreadPlan(): Restarting function with "
- "all threads enabled "
- "and timeout: %" PRIu64
- " timed out, abandoning execution.",
- timeout ? timeout->count() : -1);
+ LLDB_LOG(log, "Restarting function with all threads enabled and "
+ "timeout: {0} timed out, abandoning execution.",
+ timeout);
} else
- log->Printf("Process::RunThreadPlan(): Running function with "
- "timeout: %" PRIu64 " timed out, "
- "abandoning execution.",
- timeout ? timeout->count() : -1);
+ LLDB_LOG(log, "Running function with timeout: {0} timed out, "
+ "abandoning execution.",
+ timeout);
}
// It is possible that between the time we issued the Halt, and we get
@@ -6245,3 +6228,9 @@ bool Process::RouteAsyncStructuredData(
find_it->second->HandleArrivalOfStructuredData(*this, type_name, object_sp);
return true;
}
+
+Error Process::UpdateAutomaticSignalFiltering() {
+ // Default implementation does nothign.
+ // No automatic signal filtering to speak of.
+ return Error();
+}
diff --git a/source/Target/ProcessInfo.cpp b/source/Target/ProcessInfo.cpp
index 5c4b2f07e426..0d986bc76914 100644
--- a/source/Target/ProcessInfo.cpp
+++ b/source/Target/ProcessInfo.cpp
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallString.h"
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index 92d9371b541f..7de55f2fdcf9 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -14,15 +14,17 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/FileSystem.h"
#if !defined(_WIN32)
#include <limits.h>
@@ -368,10 +370,8 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
if (working_dir) {
new_path += working_dir.GetPath();
} else {
- char current_working_dir[PATH_MAX];
- const char *cwd =
- getcwd(current_working_dir, sizeof(current_working_dir));
- if (cwd && cwd[0])
+ llvm::SmallString<64> cwd;
+ if (! llvm::sys::fs::current_path(cwd))
new_path += cwd;
}
std::string curr_path;
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 4cce4dd6bccc..6cbfb04a6e9a 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -12,18 +12,18 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/RegisterContext.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DWARFExpression.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Utility/RegisterNumber.cpp b/source/Target/RegisterNumber.cpp
index 07dd223f6309..d1bb8adf56e1 100644
--- a/source/Utility/RegisterNumber.cpp
+++ b/source/Target/RegisterNumber.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Utility/RegisterNumber.h"
+#include "lldb/Target/RegisterNumber.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
diff --git a/source/Target/SectionLoadHistory.cpp b/source/Target/SectionLoadHistory.cpp
index 49a7cef8e39d..740f48bc829c 100644
--- a/source/Target/SectionLoadHistory.cpp
+++ b/source/Target/SectionLoadHistory.cpp
@@ -13,8 +13,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp
index a3599dd10e5e..7f12c262f47e 100644
--- a/source/Target/SectionLoadList.cpp
+++ b/source/Target/SectionLoadList.cpp
@@ -13,13 +13,13 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -67,21 +67,13 @@ SectionLoadList::GetSectionLoadAddress(const lldb::SectionSP &section) const {
bool SectionLoadList::SetSectionLoadAddress(const lldb::SectionSP &section,
addr_t load_addr,
bool warn_multiple) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER |
- LIBLLDB_LOG_VERBOSE));
-
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
ModuleSP module_sp(section->GetModule());
if (module_sp) {
- if (log) {
- const FileSpec &module_file_spec(module_sp->GetFileSpec());
- log->Printf("SectionLoadList::%s (section = %p (%s.%s), load_addr = "
- "0x%16.16" PRIx64 ") module = %p",
- __FUNCTION__, static_cast<void *>(section.get()),
- module_file_spec.GetPath().c_str(),
- section->GetName().AsCString(), load_addr,
- static_cast<void *>(module_sp.get()));
- }
+ LLDB_LOGV(log, "(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}",
+ section.get(), module_sp->GetFileSpec(), section->GetName(),
+ load_addr, module_sp.get());
if (section->GetByteSize() == 0)
return false; // No change
@@ -147,10 +139,9 @@ size_t SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp) {
size_t unload_count = 0;
if (section_sp) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER |
- LIBLLDB_LOG_VERBOSE));
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
- if (log) {
+ if (log && log->GetVerbose()) {
ModuleSP module_sp = section_sp->GetModule();
std::string module_name("<Unknown>");
if (module_sp) {
@@ -183,10 +174,9 @@ size_t SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp) {
bool SectionLoadList::SetSectionUnloaded(const lldb::SectionSP &section_sp,
addr_t load_addr) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER |
- LIBLLDB_LOG_VERBOSE));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
- if (log) {
+ if (log && log->GetVerbose()) {
ModuleSP module_sp = section_sp->GetModule();
std::string module_name("<Unknown>");
if (module_sp) {
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index ec30fd62618a..7b7b596c9773 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -221,18 +222,20 @@ bool StackFrame::ChangePC(addr_t pc) {
const char *StackFrame::Disassemble() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (m_disassembly.Empty())
- return nullptr;
-
- ExecutionContext exe_ctx(shared_from_this());
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- const char *plugin_name = nullptr;
- const char *flavor = nullptr;
- Disassembler::Disassemble(target->GetDebugger(), target->GetArchitecture(),
- plugin_name, flavor, exe_ctx, 0, false, 0, 0,
- m_disassembly);
+ if (m_disassembly.Empty()) {
+ ExecutionContext exe_ctx(shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target) {
+ const char *plugin_name = nullptr;
+ const char *flavor = nullptr;
+ Disassembler::Disassemble(target->GetDebugger(),
+ target->GetArchitecture(), plugin_name, flavor,
+ exe_ctx, 0, false, 0, 0, m_disassembly);
+ }
+ if (m_disassembly.Empty())
+ return nullptr;
}
+
return m_disassembly.GetData();
}
@@ -425,7 +428,7 @@ VariableList *StackFrame::GetVariableList(bool get_file_globals) {
m_variable_list_sp.reset(new VariableList());
frame_block->AppendBlockVariables(can_create, get_child_variables,
stop_if_child_block_is_inlined_function,
- [this](Variable *v) { return true; },
+ [](Variable *v) { return true; },
m_variable_list_sp.get());
}
}
@@ -604,8 +607,10 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
// Calculate the next separator index ahead of time
ValueObjectSP child_valobj_sp;
const char separator_type = var_expr[0];
+ bool expr_is_ptr = false;
switch (separator_type) {
case '-':
+ expr_is_ptr = true;
if (var_expr.size() >= 2 && var_expr[1] != '>')
return ValueObjectSP();
@@ -622,11 +627,32 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
return ValueObjectSP();
}
}
+
+ // If we have a non pointer type with a sythetic value then lets check if
+ // we have an sythetic dereference specified.
+ if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
+ Error deref_error;
+ if (valobj_sp->GetCompilerType().IsReferenceType()) {
+ valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
+ if (error.Fail()) {
+ error.SetErrorStringWithFormatv(
+ "Failed to dereference reference type: %s", deref_error);
+ return ValueObjectSP();
+ }
+ }
+
+ valobj_sp = valobj_sp->Dereference(deref_error);
+ if (error.Fail()) {
+ error.SetErrorStringWithFormatv(
+ "Failed to dereference sythetic value: %s", deref_error);
+ return ValueObjectSP();
+ }
+ expr_is_ptr = false;
+ }
+
var_expr = var_expr.drop_front(); // Remove the '-'
LLVM_FALLTHROUGH;
case '.': {
- const bool expr_is_ptr = var_expr[0] == '>';
-
var_expr = var_expr.drop_front(); // Remove the '.' or '>'
separator_idx = var_expr.find_first_of(".-[");
ConstString child_name(var_expr.substr(0, var_expr.find_first_of(".-[")));
@@ -1186,9 +1212,14 @@ lldb::LanguageType StackFrame::GuessLanguage() {
LanguageType lang_type = GetLanguage();
if (lang_type == eLanguageTypeUnknown) {
- Function *f = GetSymbolContext(eSymbolContextFunction).function;
- if (f) {
- lang_type = f->GetMangled().GuessLanguage();
+ SymbolContext sc = GetSymbolContext(eSymbolContextFunction
+ | eSymbolContextSymbol);
+ if (sc.function) {
+ lang_type = sc.function->GetMangled().GuessLanguage();
+ }
+ else if (sc.symbol)
+ {
+ lang_type = sc.symbol->GetMangled().GuessLanguage();
}
}
@@ -1289,7 +1320,7 @@ lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
target_arch, plugin_name, flavor, exe_ctx, pc_range, prefer_file_cache);
- if (!disassembler_sp->GetInstructionList().GetSize()) {
+ if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
return ValueObjectSP();
}
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 146b2b05dbd7..044f860ba32b 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -14,7 +14,6 @@
#include "lldb/Target/StackFrameList.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Symbol/Block.h"
@@ -27,6 +26,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/Log.h"
//#define DEBUG_STACK_FRAMES 1
diff --git a/source/Target/StackID.cpp b/source/Target/StackID.cpp
index 0d215ed5c9c3..889cf89b9be7 100644
--- a/source/Target/StackID.cpp
+++ b/source/Target/StackID.cpp
@@ -12,10 +12,10 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/StackID.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 23dea41f61fb..8d40c7678b96 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -18,8 +18,6 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Target/Process.h"
@@ -28,6 +26,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -269,6 +269,7 @@ protected:
if (!m_should_perform_action)
return;
m_should_perform_action = false;
+ bool internal_breakpoint = true;
ThreadSP thread_sp(m_thread_wp.lock());
@@ -495,6 +496,9 @@ protected:
if (callback_says_stop)
m_should_stop = true;
+ if (m_should_stop && !bp_loc_sp->GetBreakpoint().IsInternal())
+ internal_breakpoint = false;
+
// If we are going to stop for this breakpoint, then remove the
// breakpoint.
if (callback_says_stop && bp_loc_sp &&
@@ -526,6 +530,20 @@ protected:
"Process::%s could not find breakpoint site id: %" PRId64 "...",
__FUNCTION__, m_value);
}
+
+ if ((m_should_stop == false || internal_breakpoint)
+ && thread_sp->CompletedPlanOverridesBreakpoint()) {
+
+ // Override should_stop decision when we have
+ // completed step plan additionally to the breakpoint
+ m_should_stop = true;
+
+ // Here we clean the preset stop info so the next
+ // GetStopInfo call will find the appropriate stop info,
+ // which should be the stop info related to the completed plan
+ thread_sp->ResetStopInfo();
+ }
+
if (log)
log->Printf("Process::%s returning from action with m_should_stop: %d.",
__FUNCTION__, m_should_stop);
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 078fa6a7ff04..df021e3953bc 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -24,19 +24,16 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/REPL.h"
#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -57,7 +54,10 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -2173,7 +2173,7 @@ lldb::ExpressionVariableSP
Target::GetPersistentVariable(const ConstString &name) {
lldb::ExpressionVariableSP variable_sp;
m_scratch_type_system_map.ForEach(
- [this, name, &variable_sp](TypeSystem *type_system) -> bool {
+ [name, &variable_sp](TypeSystem *type_system) -> bool {
if (PersistentExpressionState *persistent_state =
type_system->GetPersistentExpressionState()) {
variable_sp = persistent_state->GetVariable(name);
@@ -2190,7 +2190,7 @@ lldb::addr_t Target::GetPersistentSymbol(const ConstString &name) {
lldb::addr_t address = LLDB_INVALID_ADDRESS;
m_scratch_type_system_map.ForEach(
- [this, name, &address](TypeSystem *type_system) -> bool {
+ [name, &address](TypeSystem *type_system) -> bool {
if (PersistentExpressionState *persistent_state =
type_system->GetPersistentExpressionState()) {
address = persistent_state->LookupSymbol(name);
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 0637cffddcc1..0849c18b89e0 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -7,12 +7,8 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/SmallString.h"
-
// Project includes
+#include "lldb/Target/TargetList.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
@@ -27,7 +23,11 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/TargetList.h"
+#include "lldb/Utility/TildeExpressionResolver.h"
+
+// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
@@ -348,10 +348,10 @@ Error TargetList::CreateTargetInternal(Debugger &debugger,
FileSpec file(user_exe_path, false);
if (!file.Exists() && user_exe_path.startswith("~")) {
// we want to expand the tilde but we don't want to resolve any symbolic
- // links
- // so we can't use the FileSpec constructor's resolve flag
- llvm::SmallString<64> unglobbed_path(user_exe_path);
- FileSpec::ResolveUsername(unglobbed_path);
+ // links so we can't use the FileSpec constructor's resolve flag
+ llvm::SmallString<64> unglobbed_path;
+ StandardTildeExpressionResolver Resolver;
+ Resolver.ResolveFullPath(user_exe_path, unglobbed_path);
if (unglobbed_path.empty())
file = FileSpec(user_exe_path, false);
@@ -363,18 +363,17 @@ Error TargetList::CreateTargetInternal(Debugger &debugger,
char resolved_bundle_exe_path[PATH_MAX];
resolved_bundle_exe_path[0] = '\0';
if (file) {
- if (file.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (llvm::sys::fs::is_directory(file.GetPath()))
user_exe_path_is_bundle = true;
if (file.IsRelative() && !user_exe_path.empty()) {
// Ignore paths that start with "./" and "../"
if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) {
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd))) {
- std::string cwd_user_exe_path(cwd);
- cwd_user_exe_path += '/';
- cwd_user_exe_path += user_exe_path;
- FileSpec cwd_file(cwd_user_exe_path, false);
+ llvm::SmallString<64> cwd;
+ if (! llvm::sys::fs::current_path(cwd)) {
+ cwd += '/';
+ cwd += user_exe_path;
+ FileSpec cwd_file(cwd, false);
if (cwd_file.Exists())
file = cwd_file;
}
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 5ead59052856..4b21382ff86f 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -17,12 +17,8 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
@@ -51,6 +47,10 @@
#include "lldb/Target/ThreadPlanStepUntil.h"
#include "lldb/Target/ThreadSpec.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -380,24 +380,32 @@ lldb::StopInfoSP Thread::GetStopInfo() {
if (m_destroy_called)
return m_stop_info_sp;
- ThreadPlanSP plan_sp(GetCompletedPlan());
+ ThreadPlanSP completed_plan_sp(GetCompletedPlan());
ProcessSP process_sp(GetProcess());
const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
- if (plan_sp && plan_sp->PlanSucceeded()) {
- return StopInfo::CreateStopReasonWithPlan(plan_sp, GetReturnValueObject(),
- GetExpressionVariable());
+
+ // Here we select the stop info according to priorirty:
+ // - m_stop_info_sp (if not trace) - preset value
+ // - completed plan stop info - new value with plan from completed plan stack
+ // - m_stop_info_sp (trace stop reason is OK now)
+ // - ask GetPrivateStopInfo to set stop info
+
+ bool have_valid_stop_info = m_stop_info_sp &&
+ m_stop_info_sp ->IsValid() &&
+ m_stop_info_stop_id == stop_id;
+ bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
+ bool plan_overrides_trace =
+ have_valid_stop_info && have_valid_completed_plan
+ && (m_stop_info_sp->GetStopReason() == eStopReasonTrace);
+
+ if (have_valid_stop_info && !plan_overrides_trace) {
+ return m_stop_info_sp;
+ } else if (have_valid_completed_plan) {
+ return StopInfo::CreateStopReasonWithPlan(
+ completed_plan_sp, GetReturnValueObject(), GetExpressionVariable());
} else {
- if ((m_stop_info_stop_id == stop_id) || // Stop info is valid, just return
- // what we have (even if empty)
- (m_stop_info_sp &&
- m_stop_info_sp
- ->IsValid())) // Stop info is valid, just return what we have
- {
- return m_stop_info_sp;
- } else {
- GetPrivateStopInfo();
- return m_stop_info_sp;
- }
+ GetPrivateStopInfo();
+ return m_stop_info_sp;
}
}
@@ -459,6 +467,12 @@ bool Thread::StopInfoIsUpToDate() const {
// date...
}
+void Thread::ResetStopInfo() {
+ if (m_stop_info_sp) {
+ m_stop_info_sp.reset();
+ }
+}
+
void Thread::SetStopInfo(const lldb::StopInfoSP &stop_info_sp) {
m_stop_info_sp = stop_info_sp;
if (m_stop_info_sp) {
@@ -526,7 +540,8 @@ bool Thread::CheckpointThreadState(ThreadStateCheckpoint &saved_state) {
if (process_sp)
saved_state.orig_stop_id = process_sp->GetStopID();
saved_state.current_inlined_depth = GetCurrentInlinedDepth();
-
+ saved_state.m_completed_plan_stack = m_completed_plan_stack;
+
return true;
}
@@ -559,6 +574,7 @@ bool Thread::RestoreThreadStateFromCheckpoint(
SetStopInfo(saved_state.stop_info_sp);
GetStackFrameList()->SetCurrentInlinedDepth(
saved_state.current_inlined_depth);
+ m_completed_plan_stack = saved_state.m_completed_plan_stack;
return true;
}
@@ -895,6 +911,9 @@ bool Thread::ShouldStop(Event *event_ptr) {
if (should_stop) {
ThreadPlan *plan_ptr = GetCurrentPlan();
+
+ // Discard the stale plans and all plans below them in the stack,
+ // plus move the completed plans to the completed plan stack
while (!PlanIsBasePlan(plan_ptr)) {
bool stale = plan_ptr->IsPlanStale();
ThreadPlan *examined_plan = plan_ptr;
@@ -905,7 +924,15 @@ bool Thread::ShouldStop(Event *event_ptr) {
log->Printf(
"Plan %s being discarded in cleanup, it says it is already done.",
examined_plan->GetName());
- DiscardThreadPlansUpToPlan(examined_plan);
+ while (GetCurrentPlan() != examined_plan) {
+ DiscardPlan();
+ }
+ if (examined_plan->IsPlanComplete()) {
+ // plan is complete but does not explain the stop (example: step to a line
+ // with breakpoint), let us move the plan to completed_plan_stack anyway
+ PopPlan();
+ } else
+ DiscardPlan();
}
}
}
@@ -1133,6 +1160,10 @@ bool Thread::WasThreadPlanDiscarded(ThreadPlan *plan) {
return false;
}
+bool Thread::CompletedPlanOverridesBreakpoint() {
+ return (!m_completed_plan_stack.empty()) ;
+}
+
ThreadPlan *Thread::GetPreviousPlan(ThreadPlan *current_plan) {
if (current_plan == nullptr)
return nullptr;
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index 1e474518aace..4cf8f9061a89 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -15,15 +15,14 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
#include "lldb/Target/ThreadPlan.h"
-#include "lldb/Utility/ConvertEnum.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -384,18 +383,14 @@ Vote ThreadList::ShouldReportStop(Event *event_ptr) {
if (result == eVoteNoOpinion) {
result = eVoteNo;
} else {
- if (log)
- log->Printf("ThreadList::%s thread 0x%4.4" PRIx64
- ": voted %s, but lost out because result was %s",
- __FUNCTION__, thread_sp->GetID(), GetVoteAsCString(vote),
- GetVoteAsCString(result));
+ LLDB_LOG(log,
+ "Thread {0:x} voted {1}, but lost out because result was {2}",
+ thread_sp->GetID(), vote, result);
}
break;
}
}
- if (log)
- log->Printf("ThreadList::%s returning %s", __FUNCTION__,
- GetVoteAsCString(result));
+ LLDB_LOG(log, "Returning {0}", result);
return result;
}
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 6b997476d92f..27c9e2aa9c00 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -13,13 +13,12 @@
// Project includes
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ConvertEnum.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -77,16 +76,11 @@ Vote ThreadPlan::ShouldReportStop(Event *event_ptr) {
ThreadPlan *prev_plan = GetPreviousPlan();
if (prev_plan) {
Vote prev_vote = prev_plan->ShouldReportStop(event_ptr);
- if (log)
- log->Printf("ThreadPlan::ShouldReportStop() returning previous thread "
- "plan vote: %s",
- GetVoteAsCString(prev_vote));
+ LLDB_LOG(log, "returning previous thread plan vote: {0}", prev_vote);
return prev_vote;
}
}
- if (log)
- log->Printf("ThreadPlan::ShouldReportStop() returning vote: %s",
- GetVoteAsCString(m_stop_vote));
+ LLDB_LOG(log, "Returning vote: {0}", m_stop_vote);
return m_stop_vote;
}
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index f290483e904d..d1c2f6dd1206 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -18,11 +18,11 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 68fd50390e64..2c630d59e84c 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -15,9 +15,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -27,6 +25,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -174,9 +174,8 @@ ThreadPlanCallFunction::~ThreadPlanCallFunction() {
}
void ThreadPlanCallFunction::ReportRegisterState(const char *message) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP |
- LIBLLDB_LOG_VERBOSE));
- if (log) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ if (log && log->GetVerbose()) {
StreamString strm;
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 6c5969577a90..b90fd9edd766 100644
--- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -13,12 +13,12 @@
// Project includes
#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 260118c31e11..679040d09a02 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -17,8 +17,6 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Expression/UserExpression.h"
@@ -30,6 +28,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp
index 180586ae0f2c..af5c76518382 100644
--- a/source/Target/ThreadPlanPython.cpp
+++ b/source/Target/ThreadPlanPython.cpp
@@ -14,7 +14,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -24,6 +23,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanPython.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index 6f31db0d93a2..44de724b608c 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -12,12 +12,12 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ThreadPlanRunToAddress.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index 408650d75f0b..42aaa4227cf9 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -11,11 +11,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Target/Thread.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Target/ThreadPlanShouldStopHere.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/ThreadPlanShouldStopHere.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 03f6679ae322..caaaffea8e8a 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -12,10 +12,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ThreadPlanStepInRange.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Process.h"
@@ -24,6 +21,9 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 6ad6a2343a5e..ca45960e1ed5 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -12,13 +12,13 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ThreadPlanStepInstruction.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -94,6 +94,15 @@ bool ThreadPlanStepInstruction::IsPlanStale() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_id == m_stack_id) {
+ // Set plan Complete when we reach next instruction
+ uint64_t pc = m_thread.GetRegisterContext()->GetPC(0);
+ uint32_t max_opcode_size = m_thread.CalculateTarget()
+ ->GetArchitecture().GetMaximumOpcodeByteSize();
+ bool next_instruction_reached = (pc > m_instruction_addr) &&
+ (pc <= m_instruction_addr + max_opcode_size);
+ if (next_instruction_reached) {
+ SetPlanComplete();
+ }
return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr);
} else if (cur_frame_id < m_stack_id) {
// If the current frame is younger than the start frame and we are stepping
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index b8d6e6dcba9d..6b6ed06e9b37 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -13,7 +13,6 @@
// Project includes
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/Block.h"
@@ -27,6 +26,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanStepOverRange.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanStepOverBreakpoint.cpp b/source/Target/ThreadPlanStepOverBreakpoint.cpp
index 39641a065482..3896a0b24714 100644
--- a/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ b/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -13,10 +13,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 48c7ff8be454..d5778fb5e8d7 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -12,8 +12,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ThreadPlanStepOverRange.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
@@ -24,6 +22,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
using namespace lldb;
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index dcee82ea32a5..09e606f490a6 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -15,8 +15,6 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
@@ -26,6 +24,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -461,6 +461,16 @@ bool ThreadPlanStepRange::IsPlanStale() {
// One tricky bit here is that some stubs don't push a frame, so we should.
// check that we are in the same symbol.
if (!InRange()) {
+ // Set plan Complete when we reach next instruction just after the range
+ lldb::addr_t addr = m_thread.GetRegisterContext()->GetPC() - 1;
+ size_t num_ranges = m_address_ranges.size();
+ for (size_t i = 0; i < num_ranges; i++) {
+ bool in_range = m_address_ranges[i].ContainsLoadAddress(
+ addr, m_thread.CalculateTarget().get());
+ if (in_range) {
+ SetPlanComplete();
+ }
+ }
return true;
}
}
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index b9751614a52c..46aadb00f2ab 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -13,13 +13,13 @@
// Project includes
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index a10e2f47c90d..01f5f948a28c 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -12,12 +12,14 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ThreadPlanStepUntil.h"
+
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 7fbd664233b6..f8368123a0c7 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -14,11 +14,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
@@ -32,6 +29,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index cee69bf67db1..a4ec32bd0075 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -123,12 +123,14 @@ void UnixSignals::AddSignal(int signo, const char *name, bool default_suppress,
Signal new_signal(name, default_suppress, default_stop, default_notify,
description, alias);
m_signals.insert(std::make_pair(signo, new_signal));
+ ++m_version;
}
void UnixSignals::RemoveSignal(int signo) {
collection::iterator pos = m_signals.find(signo);
if (pos != m_signals.end())
m_signals.erase(pos);
+ ++m_version;
}
const char *UnixSignals::GetSignalAsCString(int signo) const {
@@ -217,6 +219,7 @@ bool UnixSignals::SetShouldSuppress(int signo, bool value) {
collection::iterator pos = m_signals.find(signo);
if (pos != m_signals.end()) {
pos->second.m_suppress = value;
+ ++m_version;
return true;
}
return false;
@@ -240,6 +243,7 @@ bool UnixSignals::SetShouldStop(int signo, bool value) {
collection::iterator pos = m_signals.find(signo);
if (pos != m_signals.end()) {
pos->second.m_stop = value;
+ ++m_version;
return true;
}
return false;
@@ -263,6 +267,7 @@ bool UnixSignals::SetShouldNotify(int signo, bool value) {
collection::iterator pos = m_signals.find(signo);
if (pos != m_signals.end()) {
pos->second.m_notify = value;
+ ++m_version;
return true;
}
return false;
@@ -284,3 +289,37 @@ int32_t UnixSignals::GetSignalAtIndex(int32_t index) const {
std::advance(it, index);
return it->first;
}
+
+uint64_t UnixSignals::GetVersion() const { return m_version; }
+
+std::vector<int32_t>
+UnixSignals::GetFilteredSignals(llvm::Optional<bool> should_suppress,
+ llvm::Optional<bool> should_stop,
+ llvm::Optional<bool> should_notify) {
+ std::vector<int32_t> result;
+ for (int32_t signo = GetFirstSignalNumber();
+ signo != LLDB_INVALID_SIGNAL_NUMBER;
+ signo = GetNextSignalNumber(signo)) {
+
+ bool signal_suppress = false;
+ bool signal_stop = false;
+ bool signal_notify = false;
+ GetSignalInfo(signo, signal_suppress, signal_stop, signal_notify);
+
+ // If any of filtering conditions are not met,
+ // we move on to the next signal.
+ if (should_suppress.hasValue() &&
+ signal_suppress != should_suppress.getValue())
+ continue;
+
+ if (should_stop.hasValue() && signal_stop != should_stop.getValue())
+ continue;
+
+ if (should_notify.hasValue() && signal_notify != should_notify.getValue())
+ continue;
+
+ result.push_back(signo);
+ }
+
+ return result;
+}
diff --git a/source/Utility/ARM64_DWARF_Registers.cpp b/source/Utility/ARM64_DWARF_Registers.cpp
deleted file mode 100644
index 8c2a7160346d..000000000000
--- a/source/Utility/ARM64_DWARF_Registers.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-//===-- ARM64_DWARF_Registers.cpp -------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <string.h>
-
-#include "ARM64_DWARF_Registers.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace arm64_dwarf;
-
-const char *arm64_dwarf::GetRegisterName(unsigned reg_num,
- bool altnernate_name) {
- if (altnernate_name) {
- switch (reg_num) {
- case fp:
- return "x29";
- case lr:
- return "x30";
- case sp:
- return "x31";
- default:
- break;
- }
- return nullptr;
- }
-
- switch (reg_num) {
- case x0:
- return "x0";
- case x1:
- return "x1";
- case x2:
- return "x2";
- case x3:
- return "x3";
- case x4:
- return "x4";
- case x5:
- return "x5";
- case x6:
- return "x6";
- case x7:
- return "x7";
- case x8:
- return "x8";
- case x9:
- return "x9";
- case x10:
- return "x10";
- case x11:
- return "x11";
- case x12:
- return "x12";
- case x13:
- return "x13";
- case x14:
- return "x14";
- case x15:
- return "x15";
- case x16:
- return "x16";
- case x17:
- return "x17";
- case x18:
- return "x18";
- case x19:
- return "x19";
- case x20:
- return "x20";
- case x21:
- return "x21";
- case x22:
- return "x22";
- case x23:
- return "x23";
- case x24:
- return "x24";
- case x25:
- return "x25";
- case x26:
- return "x26";
- case x27:
- return "x27";
- case x28:
- return "x28";
- case fp:
- return "fp";
- case lr:
- return "lr";
- case sp:
- return "sp";
- case pc:
- return "pc";
- case cpsr:
- return "cpsr";
- case v0:
- return "v0";
- case v1:
- return "v1";
- case v2:
- return "v2";
- case v3:
- return "v3";
- case v4:
- return "v4";
- case v5:
- return "v5";
- case v6:
- return "v6";
- case v7:
- return "v7";
- case v8:
- return "v8";
- case v9:
- return "v9";
- case v10:
- return "v10";
- case v11:
- return "v11";
- case v12:
- return "v12";
- case v13:
- return "v13";
- case v14:
- return "v14";
- case v15:
- return "v15";
- case v16:
- return "v16";
- case v17:
- return "v17";
- case v18:
- return "v18";
- case v19:
- return "v19";
- case v20:
- return "v20";
- case v21:
- return "v21";
- case v22:
- return "v22";
- case v23:
- return "v23";
- case v24:
- return "v24";
- case v25:
- return "v25";
- case v26:
- return "v26";
- case v27:
- return "v27";
- case v28:
- return "v28";
- case v29:
- return "v29";
- case v30:
- return "v30";
- case v31:
- return "v31";
- }
- return nullptr;
-}
-
-bool arm64_dwarf::GetRegisterInfo(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 >= x0 && reg_num <= pc) {
- reg_info.byte_size = 8;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- } else if (reg_num >= v0 && reg_num <= v31) {
- reg_info.byte_size = 16;
- reg_info.format = eFormatVectorOfFloat32;
- reg_info.encoding = eEncodingVector;
- } else if (reg_num == cpsr) {
- reg_info.byte_size = 4;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- } else {
- return false;
- }
-
- reg_info.name = arm64_dwarf::GetRegisterName(reg_num, false);
- reg_info.alt_name = arm64_dwarf::GetRegisterName(reg_num, true);
- reg_info.kinds[eRegisterKindDWARF] = reg_num;
-
- switch (reg_num) {
- case fp:
- reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
- break;
- case lr:
- reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
- break;
- case sp:
- reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
- break;
- case pc:
- reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
- break;
- default:
- break;
- }
- return true;
-}
diff --git a/source/Utility/ARM64_DWARF_Registers.h b/source/Utility/ARM64_DWARF_Registers.h
index be0ea2a73fb2..ce548a2aee80 100644
--- a/source/Utility/ARM64_DWARF_Registers.h
+++ b/source/Utility/ARM64_DWARF_Registers.h
@@ -91,10 +91,6 @@ enum {
// 96-127 reserved
};
-const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
-
-bool GetRegisterInfo(unsigned reg_num, lldb_private::RegisterInfo &reg_info);
-
} // namespace arm64_dwarf
#endif // utility_ARM64_DWARF_Registers_h_
diff --git a/source/Utility/ARM_DWARF_Registers.cpp b/source/Utility/ARM_DWARF_Registers.cpp
deleted file mode 100644
index c1363763e92a..000000000000
--- a/source/Utility/ARM_DWARF_Registers.cpp
+++ /dev/null
@@ -1,925 +0,0 @@
-//===-- ARM_DWARF_Registers.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ARM_DWARF_Registers.h"
-#include <string.h>
-
-#include <string.h>
-
-using namespace lldb;
-using namespace lldb_private;
-
-const char *GetARMDWARFRegisterName(unsigned reg_num) {
- switch (reg_num) {
- case dwarf_r0:
- return "r0";
- case dwarf_r1:
- return "r1";
- case dwarf_r2:
- return "r2";
- case dwarf_r3:
- return "r3";
- case dwarf_r4:
- return "r4";
- case dwarf_r5:
- return "r5";
- case dwarf_r6:
- return "r6";
- case dwarf_r7:
- return "r7";
- case dwarf_r8:
- return "r8";
- case dwarf_r9:
- return "r9";
- case dwarf_r10:
- return "r10";
- case dwarf_r11:
- return "r11";
- case dwarf_r12:
- return "r12";
- case dwarf_sp:
- return "sp";
- case dwarf_lr:
- return "lr";
- case dwarf_pc:
- return "pc";
- case dwarf_cpsr:
- return "cpsr";
-
- case dwarf_s0:
- return "s0";
- case dwarf_s1:
- return "s1";
- case dwarf_s2:
- return "s2";
- case dwarf_s3:
- return "s3";
- case dwarf_s4:
- return "s4";
- case dwarf_s5:
- return "s5";
- case dwarf_s6:
- return "s6";
- case dwarf_s7:
- return "s7";
- case dwarf_s8:
- return "s8";
- case dwarf_s9:
- return "s9";
- case dwarf_s10:
- return "s10";
- case dwarf_s11:
- return "s11";
- case dwarf_s12:
- return "s12";
- case dwarf_s13:
- return "s13";
- case dwarf_s14:
- return "s14";
- case dwarf_s15:
- return "s15";
- case dwarf_s16:
- return "s16";
- case dwarf_s17:
- return "s17";
- case dwarf_s18:
- return "s18";
- case dwarf_s19:
- return "s19";
- case dwarf_s20:
- return "s20";
- case dwarf_s21:
- return "s21";
- case dwarf_s22:
- return "s22";
- case dwarf_s23:
- return "s23";
- case dwarf_s24:
- return "s24";
- case dwarf_s25:
- return "s25";
- case dwarf_s26:
- return "s26";
- case dwarf_s27:
- return "s27";
- case dwarf_s28:
- return "s28";
- case dwarf_s29:
- return "s29";
- case dwarf_s30:
- return "s30";
- case dwarf_s31:
- return "s31";
-
- // FPA Registers 0-7
- case dwarf_f0:
- return "f0";
- case dwarf_f1:
- return "f1";
- case dwarf_f2:
- return "f2";
- case dwarf_f3:
- return "f3";
- case dwarf_f4:
- return "f4";
- case dwarf_f5:
- return "f5";
- case dwarf_f6:
- return "f6";
- case dwarf_f7:
- return "f7";
-
- // Intel wireless MMX general purpose registers 0 - 7
- // XScale accumulator register 0 - 7 (they do overlap with wCGR0 - wCGR7)
- case dwarf_wCGR0:
- return "wCGR0/ACC0";
- case dwarf_wCGR1:
- return "wCGR1/ACC1";
- case dwarf_wCGR2:
- return "wCGR2/ACC2";
- case dwarf_wCGR3:
- return "wCGR3/ACC3";
- case dwarf_wCGR4:
- return "wCGR4/ACC4";
- case dwarf_wCGR5:
- return "wCGR5/ACC5";
- case dwarf_wCGR6:
- return "wCGR6/ACC6";
- case dwarf_wCGR7:
- return "wCGR7/ACC7";
-
- // Intel wireless MMX data registers 0 - 15
- case dwarf_wR0:
- return "wR0";
- case dwarf_wR1:
- return "wR1";
- case dwarf_wR2:
- return "wR2";
- case dwarf_wR3:
- return "wR3";
- case dwarf_wR4:
- return "wR4";
- case dwarf_wR5:
- return "wR5";
- case dwarf_wR6:
- return "wR6";
- case dwarf_wR7:
- return "wR7";
- case dwarf_wR8:
- return "wR8";
- case dwarf_wR9:
- return "wR9";
- case dwarf_wR10:
- return "wR10";
- case dwarf_wR11:
- return "wR11";
- case dwarf_wR12:
- return "wR12";
- case dwarf_wR13:
- return "wR13";
- case dwarf_wR14:
- return "wR14";
- case dwarf_wR15:
- return "wR15";
-
- case dwarf_spsr:
- return "spsr";
- case dwarf_spsr_fiq:
- return "spsr_fiq";
- case dwarf_spsr_irq:
- return "spsr_irq";
- case dwarf_spsr_abt:
- return "spsr_abt";
- case dwarf_spsr_und:
- return "spsr_und";
- case dwarf_spsr_svc:
- return "spsr_svc";
-
- case dwarf_r8_usr:
- return "r8_usr";
- case dwarf_r9_usr:
- return "r9_usr";
- case dwarf_r10_usr:
- return "r10_usr";
- case dwarf_r11_usr:
- return "r11_usr";
- case dwarf_r12_usr:
- return "r12_usr";
- case dwarf_r13_usr:
- return "r13_usr";
- case dwarf_r14_usr:
- return "r14_usr";
- case dwarf_r8_fiq:
- return "r8_fiq";
- case dwarf_r9_fiq:
- return "r9_fiq";
- case dwarf_r10_fiq:
- return "r10_fiq";
- case dwarf_r11_fiq:
- return "r11_fiq";
- case dwarf_r12_fiq:
- return "r12_fiq";
- case dwarf_r13_fiq:
- return "r13_fiq";
- case dwarf_r14_fiq:
- return "r14_fiq";
- case dwarf_r13_irq:
- return "r13_irq";
- case dwarf_r14_irq:
- return "r14_irq";
- case dwarf_r13_abt:
- return "r13_abt";
- case dwarf_r14_abt:
- return "r14_abt";
- case dwarf_r13_und:
- return "r13_und";
- case dwarf_r14_und:
- return "r14_und";
- case dwarf_r13_svc:
- return "r13_svc";
- case dwarf_r14_svc:
- return "r14_svc";
-
- // Intel wireless MMX control register in co-processor 0 - 7
- case dwarf_wC0:
- return "wC0";
- case dwarf_wC1:
- return "wC1";
- case dwarf_wC2:
- return "wC2";
- case dwarf_wC3:
- return "wC3";
- case dwarf_wC4:
- return "wC4";
- case dwarf_wC5:
- return "wC5";
- case dwarf_wC6:
- return "wC6";
- case dwarf_wC7:
- return "wC7";
-
- // VFP-v3/Neon
- case dwarf_d0:
- return "d0";
- case dwarf_d1:
- return "d1";
- case dwarf_d2:
- return "d2";
- case dwarf_d3:
- return "d3";
- case dwarf_d4:
- return "d4";
- case dwarf_d5:
- return "d5";
- case dwarf_d6:
- return "d6";
- case dwarf_d7:
- return "d7";
- case dwarf_d8:
- return "d8";
- case dwarf_d9:
- return "d9";
- case dwarf_d10:
- return "d10";
- case dwarf_d11:
- return "d11";
- case dwarf_d12:
- return "d12";
- case dwarf_d13:
- return "d13";
- case dwarf_d14:
- return "d14";
- case dwarf_d15:
- return "d15";
- case dwarf_d16:
- return "d16";
- case dwarf_d17:
- return "d17";
- case dwarf_d18:
- return "d18";
- case dwarf_d19:
- return "d19";
- case dwarf_d20:
- return "d20";
- case dwarf_d21:
- return "d21";
- case dwarf_d22:
- return "d22";
- case dwarf_d23:
- return "d23";
- case dwarf_d24:
- return "d24";
- case dwarf_d25:
- return "d25";
- case dwarf_d26:
- return "d26";
- case dwarf_d27:
- return "d27";
- case dwarf_d28:
- return "d28";
- case dwarf_d29:
- return "d29";
- case dwarf_d30:
- return "d30";
- case dwarf_d31:
- return "d31";
-
- // NEON 128-bit vector registers (overlays the d registers)
- case dwarf_q0:
- return "q0";
- case dwarf_q1:
- return "q1";
- case dwarf_q2:
- return "q2";
- case dwarf_q3:
- return "q3";
- case dwarf_q4:
- return "q4";
- case dwarf_q5:
- return "q5";
- case dwarf_q6:
- return "q6";
- case dwarf_q7:
- return "q7";
- case dwarf_q8:
- return "q8";
- case dwarf_q9:
- return "q9";
- case dwarf_q10:
- return "q10";
- case dwarf_q11:
- return "q11";
- case dwarf_q12:
- return "q12";
- case dwarf_q13:
- return "q13";
- case dwarf_q14:
- return "q14";
- case dwarf_q15:
- return "q15";
- }
- return nullptr;
-}
-
-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;
-}
diff --git a/source/Utility/ARM_DWARF_Registers.h b/source/Utility/ARM_DWARF_Registers.h
index 9b226c113ce6..ab91d8c99aa3 100644
--- a/source/Utility/ARM_DWARF_Registers.h
+++ b/source/Utility/ARM_DWARF_Registers.h
@@ -205,9 +205,4 @@ enum {
dwarf_q15
};
-const char *GetARMDWARFRegisterName(unsigned reg_num);
-
-bool GetARMDWARFRegisterInfo(unsigned reg_num,
- lldb_private::RegisterInfo &reg_info);
-
#endif // utility_ARM_DWARF_Registers_h_
diff --git a/tools/debugserver/source/MacOSX/HasAVX.h b/source/Utility/Baton.cpp
index 43fbd5e514e2..786be2fe9981 100644
--- a/tools/debugserver/source/MacOSX/HasAVX.h
+++ b/source/Utility/Baton.cpp
@@ -1,4 +1,4 @@
-//===-- HasAVX.h ------------------------------------------------*- C++ -*-===//
+//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,21 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#ifndef HasAVX_h
-#define HasAVX_h
+#include "lldb/Utility/Baton.h"
-#if defined(__i386__) || defined(__x86_64__)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int HasAVX();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-#endif
+void lldb_private::UntypedBaton::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) const {}
diff --git a/source/Utility/CMakeLists.txt b/source/Utility/CMakeLists.txt
index 9cddcc02cc58..d4e8e361017c 100644
--- a/source/Utility/CMakeLists.txt
+++ b/source/Utility/CMakeLists.txt
@@ -1,19 +1,42 @@
add_lldb_library(lldbUtility
- ARM_DWARF_Registers.cpp
- ARM64_DWARF_Registers.cpp
- ConvertEnum.cpp
+ Baton.cpp
+ ConstString.cpp
+ DataBufferHeap.cpp
+ DataBufferLLVM.cpp
+ DataEncoder.cpp
+ DataExtractor.cpp
+ Error.cpp
+ FastDemangle.cpp
+ FileSpec.cpp
+ History.cpp
JSON.cpp
LLDBAssert.cpp
- ModuleCache.cpp
+ Log.cpp
+ Logging.cpp
NameMatches.cpp
- PseudoTerminal.cpp
Range.cpp
- RegisterNumber.cpp
+ RegularExpression.cpp
SelectHelper.cpp
SharingPtr.cpp
+ Stream.cpp
+ StreamCallback.cpp
+ StreamGDBRemote.cpp
+ StreamString.cpp
StringExtractor.cpp
StringExtractorGDBRemote.cpp
StringLexer.cpp
+ StringList.cpp
TaskPool.cpp
+ TildeExpressionResolver.cpp
+ UserID.cpp
UriParser.cpp
+ UUID.cpp
+ VASprintf.cpp
+ VMRange.cpp
+
+ LINK_LIBS
+ # lldbUtility cannot have any dependencies
+
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Core/ConstString.cpp b/source/Utility/ConstString.cpp
index 21b4d3d76f1c..8adeb6f364ef 100644
--- a/source/Core/ConstString.cpp
+++ b/source/Utility/ConstString.cpp
@@ -7,20 +7,25 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
-// C Includes
-// C++ Includes
-#include <array>
-#include <mutex>
+#include "lldb/Utility/Stream.h"
-// Other libraries and framework includes
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/iterator.h" // for iterator_facade_base
+#include "llvm/Support/Allocator.h" // for BumpPtrAllocator
+#include "llvm/Support/FormatProviders.h" // for format_provider
#include "llvm/Support/RWMutex.h"
+#include "llvm/Support/Threading.h"
+
+#include <algorithm> // for min
+#include <array>
+#include <utility> // for make_pair, pair
-// Project includes
-#include "lldb/Core/Stream.h"
+#include <inttypes.h> // for PRIu64
+#include <stdint.h> // for uint8_t, uint32_t, uint64_t
+#include <string.h> // for size_t, strlen
using namespace lldb_private;
@@ -191,10 +196,10 @@ protected:
// touch ConstStrings is difficult. So we leak the pool instead.
//----------------------------------------------------------------------
static Pool &StringPool() {
- static std::once_flag g_pool_initialization_flag;
+ static llvm::once_flag g_pool_initialization_flag;
static Pool *g_string_pool = nullptr;
- std::call_once(g_pool_initialization_flag,
+ llvm::call_once(g_pool_initialization_flag,
[]() { g_string_pool = new Pool(); });
return *g_string_pool;
@@ -334,3 +339,9 @@ size_t ConstString::StaticMemorySize() {
// Get the size of the static string pool
return StringPool().MemorySize();
}
+
+void llvm::format_provider<ConstString>::format(const ConstString &CS,
+ llvm::raw_ostream &OS,
+ llvm::StringRef Options) {
+ format_provider<StringRef>::format(CS.AsCString(), OS, Options);
+}
diff --git a/source/Utility/ConvertEnum.cpp b/source/Utility/ConvertEnum.cpp
deleted file mode 100644
index bb0484ef5200..000000000000
--- a/source/Utility/ConvertEnum.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-//===-- ConvertEnum.cpp -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#include "lldb/Utility/ConvertEnum.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-const char *lldb_private::GetVoteAsCString(Vote vote) {
- switch (vote) {
- case eVoteNo:
- return "no";
- case eVoteNoOpinion:
- return "no opinion";
- case eVoteYes:
- return "yes";
- }
- return "invalid";
-}
-
-const char *lldb_private::GetSectionTypeAsCString(lldb::SectionType sect_type) {
- switch (sect_type) {
- case eSectionTypeInvalid:
- return "invalid";
- case eSectionTypeCode:
- return "code";
- case eSectionTypeContainer:
- return "container";
- case eSectionTypeData:
- return "data";
- case eSectionTypeDataCString:
- return "data-cstr";
- case eSectionTypeDataCStringPointers:
- return "data-cstr-ptr";
- case eSectionTypeDataSymbolAddress:
- return "data-symbol-addr";
- case eSectionTypeData4:
- return "data-4-byte";
- case eSectionTypeData8:
- return "data-8-byte";
- case eSectionTypeData16:
- return "data-16-byte";
- case eSectionTypeDataPointers:
- return "data-ptrs";
- case eSectionTypeDebug:
- return "debug";
- case eSectionTypeZeroFill:
- return "zero-fill";
- case eSectionTypeDataObjCMessageRefs:
- return "objc-message-refs";
- case eSectionTypeDataObjCCFStrings:
- return "objc-cfstrings";
- case eSectionTypeDWARFDebugAbbrev:
- return "dwarf-abbrev";
- case eSectionTypeDWARFDebugAddr:
- return "dwarf-addr";
- case eSectionTypeDWARFDebugAranges:
- return "dwarf-aranges";
- case eSectionTypeDWARFDebugFrame:
- return "dwarf-frame";
- case eSectionTypeDWARFDebugInfo:
- return "dwarf-info";
- case eSectionTypeDWARFDebugLine:
- return "dwarf-line";
- case eSectionTypeDWARFDebugLoc:
- return "dwarf-loc";
- case eSectionTypeDWARFDebugMacInfo:
- return "dwarf-macinfo";
- case eSectionTypeDWARFDebugMacro:
- return "dwarf-macro";
- case eSectionTypeDWARFDebugPubNames:
- return "dwarf-pubnames";
- case eSectionTypeDWARFDebugPubTypes:
- return "dwarf-pubtypes";
- case eSectionTypeDWARFDebugRanges:
- return "dwarf-ranges";
- case eSectionTypeDWARFDebugStr:
- return "dwarf-str";
- case eSectionTypeDWARFDebugStrOffsets:
- return "dwarf-str-offsets";
- case eSectionTypeELFSymbolTable:
- return "elf-symbol-table";
- case eSectionTypeELFDynamicSymbols:
- return "elf-dynamic-symbols";
- case eSectionTypeELFRelocationEntries:
- return "elf-relocation-entries";
- case eSectionTypeELFDynamicLinkInfo:
- return "elf-dynamic-link-info";
- case eSectionTypeDWARFAppleNames:
- return "apple-names";
- case eSectionTypeDWARFAppleTypes:
- return "apple-types";
- case eSectionTypeDWARFAppleNamespaces:
- return "apple-namespaces";
- case eSectionTypeDWARFAppleObjC:
- return "apple-objc";
- case eSectionTypeEHFrame:
- return "eh-frame";
- case eSectionTypeARMexidx:
- return "ARM.exidx";
- case eSectionTypeARMextab:
- return "ARM.extab";
- case eSectionTypeCompactUnwind:
- return "compact-unwind";
- case eSectionTypeGoSymtab:
- return "go-symtab";
- case eSectionTypeAbsoluteAddress:
- return "absolute";
- case eSectionTypeOther:
- return "regular";
- }
- return "unknown";
-}
diff --git a/source/Core/DataBufferHeap.cpp b/source/Utility/DataBufferHeap.cpp
index cdd37bfdf0fc..aa1c3d37ae62 100644
--- a/source/Core/DataBufferHeap.cpp
+++ b/source/Utility/DataBufferHeap.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferHeap.h"
// C Includes
// C++ Includes
diff --git a/source/Utility/DataBufferLLVM.cpp b/source/Utility/DataBufferLLVM.cpp
new file mode 100644
index 000000000000..bebcafbf9150
--- /dev/null
+++ b/source/Utility/DataBufferLLVM.cpp
@@ -0,0 +1,70 @@
+//===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/DataBufferLLVM.h"
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+#include <assert.h> // for assert
+#include <type_traits> // for move
+
+using namespace lldb_private;
+
+DataBufferLLVM::DataBufferLLVM(std::unique_ptr<llvm::MemoryBuffer> MemBuffer)
+ : Buffer(std::move(MemBuffer)) {
+ assert(Buffer != nullptr &&
+ "Cannot construct a DataBufferLLVM with a null buffer");
+}
+
+DataBufferLLVM::~DataBufferLLVM() {}
+
+std::shared_ptr<DataBufferLLVM>
+DataBufferLLVM::CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size,
+ uint64_t Offset, bool Private) {
+ // If the file resides non-locally, pass the volatile flag so that we don't
+ // mmap it.
+ if (!Private)
+ Private = !llvm::sys::fs::is_local(Path);
+
+ auto Buffer = llvm::MemoryBuffer::getFileSlice(Path, Size, Offset, Private);
+ if (!Buffer)
+ return nullptr;
+ return std::shared_ptr<DataBufferLLVM>(
+ new DataBufferLLVM(std::move(*Buffer)));
+}
+
+std::shared_ptr<DataBufferLLVM>
+DataBufferLLVM::CreateFromPath(const llvm::Twine &Path, bool NullTerminate, bool Private) {
+ // If the file resides non-locally, pass the volatile flag so that we don't
+ // mmap it.
+ if (!Private)
+ Private = !llvm::sys::fs::is_local(Path);
+
+ auto Buffer = llvm::MemoryBuffer::getFile(Path, -1, NullTerminate, Private);
+ if (!Buffer)
+ return nullptr;
+ return std::shared_ptr<DataBufferLLVM>(
+ new DataBufferLLVM(std::move(*Buffer)));
+}
+
+uint8_t *DataBufferLLVM::GetBytes() {
+ return const_cast<uint8_t *>(GetBuffer());
+}
+
+const uint8_t *DataBufferLLVM::GetBytes() const { return GetBuffer(); }
+
+lldb::offset_t DataBufferLLVM::GetByteSize() const {
+ return Buffer->getBufferSize();
+}
+
+const uint8_t *DataBufferLLVM::GetBuffer() const {
+ return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
+}
diff --git a/source/Core/DataEncoder.cpp b/source/Utility/DataEncoder.cpp
index 334043651576..f7ce46889d2f 100644
--- a/source/Core/DataEncoder.cpp
+++ b/source/Utility/DataEncoder.cpp
@@ -7,19 +7,18 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataEncoder.h"
+#include "lldb/Utility/DataEncoder.h"
-// C Includes
-// C++ Includes
-#include <cassert>
-#include <cstddef>
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/Endian.h"
-// Other libraries and framework includes
+#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable
#include "llvm/Support/MathExtras.h"
-// Project includes
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Host/Endian.h"
+#include <cassert>
+#include <cstddef>
+
+#include <string.h>
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Core/DataExtractor.cpp b/source/Utility/DataExtractor.cpp
index fbc6e80bea07..008aff220945 100644
--- a/source/Core/DataExtractor.cpp
+++ b/source/Utility/DataExtractor.cpp
@@ -7,41 +7,35 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-#include <bitset>
-#include <cassert>
-#include <cmath>
-#include <cstddef>
-#include <sstream>
-#include <string>
+#include "lldb/Utility/DataExtractor.h"
+
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
+#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderBig
+#include "lldb/lldb-forward.h" // for DataBufferSP
+#include "lldb/lldb-types.h" // for offset_t
+
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
-// Other libraries and framework includes
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
-#include "clang/AST/ASTContext.h"
-
-// Project includes
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Core/dwarf.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ExecutionContextScope.h"
-#include "lldb/Target/SectionLoadList.h"
-#include "lldb/Target/Target.h"
+#include <algorithm> // for min
+#include <array> // for array
+#include <cassert>
+#include <cstdint> // for uint8_t, uint32_t, uint64_t
+#include <string>
+
+#include <ctype.h> // for isprint
+#include <inttypes.h> // for PRIx64, PRId64
+#include <string.h> // for memcpy, memset, memchr
using namespace lldb;
using namespace lldb_private;
@@ -111,8 +105,6 @@ static inline uint64_t ReadSwapInt64(const void *ptr) {
return llvm::ByteSwap_64(value);
}
-#define NON_PRINTABLE_CHAR '.'
-
DataExtractor::DataExtractor()
: m_start(nullptr), m_end(nullptr),
m_byte_order(endian::InlHostByteOrder()), m_addr_size(sizeof(void *)),
@@ -785,130 +777,6 @@ uint64_t DataExtractor::GetPointer(offset_t *offset_ptr) const {
return GetMaxU64(offset_ptr, m_addr_size);
}
-//----------------------------------------------------------------------
-// GetDwarfEHPtr
-//
-// Used for calls when the value type is specified by a DWARF EH Frame
-// pointer encoding.
-//----------------------------------------------------------------------
-
-uint64_t DataExtractor::GetGNUEHPointer(
- offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr,
- lldb::addr_t text_addr,
- lldb::addr_t data_addr) //, BSDRelocs *data_relocs) const
-{
- if (eh_ptr_enc == DW_EH_PE_omit)
- return ULLONG_MAX; // Value isn't in the buffer...
-
- uint64_t baseAddress = 0;
- uint64_t addressValue = 0;
- const uint32_t addr_size = GetAddressByteSize();
-#ifdef LLDB_CONFIGURATION_DEBUG
- assert(addr_size == 4 || addr_size == 8);
-#endif
-
- bool signExtendValue = false;
- // Decode the base part or adjust our offset
- switch (eh_ptr_enc & 0x70) {
- case DW_EH_PE_pcrel:
- signExtendValue = true;
- baseAddress = *offset_ptr;
- if (pc_rel_addr != LLDB_INVALID_ADDRESS)
- baseAddress += pc_rel_addr;
- // else
- // Log::GlobalWarning ("PC relative pointer encoding found with
- // invalid pc relative address.");
- break;
-
- case DW_EH_PE_textrel:
- signExtendValue = true;
- if (text_addr != LLDB_INVALID_ADDRESS)
- baseAddress = text_addr;
- // else
- // Log::GlobalWarning ("text relative pointer encoding being
- // decoded with invalid text section address, setting base address
- // to zero.");
- break;
-
- case DW_EH_PE_datarel:
- signExtendValue = true;
- if (data_addr != LLDB_INVALID_ADDRESS)
- baseAddress = data_addr;
- // else
- // Log::GlobalWarning ("data relative pointer encoding being
- // decoded with invalid data section address, setting base address
- // to zero.");
- break;
-
- case DW_EH_PE_funcrel:
- signExtendValue = true;
- break;
-
- case DW_EH_PE_aligned: {
- // SetPointerSize should be called prior to extracting these so the
- // pointer size is cached
- assert(addr_size != 0);
- if (addr_size) {
- // Align to a address size boundary first
- uint32_t alignOffset = *offset_ptr % addr_size;
- if (alignOffset)
- offset_ptr += addr_size - alignOffset;
- }
- } break;
-
- default:
- break;
- }
-
- // Decode the value part
- switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING) {
- case DW_EH_PE_absptr: {
- addressValue = GetAddress(offset_ptr);
- // if (data_relocs)
- // addressValue = data_relocs->Relocate(*offset_ptr -
- // addr_size, *this, addressValue);
- } break;
- case DW_EH_PE_uleb128:
- addressValue = GetULEB128(offset_ptr);
- break;
- case DW_EH_PE_udata2:
- addressValue = GetU16(offset_ptr);
- break;
- case DW_EH_PE_udata4:
- addressValue = GetU32(offset_ptr);
- break;
- case DW_EH_PE_udata8:
- addressValue = GetU64(offset_ptr);
- break;
- case DW_EH_PE_sleb128:
- addressValue = GetSLEB128(offset_ptr);
- break;
- case DW_EH_PE_sdata2:
- addressValue = (int16_t)GetU16(offset_ptr);
- break;
- case DW_EH_PE_sdata4:
- addressValue = (int32_t)GetU32(offset_ptr);
- break;
- case DW_EH_PE_sdata8:
- addressValue = (int64_t)GetU64(offset_ptr);
- break;
- default:
- // Unhandled encoding type
- assert(eh_ptr_enc);
- break;
- }
-
- // Since we promote everything to 64 bit, we may need to sign extend
- if (signExtendValue && addr_size < sizeof(baseAddress)) {
- uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull);
- if (sign_bit & addressValue) {
- uint64_t mask = ~sign_bit + 1;
- addressValue |= mask;
- }
- }
- return baseAddress + addressValue;
-}
-
size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length,
ByteOrder dst_byte_order, void *dst) const {
const uint8_t *src = PeekData(offset, length);
@@ -1199,759 +1067,6 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {
return bytes_consumed;
}
-static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
- lldb::offset_t byte_size, llvm::APInt &result) {
- llvm::SmallVector<uint64_t, 2> uint64_array;
- lldb::offset_t bytes_left = byte_size;
- uint64_t u64;
- const lldb::ByteOrder byte_order = data.GetByteOrder();
- if (byte_order == lldb::eByteOrderLittle) {
- while (bytes_left > 0) {
- if (bytes_left >= 8) {
- u64 = data.GetU64(offset_ptr);
- bytes_left -= 8;
- } else {
- u64 = data.GetMaxU64(offset_ptr, (uint32_t)bytes_left);
- bytes_left = 0;
- }
- uint64_array.push_back(u64);
- }
- result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
- return true;
- } else if (byte_order == lldb::eByteOrderBig) {
- lldb::offset_t be_offset = *offset_ptr + byte_size;
- lldb::offset_t temp_offset;
- while (bytes_left > 0) {
- if (bytes_left >= 8) {
- be_offset -= 8;
- temp_offset = be_offset;
- u64 = data.GetU64(&temp_offset);
- bytes_left -= 8;
- } else {
- be_offset -= bytes_left;
- temp_offset = be_offset;
- u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
- bytes_left = 0;
- }
- uint64_array.push_back(u64);
- }
- *offset_ptr += byte_size;
- result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
- return true;
- }
- return false;
-}
-
-static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data,
- lldb::offset_t offset, lldb::offset_t byte_size,
- bool is_signed, unsigned radix) {
- llvm::APInt apint;
- if (GetAPInt(data, &offset, byte_size, apint)) {
- std::string apint_str(apint.toString(radix, is_signed));
- switch (radix) {
- case 2:
- s->Write("0b", 2);
- break;
- case 8:
- s->Write("0", 1);
- break;
- case 10:
- break;
- }
- s->Write(apint_str.c_str(), apint_str.size());
- }
- return offset;
-}
-
-static float half2float(uint16_t half) {
- union {
- float f;
- uint32_t u;
- } u;
- int32_t v = (int16_t)half;
-
- if (0 == (v & 0x7c00)) {
- u.u = v & 0x80007FFFU;
- return u.f * ldexpf(1, 125);
- }
-
- v <<= 13;
- u.u = v | 0x70000000U;
- return u.f * ldexpf(1, -112);
-}
-
-lldb::offset_t DataExtractor::Dump(
- Stream *s, offset_t start_offset, lldb::Format item_format,
- size_t item_byte_size, size_t item_count, size_t num_per_line,
- uint64_t base_addr,
- uint32_t item_bit_size, // If zero, this is not a bitfield value, if
- // non-zero, the value is a bitfield
- uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the
- // shift amount to apply to a bitfield
- ExecutionContextScope *exe_scope) const {
- if (s == nullptr)
- return start_offset;
-
- if (item_format == eFormatPointer) {
- if (item_byte_size != 4 && item_byte_size != 8)
- item_byte_size = s->GetAddressByteSize();
- }
-
- offset_t offset = start_offset;
-
- if (item_format == eFormatInstruction) {
- TargetSP target_sp;
- if (exe_scope)
- target_sp = exe_scope->CalculateTarget();
- if (target_sp) {
- DisassemblerSP disassembler_sp(Disassembler::FindPlugin(
- target_sp->GetArchitecture(), nullptr, nullptr));
- if (disassembler_sp) {
- lldb::addr_t addr = base_addr + start_offset;
- lldb_private::Address so_addr;
- bool data_from_file = true;
- if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) {
- data_from_file = false;
- } else {
- if (target_sp->GetSectionLoadList().IsEmpty() ||
- !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
- so_addr.SetRawAddress(addr);
- }
-
- size_t bytes_consumed = disassembler_sp->DecodeInstructions(
- so_addr, *this, start_offset, item_count, false, data_from_file);
-
- if (bytes_consumed) {
- offset += bytes_consumed;
- const bool show_address = base_addr != LLDB_INVALID_ADDRESS;
- const bool show_bytes = true;
- ExecutionContext exe_ctx;
- exe_scope->CalculateExecutionContext(exe_ctx);
- disassembler_sp->GetInstructionList().Dump(s, show_address,
- show_bytes, &exe_ctx);
- }
- }
- } else
- s->Printf("invalid target");
-
- return offset;
- }
-
- if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) &&
- item_byte_size > 8)
- item_format = eFormatHex;
-
- lldb::offset_t line_start_offset = start_offset;
- for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count) {
- if ((count % num_per_line) == 0) {
- if (count > 0) {
- if (item_format == eFormatBytesWithASCII &&
- offset > line_start_offset) {
- s->Printf("%*s",
- static_cast<int>(
- (num_per_line - (offset - line_start_offset)) * 3 + 2),
- "");
- Dump(s, line_start_offset, eFormatCharPrintable, 1,
- offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0,
- 0);
- }
- s->EOL();
- }
- if (base_addr != LLDB_INVALID_ADDRESS)
- s->Printf("0x%8.8" PRIx64 ": ",
- (uint64_t)(base_addr +
- (offset - start_offset) / m_target_byte_size));
-
- line_start_offset = offset;
- } else if (item_format != eFormatChar &&
- item_format != eFormatCharPrintable &&
- item_format != eFormatCharArray && count > 0) {
- s->PutChar(' ');
- }
-
- switch (item_format) {
- case eFormatBoolean:
- if (item_byte_size <= 8)
- s->Printf("%s", GetMaxU64Bitfield(&offset, item_byte_size,
- item_bit_size, item_bit_offset)
- ? "true"
- : "false");
- else {
- s->Printf("error: unsupported byte size (%" PRIu64
- ") for boolean format",
- (uint64_t)item_byte_size);
- return offset;
- }
- break;
-
- case eFormatBinary:
- if (item_byte_size <= 8) {
- uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size,
- item_bit_size, item_bit_offset);
- // Avoid std::bitset<64>::to_string() since it is missing in
- // earlier C++ libraries
- std::string binary_value(64, '0');
- std::bitset<64> bits(uval64);
- for (uint32_t i = 0; i < 64; ++i)
- if (bits[i])
- binary_value[64 - 1 - i] = '1';
- if (item_bit_size > 0)
- s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size);
- else if (item_byte_size > 0 && item_byte_size <= 8)
- s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
- } else {
- const bool is_signed = false;
- const unsigned radix = 2;
- offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix);
- }
- break;
-
- case eFormatBytes:
- case eFormatBytesWithASCII:
- for (uint32_t i = 0; i < item_byte_size; ++i) {
- s->Printf("%2.2x", GetU8(&offset));
- }
-
- // Put an extra space between the groups of bytes if more than one
- // is being dumped in a group (item_byte_size is more than 1).
- if (item_byte_size > 1)
- s->PutChar(' ');
- break;
-
- case eFormatChar:
- case eFormatCharPrintable:
- case eFormatCharArray: {
- // If we are only printing one character surround it with single
- // quotes
- if (item_count == 1 && item_format == eFormatChar)
- s->PutChar('\'');
-
- const uint64_t ch = GetMaxU64Bitfield(&offset, item_byte_size,
- item_bit_size, item_bit_offset);
- if (isprint(ch))
- s->Printf("%c", (char)ch);
- else if (item_format != eFormatCharPrintable) {
- switch (ch) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- case '\0':
- s->Printf("\\0");
- break;
- default:
- if (item_byte_size == 1)
- s->Printf("\\x%2.2x", (uint8_t)ch);
- else
- s->Printf("%" PRIu64, ch);
- break;
- }
- } else {
- s->PutChar(NON_PRINTABLE_CHAR);
- }
-
- // If we are only printing one character surround it with single quotes
- if (item_count == 1 && item_format == eFormatChar)
- s->PutChar('\'');
- } break;
-
- case eFormatEnum: // Print enum value as a signed integer when we don't get
- // the enum type
- case eFormatDecimal:
- if (item_byte_size <= 8)
- s->Printf("%" PRId64,
- GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset));
- else {
- const bool is_signed = true;
- const unsigned radix = 10;
- offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix);
- }
- break;
-
- case eFormatUnsigned:
- if (item_byte_size <= 8)
- s->Printf("%" PRIu64,
- GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset));
- else {
- const bool is_signed = false;
- const unsigned radix = 10;
- offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix);
- }
- break;
-
- case eFormatOctal:
- if (item_byte_size <= 8)
- s->Printf("0%" PRIo64,
- GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset));
- else {
- const bool is_signed = false;
- const unsigned radix = 8;
- offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix);
- }
- break;
-
- case eFormatOSType: {
- uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size,
- item_bit_size, item_bit_offset);
- s->PutChar('\'');
- for (uint32_t i = 0; i < item_byte_size; ++i) {
- uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
- if (isprint(ch))
- s->Printf("%c", ch);
- else {
- switch (ch) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- case '\0':
- s->Printf("\\0");
- break;
- default:
- s->Printf("\\x%2.2x", ch);
- break;
- }
- }
- }
- s->PutChar('\'');
- } break;
-
- case eFormatCString: {
- const char *cstr = GetCStr(&offset);
-
- if (!cstr) {
- s->Printf("NULL");
- offset = LLDB_INVALID_OFFSET;
- } else {
- s->PutChar('\"');
-
- while (const char c = *cstr) {
- if (isprint(c)) {
- s->PutChar(c);
- } else {
- switch (c) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- default:
- s->Printf("\\x%2.2x", c);
- break;
- }
- }
-
- ++cstr;
- }
-
- s->PutChar('\"');
- }
- } break;
-
- case eFormatPointer:
- s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset),
- sizeof(addr_t));
- break;
-
- case eFormatComplexInteger: {
- size_t complex_int_byte_size = item_byte_size / 2;
-
- if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) {
- s->Printf("%" PRIu64,
- GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
- s->Printf(" + %" PRIu64 "i",
- GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
- } else {
- s->Printf("error: unsupported byte size (%" PRIu64
- ") for complex integer format",
- (uint64_t)item_byte_size);
- return offset;
- }
- } break;
-
- case eFormatComplex:
- if (sizeof(float) * 2 == item_byte_size) {
- float f32_1 = GetFloat(&offset);
- float f32_2 = GetFloat(&offset);
-
- s->Printf("%g + %gi", f32_1, f32_2);
- break;
- } else if (sizeof(double) * 2 == item_byte_size) {
- double d64_1 = GetDouble(&offset);
- double d64_2 = GetDouble(&offset);
-
- s->Printf("%lg + %lgi", d64_1, d64_2);
- break;
- } else if (sizeof(long double) * 2 == item_byte_size) {
- long double ld64_1 = GetLongDouble(&offset);
- long double ld64_2 = GetLongDouble(&offset);
- s->Printf("%Lg + %Lgi", ld64_1, ld64_2);
- break;
- } else {
- s->Printf("error: unsupported byte size (%" PRIu64
- ") for complex float format",
- (uint64_t)item_byte_size);
- return offset;
- }
- break;
-
- default:
- case eFormatDefault:
- case eFormatHex:
- case eFormatHexUppercase: {
- bool wantsuppercase = (item_format == eFormatHexUppercase);
- switch (item_byte_size) {
- case 1:
- case 2:
- case 4:
- case 8:
- s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
- (int)(2 * item_byte_size), (int)(2 * item_byte_size),
- GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset));
- break;
- default: {
- assert(item_bit_size == 0 && item_bit_offset == 0);
- const uint8_t *bytes =
- (const uint8_t *)GetData(&offset, item_byte_size);
- if (bytes) {
- s->PutCString("0x");
- uint32_t idx;
- if (m_byte_order == eByteOrderBig) {
- for (idx = 0; idx < item_byte_size; ++idx)
- s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]);
- } else {
- for (idx = 0; idx < item_byte_size; ++idx)
- s->Printf(wantsuppercase ? "%2.2X" : "%2.2x",
- bytes[item_byte_size - 1 - idx]);
- }
- }
- } break;
- }
- } break;
-
- case eFormatFloat: {
- TargetSP target_sp;
- bool used_apfloat = false;
- if (exe_scope)
- target_sp = exe_scope->CalculateTarget();
- if (target_sp) {
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast) {
- clang::ASTContext *ast = clang_ast->getASTContext();
- if (ast) {
- llvm::SmallVector<char, 256> sv;
- // Show full precision when printing float values
- const unsigned format_precision = 0;
- const unsigned format_max_padding = 100;
- size_t item_bit_size = item_byte_size * 8;
-
- if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
- llvm::APInt apint(item_bit_size,
- this->GetMaxU64(&offset, item_byte_size));
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- } else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
- llvm::APInt apint;
- if (GetAPInt(*this, &offset, item_byte_size, apint)) {
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
- } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
- const auto &semantics =
- ast->getFloatTypeSemantics(ast->LongDoubleTy);
- const auto byte_size =
- (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
-
- llvm::APInt apint;
- if (GetAPInt(*this, &offset, byte_size, apint)) {
- llvm::APFloat apfloat(semantics, apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
- } else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
- llvm::APInt apint(item_bit_size, this->GetU16(&offset));
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
-
- if (!sv.empty()) {
- s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data());
- used_apfloat = true;
- }
- }
- }
- }
-
- if (!used_apfloat) {
- std::ostringstream ss;
- if (item_byte_size == sizeof(float) || item_byte_size == 2) {
- float f;
- if (item_byte_size == 2) {
- uint16_t half = this->GetU16(&offset);
- f = half2float(half);
- } else {
- f = GetFloat(&offset);
- }
- ss.precision(std::numeric_limits<float>::digits10);
- ss << f;
- } else if (item_byte_size == sizeof(double)) {
- ss.precision(std::numeric_limits<double>::digits10);
- ss << GetDouble(&offset);
- } else if (item_byte_size == sizeof(long double) ||
- item_byte_size == 10) {
- ss.precision(std::numeric_limits<long double>::digits10);
- ss << GetLongDouble(&offset);
- } else {
- s->Printf("error: unsupported byte size (%" PRIu64
- ") for float format",
- (uint64_t)item_byte_size);
- return offset;
- }
- ss.flush();
- s->Printf("%s", ss.str().c_str());
- }
- } break;
-
- case eFormatUnicode16:
- s->Printf("U+%4.4x", GetU16(&offset));
- break;
-
- case eFormatUnicode32:
- s->Printf("U+0x%8.8x", GetU32(&offset));
- break;
-
- case eFormatAddressInfo: {
- addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
- item_bit_offset);
- s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size),
- (int)(2 * item_byte_size), addr);
- if (exe_scope) {
- TargetSP target_sp(exe_scope->CalculateTarget());
- lldb_private::Address so_addr;
- if (target_sp) {
- if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr,
- so_addr)) {
- s->PutChar(' ');
- so_addr.Dump(s, exe_scope, Address::DumpStyleResolvedDescription,
- Address::DumpStyleModuleWithFileAddress);
- } else {
- so_addr.SetOffset(addr);
- so_addr.Dump(s, exe_scope,
- Address::DumpStyleResolvedPointerDescription);
- }
- }
- }
- } break;
-
- case eFormatHexFloat:
- if (sizeof(float) == item_byte_size) {
- char float_cstr[256];
- llvm::APFloat ap_float(GetFloat(&offset));
- ap_float.convertToHexString(float_cstr, 0, false,
- llvm::APFloat::rmNearestTiesToEven);
- s->Printf("%s", float_cstr);
- break;
- } else if (sizeof(double) == item_byte_size) {
- char float_cstr[256];
- llvm::APFloat ap_float(GetDouble(&offset));
- ap_float.convertToHexString(float_cstr, 0, false,
- llvm::APFloat::rmNearestTiesToEven);
- s->Printf("%s", float_cstr);
- break;
- } else {
- s->Printf("error: unsupported byte size (%" PRIu64
- ") for hex float format",
- (uint64_t)item_byte_size);
- return offset;
- }
- break;
-
- // please keep the single-item formats below in sync with
- // FormatManager::GetSingleItemFormat
- // if you fail to do so, users will start getting different outputs
- // depending on internal
- // implementation details they should not care about ||
- case eFormatVectorOfChar: // ||
- s->PutChar('{'); // \/
- offset = Dump(s, offset, eFormatCharArray, 1, item_byte_size,
- item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfSInt8:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatDecimal, 1, item_byte_size,
- item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfUInt8:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatHex, 1, item_byte_size, item_byte_size,
- LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfSInt16:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatDecimal, sizeof(uint16_t),
- item_byte_size / sizeof(uint16_t),
- item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfUInt16:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatHex, sizeof(uint16_t),
- item_byte_size / sizeof(uint16_t),
- item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfSInt32:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatDecimal, sizeof(uint32_t),
- item_byte_size / sizeof(uint32_t),
- item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfUInt32:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatHex, sizeof(uint32_t),
- item_byte_size / sizeof(uint32_t),
- item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfSInt64:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatDecimal, sizeof(uint64_t),
- item_byte_size / sizeof(uint64_t),
- item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfUInt64:
- s->PutChar('{');
- offset =
- Dump(s, offset, eFormatHex, sizeof(uint64_t),
- item_byte_size / sizeof(uint64_t),
- item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfFloat16:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatFloat, 2, item_byte_size / 2,
- item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfFloat32:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatFloat, 4, item_byte_size / 4,
- item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfFloat64:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatFloat, 8, item_byte_size / 8,
- item_byte_size / 8, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
-
- case eFormatVectorOfUInt128:
- s->PutChar('{');
- offset = Dump(s, offset, eFormatHex, 16, item_byte_size / 16,
- item_byte_size / 16, LLDB_INVALID_ADDRESS, 0, 0);
- s->PutChar('}');
- break;
- }
- }
-
- if (item_format == eFormatBytesWithASCII && offset > line_start_offset) {
- s->Printf("%*s", static_cast<int>(
- (num_per_line - (offset - line_start_offset)) * 3 + 2),
- "");
- Dump(s, line_start_offset, eFormatCharPrintable, 1,
- offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- }
- return offset; // Return the offset at which we ended up
-}
-
//----------------------------------------------------------------------
// Dumps bytes from this object's data to the stream "s" starting
// "start_offset" bytes into this data, and ending with the byte
@@ -2043,19 +1158,6 @@ void DataExtractor::DumpUUID(Stream *s, offset_t offset) const {
}
}
-void DataExtractor::DumpHexBytes(Stream *s, const void *src, size_t src_len,
- uint32_t bytes_per_line, addr_t base_addr) {
- DataExtractor data(src, src_len, eByteOrderLittle, 4);
- data.Dump(s,
- 0, // Offset into "src"
- eFormatBytes, // Dump as hex bytes
- 1, // Size of each item is 1 for single bytes
- src_len, // Number of bytes
- bytes_per_line, // Num bytes per line
- base_addr, // Base address
- 0, 0); // Bitfield info
-}
-
size_t DataExtractor::Copy(DataExtractor &dest_data) const {
if (m_data_sp) {
// we can pass along the SP to the data
@@ -2138,6 +1240,6 @@ void DataExtractor::Checksum(llvm::SmallVectorImpl<uint8_t> &dest,
llvm::MD5::MD5Result result;
md5.final(result);
- dest.resize(16);
- std::copy(result, result + 16, dest.begin());
+ dest.clear();
+ dest.append(result.Bytes.begin(), result.Bytes.end());
}
diff --git a/source/Core/Error.cpp b/source/Utility/Error.cpp
index 23696127d3b4..b21ee57b61af 100644
--- a/source/Core/Error.cpp
+++ b/source/Utility/Error.cpp
@@ -7,22 +7,30 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-#ifdef __APPLE__
-#include <mach/mach.h>
-#endif
+#include "lldb/Utility/Error.h"
+
+#include "lldb/Utility/VASPrintf.h"
+#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR
+#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr...
+#include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/FormatProviders.h" // for format_provider
-// C++ Includes
#include <cerrno>
#include <cstdarg>
+#include <string> // for string
+#include <system_error>
+
+#ifdef __APPLE__
+#include <mach/mach.h>
+#endif
-// Other libraries and framework includes
-#include "llvm/ADT/SmallVector.h"
+#include <stdint.h> // for uint32_t
+#include <string.h> // for strerror
-// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Host/PosixApi.h"
+namespace llvm {
+class raw_ostream;
+}
using namespace lldb;
using namespace lldb_private;
@@ -32,6 +40,10 @@ Error::Error() : m_code(0), m_type(eErrorTypeInvalid), m_string() {}
Error::Error(ValueType err, ErrorType type)
: m_code(err), m_type(type), m_string() {}
+Error::Error(std::error_code EC)
+ : m_code(EC.value()), m_type(ErrorType::eErrorTypeGeneric),
+ m_string(EC.message()) {}
+
Error::Error(const Error &rhs) = default;
Error::Error(const char *format, ...)
@@ -130,72 +142,6 @@ ErrorType Error::GetType() const { return m_type; }
bool Error::Fail() const { return m_code != 0; }
//----------------------------------------------------------------------
-// Log the error given a string with format. If the this object
-// contains an error code, update the error string to contain the
-// "error: " followed by the formatted string, followed by the error
-// value and any string that describes the current error. This
-// allows more context to be given to an error string that remains
-// cached in this object. Logging always occurs even when the error
-// code contains a non-error value.
-//----------------------------------------------------------------------
-void Error::PutToLog(Log *log, const char *format, ...) {
- char *arg_msg = nullptr;
- va_list args;
- va_start(args, format);
- ::vasprintf(&arg_msg, format, args);
- va_end(args);
-
- if (arg_msg != nullptr) {
- if (Fail()) {
- const char *err_str = AsCString();
- if (err_str == nullptr)
- err_str = "???";
-
- SetErrorStringWithFormat("error: %s err = %s (0x%8.8x)", arg_msg, err_str,
- m_code);
- if (log != nullptr)
- log->Error("%s", m_string.c_str());
- } else {
- if (log != nullptr)
- log->Printf("%s err = 0x%8.8x", arg_msg, m_code);
- }
- ::free(arg_msg);
- }
-}
-
-//----------------------------------------------------------------------
-// Log the error given a string with format. If the this object
-// contains an error code, update the error string to contain the
-// "error: " followed by the formatted string, followed by the error
-// value and any string that describes the current error. This
-// allows more context to be given to an error string that remains
-// cached in this object. Logging only occurs even when the error
-// code contains a error value.
-//----------------------------------------------------------------------
-void Error::LogIfError(Log *log, const char *format, ...) {
- if (Fail()) {
- char *arg_msg = nullptr;
- va_list args;
- va_start(args, format);
- ::vasprintf(&arg_msg, format, args);
- va_end(args);
-
- if (arg_msg != nullptr) {
- const char *err_str = AsCString();
- if (err_str == nullptr)
- err_str = "???";
-
- SetErrorStringWithFormat("%s err = %s (0x%8.8x)", arg_msg, err_str,
- m_code);
- if (log != nullptr)
- log->Error("%s", m_string.c_str());
-
- ::free(arg_msg);
- }
- }
-}
-
-//----------------------------------------------------------------------
// Set accesssor for the error value to "err" and the type to
// "eErrorTypeMachKernel"
//----------------------------------------------------------------------
@@ -300,25 +246,10 @@ int Error::SetErrorStringWithVarArg(const char *format, va_list args) {
if (Success())
SetErrorToGenericError();
- // Try and fit our error into a 1024 byte buffer first...
- llvm::SmallVector<char, 1024> buf;
- buf.resize(1024);
- // Copy in case our first call to vsnprintf doesn't fit into our
- // allocated buffer above
- va_list copy_args;
- va_copy(copy_args, args);
- unsigned length = ::vsnprintf(buf.data(), buf.size(), format, args);
- if (length >= buf.size()) {
- // The error formatted string didn't fit into our buffer, resize it
- // to the exact needed size, and retry
- buf.resize(length + 1);
- length = ::vsnprintf(buf.data(), buf.size(), format, copy_args);
- va_end(copy_args);
- assert(length < buf.size());
- }
- m_string.assign(buf.data(), length);
- va_end(args);
- return length;
+ llvm::SmallString<1024> buf;
+ VASprintf(buf, format, args);
+ m_string = buf.str();
+ return buf.size();
} else {
m_string.clear();
}
@@ -334,3 +265,10 @@ bool Error::Success() const { return m_code == 0; }
bool Error::WasInterrupted() const {
return (m_type == eErrorTypePOSIX && m_code == EINTR);
}
+
+void llvm::format_provider<lldb_private::Error>::format(
+ const lldb_private::Error &error, llvm::raw_ostream &OS,
+ llvm::StringRef Options) {
+ llvm::format_provider<llvm::StringRef>::format(error.AsCString(), OS,
+ Options);
+}
diff --git a/source/Core/FastDemangle.cpp b/source/Utility/FastDemangle.cpp
index 0bed4a1f20ad..90326c5f15c3 100644
--- a/source/Core/FastDemangle.cpp
+++ b/source/Utility/FastDemangle.cpp
@@ -7,14 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "lldb/Utility/FastDemangle.h"
+
+#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH
#include <functional>
-#include "lldb/Core/FastDemangle.h"
-#include "lldb/lldb-private.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
//#define DEBUG_FAILURES 1
//#define DEBUG_SUBSTITUTIONS 1
diff --git a/source/Host/common/FileSpec.cpp b/source/Utility/FileSpec.cpp
index 7f46d303a5d8..3c4e3407ddf6 100644
--- a/source/Host/common/FileSpec.cpp
+++ b/source/Utility/FileSpec.cpp
@@ -7,52 +7,48 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _WIN32
-#include <dirent.h>
-#else
-#include "lldb/Host/windows/windows.h"
-#endif
-#include <fcntl.h>
-#ifndef _MSC_VER
-#include <libgen.h>
-#endif
-#include <fstream>
-#include <set>
-#include <string.h>
-
-#include "lldb/Host/Config.h" // Have to include this before we test the define...
-#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
-#include <pwd.h>
-#endif
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/TildeExpressionResolver.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataBufferMemoryMap.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/File.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Utility/CleanUp.h"
-
-#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/ADT/SmallVector.h" // for SmallVectorTemplat...
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ConvertUTF.h"
+#include "llvm/ADT/Triple.h" // for Triple
+#include "llvm/ADT/Twine.h" // for Twine
+#include "llvm/Config/llvm-config.h" // for LLVM_ON_WIN32
+#include "llvm/Support/ErrorOr.h" // for ErrorOr
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
+#include "llvm/Support/raw_ostream.h" // for raw_ostream, fs
+
+#include <algorithm> // for replace, min, unique
+#include <system_error> // for error_code
+#include <vector> // for vector
+
+#include <assert.h> // for assert
+#include <stdio.h> // for size_t, NULL, snpr...
+#include <string.h> // for strcmp
using namespace lldb;
using namespace lldb_private;
namespace {
+static constexpr FileSpec::PathSyntax GetNativeSyntax() {
+#if defined(LLVM_ON_WIN32)
+ return FileSpec::ePathSyntaxWindows;
+#else
+ return FileSpec::ePathSyntaxPosix;
+#endif
+}
+
bool PathSyntaxIsPosix(FileSpec::PathSyntax syntax) {
return (syntax == FileSpec::ePathSyntaxPosix ||
(syntax == FileSpec::ePathSyntaxHostNative &&
- FileSystem::GetNativePathSyntax() == FileSpec::ePathSyntaxPosix));
+ GetNativeSyntax() == FileSpec::ePathSyntaxPosix));
}
const char *GetPathSeparators(FileSpec::PathSyntax syntax) {
@@ -88,13 +84,6 @@ void Denormalize(llvm::SmallVectorImpl<char> &path,
std::replace(path.begin(), path.end(), '/', '\\');
}
-bool GetFileStats(const FileSpec *file_spec, struct stat *stats_ptr) {
- char resolved_path[PATH_MAX];
- if (file_spec->GetPath(resolved_path, sizeof(resolved_path)))
- return FileSystem::Stat(resolved_path, stats_ptr) == 0;
- return false;
-}
-
size_t FilenamePos(llvm::StringRef str, FileSpec::PathSyntax syntax) {
if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
return 0;
@@ -157,115 +146,13 @@ size_t ParentPathEnd(llvm::StringRef path, FileSpec::PathSyntax syntax) {
} // end anonymous namespace
-// Resolves the username part of a path of the form ~user/other/directories, and
-// writes the result into dst_path. This will also resolve "~" to the current
-// user.
-// If you want to complete "~" to the list of users, pass it to
-// ResolvePartialUsername.
-void FileSpec::ResolveUsername(llvm::SmallVectorImpl<char> &path) {
-#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER
- if (path.empty() || path[0] != '~')
- return;
-
- llvm::StringRef path_str(path.data(), path.size());
- size_t slash_pos = path_str.find('/', 1);
- if (slash_pos == 1 || path.size() == 1) {
- // A path of ~/ resolves to the current user's home dir
- llvm::SmallString<64> home_dir;
- // llvm::sys::path::home_directory() only checks if "HOME" is set in the
- // environment and does nothing else to locate the user home directory
- if (!llvm::sys::path::home_directory(home_dir)) {
- struct passwd *pw = getpwuid(getuid());
- if (pw && pw->pw_dir && pw->pw_dir[0]) {
- // Update our environemnt so llvm::sys::path::home_directory() works
- // next time
- setenv("HOME", pw->pw_dir, 0);
- home_dir.assign(llvm::StringRef(pw->pw_dir));
- } else {
- return;
- }
- }
-
- // Overwrite the ~ with the first character of the homedir, and insert
- // the rest. This way we only trigger one move, whereas an insert
- // followed by a delete (or vice versa) would trigger two.
- path[0] = home_dir[0];
- path.insert(path.begin() + 1, home_dir.begin() + 1, home_dir.end());
- return;
- }
-
- auto username_begin = path.begin() + 1;
- auto username_end = (slash_pos == llvm::StringRef::npos)
- ? path.end()
- : (path.begin() + slash_pos);
- size_t replacement_length = std::distance(path.begin(), username_end);
-
- llvm::SmallString<20> username(username_begin, username_end);
- struct passwd *user_entry = ::getpwnam(username.c_str());
- if (user_entry != nullptr) {
- // Copy over the first n characters of the path, where n is the smaller of
- // the length
- // of the home directory and the slash pos.
- llvm::StringRef homedir(user_entry->pw_dir);
- size_t initial_copy_length = std::min(homedir.size(), replacement_length);
- auto src_begin = homedir.begin();
- auto src_end = src_begin + initial_copy_length;
- std::copy(src_begin, src_end, path.begin());
- if (replacement_length > homedir.size()) {
- // We copied the entire home directory, but the ~username portion of the
- // path was
- // longer, so there's characters that need to be removed.
- path.erase(path.begin() + initial_copy_length, username_end);
- } else if (replacement_length < homedir.size()) {
- // We copied all the way up to the slash in the destination, but there's
- // still more
- // characters that need to be inserted.
- path.insert(username_end, src_end, homedir.end());
- }
- } else {
- // Unable to resolve username (user doesn't exist?)
- path.clear();
- }
-#endif
-}
-
-size_t FileSpec::ResolvePartialUsername(llvm::StringRef partial_name,
- StringList &matches) {
-#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
- size_t extant_entries = matches.GetSize();
-
- setpwent();
- struct passwd *user_entry;
- partial_name = partial_name.drop_front();
- std::set<std::string> name_list;
-
- while ((user_entry = getpwent()) != NULL) {
- if (llvm::StringRef(user_entry->pw_name).startswith(partial_name)) {
- std::string tmp_buf("~");
- tmp_buf.append(user_entry->pw_name);
- tmp_buf.push_back('/');
- name_list.insert(tmp_buf);
- }
- }
-
- for (auto &name : name_list) {
- matches.AppendString(name);
- }
- return matches.GetSize() - extant_entries;
-#else
- // Resolving home directories is not supported, just copy the path...
- return 0;
-#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
-}
-
void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) {
if (path.empty())
return;
-#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
- if (path[0] == '~')
- ResolveUsername(path);
-#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
+ llvm::SmallString<32> Source(path.begin(), path.end());
+ StandardTildeExpressionResolver Resolver;
+ Resolver.ResolveFullPath(Source, path);
// Save a copy of the original path that's passed in
llvm::SmallString<128> original_path(path.begin(), path.end());
@@ -277,7 +164,7 @@ void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) {
}
}
-FileSpec::FileSpec() : m_syntax(FileSystem::GetNativePathSyntax()) {}
+FileSpec::FileSpec() : m_syntax(GetNativeSyntax()) {}
//------------------------------------------------------------------
// Default constructor that can take an optional full path to a
@@ -288,10 +175,10 @@ FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, PathSyntax syntax)
SetFile(path, resolve_path, syntax);
}
-FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, ArchSpec arch)
- : FileSpec{path, resolve_path, arch.GetTriple().isOSWindows()
- ? ePathSyntaxWindows
- : ePathSyntaxPosix} {}
+FileSpec::FileSpec(llvm::StringRef path, bool resolve_path,
+ const llvm::Triple &Triple)
+ : FileSpec{path, resolve_path,
+ Triple.isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix} {}
//------------------------------------------------------------------
// Copy constructor
@@ -340,9 +227,7 @@ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve,
m_filename.Clear();
m_directory.Clear();
m_is_resolved = false;
- m_syntax = (syntax == ePathSyntaxHostNative)
- ? FileSystem::GetNativePathSyntax()
- : syntax;
+ m_syntax = (syntax == ePathSyntaxHostNative) ? GetNativeSyntax() : syntax;
if (pathname.empty())
return;
@@ -378,10 +263,10 @@ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve,
: resolve_path_ref.substr(filename_begin));
}
-void FileSpec::SetFile(llvm::StringRef path, bool resolve, ArchSpec arch) {
- return SetFile(path, resolve, arch.GetTriple().isOSWindows()
- ? ePathSyntaxWindows
- : ePathSyntaxPosix);
+void FileSpec::SetFile(llvm::StringRef path, bool resolve,
+ const llvm::Triple &Triple) {
+ return SetFile(path, resolve,
+ Triple.isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix);
}
//----------------------------------------------------------------------
@@ -526,11 +411,36 @@ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) {
bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full,
bool remove_backups) {
+ static ConstString g_dot_string(".");
+ static ConstString g_dot_dot_string("..");
+
// case sensitivity of equality test
const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
+
+ bool filenames_equal = ConstString::Equals(a.m_filename,
+ b.m_filename,
+ case_sensitive);
+
+ // The only way two FileSpecs can be equal if their filenames are
+ // unequal is if we are removing backups and one or the other filename
+ // is a backup string:
+
+ if (!filenames_equal && !remove_backups)
+ return false;
+
+ bool last_component_is_dot = ConstString::Equals(a.m_filename, g_dot_string)
+ || ConstString::Equals(a.m_filename,
+ g_dot_dot_string)
+ || ConstString::Equals(b.m_filename,
+ g_dot_string)
+ || ConstString::Equals(b.m_filename,
+ g_dot_dot_string);
+
+ if (!filenames_equal && !last_component_is_dot)
+ return false;
if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty()))
- return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive);
+ return filenames_equal;
if (remove_backups == false)
return a == b;
@@ -619,16 +529,10 @@ void FileSpec::Dump(Stream *s) const {
//------------------------------------------------------------------
// Returns true if the file exists.
//------------------------------------------------------------------
-bool FileSpec::Exists() const {
- struct stat file_stats;
- return GetFileStats(this, &file_stats);
-}
+bool FileSpec::Exists() const { return llvm::sys::fs::exists(GetPath()); }
bool FileSpec::Readable() const {
- const uint32_t permissions = GetPermissions();
- if (permissions & eFilePermissionsEveryoneR)
- return true;
- return false;
+ return GetPermissions() & llvm::sys::fs::perms::all_read;
}
bool FileSpec::ResolveExecutableLocation() {
@@ -672,76 +576,27 @@ bool FileSpec::ResolvePath() {
if (m_is_resolved)
return true; // We have already resolved this path
- char path_buf[PATH_MAX];
- if (!GetPath(path_buf, PATH_MAX, false))
- return false;
// SetFile(...) will set m_is_resolved correctly if it can resolve the path
- SetFile(path_buf, true);
+ SetFile(GetPath(false), true);
return m_is_resolved;
}
uint64_t FileSpec::GetByteSize() const {
- struct stat file_stats;
- if (GetFileStats(this, &file_stats))
- return file_stats.st_size;
- return 0;
+ uint64_t Size = 0;
+ if (llvm::sys::fs::file_size(GetPath(), Size))
+ return 0;
+ return Size;
}
FileSpec::PathSyntax FileSpec::GetPathSyntax() const { return m_syntax; }
-FileSpec::FileType FileSpec::GetFileType() const {
- struct stat file_stats;
- if (GetFileStats(this, &file_stats)) {
- mode_t file_type = file_stats.st_mode & S_IFMT;
- switch (file_type) {
- case S_IFDIR:
- return eFileTypeDirectory;
- case S_IFREG:
- return eFileTypeRegular;
-#ifndef _WIN32
- case S_IFIFO:
- return eFileTypePipe;
- case S_IFSOCK:
- return eFileTypeSocket;
- case S_IFLNK:
- return eFileTypeSymbolicLink;
-#endif
- default:
- break;
- }
- return eFileTypeUnknown;
- }
- return eFileTypeInvalid;
-}
-
-bool FileSpec::IsSymbolicLink() const {
- char resolved_path[PATH_MAX];
- if (!GetPath(resolved_path, sizeof(resolved_path)))
- return false;
-
-#ifdef _WIN32
- std::wstring wpath;
- if (!llvm::ConvertUTF8toWide(resolved_path, wpath))
- return false;
- auto attrs = ::GetFileAttributesW(wpath.c_str());
- if (attrs == INVALID_FILE_ATTRIBUTES)
- return false;
-
- return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
-#else
- struct stat file_stats;
- if (::lstat(resolved_path, &file_stats) != 0)
- return false;
-
- return (file_stats.st_mode & S_IFMT) == S_IFLNK;
-#endif
-}
-
uint32_t FileSpec::GetPermissions() const {
- uint32_t file_permissions = 0;
- if (*this)
- FileSystem::GetFilePermissions(*this, file_permissions);
- return file_permissions;
+ namespace fs = llvm::sys::fs;
+ fs::file_status st;
+ if (fs::status(GetPath(), st, false))
+ return fs::perms::perms_not_known;
+
+ return st.permissions();
}
//------------------------------------------------------------------
@@ -826,39 +681,6 @@ ConstString FileSpec::GetFileNameStrippingExtension() const {
}
//------------------------------------------------------------------
-// Returns a shared pointer to a data buffer that contains all or
-// part of the contents of a file. The data is memory mapped and
-// will lazily page in data from the file as memory is accessed.
-// The data that is mapped will start "file_offset" bytes into the
-// file, and "file_size" bytes will be mapped. If "file_size" is
-// greater than the number of bytes available in the file starting
-// at "file_offset", the number of bytes will be appropriately
-// truncated. The final number of bytes that get mapped can be
-// verified using the DataBuffer::GetByteSize() function.
-//------------------------------------------------------------------
-DataBufferSP FileSpec::MemoryMapFileContents(off_t file_offset,
- size_t file_size) const {
- DataBufferSP data_sp;
- std::unique_ptr<DataBufferMemoryMap> mmap_data(new DataBufferMemoryMap());
- if (mmap_data.get()) {
- const size_t mapped_length =
- mmap_data->MemoryMapFromFileSpec(this, file_offset, file_size);
- if (((file_size == SIZE_MAX) && (mapped_length > 0)) ||
- (mapped_length >= file_size))
- data_sp.reset(mmap_data.release());
- }
- return data_sp;
-}
-
-DataBufferSP FileSpec::MemoryMapFileContentsIfLocal(off_t file_offset,
- size_t file_size) const {
- if (FileSystem::IsLocal(*this))
- return MemoryMapFileContents(file_offset, file_size);
- else
- return ReadFileContents(file_offset, file_size, NULL);
-}
-
-//------------------------------------------------------------------
// Return the size in bytes that this object takes in memory. This
// returns the size in bytes of this object, not any shared string
// values it may refer to.
@@ -867,322 +689,37 @@ size_t FileSpec::MemorySize() const {
return m_filename.MemorySize() + m_directory.MemorySize();
}
-size_t FileSpec::ReadFileContents(off_t file_offset, void *dst, size_t dst_len,
- Error *error_ptr) const {
- Error error;
- size_t bytes_read = 0;
- char resolved_path[PATH_MAX];
- if (GetPath(resolved_path, sizeof(resolved_path))) {
- File file;
- error = file.Open(resolved_path, File::eOpenOptionRead);
- if (error.Success()) {
- off_t file_offset_after_seek = file_offset;
- bytes_read = dst_len;
- error = file.Read(dst, bytes_read, file_offset_after_seek);
- }
- } else {
- error.SetErrorString("invalid file specification");
- }
- if (error_ptr)
- *error_ptr = error;
- return bytes_read;
-}
-
-//------------------------------------------------------------------
-// Returns a shared pointer to a data buffer that contains all or
-// part of the contents of a file. The data copies into a heap based
-// buffer that lives in the DataBuffer shared pointer object returned.
-// The data that is cached will start "file_offset" bytes into the
-// file, and "file_size" bytes will be mapped. If "file_size" is
-// greater than the number of bytes available in the file starting
-// at "file_offset", the number of bytes will be appropriately
-// truncated. The final number of bytes that get mapped can be
-// verified using the DataBuffer::GetByteSize() function.
-//------------------------------------------------------------------
-DataBufferSP FileSpec::ReadFileContents(off_t file_offset, size_t file_size,
- Error *error_ptr) const {
- Error error;
- DataBufferSP data_sp;
- char resolved_path[PATH_MAX];
- if (GetPath(resolved_path, sizeof(resolved_path))) {
- File file;
- error = file.Open(resolved_path, File::eOpenOptionRead);
- if (error.Success()) {
- const bool null_terminate = false;
- error = file.Read(file_size, file_offset, null_terminate, data_sp);
- }
- } else {
- error.SetErrorString("invalid file specification");
- }
- if (error_ptr)
- *error_ptr = error;
- return data_sp;
-}
-
-DataBufferSP FileSpec::ReadFileContentsAsCString(Error *error_ptr) {
- Error error;
- DataBufferSP data_sp;
- char resolved_path[PATH_MAX];
- if (GetPath(resolved_path, sizeof(resolved_path))) {
- File file;
- error = file.Open(resolved_path, File::eOpenOptionRead);
- if (error.Success()) {
- off_t offset = 0;
- size_t length = SIZE_MAX;
- const bool null_terminate = true;
- error = file.Read(length, offset, null_terminate, data_sp);
- }
- } else {
- error.SetErrorString("invalid file specification");
- }
- if (error_ptr)
- *error_ptr = error;
- return data_sp;
-}
-
-size_t FileSpec::ReadFileLines(STLStringArray &lines) {
- lines.clear();
- char path[PATH_MAX];
- if (GetPath(path, sizeof(path))) {
- std::ifstream file_stream(path);
-
- if (file_stream) {
- std::string line;
- while (getline(file_stream, line))
- lines.push_back(line);
+void FileSpec::EnumerateDirectory(llvm::StringRef dir_path,
+ bool find_directories, bool find_files,
+ bool find_other,
+ EnumerateDirectoryCallbackType callback,
+ void *callback_baton) {
+ namespace fs = llvm::sys::fs;
+ std::error_code EC;
+ fs::recursive_directory_iterator Iter(dir_path, EC);
+ fs::recursive_directory_iterator End;
+ for (; Iter != End && !EC; Iter.increment(EC)) {
+ const auto &Item = *Iter;
+ fs::file_status Status;
+ if ((EC = Item.status(Status)))
+ break;
+ if (!find_files && fs::is_regular_file(Status))
+ continue;
+ if (!find_directories && fs::is_directory(Status))
+ continue;
+ if (!find_other && fs::is_other(Status))
+ continue;
+
+ FileSpec Spec(Item.path(), false);
+ auto Result = callback(callback_baton, Status.type(), Spec);
+ if (Result == eEnumerateDirectoryResultQuit)
+ return;
+ if (Result == eEnumerateDirectoryResultNext) {
+ // Default behavior is to recurse. Opt out if the callback doesn't want
+ // this behavior.
+ Iter.no_push();
}
}
- return lines.size();
-}
-
-FileSpec::EnumerateDirectoryResult
-FileSpec::ForEachItemInDirectory(llvm::StringRef dir_path,
- DirectoryCallback const &callback) {
- if (dir_path.empty())
- return eEnumerateDirectoryResultNext;
-
-#ifdef _WIN32
- std::string szDir(dir_path);
- szDir += "\\*";
-
- std::wstring wszDir;
- if (!llvm::ConvertUTF8toWide(szDir, wszDir)) {
- return eEnumerateDirectoryResultNext;
- }
-
- WIN32_FIND_DATAW ffd;
- HANDLE hFind = FindFirstFileW(wszDir.c_str(), &ffd);
-
- if (hFind == INVALID_HANDLE_VALUE) {
- return eEnumerateDirectoryResultNext;
- }
-
- do {
- FileSpec::FileType file_type = eFileTypeUnknown;
- if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- size_t len = wcslen(ffd.cFileName);
-
- if (len == 1 && ffd.cFileName[0] == L'.')
- continue;
-
- if (len == 2 && ffd.cFileName[0] == L'.' && ffd.cFileName[1] == L'.')
- continue;
-
- file_type = eFileTypeDirectory;
- } else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) {
- file_type = eFileTypeOther;
- } else {
- file_type = eFileTypeRegular;
- }
-
- std::string fileName;
- if (!llvm::convertWideToUTF8(ffd.cFileName, fileName)) {
- continue;
- }
-
- std::string child_path = llvm::join_items("\\", dir_path, fileName);
- // Don't resolve the file type or path
- FileSpec child_path_spec(child_path.data(), false);
-
- EnumerateDirectoryResult result = callback(file_type, child_path_spec);
-
- switch (result) {
- case eEnumerateDirectoryResultNext:
- // Enumerate next entry in the current directory. We just
- // exit this switch and will continue enumerating the
- // current directory as we currently are...
- break;
-
- case eEnumerateDirectoryResultEnter: // Recurse into the current entry
- // if it is a directory or symlink,
- // or next if not
- if (FileSpec::ForEachItemInDirectory(child_path.data(), callback) ==
- eEnumerateDirectoryResultQuit) {
- // The subdirectory returned Quit, which means to
- // stop all directory enumerations at all levels.
- return eEnumerateDirectoryResultQuit;
- }
- break;
-
- case eEnumerateDirectoryResultExit: // Exit from the current directory
- // at the current level.
- // Exit from this directory level and tell parent to
- // keep enumerating.
- return eEnumerateDirectoryResultNext;
-
- case eEnumerateDirectoryResultQuit: // Stop directory enumerations at
- // any level
- return eEnumerateDirectoryResultQuit;
- }
- } while (FindNextFileW(hFind, &ffd) != 0);
-
- FindClose(hFind);
-#else
- std::string dir_string(dir_path);
- lldb_utility::CleanUp<DIR *, int> dir_path_dir(opendir(dir_string.c_str()),
- NULL, closedir);
- if (dir_path_dir.is_valid()) {
- char dir_path_last_char = dir_path.back();
-
- long path_max = fpathconf(dirfd(dir_path_dir.get()), _PC_NAME_MAX);
-#if defined(__APPLE_) && defined(__DARWIN_MAXPATHLEN)
- if (path_max < __DARWIN_MAXPATHLEN)
- path_max = __DARWIN_MAXPATHLEN;
-#endif
- struct dirent *buf, *dp;
- buf = (struct dirent *)malloc(offsetof(struct dirent, d_name) + path_max +
- 1);
-
- while (buf && readdir_r(dir_path_dir.get(), buf, &dp) == 0 && dp) {
- // Only search directories
- if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
- size_t len = strlen(dp->d_name);
-
- if (len == 1 && dp->d_name[0] == '.')
- continue;
-
- if (len == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
- continue;
- }
-
- FileSpec::FileType file_type = eFileTypeUnknown;
-
- switch (dp->d_type) {
- default:
- case DT_UNKNOWN:
- file_type = eFileTypeUnknown;
- break;
- case DT_FIFO:
- file_type = eFileTypePipe;
- break;
- case DT_CHR:
- file_type = eFileTypeOther;
- break;
- case DT_DIR:
- file_type = eFileTypeDirectory;
- break;
- case DT_BLK:
- file_type = eFileTypeOther;
- break;
- case DT_REG:
- file_type = eFileTypeRegular;
- break;
- case DT_LNK:
- file_type = eFileTypeSymbolicLink;
- break;
- case DT_SOCK:
- file_type = eFileTypeSocket;
- break;
-#if !defined(__OpenBSD__)
- case DT_WHT:
- file_type = eFileTypeOther;
- break;
-#endif
- }
-
- std::string child_path;
- // Don't make paths with "/foo//bar", that just confuses everybody.
- if (dir_path_last_char == '/')
- child_path = llvm::join_items("", dir_path, dp->d_name);
- else
- child_path = llvm::join_items('/', dir_path, dp->d_name);
-
- // Don't resolve the file type or path
- FileSpec child_path_spec(child_path, false);
-
- EnumerateDirectoryResult result =
- callback(file_type, child_path_spec);
-
- switch (result) {
- case eEnumerateDirectoryResultNext:
- // Enumerate next entry in the current directory. We just
- // exit this switch and will continue enumerating the
- // current directory as we currently are...
- break;
-
- case eEnumerateDirectoryResultEnter: // Recurse into the current entry
- // if it is a directory or
- // symlink, or next if not
- if (FileSpec::ForEachItemInDirectory(child_path, callback) ==
- eEnumerateDirectoryResultQuit) {
- // The subdirectory returned Quit, which means to
- // stop all directory enumerations at all levels.
- if (buf)
- free(buf);
- return eEnumerateDirectoryResultQuit;
- }
- break;
-
- case eEnumerateDirectoryResultExit: // Exit from the current directory
- // at the current level.
- // Exit from this directory level and tell parent to
- // keep enumerating.
- if (buf)
- free(buf);
- return eEnumerateDirectoryResultNext;
-
- case eEnumerateDirectoryResultQuit: // Stop directory enumerations at
- // any level
- if (buf)
- free(buf);
- return eEnumerateDirectoryResultQuit;
- }
- }
- if (buf) {
- free(buf);
- }
- }
-#endif
- // By default when exiting a directory, we tell the parent enumeration
- // to continue enumerating.
- return eEnumerateDirectoryResultNext;
-}
-
-FileSpec::EnumerateDirectoryResult
-FileSpec::EnumerateDirectory(llvm::StringRef dir_path, bool find_directories,
- bool find_files, bool find_other,
- EnumerateDirectoryCallbackType callback,
- void *callback_baton) {
- return ForEachItemInDirectory(
- dir_path,
- [&find_directories, &find_files, &find_other, &callback,
- &callback_baton](FileType file_type, const FileSpec &file_spec) {
- switch (file_type) {
- case FileType::eFileTypeDirectory:
- if (find_directories)
- return callback(callback_baton, file_type, file_spec);
- break;
- case FileType::eFileTypeRegular:
- if (find_files)
- return callback(callback_baton, file_type, file_spec);
- break;
- default:
- if (find_other)
- return callback(callback_baton, file_type, file_spec);
- break;
- }
- return eEnumerateDirectoryResultNext;
- });
}
FileSpec
@@ -1248,6 +785,22 @@ ConstString FileSpec::GetLastPathComponent() const {
return ConstString();
}
+static std::string
+join_path_components(FileSpec::PathSyntax syntax,
+ const std::vector<llvm::StringRef> components) {
+ std::string result;
+ for (size_t i = 0; i < components.size(); ++i) {
+ if (components[i].empty())
+ continue;
+ result += components[i];
+ if (i != components.size() - 1 &&
+ !IsPathSeparator(components[i].back(), syntax))
+ result += GetPreferredPathSeparator(syntax);
+ }
+
+ return result;
+}
+
void FileSpec::PrependPathComponent(llvm::StringRef component) {
if (component.empty())
return;
@@ -1258,17 +811,10 @@ void FileSpec::PrependPathComponent(llvm::StringRef component) {
return;
}
- char sep = GetPreferredPathSeparator(m_syntax);
- std::string result;
- if (m_filename.IsEmpty())
- result = llvm::join_items(sep, component, m_directory.GetStringRef());
- else if (m_directory.IsEmpty())
- result = llvm::join_items(sep, component, m_filename.GetStringRef());
- else
- result = llvm::join_items(sep, component, m_directory.GetStringRef(),
- m_filename.GetStringRef());
-
- SetFile(result, resolve);
+ std::string result =
+ join_path_components(m_syntax, {component, m_directory.GetStringRef(),
+ m_filename.GetStringRef()});
+ SetFile(result, resolve, m_syntax);
}
void FileSpec::PrependPathComponent(const FileSpec &new_path) {
@@ -1279,23 +825,12 @@ void FileSpec::AppendPathComponent(llvm::StringRef component) {
if (component.empty())
return;
- std::string result;
- if (!m_directory.IsEmpty()) {
- result += m_directory.GetStringRef();
- if (!IsPathSeparator(m_directory.GetStringRef().back(), m_syntax))
- result += GetPreferredPathSeparator(m_syntax);
- }
-
- if (!m_filename.IsEmpty()) {
- result += m_filename.GetStringRef();
- if (!IsPathSeparator(m_filename.GetStringRef().back(), m_syntax))
- result += GetPreferredPathSeparator(m_syntax);
- }
-
component = component.drop_while(
[this](char c) { return IsPathSeparator(c, m_syntax); });
- result += component;
+ std::string result =
+ join_path_components(m_syntax, {m_directory.GetStringRef(),
+ m_filename.GetStringRef(), component});
SetFile(result, false, m_syntax);
}
diff --git a/source/Core/History.cpp b/source/Utility/History.cpp
index 0466a83da519..10344b67c635 100644
--- a/source/Core/History.cpp
+++ b/source/Utility/History.cpp
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/History.h"
+#include "lldb/Utility/History.h"
// C Includes
#include <inttypes.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp
index 5b809c5d2e1d..d20d9e46fefd 100644
--- a/source/Utility/JSON.cpp
+++ b/source/Utility/JSON.cpp
@@ -9,10 +9,15 @@
#include "lldb/Utility/JSON.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
+
+#include <inttypes.h> // for PRIu64, PRId64
#include <limits.h>
+#include <stddef.h> // for size_t
+#include <utility> // for pair
using namespace lldb_private;
@@ -512,23 +517,20 @@ JSONValue::SP JSONParser::ParseJSONValue() {
case JSONParser::Token::Integer: {
if (value.front() == '-') {
- bool success = false;
- int64_t sval = StringConvert::ToSInt64(value.c_str(), 0, 0, &success);
- if (success)
+ int64_t sval = 0;
+ if (!llvm::StringRef(value).getAsInteger(0, sval))
return JSONValue::SP(new JSONNumber(sval));
} else {
- bool success = false;
- uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success);
- if (success)
+ uint64_t uval = 0;
+ if (!llvm::StringRef(value).getAsInteger(0, uval))
return JSONValue::SP(new JSONNumber(uval));
}
} break;
case JSONParser::Token::Float: {
- bool success = false;
- double val = StringConvert::ToDouble(value.c_str(), 0.0, &success);
- if (success)
- return JSONValue::SP(new JSONNumber(val));
+ double D;
+ if (!llvm::StringRef(value).getAsDouble(D))
+ return JSONValue::SP(new JSONNumber(D));
} break;
case JSONParser::Token::String:
diff --git a/source/Utility/LLDBAssert.cpp b/source/Utility/LLDBAssert.cpp
index 6f35dcd32f4a..48c1b69e8947 100644
--- a/source/Utility/LLDBAssert.cpp
+++ b/source/Utility/LLDBAssert.cpp
@@ -1,5 +1,4 @@
-//===--------------------- LLDBAssert.cpp --------------------------*- C++
-//-*-===//
+//===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
diff --git a/source/Utility/Log.cpp b/source/Utility/Log.cpp
new file mode 100644
index 000000000000..a80b106838bc
--- /dev/null
+++ b/source/Utility/Log.cpp
@@ -0,0 +1,323 @@
+//===-- Log.cpp -------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/VASPrintf.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Twine.h" // for operator+, Twine
+#include "llvm/ADT/iterator.h" // for iterator_facade_base
+
+#include "llvm/Support/Chrono.h"
+#include "llvm/Support/ManagedStatic.h" // for ManagedStatic
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/Threading.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <chrono> // for duration, system_clock, syst...
+#include <cstdarg>
+#include <mutex>
+#include <utility> // for pair
+
+#include <assert.h> // for assert
+#if defined(LLVM_ON_WIN32)
+#include <process.h> // for getpid
+#else
+#include <unistd.h>
+#endif
+
+using namespace lldb_private;
+
+llvm::ManagedStatic<Log::ChannelMap> Log::g_channel_map;
+
+void Log::ListCategories(llvm::raw_ostream &stream, const ChannelMap::value_type &entry) {
+ stream << llvm::formatv("Logging categories for '{0}':\n", entry.first());
+ stream << " all - all available logging categories\n";
+ stream << " default - default set of logging categories\n";
+ for (const auto &category : entry.second.m_channel.categories)
+ stream << llvm::formatv(" {0} - {1}\n", category.name,
+ category.description);
+}
+
+uint32_t Log::GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry,
+ llvm::ArrayRef<const char *> categories) {
+ bool list_categories = false;
+ uint32_t flags = 0;
+ for (const char *category : categories) {
+ if (llvm::StringRef("all").equals_lower(category)) {
+ flags |= UINT32_MAX;
+ continue;
+ }
+ if (llvm::StringRef("default").equals_lower(category)) {
+ flags |= entry.second.m_channel.default_flags;
+ continue;
+ }
+ auto cat = llvm::find_if(
+ entry.second.m_channel.categories,
+ [&](const Log::Category &c) { return c.name.equals_lower(category); });
+ if (cat != entry.second.m_channel.categories.end()) {
+ flags |= cat->flag;
+ continue;
+ }
+ stream << llvm::formatv("error: unrecognized log category '{0}'\n",
+ category);
+ list_categories = true;
+ }
+ if (list_categories)
+ ListCategories(stream, entry);
+ return flags;
+}
+
+void Log::Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp,
+ uint32_t options, uint32_t flags) {
+ llvm::sys::ScopedWriter lock(m_mutex);
+
+ uint32_t mask = m_mask.fetch_or(flags, std::memory_order_relaxed);
+ if (mask | flags) {
+ m_options.store(options, std::memory_order_relaxed);
+ m_stream_sp = stream_sp;
+ m_channel.log_ptr.store(this, std::memory_order_relaxed);
+ }
+}
+
+void Log::Disable(uint32_t flags) {
+ llvm::sys::ScopedWriter lock(m_mutex);
+
+ uint32_t mask = m_mask.fetch_and(~flags, std::memory_order_relaxed);
+ if (!(mask & ~flags)) {
+ m_stream_sp.reset();
+ m_channel.log_ptr.store(nullptr, std::memory_order_relaxed);
+ }
+}
+
+const Flags Log::GetOptions() const {
+ return m_options.load(std::memory_order_relaxed);
+}
+
+const Flags Log::GetMask() const {
+ return m_mask.load(std::memory_order_relaxed);
+}
+
+void Log::PutCString(const char *cstr) { Printf("%s", cstr); }
+void Log::PutString(llvm::StringRef str) { PutCString(str.str().c_str()); }
+
+//----------------------------------------------------------------------
+// Simple variable argument logging with flags.
+//----------------------------------------------------------------------
+void Log::Printf(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ VAPrintf(format, args);
+ va_end(args);
+}
+
+//----------------------------------------------------------------------
+// All logging eventually boils down to this function call. If we have
+// a callback registered, then we call the logging callback. If we have
+// a valid file handle, we also log to the file.
+//----------------------------------------------------------------------
+void Log::VAPrintf(const char *format, va_list args) {
+ llvm::SmallString<64> FinalMessage;
+ llvm::raw_svector_ostream Stream(FinalMessage);
+ WriteHeader(Stream, "", "");
+
+ llvm::SmallString<64> Content;
+ lldb_private::VASprintf(Content, format, args);
+
+ Stream << Content << "\n";
+
+ WriteMessage(FinalMessage.str());
+}
+
+//----------------------------------------------------------------------
+// Printing of errors that are not fatal.
+//----------------------------------------------------------------------
+void Log::Error(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ VAError(format, args);
+ va_end(args);
+}
+
+void Log::VAError(const char *format, va_list args) {
+ llvm::SmallString<64> Content;
+ VASprintf(Content, format, args);
+
+ Printf("error: %s", Content.c_str());
+}
+
+//----------------------------------------------------------------------
+// Printing of warnings that are not fatal only if verbose mode is
+// enabled.
+//----------------------------------------------------------------------
+void Log::Verbose(const char *format, ...) {
+ if (!GetVerbose())
+ return;
+
+ va_list args;
+ va_start(args, format);
+ VAPrintf(format, args);
+ va_end(args);
+}
+
+//----------------------------------------------------------------------
+// Printing of warnings that are not fatal.
+//----------------------------------------------------------------------
+void Log::Warning(const char *format, ...) {
+ llvm::SmallString<64> Content;
+ va_list args;
+ va_start(args, format);
+ VASprintf(Content, format, args);
+ va_end(args);
+
+ Printf("warning: %s", Content.c_str());
+}
+
+void Log::Register(llvm::StringRef name, Channel &channel) {
+ auto iter = g_channel_map->try_emplace(name, channel);
+ assert(iter.second == true);
+ (void)iter;
+}
+
+void Log::Unregister(llvm::StringRef name) {
+ auto iter = g_channel_map->find(name);
+ assert(iter != g_channel_map->end());
+ iter->second.Disable(UINT32_MAX);
+ g_channel_map->erase(iter);
+}
+
+bool Log::EnableLogChannel(
+ const std::shared_ptr<llvm::raw_ostream> &log_stream_sp,
+ uint32_t log_options, llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories, llvm::raw_ostream &error_stream) {
+ auto iter = g_channel_map->find(channel);
+ if (iter == g_channel_map->end()) {
+ error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel);
+ return false;
+ }
+ uint32_t flags = categories.empty()
+ ? iter->second.m_channel.default_flags
+ : GetFlags(error_stream, *iter, categories);
+ iter->second.Enable(log_stream_sp, log_options, flags);
+ return true;
+}
+
+bool Log::DisableLogChannel(llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ llvm::raw_ostream &error_stream) {
+ auto iter = g_channel_map->find(channel);
+ if (iter == g_channel_map->end()) {
+ error_stream << llvm::formatv("Invalid log channel '{0}'.\n", channel);
+ return false;
+ }
+ uint32_t flags = categories.empty()
+ ? UINT32_MAX
+ : GetFlags(error_stream, *iter, categories);
+ iter->second.Disable(flags);
+ return true;
+}
+
+bool Log::ListChannelCategories(llvm::StringRef channel,
+ llvm::raw_ostream &stream) {
+ auto ch = g_channel_map->find(channel);
+ if (ch == g_channel_map->end()) {
+ stream << llvm::formatv("Invalid log channel '{0}'.\n", channel);
+ return false;
+ }
+ ListCategories(stream, *ch);
+ return true;
+}
+
+void Log::DisableAllLogChannels() {
+ for (auto &entry : *g_channel_map)
+ entry.second.Disable(UINT32_MAX);
+}
+
+void Log::ListAllLogChannels(llvm::raw_ostream &stream) {
+ if (g_channel_map->empty()) {
+ stream << "No logging channels are currently registered.\n";
+ return;
+ }
+
+ for (const auto &channel : *g_channel_map)
+ ListCategories(stream, channel);
+}
+
+bool Log::GetVerbose() const {
+ return m_options.load(std::memory_order_relaxed) & LLDB_LOG_OPTION_VERBOSE;
+}
+
+void Log::WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
+ llvm::StringRef function) {
+ Flags options = GetOptions();
+ static uint32_t g_sequence_id = 0;
+ // Add a sequence ID if requested
+ if (options.Test(LLDB_LOG_OPTION_PREPEND_SEQUENCE))
+ OS << ++g_sequence_id << " ";
+
+ // Timestamp if requested
+ if (options.Test(LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) {
+ auto now = std::chrono::duration<double>(
+ std::chrono::system_clock::now().time_since_epoch());
+ OS << llvm::formatv("{0:f9} ", now.count());
+ }
+
+ // Add the process and thread if requested
+ if (options.Test(LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
+ OS << llvm::formatv("[{0,0+4}/{1,0+4}] ", getpid(),
+ llvm::get_threadid());
+
+ // Add the thread name if requested
+ if (options.Test(LLDB_LOG_OPTION_PREPEND_THREAD_NAME)) {
+ llvm::SmallString<32> thread_name;
+ llvm::get_thread_name(thread_name);
+ if (!thread_name.empty())
+ OS << thread_name;
+ }
+
+ if (options.Test(LLDB_LOG_OPTION_BACKTRACE))
+ llvm::sys::PrintStackTrace(OS);
+
+ if (options.Test(LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION) &&
+ (!file.empty() || !function.empty())) {
+ file = llvm::sys::path::filename(file).take_front(40);
+ function = function.take_front(40);
+ OS << llvm::formatv("{0,-60:60} ", (file + ":" + function).str());
+ }
+}
+
+void Log::WriteMessage(const std::string &message) {
+ // Make a copy of our stream shared pointer in case someone disables our
+ // log while we are logging and releases the stream
+ auto stream_sp = GetStream();
+ if (!stream_sp)
+ return;
+
+ Flags options = GetOptions();
+ if (options.Test(LLDB_LOG_OPTION_THREADSAFE)) {
+ static std::recursive_mutex g_LogThreadedMutex;
+ std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
+ *stream_sp << message;
+ stream_sp->flush();
+ } else {
+ *stream_sp << message;
+ stream_sp->flush();
+ }
+}
+
+void Log::Format(llvm::StringRef file, llvm::StringRef function,
+ const llvm::formatv_object_base &payload) {
+ std::string message_string;
+ llvm::raw_string_ostream message(message_string);
+ WriteHeader(message, file, function);
+ message << payload << "\n";
+ WriteMessage(message.str());
+}
diff --git a/source/Utility/Logging.cpp b/source/Utility/Logging.cpp
new file mode 100644
index 000000000000..0bd6d6692e37
--- /dev/null
+++ b/source/Utility/Logging.cpp
@@ -0,0 +1,74 @@
+//===-- Logging.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/Logging.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/ADT/ArrayRef.h" // for ArrayRef
+
+#include <stdarg.h> // for va_end, va_list, va_start
+
+using namespace lldb_private;
+
+static constexpr Log::Category g_categories[] = {
+ {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API},
+ {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS},
+ {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS},
+ {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION},
+ {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION},
+ {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE},
+ {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER},
+ {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS},
+ {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS},
+ {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS},
+ {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST},
+ {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER},
+ {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE},
+ {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP},
+ {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES},
+ {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT},
+ {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS},
+ {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM},
+ {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS},
+ {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT},
+ {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE},
+ {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP},
+ {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS},
+ {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME},
+ {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET},
+ {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY},
+ {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD},
+ {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES},
+ {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND},
+ {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS},
+};
+
+static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT);
+
+void lldb_private::InitializeLog() {
+ Log::Register("lldb", g_log_channel);
+}
+
+Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) {
+ return g_log_channel.GetLogIfAll(mask);
+}
+
+Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) {
+ return g_log_channel.GetLogIfAny(mask);
+}
+
+
+void lldb_private::LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...) {
+ if (Log *log = GetLogIfAnyCategoriesSet(mask)) {
+ va_list args;
+ va_start(args, format);
+ log->VAPrintf(format, args);
+ va_end(args);
+ }
+}
diff --git a/source/Utility/NameMatches.cpp b/source/Utility/NameMatches.cpp
index 7b733d24eba2..a76df3f929e8 100644
--- a/source/Utility/NameMatches.cpp
+++ b/source/Utility/NameMatches.cpp
@@ -7,38 +7,29 @@
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/NameMatches.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/StringRef.h"
using namespace lldb_private;
-bool lldb_private::NameMatches(llvm::StringRef name, NameMatchType match_type,
+bool lldb_private::NameMatches(llvm::StringRef name, NameMatch match_type,
llvm::StringRef match) {
- if (match_type == eNameMatchIgnore)
- return true;
-
- if (name == match)
- return true;
-
- if (name.empty() || match.empty())
- return false;
-
switch (match_type) {
- case eNameMatchIgnore: // This case cannot occur: tested before
+ case NameMatch::Ignore:
return true;
- case eNameMatchEquals:
+ case NameMatch::Equals:
return name == match;
- case eNameMatchContains:
+ case NameMatch::Contains:
return name.contains(match);
- case eNameMatchStartsWith:
+ case NameMatch::StartsWith:
return name.startswith(match);
- case eNameMatchEndsWith:
+ case NameMatch::EndsWith:
return name.endswith(match);
- case eNameMatchRegularExpression: {
+ case NameMatch::RegularExpression: {
RegularExpression regex(match);
return regex.Execute(name);
- } break;
+ }
}
return false;
}
diff --git a/source/Utility/Range.cpp b/source/Utility/Range.cpp
index 95f00e5c7599..9d1d28ea484b 100644
--- a/source/Utility/Range.cpp
+++ b/source/Utility/Range.cpp
@@ -1,5 +1,4 @@
-//===--------------------- Range.cpp -----------------------------*- C++
-//-*-===//
+//===--------------------- Range.cpp -----------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,6 +9,9 @@
#include "lldb/Utility/Range.h"
+#include <algorithm>
+#include <utility>
+
using namespace lldb_utility;
Range::Range(const Range &rng) : m_low(rng.m_low), m_high(rng.m_high) {
diff --git a/source/Core/RegularExpression.cpp b/source/Utility/RegularExpression.cpp
index 54e0231556db..d58b315d0d1d 100644
--- a/source/Core/RegularExpression.cpp
+++ b/source/Utility/RegularExpression.cpp
@@ -7,17 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Utility/RegularExpression.h"
-// C Includes
-// C++ Includes
-#include <cstring>
-
-// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
-// Project includes
-#include "lldb/Core/Error.h"
+#include <string>
//----------------------------------------------------------------------
// Enable enhanced mode if it is available. This allows for things like
@@ -81,14 +75,10 @@ RegularExpression::~RegularExpression() { Free(); }
bool RegularExpression::Compile(llvm::StringRef str) {
Free();
- if (!str.empty()) {
- m_re = str;
- m_comp_err = ::regcomp(&m_preg, m_re.c_str(), DEFAULT_COMPILE_FLAGS);
- } else {
- // No valid regular expression
- m_comp_err = 1;
- }
-
+ // regcomp() on darwin does not recognize "" as a valid regular expression, so
+ // we substitute it with an equivalent non-empty one.
+ m_re = str.empty() ? "()" : str;
+ m_comp_err = ::regcomp(&m_preg, m_re.c_str(), DEFAULT_COMPILE_FLAGS);
return m_comp_err == 0;
}
diff --git a/source/Utility/SelectHelper.cpp b/source/Utility/SelectHelper.cpp
index 805bcf2c7950..7b0557ea192c 100644
--- a/source/Utility/SelectHelper.cpp
+++ b/source/Utility/SelectHelper.cpp
@@ -14,7 +14,18 @@
#define _DARWIN_UNLIMITED_SELECT
#endif
-// C Includes
+#include "lldb/Utility/SelectHelper.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-enumerations.h" // for ErrorType::eErrorTypePOSIX
+#include "lldb/lldb-types.h" // for socket_t
+
+#include "llvm/ADT/DenseMap.h" // for DenseMapPair, DenseMap, Dense...
+#include "llvm/ADT/Optional.h" // for Optional
+
+#include <algorithm>
+#include <chrono> // for microseconds, seconds, steady...
+
#include <errno.h>
#if defined(_WIN32)
// Define NOMINMAX to avoid macros that conflict with std::min and std::max
@@ -24,16 +35,6 @@
#include <sys/select.h>
#endif
-// C++ Includes
-#include <algorithm>
-
-// Other libraries and framework includes
-#include "llvm/ADT/SmallVector.h"
-
-// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/SelectHelper.h"
SelectHelper::SelectHelper()
: m_fd_map(), m_end_time() // Infinite timeout unless
diff --git a/source/Core/Stream.cpp b/source/Utility/Stream.cpp
index 2f9c650ee5b0..04edc25b2b09 100644
--- a/source/Core/Stream.cpp
+++ b/source/Utility/Stream.cpp
@@ -7,15 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Stream.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/PosixApi.h"
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "lldb/Utility/Stream.h"
+
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/VASPrintf.h"
+#include "llvm/ADT/SmallString.h" // for SmallString
+
+#include <string>
#include <inttypes.h>
+#include <stddef.h>
using namespace lldb;
using namespace lldb_private;
@@ -162,36 +163,14 @@ size_t Stream::Printf(const char *format, ...) {
// Print some formatted output to the stream.
//------------------------------------------------------------------
size_t Stream::PrintfVarArg(const char *format, va_list args) {
- char str[1024];
- va_list args_copy;
+ llvm::SmallString<1024> buf;
+ VASprintf(buf, format, args);
- va_copy(args_copy, args);
-
- size_t bytes_written = 0;
- // Try and format our string into a fixed buffer first and see if it fits
- size_t length = ::vsnprintf(str, sizeof(str), format, args);
- if (length < sizeof(str)) {
- // Include the NULL termination byte for binary output
- if (m_flags.Test(eBinary))
- length += 1;
- // The formatted string fit into our stack based buffer, so we can just
- // append that to our packet
- bytes_written = Write(str, length);
- } else {
- // Our stack buffer wasn't big enough to contain the entire formatted
- // string, so lets let vasprintf create the string for us!
- char *str_ptr = NULL;
- length = ::vasprintf(&str_ptr, format, args_copy);
- if (str_ptr) {
- // Include the NULL termination byte for binary output
- if (m_flags.Test(eBinary))
- length += 1;
- bytes_written = Write(str_ptr, length);
- ::free(str_ptr);
- }
- }
- va_end(args_copy);
- return bytes_written;
+ // Include the NULL termination byte for binary output
+ size_t length = buf.size();
+ if (m_flags.Test(eBinary))
+ ++length;
+ return Write(buf.c_str(), length);
}
//------------------------------------------------------------------
@@ -208,7 +187,8 @@ size_t Stream::Indent(const char *s) {
}
size_t Stream::Indent(llvm::StringRef str) {
- return Printf("%*.*s%s", m_indent_level, m_indent_level, "", str.str().c_str());
+ return Printf("%*.*s%s", m_indent_level, m_indent_level, "",
+ str.str().c_str());
}
//------------------------------------------------------------------
@@ -340,16 +320,6 @@ uint32_t Stream::GetAddressByteSize() const { return m_addr_size; }
void Stream::SetAddressByteSize(uint32_t addr_size) { m_addr_size = addr_size; }
//------------------------------------------------------------------
-// Returns true if the verbose flag bit is set in this stream.
-//------------------------------------------------------------------
-bool Stream::GetVerbose() const { return m_flags.Test(eVerbose); }
-
-//------------------------------------------------------------------
-// Returns true if the debug flag bit is set in this stream.
-//------------------------------------------------------------------
-bool Stream::GetDebug() const { return m_flags.Test(eDebug); }
-
-//------------------------------------------------------------------
// The flags get accessor
//------------------------------------------------------------------
Flags &Stream::GetFlags() { return m_flags; }
@@ -367,40 +337,24 @@ lldb::ByteOrder Stream::GetByteOrder() const { return m_byte_order; }
size_t Stream::PrintfAsRawHex8(const char *format, ...) {
va_list args;
- va_list args_copy;
va_start(args, format);
- va_copy(args_copy, args); // Copy this so we
- char str[1024];
- size_t bytes_written = 0;
- // Try and format our string into a fixed buffer first and see if it fits
- size_t length = ::vsnprintf(str, sizeof(str), format, args);
- if (length < sizeof(str)) {
- // The formatted string fit into our stack based buffer, so we can just
- // append that to our packet
- for (size_t i = 0; i < length; ++i)
- bytes_written += _PutHex8(str[i], false);
- } else {
- // Our stack buffer wasn't big enough to contain the entire formatted
- // string, so lets let vasprintf create the string for us!
- char *str_ptr = NULL;
- length = ::vasprintf(&str_ptr, format, args_copy);
- if (str_ptr) {
- for (size_t i = 0; i < length; ++i)
- bytes_written += _PutHex8(str_ptr[i], false);
- ::free(str_ptr);
- }
- }
+ llvm::SmallString<1024> buf;
+ VASprintf(buf, format, args);
+
+ size_t length = 0;
+ for (char C : buf)
+ length += _PutHex8(C, false);
+
va_end(args);
- va_end(args_copy);
- return bytes_written;
+ return length;
}
size_t Stream::PutNHex8(size_t n, uint8_t uvalue) {
size_t bytes_written = 0;
for (size_t i = 0; i < n; ++i)
- bytes_written += _PutHex8(uvalue, m_flags.Test(eAddPrefix));
+ bytes_written += _PutHex8(uvalue, false);
return bytes_written;
}
@@ -423,23 +377,19 @@ size_t Stream::_PutHex8(uint8_t uvalue, bool add_prefix) {
return bytes_written;
}
-size_t Stream::PutHex8(uint8_t uvalue) {
- return _PutHex8(uvalue, m_flags.Test(eAddPrefix));
-}
+size_t Stream::PutHex8(uint8_t uvalue) { return _PutHex8(uvalue, false); }
size_t Stream::PutHex16(uint16_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.Test(eAddPrefix);
size_t bytes_written = 0;
if (byte_order == eByteOrderLittle) {
- for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
} else {
- for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue);
- --byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
}
return bytes_written;
}
@@ -448,15 +398,13 @@ size_t Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.Test(eAddPrefix);
size_t bytes_written = 0;
if (byte_order == eByteOrderLittle) {
- for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
} else {
- for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue);
- --byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
}
return bytes_written;
}
@@ -465,15 +413,13 @@ size_t Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
- bool add_prefix = m_flags.Test(eAddPrefix);
size_t bytes_written = 0;
if (byte_order == eByteOrderLittle) {
- for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
} else {
- for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue);
- --byte, add_prefix = false)
- bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), add_prefix);
+ for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
+ bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
}
return bytes_written;
}
diff --git a/source/Utility/StreamCallback.cpp b/source/Utility/StreamCallback.cpp
new file mode 100644
index 000000000000..97528439005a
--- /dev/null
+++ b/source/Utility/StreamCallback.cpp
@@ -0,0 +1,23 @@
+//===-- StreamCallback.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/StreamCallback.h"
+
+#include <string>
+
+using namespace lldb_private;
+
+StreamCallback::StreamCallback(lldb::LogOutputCallback callback, void *baton)
+ : llvm::raw_ostream(true), m_callback(callback), m_baton(baton) {}
+
+void StreamCallback::write_impl(const char *Ptr, size_t Size) {
+ m_callback(std::string(Ptr, Size).c_str(), m_baton);
+}
+
+uint64_t StreamCallback::current_pos() const { return 0; }
diff --git a/source/Core/StreamGDBRemote.cpp b/source/Utility/StreamGDBRemote.cpp
index a371d1316c7c..2620e3786d29 100644
--- a/source/Core/StreamGDBRemote.cpp
+++ b/source/Utility/StreamGDBRemote.cpp
@@ -7,7 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/StreamGDBRemote.h"
+#include "lldb/Utility/StreamGDBRemote.h"
+
+#include "lldb/Utility/Flags.h" // for Flags
+#include "lldb/Utility/Stream.h" // for Stream::::eBinary
+
#include <stdio.h>
using namespace lldb;
diff --git a/source/Core/StreamString.cpp b/source/Utility/StreamString.cpp
index 461648815f18..75f58de28b97 100644
--- a/source/Core/StreamString.cpp
+++ b/source/Utility/StreamString.cpp
@@ -7,8 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/StreamString.h"
-#include <stdio.h>
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp
index d8ba39710d1b..a94f6bcd0087 100644
--- a/source/Utility/StringExtractor.cpp
+++ b/source/Utility/StringExtractor.cpp
@@ -9,13 +9,11 @@
#include "lldb/Utility/StringExtractor.h"
-// C Includes
-#include <stdlib.h>
-
-// C++ Includes
#include <tuple>
-// Other libraries and framework includes
-// Project includes
+
+#include <ctype.h> // for isxdigit, isspace
+#include <stdlib.h>
+#include <string.h> // for memset
static inline int xdigit_to_sint(char ch) {
if (ch >= 'a' && ch <= 'f')
diff --git a/source/Utility/StringExtractorGDBRemote.cpp b/source/Utility/StringExtractorGDBRemote.cpp
index dd13be9a763e..08226f4c8f90 100644
--- a/source/Utility/StringExtractorGDBRemote.cpp
+++ b/source/Utility/StringExtractorGDBRemote.cpp
@@ -7,14 +7,11 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-#include <string.h>
-
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "Utility/StringExtractorGDBRemote.h"
+#include <ctype.h> // for isxdigit
+#include <string.h>
+
StringExtractorGDBRemote::ResponseType
StringExtractorGDBRemote::GetResponseType() const {
if (m_packet.empty())
@@ -91,6 +88,10 @@ StringExtractorGDBRemote::GetServerPacketType() const {
return eServerPacketType_QEnvironmentHexEncoded;
break;
+ case 'P':
+ if (PACKET_STARTS_WITH("QPassSignals:"))
+ return eServerPacketType_QPassSignals;
+
case 'S':
if (PACKET_MATCHES("QStartNoAckMode"))
return eServerPacketType_QStartNoAckMode;
diff --git a/source/Utility/StringExtractorGDBRemote.h b/source/Utility/StringExtractorGDBRemote.h
index ce12660f0d35..a5c0c8e803b6 100644
--- a/source/Utility/StringExtractorGDBRemote.h
+++ b/source/Utility/StringExtractorGDBRemote.h
@@ -10,12 +10,13 @@
#ifndef utility_StringExtractorGDBRemote_h_
#define utility_StringExtractorGDBRemote_h_
-// C Includes
-// C++ Includes
-#include <string>
-// Other libraries and framework includes
-// Project includes
#include "lldb/Utility/StringExtractor.h"
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <string>
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for uint8_t
class StringExtractorGDBRemote : public StringExtractor {
public:
@@ -96,6 +97,7 @@ public:
// debug server packages
eServerPacketType_QEnvironmentHexEncoded,
eServerPacketType_QListThreadsInStopReply,
+ eServerPacketType_QPassSignals,
eServerPacketType_QRestoreRegisterState,
eServerPacketType_QSaveRegisterState,
eServerPacketType_QSetLogging,
diff --git a/source/Utility/StringLexer.cpp b/source/Utility/StringLexer.cpp
index ec18f049476e..77484d6e43fb 100644
--- a/source/Utility/StringLexer.cpp
+++ b/source/Utility/StringLexer.cpp
@@ -1,5 +1,4 @@
-//===--------------------- StringLexer.cpp -----------------------*- C++
-//-*-===//
+//===--------------------- StringLexer.cpp -----------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
diff --git a/source/Core/StringList.cpp b/source/Utility/StringList.cpp
index d2c4ac6775aa..190cb9d682c9 100644
--- a/source/Core/StringList.cpp
+++ b/source/Utility/StringList.cpp
@@ -7,13 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/StringList.h"
+#include "lldb/Utility/StringList.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h" // for Stream
+#include "lldb/Utility/StreamString.h"
+#include "llvm/ADT/ArrayRef.h" // for ArrayRef, makeArrayRef
-#include <string>
+#include <algorithm> // for min
+#include <stdint.h> // for SIZE_MAX, uint32_t
+#include <string.h> // for size_t, strcspn, NULL
using namespace lldb_private;
@@ -65,10 +68,6 @@ void StringList::AppendList(StringList strings) {
m_strings.push_back(strings.GetStringAtIndex(i));
}
-bool StringList::ReadFileLines(FileSpec &input_file) {
- return input_file.ReadFileLines(m_strings);
-}
-
size_t StringList::GetSize() const { return m_strings.size(); }
size_t StringList::GetMaxStringLength() const {
@@ -223,9 +222,7 @@ StringList &StringList::operator<<(StringList strings) {
}
StringList &StringList::operator=(const std::vector<std::string> &rhs) {
- Clear();
- for (const auto &s : rhs)
- m_strings.push_back(s);
+ m_strings.assign(rhs.begin(), rhs.end());
return *this;
}
@@ -267,5 +264,5 @@ void StringList::LogDump(Log *log, const char *name) {
if (name)
strm.Printf("End %s.\n", name);
- log->Debug("%s", strm.GetData());
+ LLDB_LOGV(log, "{0}", strm.GetData());
}
diff --git a/source/Utility/TaskPool.cpp b/source/Utility/TaskPool.cpp
index f66f7bf9170d..244e64fdb5fb 100644
--- a/source/Utility/TaskPool.cpp
+++ b/source/Utility/TaskPool.cpp
@@ -9,6 +9,10 @@
#include "lldb/Utility/TaskPool.h"
+#include <cstdint> // for uint32_t
+#include <queue> // for queue
+#include <thread> // for thread
+
namespace {
class TaskPoolImpl {
public:
diff --git a/source/Utility/TildeExpressionResolver.cpp b/source/Utility/TildeExpressionResolver.cpp
new file mode 100644
index 000000000000..64a771118d6e
--- /dev/null
+++ b/source/Utility/TildeExpressionResolver.cpp
@@ -0,0 +1,95 @@
+//===--------------------- TildeExpressionResolver.cpp ----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/TildeExpressionResolver.h"
+
+#include <assert.h> // for assert
+#include <system_error> // for error_code
+
+#include "llvm/ADT/STLExtras.h" // for any_of
+#include "llvm/ADT/SmallVector.h" // for SmallVectorImpl
+#include "llvm/Config/llvm-config.h" // for LLVM_ON_WIN32
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h" // for fs
+
+#if !defined(LLVM_ON_WIN32)
+#include <pwd.h>
+#endif
+
+using namespace lldb_private;
+using namespace llvm;
+
+namespace fs = llvm::sys::fs;
+namespace path = llvm::sys::path;
+
+TildeExpressionResolver::~TildeExpressionResolver() {}
+
+bool StandardTildeExpressionResolver::ResolveExact(
+ StringRef Expr, SmallVectorImpl<char> &Output) {
+ // We expect the tilde expression to be ONLY the expression itself, and
+ // contain no separators.
+ assert(!llvm::any_of(Expr, [](char c) { return path::is_separator(c); }));
+ assert(Expr.empty() || Expr[0] == '~');
+
+ return !fs::real_path(Expr, Output, true);
+}
+
+bool StandardTildeExpressionResolver::ResolvePartial(StringRef Expr,
+ StringSet<> &Output) {
+ // We expect the tilde expression to be ONLY the expression itself, and
+ // contain no separators.
+ assert(!llvm::any_of(Expr, [](char c) { return path::is_separator(c); }));
+ assert(Expr.empty() || Expr[0] == '~');
+
+ Output.clear();
+#if defined(LLVM_ON_WIN32) || defined(__ANDROID__)
+ return false;
+#else
+ if (Expr.empty())
+ return false;
+
+ SmallString<32> Buffer("~");
+ setpwent();
+ struct passwd *user_entry;
+ Expr = Expr.drop_front();
+
+ while ((user_entry = getpwent()) != NULL) {
+ StringRef ThisName(user_entry->pw_name);
+ if (!ThisName.startswith(Expr))
+ continue;
+
+ Buffer.resize(1);
+ Buffer.append(ThisName);
+ Buffer.append(path::get_separator());
+ Output.insert(Buffer);
+ }
+
+ return true;
+#endif
+}
+
+bool TildeExpressionResolver::ResolveFullPath(
+ StringRef Expr, llvm::SmallVectorImpl<char> &Output) {
+ Output.clear();
+ if (!Expr.startswith("~")) {
+ Output.append(Expr.begin(), Expr.end());
+ return false;
+ }
+
+ namespace path = llvm::sys::path;
+ StringRef Left =
+ Expr.take_until([](char c) { return path::is_separator(c); });
+
+ if (!ResolveExact(Left, Output))
+ return false;
+
+ Output.append(Expr.begin() + Left.size(), Expr.end());
+ return true;
+}
diff --git a/source/Core/UUID.cpp b/source/Utility/UUID.cpp
index a08a748821de..d82f4d41215e 100644
--- a/source/Core/UUID.cpp
+++ b/source/Utility/UUID.cpp
@@ -7,19 +7,18 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/UUID.h"
+#include "lldb/Utility/UUID.h"
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringRef.h"
+
// C Includes
#include <ctype.h>
#include <stdio.h>
#include <string.h>
-// C++ Includes
-#include <string>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Stream.h"
-
namespace lldb_private {
UUID::UUID() : m_num_uuid_bytes(16) { ::memset(m_uuid, 0, sizeof(m_uuid)); }
diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp
index a1d6e4c3d859..bb57211af468 100644
--- a/source/Utility/UriParser.cpp
+++ b/source/Utility/UriParser.cpp
@@ -7,16 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "Utility/UriParser.h"
+#include "lldb/Utility/UriParser.h"
-// C Includes
+#include <string>
-// C++ Includes
-#include <cstring>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Host/StringConvert.h"
+#include <stdint.h>
+#include <tuple>
using namespace lldb_private;
diff --git a/source/Core/UserID.cpp b/source/Utility/UserID.cpp
index 5446154c1d27..e65b8fa87d81 100644
--- a/source/Core/UserID.cpp
+++ b/source/Utility/UserID.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/UserID.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/UserID.h"
+#include "lldb/Utility/Stream.h"
#include <inttypes.h>
diff --git a/source/Utility/VASprintf.cpp b/source/Utility/VASprintf.cpp
new file mode 100644
index 000000000000..e950fb75cfa0
--- /dev/null
+++ b/source/Utility/VASprintf.cpp
@@ -0,0 +1,56 @@
+//===-- VASPrintf.cpp -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/VASPrintf.h"
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h" // for SmallVectorImpl
+#include "llvm/ADT/StringRef.h" // for StringRef
+
+#include <assert.h> // for assert
+#include <stdarg.h> // for va_end, va_list, va_copy
+#include <stdio.h> // for vsnprintf, size_t
+
+bool lldb_private::VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt,
+ va_list args) {
+ llvm::SmallString<16> error("<Encoding error>");
+ bool result = true;
+
+ // Copy in case our first call to vsnprintf doesn't fit into our buffer
+ va_list copy_args;
+ va_copy(copy_args, args);
+
+ buf.resize(buf.capacity());
+ // Write up to `capacity` bytes, ignoring the current size.
+ int length = ::vsnprintf(buf.data(), buf.size(), fmt, args);
+ if (length < 0) {
+ buf = error;
+ result = false;
+ goto finish;
+ }
+
+ if (size_t(length) >= buf.size()) {
+ // The error formatted string didn't fit into our buffer, resize it
+ // to the exact needed size, and retry
+ buf.resize(length + 1);
+ length = ::vsnprintf(buf.data(), buf.size(), fmt, copy_args);
+ if (length < 0) {
+ buf = error;
+ result = false;
+ goto finish;
+ }
+ assert(size_t(length) < buf.size());
+ }
+ buf.resize(length);
+
+finish:
+ va_end(args);
+ va_end(copy_args);
+ return result;
+}
diff --git a/source/Core/VMRange.cpp b/source/Utility/VMRange.cpp
index 8d21f4b1273c..5eccd292a851 100644
--- a/source/Core/VMRange.cpp
+++ b/source/Utility/VMRange.cpp
@@ -7,11 +7,17 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private.h"
+#include "lldb/Utility/VMRange.h"
+
+#include "lldb/Utility/Stream.h"
+#include "lldb/lldb-types.h" // for addr_t
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/VMRange.h"
#include <algorithm>
+#include <iterator> // for distance
+#include <vector> // for const_iterator
+
+#include <stddef.h> // for size_t
+#include <stdint.h> // for UINT32_MAX, uint32_t
using namespace lldb;
using namespace lldb_private;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2ff5a9ca0512..0cb744760a58 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -43,11 +43,6 @@ set(LLDB_TEST_ARCH
${LLDB_DEFAULT_TEST_ARCH}
CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64")
-# Scrub LLDB_TEST_COMPILER out of the CMake caches
-# TODO: remove the replace lines and the FORCE parameter in a few days once the
-# change has made its way through bots to clean up their CMake caches.
-string(REPLACE "-C;${LLDB_TEST_COMPILER}" "" LLDB_TEST_USER_ARGS_New "${LLDB_TEST_USER_ARGS}")
-
if(LLDB_TEST_CLANG)
set(LLDB_TEST_COMPILER $<TARGET_FILE:clang>)
endif()
@@ -97,6 +92,15 @@ if(LLDB_BUILD_FRAMEWORK)
list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
endif()
+if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
+ list(APPEND LLDB_TEST_COMMON_ARGS
+ --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
+endif()
+
+if(CMAKE_HOST_APPLE)
+ list(APPEND LLDB_TEST_COMMON_ARGS --server $<TARGET_FILE:debugserver>)
+endif()
+
add_python_test_target(check-lldb-single
${LLDB_SOURCE_DIR}/test/dotest.py
"--no-multiprocess;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
@@ -112,3 +116,8 @@ add_python_test_target(check-lldb
"${LLDB_DOTEST_ARGS}"
"Testing LLDB (parallel execution, with a separate subprocess per test)"
)
+
+add_custom_target(lldb-test-depends DEPENDS ${LLDB_TEST_DEPENDS})
+# This will add LLDB's test dependencies to the depenednecies for check-all and
+# include them in the test-depends target.
+set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 86b9621a198e..7b26f5907a86 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -8,3 +8,4 @@ add_subdirectory(lldb-mi)
if (LLDB_CAN_USE_LLDB_SERVER)
add_subdirectory(lldb-server)
endif()
+add_subdirectory(intel-mpx)
diff --git a/tools/argdumper/CMakeLists.txt b/tools/argdumper/CMakeLists.txt
index 9bf956396b4f..42f1dd51582a 100644
--- a/tools/argdumper/CMakeLists.txt
+++ b/tools/argdumper/CMakeLists.txt
@@ -2,12 +2,9 @@ include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
argdumper.cpp
- )
-if (LLDB_LINKER_SUPPORTS_GROUPS)
- target_link_libraries(lldb-argdumper -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
-else()
- target_link_libraries(lldb-argdumper ${LLDB_USED_LIBS})
-endif()
-llvm_config(lldb-argdumper ${LLVM_LINK_COMPONENTS})
+ LINK_LIBS
+ lldbCore
+ lldbUtility
+ )
diff --git a/tools/argdumper/argdumper.cpp b/tools/argdumper/argdumper.cpp
index 01a070efb82c..67fd309fa14c 100644
--- a/tools/argdumper/argdumper.cpp
+++ b/tools/argdumper/argdumper.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/StreamString.h"
#include "lldb/Utility/JSON.h"
+#include "lldb/Utility/StreamString.h"
#include <iostream>
diff --git a/tools/debugserver/debugserver.xcodeproj/project.pbxproj b/tools/debugserver/debugserver.xcodeproj/project.pbxproj
index a4c3de58113e..e0d1b68db702 100644
--- a/tools/debugserver/debugserver.xcodeproj/project.pbxproj
+++ b/tools/debugserver/debugserver.xcodeproj/project.pbxproj
@@ -94,12 +94,12 @@
456F67641AD46CE9002850C2 /* CFBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2695DD910D3EBFF6007E4CA2 /* CFBundle.cpp */; };
456F67651AD46CE9002850C2 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF67ABFF0D34604D0022D128 /* PseudoTerminal.cpp */; };
456F67671AD46CE9002850C2 /* DNBArch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D5D571293835600ED4C01 /* DNBArch.cpp */; };
- 456F67681AD46CE9002850C2 /* HasAVX.s in Sources */ = {isa = PBXBuildFile; fileRef = 4971AE7113D10F4F00649E37 /* HasAVX.s */; };
456F67691AD46CE9002850C2 /* DNBArchImplARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266B5ECF1460A68200E43F0A /* DNBArchImplARM64.cpp */; };
456F676B1AD46CE9002850C2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26ACA3340D3E956300A2120B /* CoreFoundation.framework */; settings = {ATTRIBUTES = (Required, ); }; };
- 4971AE7213D10F4F00649E37 /* HasAVX.s in Sources */ = {isa = PBXBuildFile; fileRef = 4971AE7113D10F4F00649E37 /* HasAVX.s */; };
+ 49D404621E39260F00570CDC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49D404611E39260F00570CDC /* Foundation.framework */; };
AF48558C1D75126800D19C07 /* StdStringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF48558B1D75126800D19C07 /* StdStringExtractor.cpp */; };
AF48558D1D75127500D19C07 /* StdStringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF48558B1D75126800D19C07 /* StdStringExtractor.cpp */; };
+ AFA3FCA11E39984900218D5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49D404611E39260F00570CDC /* Foundation.framework */; };
AFEC3364194A8B0B00FF05C6 /* Genealogy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFEC3363194A8B0B00FF05C6 /* Genealogy.cpp */; };
/* End PBXBuildFile section */
@@ -208,8 +208,7 @@
26CF99A31142EB7400011AAB /* DNBArchImplX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNBArchImplX86_64.h; sourceTree = "<group>"; };
26E6B9DA0D1329010037ECDD /* RNBDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNBDefs.h; sourceTree = "<group>"; };
456F67721AD46CE9002850C2 /* debugserver-nonui */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "debugserver-nonui"; sourceTree = BUILT_PRODUCTS_DIR; };
- 4971AE7013D10F4F00649E37 /* HasAVX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HasAVX.h; sourceTree = "<group>"; };
- 4971AE7113D10F4F00649E37 /* HasAVX.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = HasAVX.s; sourceTree = "<group>"; };
+ 49D404611E39260F00570CDC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
49F530111331519C008956F6 /* MachRegisterStatesI386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachRegisterStatesI386.h; sourceTree = "<group>"; };
49F5301213316D7F008956F6 /* MachRegisterStatesX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachRegisterStatesX86_64.h; sourceTree = "<group>"; };
9457ECF61419864100DFE7D8 /* stack_logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stack_logging.h; sourceTree = "<group>"; };
@@ -232,6 +231,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 49D404621E39260F00570CDC /* Foundation.framework in Frameworks */,
26CE05CF115C36F70022F371 /* CoreFoundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -241,6 +241,7 @@
buildActionMask = 2147483647;
files = (
456F676B1AD46CE9002850C2 /* CoreFoundation.framework in Frameworks */,
+ AFA3FCA11E39984900218D5E /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -253,6 +254,7 @@
26ACA3330D3E94F200A2120B /* Framework */,
26C637D50C71334A0024798E /* source */,
1AB674ADFE9D54B511CA2CBB /* Products */,
+ 49D404601E39260F00570CDC /* Frameworks */,
);
name = dbgnub;
sourceTree = "<group>";
@@ -407,8 +409,6 @@
26C637E90C71334A0024798E /* i386 */,
26C637FA0C71334A0024798E /* ppc */,
26CF99A11142EB7400011AAB /* x86_64 */,
- 4971AE7013D10F4F00649E37 /* HasAVX.h */,
- 4971AE7113D10F4F00649E37 /* HasAVX.s */,
26C637E80C71334A0024798E /* dbgnub-mig.defs */,
AFEC3363194A8B0B00FF05C6 /* Genealogy.cpp */,
AF0934BA18E12B92005A11FD /* Genealogy.h */,
@@ -483,6 +483,14 @@
sourceTree = "<group>";
usesTabs = 0;
};
+ 49D404601E39260F00570CDC /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 49D404611E39260F00570CDC /* Foundation.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -612,7 +620,6 @@
23562ED91D342B0000AB2BD4 /* LogMessage.cpp in Sources */,
26CE05F1115C387C0022F371 /* PseudoTerminal.cpp in Sources */,
264D5D581293835600ED4C01 /* DNBArch.cpp in Sources */,
- 4971AE7213D10F4F00649E37 /* HasAVX.s in Sources */,
237821B01D4917D20028B7A1 /* LogFilterExactMatch.cpp in Sources */,
266B5ED11460A68200E43F0A /* DNBArchImplARM64.cpp in Sources */,
);
@@ -665,7 +672,6 @@
456F67641AD46CE9002850C2 /* CFBundle.cpp in Sources */,
456F67651AD46CE9002850C2 /* PseudoTerminal.cpp in Sources */,
456F67671AD46CE9002850C2 /* DNBArch.cpp in Sources */,
- 456F67681AD46CE9002850C2 /* HasAVX.s in Sources */,
23AC04D01D2F58AF0072351D /* LogFilterRegex.cpp in Sources */,
456F67691AD46CE9002850C2 /* DNBArchImplARM64.cpp in Sources */,
);
@@ -874,8 +880,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -976,8 +980,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -1077,8 +1079,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -1519,8 +1519,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -1661,8 +1659,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -1877,8 +1873,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
@@ -2010,8 +2004,6 @@
SpringBoardServices,
"-framework",
BackBoardServices,
- "-framework",
- Foundation,
"-llockdown",
"-framework",
FrontBoardServices,
diff --git a/tools/debugserver/source/CMakeLists.txt b/tools/debugserver/source/CMakeLists.txt
index 43479bd36435..782c946f702f 100644
--- a/tools/debugserver/source/CMakeLists.txt
+++ b/tools/debugserver/source/CMakeLists.txt
@@ -2,12 +2,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${LLDB_SOURCE_DIR}/source)
include_directories(MacOSX/DarwinLog)
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- include_directories(MacOSX)
- #include_directories(${CMAKE_CURRENT_BINARY_DIR}/MacOSX)
+include_directories(MacOSX)
+#include_directories(${CMAKE_CURRENT_BINARY_DIR}/MacOSX)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist")
-endif()
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist")
check_cxx_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments"
CXX_SUPPORTS_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS)
@@ -27,14 +25,31 @@ if (CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
endif ()
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
- add_definitions(
- -DDEBUGSERVER_VERSION_STR="${LLDB_VERSION}"
- )
-endif ()
+find_library(COCOA_LIBRARY Cocoa)
+add_subdirectory(MacOSX)
-add_library(lldbDebugserverCommon
- debugserver.cpp
+set(generated_mach_interfaces
+ ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
+ ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
+ ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
+ )
+add_custom_command(OUTPUT ${generated_mach_interfaces}
+ COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+ )
+
+set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
+set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
+
+add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
+ COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
+ ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
+ > ${DEBUGSERVER_VERS_GENERATED_FILE}
+ DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
+ ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
+ )
+
+set(lldbDebugserverCommonSources
DNBArch.cpp
DNBBreakpoint.cpp
DNB.cpp
@@ -58,11 +73,54 @@ add_library(lldbDebugserverCommon
RNBSocket.cpp
SysSignal.cpp
TTYState.cpp
+
+ MacOSX/CFBundle.cpp
+ MacOSX/CFString.cpp
+ MacOSX/Genealogy.cpp
+ MacOSX/MachException.cpp
+ MacOSX/MachProcess.mm
+ MacOSX/MachTask.mm
+ MacOSX/MachThread.cpp
+ MacOSX/MachThreadList.cpp
+ MacOSX/MachVMMemory.cpp
+ MacOSX/MachVMRegion.cpp
+ MacOSX/OsLogger.cpp
+ ${generated_mach_interfaces}
+ ${DEBUGSERVER_VERS_GENERATED_FILE})
+
+add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
+
+target_link_libraries(lldbDebugserverCommon
+ INTERFACE ${COCOA_LIBRARY}
+ lldbDebugserverMacOSX_I386
+ lldbDebugserverMacOSX_X86_64
+ lldbDebugserverMacOSX_DarwinLog)
+
+set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
+add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
+ debugserver.cpp
+
+ LINK_LIBS
+ lldbDebugserverCommon
)
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- find_library(COCOA_LIBRARY Cocoa)
- target_link_libraries(lldbDebugserverCommon ${COCOA_LIBRARY})
- add_subdirectory(MacOSX)
+set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
+ CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL ""))
+ execute_process(
+ COMMAND xcrun -f codesign_allocate
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE CODESIGN_ALLOCATE
+ )
+ add_custom_command(TARGET debugserver
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
+ codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
+ $<TARGET_FILE:debugserver>
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+ )
endif()
+
+
+
diff --git a/tools/debugserver/source/MacOSX/CMakeLists.txt b/tools/debugserver/source/MacOSX/CMakeLists.txt
index 7b77eb25d554..59b39a1bff63 100644
--- a/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -6,75 +6,3 @@ add_subdirectory(x86_64)
add_subdirectory(DarwinLog)
include_directories(..)
-
-set(generated_mach_interfaces
- ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
- ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
- ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
- )
-add_custom_command(OUTPUT ${generated_mach_interfaces}
- COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
- )
-
-set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
-
-add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
- COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
- ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
- > ${DEBUGSERVER_VERS_GENERATED_FILE}
- DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
- ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
- )
-
-set(DEBUGSERVER_USED_LIBS
- lldbDebugserverCommon
- lldbUtility
- lldbDebugserverMacOSX_I386
- lldbDebugserverMacOSX_X86_64
- lldbDebugserverMacOSX_DarwinLog
- )
-
-add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
- HasAVX.s
- CFBundle.cpp
- CFString.cpp
- Genealogy.cpp
- MachException.cpp
- MachProcess.mm
- MachTask.mm
- MachThread.cpp
- MachThreadList.cpp
- MachVMMemory.cpp
- MachVMRegion.cpp
- OsLogger.cpp
- ${generated_mach_interfaces}
- ${DEBUGSERVER_VERS_GENERATED_FILE}
- )
-
-set_source_files_properties(
- HasAVX.s
- # Necessary since compilation will fail with stand-alone assembler
- PROPERTIES LANGUAGE C COMPILE_FLAGS "-x assembler-with-cpp"
- )
-
-target_link_libraries(debugserver ${DEBUGSERVER_USED_LIBS})
-
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
- CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
-if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL ""))
- execute_process(
- COMMAND xcrun -f codesign_allocate
- OUTPUT_STRIP_TRAILING_WHITESPACE
- OUTPUT_VARIABLE CODESIGN_ALLOCATE
- )
- add_custom_command(TARGET debugserver
- POST_BUILD
- # Note: --entitlements option removed (see comment above).
- COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
- codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
- $<TARGET_FILE:debugserver>
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
- )
-endif()
diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
index 982367092ede..1e833c4cb165 100644
--- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
+++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
@@ -50,6 +50,7 @@ bool LookupSPICalls() {
static bool s_has_spi;
std::call_once(s_once_flag, [] {
+ dlopen ("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_NOW);
s_os_activity_stream_for_pid = (os_activity_stream_for_pid_t)dlsym(
RTLD_DEFAULT, "os_activity_stream_for_pid");
s_os_activity_stream_resume = (os_activity_stream_resume_t)dlsym(
@@ -691,7 +692,7 @@ void DarwinLogCollector::CancelActivityStream() {
DNBLogThreadedIf(LOG_DARWIN_LOG, "DarwinLogCollector::%s(): canceling "
"activity stream %p",
- __FUNCTION__, m_activity_stream);
+ __FUNCTION__, reinterpret_cast<void *>(m_activity_stream));
(*s_os_activity_stream_cancel)(m_activity_stream);
m_activity_stream = nullptr;
}
diff --git a/tools/debugserver/source/MacOSX/HasAVX.s b/tools/debugserver/source/MacOSX/HasAVX.s
deleted file mode 100644
index b66ccf14dbee..000000000000
--- a/tools/debugserver/source/MacOSX/HasAVX.s
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- HasAVX.s ---------------------------------------*- x86 Assembly -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#if defined (__i386__) || defined (__x86_64__)
-
-.globl _HasAVX
-
-_HasAVX:
-#if defined (__x86_64__)
- pushq %rbp
- movq %rsp, %rbp
- pushq %rbx
-#else
- pushl %ebp
- movl %esp, %ebp
- pushl %ebx
-#endif
- mov $1, %eax
- cpuid // clobbers ebx
- and $0x018000000, %ecx
- cmp $0x018000000, %ecx
- jne not_supported
- mov $0, %ecx
-.byte 0x0f, 0x01, 0xd0 // xgetbv, for those assemblers that don't know it
- and $0x06, %eax
- cmp $0x06, %eax
- jne not_supported
- mov $1, %eax
- jmp done
-not_supported:
- mov $0, %eax
-done:
-#if defined (__x86_64__)
- popq %rbx
- movq %rbp, %rsp
- popq %rbp
-#else
- popl %ebx
- movl %ebp, %esp
- popl %ebp
-#endif
- ret // return
-
-#endif
diff --git a/tools/debugserver/source/MacOSX/MachProcess.mm b/tools/debugserver/source/MacOSX/MachProcess.mm
index 720f6bc8899e..0daaca1db37e 100644
--- a/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -1269,7 +1269,7 @@ bool MachProcess::Interrupt() {
bool MachProcess::Signal(int signal, const struct timespec *timeout_abstime) {
DNBLogThreadedIf(LOG_PROCESS,
"MachProcess::Signal (signal = %d, timeout = %p)", signal,
- timeout_abstime);
+ reinterpret_cast<const void *>(timeout_abstime));
nub_state_t state = GetState();
if (::kill(ProcessID(), signal) == 0) {
// If we were running and we have a timeout, wait for the signal to stop
@@ -1277,20 +1277,21 @@ bool MachProcess::Signal(int signal, const struct timespec *timeout_abstime) {
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Signal (signal = %d, timeout "
"= %p) waiting for signal to stop "
"process...",
- signal, timeout_abstime);
+ signal, reinterpret_cast<const void *>(timeout_abstime));
m_private_events.WaitForSetEvents(eEventProcessStoppedStateChanged,
timeout_abstime);
state = GetState();
DNBLogThreadedIf(
LOG_PROCESS,
"MachProcess::Signal (signal = %d, timeout = %p) state = %s", signal,
- timeout_abstime, DNBStateAsString(state));
+ reinterpret_cast<const void *>(timeout_abstime),
+ DNBStateAsString(state));
return !IsRunning(state);
}
DNBLogThreadedIf(
LOG_PROCESS,
"MachProcess::Signal (signal = %d, timeout = %p) not waiting...",
- signal, timeout_abstime);
+ signal, reinterpret_cast<const void *>(timeout_abstime));
return true;
}
DNBError err(errno, DNBError::POSIX);
@@ -1596,7 +1597,8 @@ DNBBreakpoint *MachProcess::CreateBreakpoint(nub_addr_t addr, nub_size_t length,
if (EnableBreakpoint(addr)) {
DNBLogThreadedIf(LOG_BREAKPOINTS, "MachProcess::CreateBreakpoint ( addr = "
"0x%8.8llx, length = %llu) => %p",
- (uint64_t)addr, (uint64_t)length, bp);
+ (uint64_t)addr, (uint64_t)length,
+ reinterpret_cast<void *>(bp));
return bp;
} else if (bp->Release() == 0) {
m_breakpoints.Remove(addr);
@@ -1627,7 +1629,8 @@ DNBBreakpoint *MachProcess::CreateWatchpoint(nub_addr_t addr, nub_size_t length,
if (EnableWatchpoint(addr)) {
DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = "
"0x%8.8llx, length = %llu) => %p",
- (uint64_t)addr, (uint64_t)length, wp);
+ (uint64_t)addr, (uint64_t)length,
+ reinterpret_cast<void *>(wp));
return wp;
} else {
DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = "
@@ -2156,7 +2159,7 @@ void MachProcess::AppendSTDOUT(char *s, size_t len) {
size_t MachProcess::GetAvailableSTDOUT(char *buf, size_t buf_size) {
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__,
- buf, (uint64_t)buf_size);
+ reinterpret_cast<void *>(buf), (uint64_t)buf_size);
PTHREAD_MUTEX_LOCKER(locker, m_stdio_mutex);
size_t bytes_available = m_stdout_data.size();
if (bytes_available > 0) {
@@ -2316,7 +2319,7 @@ void MachProcess::SignalAsyncProfileData(const char *info) {
size_t MachProcess::GetAsyncProfileData(char *buf, size_t buf_size) {
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__,
- buf, (uint64_t)buf_size);
+ reinterpret_cast<void *>(buf), (uint64_t)buf_size);
PTHREAD_MUTEX_LOCKER(locker, m_profile_data_mutex);
if (m_profile_data.empty())
return 0;
@@ -2839,9 +2842,12 @@ pid_t MachProcess::LaunchForDebug(
// Clear out and clean up from any current state
Clear();
- DNBLogThreadedIf(LOG_PROCESS, "%s( path = '%s', argv = %p, envp = %p, "
- "launch_flavor = %u, disable_aslr = %d )",
- __FUNCTION__, path, argv, envp, launch_flavor, disable_aslr);
+ DNBLogThreadedIf(LOG_PROCESS,
+ "%s( path = '%s', argv = %p, envp = %p, "
+ "launch_flavor = %u, disable_aslr = %d )",
+ __FUNCTION__, path, reinterpret_cast<const void *>(argv),
+ reinterpret_cast<const void *>(envp), launch_flavor,
+ disable_aslr);
// Fork a child process for debugging
SetState(eStateLaunching);
@@ -2984,7 +2990,8 @@ pid_t MachProcess::PosixSpawnChildForPTraceDebugging(
DNBLogThreadedIf(LOG_PROCESS, "%s ( path='%s', argv=%p, envp=%p, "
"working_dir=%s, stdin=%s, stdout=%s "
"stderr=%s, no-stdio=%i)",
- __FUNCTION__, path, argv, envp, working_directory,
+ __FUNCTION__, path, reinterpret_cast<const void *>(argv),
+ reinterpret_cast<const void *>(envp), working_directory,
stdin_path, stdout_path, stderr_path, no_stdio);
err.SetError(::posix_spawnattr_init(&attr), DNBError::POSIX);
diff --git a/tools/debugserver/source/MacOSX/MachThread.cpp b/tools/debugserver/source/MacOSX/MachThread.cpp
index 36aa8c04bf2a..5686e42e4a49 100644
--- a/tools/debugserver/source/MacOSX/MachThread.cpp
+++ b/tools/debugserver/source/MacOSX/MachThread.cpp
@@ -50,7 +50,7 @@ MachThread::MachThread(MachProcess *process, bool is_64_bit,
DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE,
"MachThread::MachThread ( process = %p, tid = 0x%8.8" PRIx64
", seq_id = %u )",
- &m_process, m_unique_id, m_seq_id);
+ reinterpret_cast<void *>(&m_process), m_unique_id, m_seq_id);
}
MachThread::~MachThread() {
diff --git a/tools/debugserver/source/MacOSX/OsLogger.cpp b/tools/debugserver/source/MacOSX/OsLogger.cpp
index efecea30212f..6cc04a8a7c83 100644
--- a/tools/debugserver/source/MacOSX/OsLogger.cpp
+++ b/tools/debugserver/source/MacOSX/OsLogger.cpp
@@ -8,8 +8,9 @@
//===----------------------------------------------------------------------===//
#include "OsLogger.h"
+#include <Availability.h>
-#if LLDB_USE_OS_LOG
+#if (LLDB_USE_OS_LOG) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101200)
#include <os/log.h>
@@ -64,3 +65,4 @@ DNBCallbackLog OsLogger::GetLogFunction() {
DNBCallbackLog OsLogger::GetLogFunction() { return nullptr; }
#endif
+
diff --git a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
index 0974b168326d..6cc5ae6c36c4 100644
--- a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
+++ b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
@@ -339,60 +339,61 @@ kern_return_t DNBArchImplI386::GetGPRState(bool force) {
kern_return_t DNBArchImplI386::GetFPUState(bool force) {
if (force || m_state.GetError(e_regSetFPU, Read)) {
if (DEBUG_FPU_REGS) {
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- m_state.context.fpu.avx.__fpu_reserved[0] = -1;
- m_state.context.fpu.avx.__fpu_reserved[1] = -1;
- *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fcw) = 0x1234;
- *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fsw) = 0x5678;
- m_state.context.fpu.avx.__fpu_ftw = 1;
- m_state.context.fpu.avx.__fpu_rsrv1 = UINT8_MAX;
- m_state.context.fpu.avx.__fpu_fop = 2;
- m_state.context.fpu.avx.__fpu_ip = 3;
- m_state.context.fpu.avx.__fpu_cs = 4;
- m_state.context.fpu.avx.__fpu_rsrv2 = 5;
- m_state.context.fpu.avx.__fpu_dp = 6;
- m_state.context.fpu.avx.__fpu_ds = 7;
- m_state.context.fpu.avx.__fpu_rsrv3 = UINT16_MAX;
- m_state.context.fpu.avx.__fpu_mxcsr = 8;
- m_state.context.fpu.avx.__fpu_mxcsrmask = 9;
- int i;
- for (i = 0; i < 16; ++i) {
- if (i < 10) {
- m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = 'a';
- m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = 'b';
- m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = 'c';
- m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = 'd';
- m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = 'e';
- m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = 'f';
- m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = 'g';
- m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = 'h';
- } else {
- m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
- }
- m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg[i] = '0';
- m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg[i] = '1';
- m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg[i] = '2';
- m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg[i] = '3';
- m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg[i] = '4';
- m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg[i] = '5';
- m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg[i] = '6';
- m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg[i] = '7';
+ m_state.context.fpu.no_avx.__fpu_reserved[0] = -1;
+ m_state.context.fpu.no_avx.__fpu_reserved[1] = -1;
+ *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fcw) = 0x1234;
+ *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fsw) = 0x5678;
+ m_state.context.fpu.no_avx.__fpu_ftw = 1;
+ m_state.context.fpu.no_avx.__fpu_rsrv1 = UINT8_MAX;
+ m_state.context.fpu.no_avx.__fpu_fop = 2;
+ m_state.context.fpu.no_avx.__fpu_ip = 3;
+ m_state.context.fpu.no_avx.__fpu_cs = 4;
+ m_state.context.fpu.no_avx.__fpu_rsrv2 = 5;
+ m_state.context.fpu.no_avx.__fpu_dp = 6;
+ m_state.context.fpu.no_avx.__fpu_ds = 7;
+ m_state.context.fpu.no_avx.__fpu_rsrv3 = UINT16_MAX;
+ m_state.context.fpu.no_avx.__fpu_mxcsr = 8;
+ m_state.context.fpu.no_avx.__fpu_mxcsrmask = 9;
+ for (int i = 0; i < 16; ++i) {
+ if (i < 10) {
+ m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = 'a';
+ m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = 'b';
+ m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = 'c';
+ m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = 'd';
+ m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = 'e';
+ m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = 'f';
+ m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = 'g';
+ m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = 'h';
+ } else {
+ m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
}
- for (i = 0; i < sizeof(m_state.context.fpu.avx.__fpu_rsrv4); ++i)
- m_state.context.fpu.avx.__fpu_rsrv4[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_reserved1 = -1;
- for (i = 0; i < sizeof(m_state.context.fpu.avx.__avx_reserved1); ++i)
+
+ m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg[i] = '0';
+ m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg[i] = '1';
+ m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg[i] = '2';
+ m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg[i] = '3';
+ m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg[i] = '4';
+ m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg[i] = '5';
+ m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg[i] = '6';
+ m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg[i] = '7';
+ }
+ for (int i = 0; i < sizeof(m_state.context.fpu.no_avx.__fpu_rsrv4); ++i)
+ m_state.context.fpu.no_avx.__fpu_rsrv4[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_reserved1 = -1;
+
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
+ for (int i = 0; i < sizeof(m_state.context.fpu.avx.__avx_reserved1); ++i)
m_state.context.fpu.avx.__avx_reserved1[i] = INT8_MIN;
- for (i = 0; i < 16; ++i) {
+ for (int i = 0; i < 16; ++i) {
m_state.context.fpu.avx.__fpu_ymmh0.__xmm_reg[i] = '0';
m_state.context.fpu.avx.__fpu_ymmh1.__xmm_reg[i] = '1';
m_state.context.fpu.avx.__fpu_ymmh2.__xmm_reg[i] = '2';
@@ -402,83 +403,24 @@ kern_return_t DNBArchImplI386::GetFPUState(bool force) {
m_state.context.fpu.avx.__fpu_ymmh6.__xmm_reg[i] = '6';
m_state.context.fpu.avx.__fpu_ymmh7.__xmm_reg[i] = '7';
}
- } else {
- m_state.context.fpu.no_avx.__fpu_reserved[0] = -1;
- m_state.context.fpu.no_avx.__fpu_reserved[1] = -1;
- *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fcw) = 0x1234;
- *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fsw) = 0x5678;
- m_state.context.fpu.no_avx.__fpu_ftw = 1;
- m_state.context.fpu.no_avx.__fpu_rsrv1 = UINT8_MAX;
- m_state.context.fpu.no_avx.__fpu_fop = 2;
- m_state.context.fpu.no_avx.__fpu_ip = 3;
- m_state.context.fpu.no_avx.__fpu_cs = 4;
- m_state.context.fpu.no_avx.__fpu_rsrv2 = 5;
- m_state.context.fpu.no_avx.__fpu_dp = 6;
- m_state.context.fpu.no_avx.__fpu_ds = 7;
- m_state.context.fpu.no_avx.__fpu_rsrv3 = UINT16_MAX;
- m_state.context.fpu.no_avx.__fpu_mxcsr = 8;
- m_state.context.fpu.no_avx.__fpu_mxcsrmask = 9;
- int i;
- for (i = 0; i < 16; ++i) {
- if (i < 10) {
- m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = 'a';
- m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = 'b';
- m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = 'c';
- m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = 'd';
- m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = 'e';
- m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = 'f';
- m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = 'g';
- m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = 'h';
- } else {
- m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
- }
-
- m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg[i] = '0';
- m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg[i] = '1';
- m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg[i] = '2';
- m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg[i] = '3';
- m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg[i] = '4';
- m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg[i] = '5';
- m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg[i] = '6';
- m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg[i] = '7';
- }
- for (i = 0; i < sizeof(m_state.context.fpu.avx.__fpu_rsrv4); ++i)
- m_state.context.fpu.no_avx.__fpu_rsrv4[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_reserved1 = -1;
}
m_state.SetError(e_regSetFPU, Read, 0);
} else {
+ mach_msg_type_number_t count = e_regSetWordSizeFPU;
+ int flavor = __i386_FLOAT_STATE;
+
if (CPUHasAVX() || FORCE_AVX_REGS) {
- mach_msg_type_number_t count = e_regSetWordSizeAVX;
- m_state.SetError(e_regSetFPU, Read,
- ::thread_get_state(
- m_thread->MachPortNumber(), __i386_AVX_STATE,
- (thread_state_t)&m_state.context.fpu.avx, &count));
- DNBLogThreadedIf(LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, "
- "%u (%u passed in)) => 0x%8.8x",
- m_thread->MachPortNumber(), __i386_AVX_STATE, count,
- e_regSetWordSizeAVX,
- m_state.GetError(e_regSetFPU, Read));
- } else {
- mach_msg_type_number_t count = e_regSetWordSizeFPU;
- m_state.SetError(
- e_regSetFPU, Read,
- ::thread_get_state(m_thread->MachPortNumber(), __i386_FLOAT_STATE,
- (thread_state_t)&m_state.context.fpu.no_avx,
- &count));
- DNBLogThreadedIf(LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, "
- "%u (%u passed in) => 0x%8.8x",
- m_thread->MachPortNumber(), __i386_FLOAT_STATE, count,
- e_regSetWordSizeFPU,
- m_state.GetError(e_regSetFPU, Read));
+ count = e_regSetWordSizeAVX;
+ flavor = __i386_AVX_STATE;
}
+ m_state.SetError(e_regSetFPU, Read,
+ ::thread_get_state(m_thread->MachPortNumber(), flavor,
+ (thread_state_t)&m_state.context.fpu,
+ &count));
+ DNBLogThreadedIf(LOG_THREAD,
+ "::thread_get_state (0x%4.4x, %u, &fpu, %u => 0x%8.8x",
+ m_thread->MachPortNumber(), flavor, (uint32_t)count,
+ m_state.GetError(e_regSetFPU, Read));
}
}
return m_state.GetError(e_regSetFPU, Read);
@@ -1460,239 +1402,138 @@ bool DNBArchImplI386::GetRegisterValue(uint32_t set, uint32_t reg,
break;
case e_regSetFPU:
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- switch (reg) {
- case fpu_fcw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw));
- return true;
- case fpu_fsw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw));
- return true;
- case fpu_ftw:
- value->value.uint8 = m_state.context.fpu.avx.__fpu_ftw;
- return true;
- case fpu_fop:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_fop;
- return true;
- case fpu_ip:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_ip;
- return true;
- case fpu_cs:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_cs;
- return true;
- case fpu_dp:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_dp;
- return true;
- case fpu_ds:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_ds;
- return true;
- case fpu_mxcsr:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsr;
- return true;
- case fpu_mxcsrmask:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsrmask;
- return true;
-
- case fpu_stmm0:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg, 10);
- return true;
- case fpu_stmm1:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg, 10);
- return true;
- case fpu_stmm2:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg, 10);
- return true;
- case fpu_stmm3:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg, 10);
- return true;
- case fpu_stmm4:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg, 10);
- return true;
- case fpu_stmm5:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg, 10);
- return true;
- case fpu_stmm6:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg, 10);
- return true;
- case fpu_stmm7:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg, 10);
- return true;
-
- case fpu_xmm0:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg, 16);
- return true;
- case fpu_xmm1:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg, 16);
- return true;
- case fpu_xmm2:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg, 16);
- return true;
- case fpu_xmm3:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg, 16);
- return true;
- case fpu_xmm4:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg, 16);
- return true;
- case fpu_xmm5:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg, 16);
- return true;
- case fpu_xmm6:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg, 16);
- return true;
- case fpu_xmm7:
- memcpy(&value->value.uint8,
- m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg, 16);
- return true;
+ if (reg > fpu_xmm7 && !(CPUHasAVX() || FORCE_AVX_REGS))
+ return false;
+ switch (reg) {
+ case fpu_fcw:
+ value->value.uint16 =
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw));
+ return true;
+ case fpu_fsw:
+ value->value.uint16 =
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw));
+ return true;
+ case fpu_ftw:
+ value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw;
+ return true;
+ case fpu_fop:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop;
+ return true;
+ case fpu_ip:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip;
+ return true;
+ case fpu_cs:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs;
+ return true;
+ case fpu_dp:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp;
+ return true;
+ case fpu_ds:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds;
+ return true;
+ case fpu_mxcsr:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr;
+ return true;
+ case fpu_mxcsrmask:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask;
+ return true;
+
+ case fpu_stmm0:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg, 10);
+ return true;
+ case fpu_stmm1:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg, 10);
+ return true;
+ case fpu_stmm2:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg, 10);
+ return true;
+ case fpu_stmm3:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg, 10);
+ return true;
+ case fpu_stmm4:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg, 10);
+ return true;
+ case fpu_stmm5:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg, 10);
+ return true;
+ case fpu_stmm6:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg, 10);
+ return true;
+ case fpu_stmm7:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg, 10);
+ return true;
+
+ case fpu_xmm0:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg, 16);
+ return true;
+ case fpu_xmm1:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg, 16);
+ return true;
+ case fpu_xmm2:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg, 16);
+ return true;
+ case fpu_xmm3:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg, 16);
+ return true;
+ case fpu_xmm4:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg, 16);
+ return true;
+ case fpu_xmm5:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg, 16);
+ return true;
+ case fpu_xmm6:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg, 16);
+ return true;
+ case fpu_xmm7:
+ memcpy(&value->value.uint8,
+ m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg, 16);
+ return true;
#define MEMCPY_YMM(n) \
memcpy(&value->value.uint8, m_state.context.fpu.avx.__fpu_xmm##n.__xmm_reg, \
16); \
memcpy((&value->value.uint8) + 16, \
m_state.context.fpu.avx.__fpu_ymmh##n.__xmm_reg, 16);
- case fpu_ymm0:
- MEMCPY_YMM(0);
- return true;
- case fpu_ymm1:
- MEMCPY_YMM(1);
- return true;
- case fpu_ymm2:
- MEMCPY_YMM(2);
- return true;
- case fpu_ymm3:
- MEMCPY_YMM(3);
- return true;
- case fpu_ymm4:
- MEMCPY_YMM(4);
- return true;
- case fpu_ymm5:
- MEMCPY_YMM(5);
- return true;
- case fpu_ymm6:
- MEMCPY_YMM(6);
- return true;
- case fpu_ymm7:
- MEMCPY_YMM(7);
- return true;
+ case fpu_ymm0:
+ MEMCPY_YMM(0);
+ return true;
+ case fpu_ymm1:
+ MEMCPY_YMM(1);
+ return true;
+ case fpu_ymm2:
+ MEMCPY_YMM(2);
+ return true;
+ case fpu_ymm3:
+ MEMCPY_YMM(3);
+ return true;
+ case fpu_ymm4:
+ MEMCPY_YMM(4);
+ return true;
+ case fpu_ymm5:
+ MEMCPY_YMM(5);
+ return true;
+ case fpu_ymm6:
+ MEMCPY_YMM(6);
+ return true;
+ case fpu_ymm7:
+ MEMCPY_YMM(7);
+ return true;
#undef MEMCPY_YMM
- }
- } else {
- switch (reg) {
- case fpu_fcw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw));
- return true;
- case fpu_fsw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw));
- return true;
- case fpu_ftw:
- value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw;
- return true;
- case fpu_fop:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop;
- return true;
- case fpu_ip:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip;
- return true;
- case fpu_cs:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs;
- return true;
- case fpu_dp:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp;
- return true;
- case fpu_ds:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds;
- return true;
- case fpu_mxcsr:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr;
- return true;
- case fpu_mxcsrmask:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask;
- return true;
-
- case fpu_stmm0:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg, 10);
- return true;
- case fpu_stmm1:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg, 10);
- return true;
- case fpu_stmm2:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg, 10);
- return true;
- case fpu_stmm3:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg, 10);
- return true;
- case fpu_stmm4:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg, 10);
- return true;
- case fpu_stmm5:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg, 10);
- return true;
- case fpu_stmm6:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg, 10);
- return true;
- case fpu_stmm7:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg, 10);
- return true;
-
- case fpu_xmm0:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg, 16);
- return true;
- case fpu_xmm1:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg, 16);
- return true;
- case fpu_xmm2:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg, 16);
- return true;
- case fpu_xmm3:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg, 16);
- return true;
- case fpu_xmm4:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg, 16);
- return true;
- case fpu_xmm5:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg, 16);
- return true;
- case fpu_xmm6:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg, 16);
- return true;
- case fpu_xmm7:
- memcpy(&value->value.uint8,
- m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg, 16);
- return true;
- }
}
break;
@@ -1752,291 +1593,164 @@ bool DNBArchImplI386::SetRegisterValue(uint32_t set, uint32_t reg,
break;
case e_regSetFPU:
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- switch (reg) {
- case fpu_fcw:
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_fsw:
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_ftw:
- m_state.context.fpu.avx.__fpu_ftw = value->value.uint8;
- success = true;
- break;
- case fpu_fop:
- m_state.context.fpu.avx.__fpu_fop = value->value.uint16;
- success = true;
- break;
- case fpu_ip:
- m_state.context.fpu.avx.__fpu_ip = value->value.uint32;
- success = true;
- break;
- case fpu_cs:
- m_state.context.fpu.avx.__fpu_cs = value->value.uint16;
- success = true;
- break;
- case fpu_dp:
- m_state.context.fpu.avx.__fpu_dp = value->value.uint32;
- success = true;
- break;
- case fpu_ds:
- m_state.context.fpu.avx.__fpu_ds = value->value.uint16;
- success = true;
- break;
- case fpu_mxcsr:
- m_state.context.fpu.avx.__fpu_mxcsr = value->value.uint32;
- success = true;
- break;
- case fpu_mxcsrmask:
- m_state.context.fpu.avx.__fpu_mxcsrmask = value->value.uint32;
- success = true;
- break;
-
- case fpu_stmm0:
- memcpy(m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm1:
- memcpy(m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm2:
- memcpy(m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm3:
- memcpy(m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm4:
- memcpy(m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm5:
- memcpy(m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm6:
- memcpy(m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm7:
- memcpy(m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
-
- case fpu_xmm0:
- memcpy(m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm1:
- memcpy(m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm2:
- memcpy(m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm3:
- memcpy(m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm4:
- memcpy(m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm5:
- memcpy(m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm6:
- memcpy(m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm7:
- memcpy(m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
+ if (reg > fpu_xmm7 && !(CPUHasAVX() || FORCE_AVX_REGS))
+ return false;
+ switch (reg) {
+ case fpu_fcw:
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) =
+ value->value.uint16;
+ success = true;
+ break;
+ case fpu_fsw:
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) =
+ value->value.uint16;
+ success = true;
+ break;
+ case fpu_ftw:
+ m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8;
+ success = true;
+ break;
+ case fpu_fop:
+ m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16;
+ success = true;
+ break;
+ case fpu_ip:
+ m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32;
+ success = true;
+ break;
+ case fpu_cs:
+ m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16;
+ success = true;
+ break;
+ case fpu_dp:
+ m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32;
+ success = true;
+ break;
+ case fpu_ds:
+ m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16;
+ success = true;
+ break;
+ case fpu_mxcsr:
+ m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32;
+ success = true;
+ break;
+ case fpu_mxcsrmask:
+ m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32;
+ success = true;
+ break;
+
+ case fpu_stmm0:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm1:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm2:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm3:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm4:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm5:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm6:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+ case fpu_stmm7:
+ memcpy(m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg,
+ &value->value.uint8, 10);
+ success = true;
+ break;
+
+ case fpu_xmm0:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm1:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm2:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm3:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm4:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm5:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm6:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
+ case fpu_xmm7:
+ memcpy(m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg,
+ &value->value.uint8, 16);
+ success = true;
+ break;
#define MEMCPY_YMM(n) \
memcpy(m_state.context.fpu.avx.__fpu_xmm##n.__xmm_reg, &value->value.uint8, \
16); \
memcpy(m_state.context.fpu.avx.__fpu_ymmh##n.__xmm_reg, \
(&value->value.uint8) + 16, 16);
- case fpu_ymm0:
- MEMCPY_YMM(0);
- return true;
- case fpu_ymm1:
- MEMCPY_YMM(1);
- return true;
- case fpu_ymm2:
- MEMCPY_YMM(2);
- return true;
- case fpu_ymm3:
- MEMCPY_YMM(3);
- return true;
- case fpu_ymm4:
- MEMCPY_YMM(4);
- return true;
- case fpu_ymm5:
- MEMCPY_YMM(5);
- return true;
- case fpu_ymm6:
- MEMCPY_YMM(6);
- return true;
- case fpu_ymm7:
- MEMCPY_YMM(7);
- return true;
+ case fpu_ymm0:
+ MEMCPY_YMM(0);
+ return true;
+ case fpu_ymm1:
+ MEMCPY_YMM(1);
+ return true;
+ case fpu_ymm2:
+ MEMCPY_YMM(2);
+ return true;
+ case fpu_ymm3:
+ MEMCPY_YMM(3);
+ return true;
+ case fpu_ymm4:
+ MEMCPY_YMM(4);
+ return true;
+ case fpu_ymm5:
+ MEMCPY_YMM(5);
+ return true;
+ case fpu_ymm6:
+ MEMCPY_YMM(6);
+ return true;
+ case fpu_ymm7:
+ MEMCPY_YMM(7);
+ return true;
#undef MEMCPY_YMM
- }
- } else {
- switch (reg) {
- case fpu_fcw:
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_fsw:
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_ftw:
- m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8;
- success = true;
- break;
- case fpu_fop:
- m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16;
- success = true;
- break;
- case fpu_ip:
- m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32;
- success = true;
- break;
- case fpu_cs:
- m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16;
- success = true;
- break;
- case fpu_dp:
- m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32;
- success = true;
- break;
- case fpu_ds:
- m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16;
- success = true;
- break;
- case fpu_mxcsr:
- m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32;
- success = true;
- break;
- case fpu_mxcsrmask:
- m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32;
- success = true;
- break;
-
- case fpu_stmm0:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm1:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm2:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm3:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm4:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm5:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm6:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
- case fpu_stmm7:
- memcpy(m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg,
- &value->value.uint8, 10);
- success = true;
- break;
-
- case fpu_xmm0:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm1:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm2:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm3:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm4:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm5:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm6:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- case fpu_xmm7:
- memcpy(m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg,
- &value->value.uint8, 16);
- success = true;
- break;
- }
}
break;
@@ -2113,24 +1827,24 @@ nub_size_t DNBArchImplI386::GetRegisterContext(void *buf, nub_size_t buf_len) {
memcpy(p, &m_state.context.gpr, sizeof(GPR));
p += sizeof(GPR);
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- // Walk around the gaps in the FPU regs
- memcpy(p, &m_state.context.fpu.avx.__fpu_fcw, 5);
- p += 5;
- memcpy(p, &m_state.context.fpu.avx.__fpu_fop, 8);
- p += 8;
- memcpy(p, &m_state.context.fpu.avx.__fpu_dp, 6);
- p += 6;
- memcpy(p, &m_state.context.fpu.avx.__fpu_mxcsr, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(p, &m_state.context.fpu.avx.__fpu_stmm0 + i, 10);
- p += 10;
- }
+ // Walk around the gaps in the FPU regs
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_fcw, 5);
+ p += 5;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_fop, 8);
+ p += 8;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_dp, 6);
+ p += 6;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_mxcsr, 8);
+ p += 8;
+
+ // Work around the padding between the stmm registers as they are 16
+ // byte structs with 10 bytes of the value in each
+ for (size_t i = 0; i < 8; ++i) {
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_stmm0 + i, 10);
+ p += 10;
+ }
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
// Interleave the XMM and YMMH registers to make the YMM registers
for (size_t i = 0; i < 8; ++i) {
memcpy(p, &m_state.context.fpu.avx.__fpu_xmm0 + i, 16);
@@ -2139,23 +1853,6 @@ nub_size_t DNBArchImplI386::GetRegisterContext(void *buf, nub_size_t buf_len) {
p += 16;
}
} else {
- // Walk around the gaps in the FPU regs
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_fcw, 5);
- p += 5;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_fop, 8);
- p += 8;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_dp, 6);
- p += 6;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_mxcsr, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_stmm0 + i, 10);
- p += 10;
- }
-
// Copy the XMM registers in a single block
memcpy(p, &m_state.context.fpu.no_avx.__fpu_xmm0, 8 * 16);
p += 8 * 16;
@@ -2194,24 +1891,24 @@ nub_size_t DNBArchImplI386::SetRegisterContext(const void *buf,
memcpy(&m_state.context.gpr, p, sizeof(GPR));
p += sizeof(GPR);
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- // Walk around the gaps in the FPU regs
- memcpy(&m_state.context.fpu.avx.__fpu_fcw, p, 5);
- p += 5;
- memcpy(&m_state.context.fpu.avx.__fpu_fop, p, 8);
- p += 8;
- memcpy(&m_state.context.fpu.avx.__fpu_dp, p, 6);
- p += 6;
- memcpy(&m_state.context.fpu.avx.__fpu_mxcsr, p, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(&m_state.context.fpu.avx.__fpu_stmm0 + i, p, 10);
- p += 10;
- }
+ // Copy fcw through mxcsrmask as there is no padding
+ memcpy(&m_state.context.fpu.no_avx.__fpu_fcw, p, 5);
+ p += 5;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_fop, p, 8);
+ p += 8;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_dp, p, 6);
+ p += 6;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_mxcsr, p, 8);
+ p += 8;
+
+ // Work around the padding between the stmm registers as they are 16
+ // byte structs with 10 bytes of the value in each
+ for (size_t i = 0; i < 8; ++i) {
+ memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + i, p, 10);
+ p += 10;
+ }
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
// Interleave the XMM and YMMH registers to make the YMM registers
for (size_t i = 0; i < 8; ++i) {
memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + i, p, 16);
@@ -2220,23 +1917,6 @@ nub_size_t DNBArchImplI386::SetRegisterContext(const void *buf,
p += 16;
}
} else {
- // Copy fcw through mxcsrmask as there is no padding
- memcpy(&m_state.context.fpu.no_avx.__fpu_fcw, p, 5);
- p += 5;
- memcpy(&m_state.context.fpu.no_avx.__fpu_fop, p, 8);
- p += 8;
- memcpy(&m_state.context.fpu.no_avx.__fpu_dp, p, 6);
- p += 6;
- memcpy(&m_state.context.fpu.no_avx.__fpu_mxcsr, p, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + i, p, 10);
- p += 10;
- }
-
// Copy the XMM registers in a single block
memcpy(&m_state.context.fpu.no_avx.__fpu_xmm0, p, 8 * 16);
p += 8 * 16;
diff --git a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
index 5b0426688187..2e9542b051c6 100644
--- a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
+++ b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
@@ -16,7 +16,6 @@
#if defined(__i386__) || defined(__x86_64__)
-#include "../HasAVX.h"
#include "DNBArch.h"
#include "MachRegisterStatesI386.h"
diff --git a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
index b8d35fe2f7c9..416b21f29958 100644
--- a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -17,7 +17,6 @@
#include <sys/sysctl.h>
#include <sys/types.h>
-#include "../HasAVX.h"
#include "DNBLog.h"
#include "MacOSX/x86_64/DNBArchImplX86_64.h"
#include "MachProcess.h"
@@ -60,42 +59,64 @@ static bool ForceAVXRegs() {
#define FORCE_AVX_REGS (0)
#endif
-extern "C" bool CPUHasAVX() {
- enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+bool DetectHardwareFeature(const char *feature) {
+ int answer = 0;
+ size_t answer_size = sizeof(answer);
+ int error = ::sysctlbyname(feature, &answer, &answer_size, NULL, 0);
+ return error == 0 && answer != 0;
+}
+
+enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+
+bool LogAVXAndReturn(AVXPresence has_avx, int err, const char * os_ver) {
+ DNBLogThreadedIf(LOG_THREAD,
+ "CPUHasAVX(): g_has_avx = %i (err = %i, os_ver = %s)",
+ has_avx, err, os_ver);
+ return (has_avx == eAVXPresent);
+}
+extern "C" bool CPUHasAVX() {
static AVXPresence g_has_avx = eAVXUnknown;
- if (g_has_avx == eAVXUnknown) {
- g_has_avx = eAVXNotPresent;
-
- // Only xnu-2020 or later has AVX support, any versions before
- // this have a busted thread_get_state RPC where it would truncate
- // the thread state buffer (<rdar://problem/10122874>). So we need to
- // verify the kernel version number manually or disable AVX support.
- int mib[2];
- char buffer[1024];
- size_t length = sizeof(buffer);
- uint64_t xnu_version = 0;
- mib[0] = CTL_KERN;
- mib[1] = KERN_VERSION;
- int err = ::sysctl(mib, 2, &buffer, &length, NULL, 0);
- if (err == 0) {
- const char *xnu = strstr(buffer, "xnu-");
- if (xnu) {
- const char *xnu_version_cstr = xnu + 4;
- xnu_version = strtoull(xnu_version_cstr, NULL, 0);
- if (xnu_version >= 2020 && xnu_version != ULLONG_MAX) {
- if (::HasAVX()) {
- g_has_avx = eAVXPresent;
- }
- }
- }
- }
- DNBLogThreadedIf(LOG_THREAD, "CPUHasAVX(): g_has_avx = %i (err = %i, errno "
- "= %i, xnu_version = %llu)",
- g_has_avx, err, errno, xnu_version);
+ if (g_has_avx != eAVXUnknown)
+ return LogAVXAndReturn(g_has_avx, 0, "");
+
+ g_has_avx = eAVXNotPresent;
+
+ // OS X 10.7.3 and earlier have a bug in thread_get_state that truncated the
+ // size of the return. To work around this we have to disable AVX debugging
+ // on hosts prior to 10.7.3 (<rdar://problem/10122874>).
+ int mib[2];
+ char buffer[1024];
+ size_t length = sizeof(buffer);
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_OSVERSION;
+
+ // KERN_OSVERSION returns the build number which is a number signifying the
+ // major version, a capitol letter signifying the minor version, and numbers
+ // signifying the build (ex: on 10.12.3, the returned value is 16D32).
+ int err = ::sysctl(mib, 2, &buffer, &length, NULL, 0);
+ if (err != 0)
+ return LogAVXAndReturn(g_has_avx, err, "");
+
+ size_t first_letter = 0;
+ for (; first_letter < length; ++first_letter) {
+ // This is looking for the first uppercase letter
+ if (isupper(buffer[first_letter]))
+ break;
}
-
- return (g_has_avx == eAVXPresent);
+ char letter = buffer[first_letter];
+ buffer[first_letter] = '\0';
+ auto major_ver = strtoull(buffer, NULL, 0);
+ buffer[first_letter] = letter;
+
+ // In this check we're looking to see that our major and minor version numer
+ // was >= 11E, which is the 10.7.4 release.
+ if (major_ver < 11 || (major_ver == 11 && letter < 'E'))
+ return LogAVXAndReturn(g_has_avx, err, buffer);
+ if (DetectHardwareFeature("hw.optional.avx1_0"))
+ g_has_avx = eAVXPresent;
+
+ return LogAVXAndReturn(g_has_avx, err, buffer);
}
uint64_t DNBArchImplX86_64::GetPC(uint64_t failValue) {
@@ -238,61 +259,65 @@ kern_return_t DNBArchImplX86_64::GetGPRState(bool force) {
kern_return_t DNBArchImplX86_64::GetFPUState(bool force) {
if (force || m_state.GetError(e_regSetFPU, Read)) {
if (DEBUG_FPU_REGS) {
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- m_state.context.fpu.avx.__fpu_reserved[0] = -1;
- m_state.context.fpu.avx.__fpu_reserved[1] = -1;
- *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fcw) = 0x1234;
- *(uint16_t *)&(m_state.context.fpu.avx.__fpu_fsw) = 0x5678;
- m_state.context.fpu.avx.__fpu_ftw = 1;
- m_state.context.fpu.avx.__fpu_rsrv1 = UINT8_MAX;
- m_state.context.fpu.avx.__fpu_fop = 2;
- m_state.context.fpu.avx.__fpu_ip = 3;
- m_state.context.fpu.avx.__fpu_cs = 4;
- m_state.context.fpu.avx.__fpu_rsrv2 = UINT8_MAX;
- m_state.context.fpu.avx.__fpu_dp = 5;
- m_state.context.fpu.avx.__fpu_ds = 6;
- m_state.context.fpu.avx.__fpu_rsrv3 = UINT16_MAX;
- m_state.context.fpu.avx.__fpu_mxcsr = 8;
- m_state.context.fpu.avx.__fpu_mxcsrmask = 9;
- int i;
- for (i = 0; i < 16; ++i) {
- if (i < 10) {
- m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = 'a';
- m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = 'b';
- m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = 'c';
- m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = 'd';
- m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = 'e';
- m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = 'f';
- m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = 'g';
- m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = 'h';
- } else {
- m_state.context.fpu.avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
- }
-
- m_state.context.fpu.avx.__fpu_xmm0.__xmm_reg[i] = '0' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm1.__xmm_reg[i] = '1' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm2.__xmm_reg[i] = '2' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm3.__xmm_reg[i] = '3' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm4.__xmm_reg[i] = '4' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm5.__xmm_reg[i] = '5' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm6.__xmm_reg[i] = '6' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm7.__xmm_reg[i] = '7' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm8.__xmm_reg[i] = '8' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm9.__xmm_reg[i] = '9' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm10.__xmm_reg[i] = 'A' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm11.__xmm_reg[i] = 'B' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm12.__xmm_reg[i] = 'C' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm13.__xmm_reg[i] = 'D' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm14.__xmm_reg[i] = 'E' + 2 * i;
- m_state.context.fpu.avx.__fpu_xmm15.__xmm_reg[i] = 'F' + 2 * i;
+ m_state.context.fpu.no_avx.__fpu_reserved[0] = -1;
+ m_state.context.fpu.no_avx.__fpu_reserved[1] = -1;
+ *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fcw) = 0x1234;
+ *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fsw) = 0x5678;
+ m_state.context.fpu.no_avx.__fpu_ftw = 1;
+ m_state.context.fpu.no_avx.__fpu_rsrv1 = UINT8_MAX;
+ m_state.context.fpu.no_avx.__fpu_fop = 2;
+ m_state.context.fpu.no_avx.__fpu_ip = 3;
+ m_state.context.fpu.no_avx.__fpu_cs = 4;
+ m_state.context.fpu.no_avx.__fpu_rsrv2 = 5;
+ m_state.context.fpu.no_avx.__fpu_dp = 6;
+ m_state.context.fpu.no_avx.__fpu_ds = 7;
+ m_state.context.fpu.no_avx.__fpu_rsrv3 = UINT16_MAX;
+ m_state.context.fpu.no_avx.__fpu_mxcsr = 8;
+ m_state.context.fpu.no_avx.__fpu_mxcsrmask = 9;
+ for (int i = 0; i < 16; ++i) {
+ if (i < 10) {
+ m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = 'a';
+ m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = 'b';
+ m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = 'c';
+ m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = 'd';
+ m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = 'e';
+ m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = 'f';
+ m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = 'g';
+ m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = 'h';
+ } else {
+ m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
+ }
+ m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg[i] = '0';
+ m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg[i] = '1';
+ m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg[i] = '2';
+ m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg[i] = '3';
+ m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg[i] = '4';
+ m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg[i] = '5';
+ m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg[i] = '6';
+ m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg[i] = '7';
+ m_state.context.fpu.no_avx.__fpu_xmm8.__xmm_reg[i] = '8';
+ m_state.context.fpu.no_avx.__fpu_xmm9.__xmm_reg[i] = '9';
+ m_state.context.fpu.no_avx.__fpu_xmm10.__xmm_reg[i] = 'A';
+ m_state.context.fpu.no_avx.__fpu_xmm11.__xmm_reg[i] = 'B';
+ m_state.context.fpu.no_avx.__fpu_xmm12.__xmm_reg[i] = 'C';
+ m_state.context.fpu.no_avx.__fpu_xmm13.__xmm_reg[i] = 'D';
+ m_state.context.fpu.no_avx.__fpu_xmm14.__xmm_reg[i] = 'E';
+ m_state.context.fpu.no_avx.__fpu_xmm15.__xmm_reg[i] = 'F';
+ }
+ for (int i = 0; i < sizeof(m_state.context.fpu.no_avx.__fpu_rsrv4); ++i)
+ m_state.context.fpu.no_avx.__fpu_rsrv4[i] = INT8_MIN;
+ m_state.context.fpu.no_avx.__fpu_reserved1 = -1;
+
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
+ for (int i = 0; i < 16; ++i) {
m_state.context.fpu.avx.__fpu_ymmh0.__xmm_reg[i] = '0' + i;
m_state.context.fpu.avx.__fpu_ymmh1.__xmm_reg[i] = '1' + i;
m_state.context.fpu.avx.__fpu_ymmh2.__xmm_reg[i] = '2' + i;
@@ -310,97 +335,25 @@ kern_return_t DNBArchImplX86_64::GetFPUState(bool force) {
m_state.context.fpu.avx.__fpu_ymmh14.__xmm_reg[i] = 'E' + i;
m_state.context.fpu.avx.__fpu_ymmh15.__xmm_reg[i] = 'F' + i;
}
- for (i = 0; i < sizeof(m_state.context.fpu.avx.__fpu_rsrv4); ++i)
- m_state.context.fpu.avx.__fpu_rsrv4[i] = INT8_MIN;
- m_state.context.fpu.avx.__fpu_reserved1 = -1;
- for (i = 0; i < sizeof(m_state.context.fpu.avx.__avx_reserved1); ++i)
+ for (int i = 0; i < sizeof(m_state.context.fpu.avx.__avx_reserved1); ++i)
m_state.context.fpu.avx.__avx_reserved1[i] = INT8_MIN;
- m_state.SetError(e_regSetFPU, Read, 0);
- } else {
- m_state.context.fpu.no_avx.__fpu_reserved[0] = -1;
- m_state.context.fpu.no_avx.__fpu_reserved[1] = -1;
- *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fcw) = 0x1234;
- *(uint16_t *)&(m_state.context.fpu.no_avx.__fpu_fsw) = 0x5678;
- m_state.context.fpu.no_avx.__fpu_ftw = 1;
- m_state.context.fpu.no_avx.__fpu_rsrv1 = UINT8_MAX;
- m_state.context.fpu.no_avx.__fpu_fop = 2;
- m_state.context.fpu.no_avx.__fpu_ip = 3;
- m_state.context.fpu.no_avx.__fpu_cs = 4;
- m_state.context.fpu.no_avx.__fpu_rsrv2 = 5;
- m_state.context.fpu.no_avx.__fpu_dp = 6;
- m_state.context.fpu.no_avx.__fpu_ds = 7;
- m_state.context.fpu.no_avx.__fpu_rsrv3 = UINT16_MAX;
- m_state.context.fpu.no_avx.__fpu_mxcsr = 8;
- m_state.context.fpu.no_avx.__fpu_mxcsrmask = 9;
- int i;
- for (i = 0; i < 16; ++i) {
- if (i < 10) {
- m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = 'a';
- m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = 'b';
- m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = 'c';
- m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = 'd';
- m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = 'e';
- m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = 'f';
- m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = 'g';
- m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = 'h';
- } else {
- m_state.context.fpu.no_avx.__fpu_stmm0.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm1.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm2.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm3.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm4.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm5.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm6.__mmst_reg[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_stmm7.__mmst_reg[i] = INT8_MIN;
- }
-
- m_state.context.fpu.no_avx.__fpu_xmm0.__xmm_reg[i] = '0';
- m_state.context.fpu.no_avx.__fpu_xmm1.__xmm_reg[i] = '1';
- m_state.context.fpu.no_avx.__fpu_xmm2.__xmm_reg[i] = '2';
- m_state.context.fpu.no_avx.__fpu_xmm3.__xmm_reg[i] = '3';
- m_state.context.fpu.no_avx.__fpu_xmm4.__xmm_reg[i] = '4';
- m_state.context.fpu.no_avx.__fpu_xmm5.__xmm_reg[i] = '5';
- m_state.context.fpu.no_avx.__fpu_xmm6.__xmm_reg[i] = '6';
- m_state.context.fpu.no_avx.__fpu_xmm7.__xmm_reg[i] = '7';
- m_state.context.fpu.no_avx.__fpu_xmm8.__xmm_reg[i] = '8';
- m_state.context.fpu.no_avx.__fpu_xmm9.__xmm_reg[i] = '9';
- m_state.context.fpu.no_avx.__fpu_xmm10.__xmm_reg[i] = 'A';
- m_state.context.fpu.no_avx.__fpu_xmm11.__xmm_reg[i] = 'B';
- m_state.context.fpu.no_avx.__fpu_xmm12.__xmm_reg[i] = 'C';
- m_state.context.fpu.no_avx.__fpu_xmm13.__xmm_reg[i] = 'D';
- m_state.context.fpu.no_avx.__fpu_xmm14.__xmm_reg[i] = 'E';
- m_state.context.fpu.no_avx.__fpu_xmm15.__xmm_reg[i] = 'F';
- }
- for (i = 0; i < sizeof(m_state.context.fpu.no_avx.__fpu_rsrv4); ++i)
- m_state.context.fpu.no_avx.__fpu_rsrv4[i] = INT8_MIN;
- m_state.context.fpu.no_avx.__fpu_reserved1 = -1;
- m_state.SetError(e_regSetFPU, Read, 0);
}
+ m_state.SetError(e_regSetFPU, Read, 0);
} else {
+ mach_msg_type_number_t count = e_regSetWordSizeFPU;
+ int flavor = __x86_64_FLOAT_STATE;
if (CPUHasAVX() || FORCE_AVX_REGS) {
- mach_msg_type_number_t count = e_regSetWordSizeAVX;
- m_state.SetError(e_regSetFPU, Read,
- ::thread_get_state(
- m_thread->MachPortNumber(), __x86_64_AVX_STATE,
- (thread_state_t)&m_state.context.fpu.avx, &count));
- DNBLogThreadedIf(LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, "
- "%u (%u passed in) carp) => 0x%8.8x",
- m_thread->MachPortNumber(), __x86_64_AVX_STATE,
- (uint32_t)count, e_regSetWordSizeAVX,
- m_state.GetError(e_regSetFPU, Read));
- } else {
- mach_msg_type_number_t count = e_regSetWordSizeFPU;
- m_state.SetError(
- e_regSetFPU, Read,
- ::thread_get_state(m_thread->MachPortNumber(), __x86_64_FLOAT_STATE,
- (thread_state_t)&m_state.context.fpu.no_avx,
- &count));
- DNBLogThreadedIf(LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, "
- "%u (%u passed in) => 0x%8.8x",
- m_thread->MachPortNumber(), __x86_64_FLOAT_STATE,
- (uint32_t)count, e_regSetWordSizeFPU,
- m_state.GetError(e_regSetFPU, Read));
+ count = e_regSetWordSizeAVX;
+ flavor = __x86_64_AVX_STATE;
}
+ m_state.SetError(e_regSetFPU, Read,
+ ::thread_get_state(m_thread->MachPortNumber(), flavor,
+ (thread_state_t)&m_state.context.fpu,
+ &count));
+ DNBLogThreadedIf(LOG_THREAD,
+ "::thread_get_state (0x%4.4x, %u, &fpu, %u => 0x%8.8x",
+ m_thread->MachPortNumber(), flavor, (uint32_t)count,
+ m_state.GetError(e_regSetFPU, Read));
}
}
return m_state.GetError(e_regSetFPU, Read);
@@ -458,21 +411,17 @@ kern_return_t DNBArchImplX86_64::SetFPUState() {
m_state.SetError(e_regSetFPU, Write, 0);
return m_state.GetError(e_regSetFPU, Write);
} else {
+ int flavor = __x86_64_FLOAT_STATE;
+ mach_msg_type_number_t count = e_regSetWordSizeFPU;
if (CPUHasAVX() || FORCE_AVX_REGS) {
- m_state.SetError(
- e_regSetFPU, Write,
- ::thread_set_state(m_thread->MachPortNumber(), __x86_64_AVX_STATE,
- (thread_state_t)&m_state.context.fpu.avx,
- e_regSetWordSizeAVX));
- return m_state.GetError(e_regSetFPU, Write);
- } else {
- m_state.SetError(
- e_regSetFPU, Write,
- ::thread_set_state(m_thread->MachPortNumber(), __x86_64_FLOAT_STATE,
- (thread_state_t)&m_state.context.fpu.no_avx,
- e_regSetWordSizeFPU));
- return m_state.GetError(e_regSetFPU, Write);
+ flavor = __x86_64_AVX_STATE;
+ count = e_regSetWordSizeAVX;
}
+ m_state.SetError(
+ e_regSetFPU, Write,
+ ::thread_set_state(m_thread->MachPortNumber(), flavor,
+ (thread_state_t)&m_state.context.fpu, count));
+ return m_state.GetError(e_regSetFPU, Write);
}
}
@@ -1814,163 +1763,96 @@ bool DNBArchImplX86_64::GetRegisterValue(uint32_t set, uint32_t reg,
break;
case e_regSetFPU:
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- switch (reg) {
- case fpu_fcw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw));
- return true;
- case fpu_fsw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw));
- return true;
- case fpu_ftw:
- value->value.uint8 = m_state.context.fpu.avx.__fpu_ftw;
- return true;
- case fpu_fop:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_fop;
- return true;
- case fpu_ip:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_ip;
- return true;
- case fpu_cs:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_cs;
- return true;
- case fpu_dp:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_dp;
- return true;
- case fpu_ds:
- value->value.uint16 = m_state.context.fpu.avx.__fpu_ds;
- return true;
- case fpu_mxcsr:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsr;
- return true;
- case fpu_mxcsrmask:
- value->value.uint32 = m_state.context.fpu.avx.__fpu_mxcsrmask;
- return true;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- memcpy(&value->value.uint8,
- &m_state.context.fpu.avx.__fpu_stmm0 + (reg - fpu_stmm0), 10);
- return true;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- memcpy(&value->value.uint8,
- &m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_xmm0), 16);
- return true;
-
- case fpu_ymm0:
- case fpu_ymm1:
- case fpu_ymm2:
- case fpu_ymm3:
- case fpu_ymm4:
- case fpu_ymm5:
- case fpu_ymm6:
- case fpu_ymm7:
- case fpu_ymm8:
- case fpu_ymm9:
- case fpu_ymm10:
- case fpu_ymm11:
- case fpu_ymm12:
- case fpu_ymm13:
- case fpu_ymm14:
- case fpu_ymm15:
- memcpy(&value->value.uint8,
- &m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0), 16);
- memcpy((&value->value.uint8) + 16,
- &m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0), 16);
- return true;
- }
- } else {
- switch (reg) {
- case fpu_fcw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw));
- return true;
- case fpu_fsw:
- value->value.uint16 =
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw));
- return true;
- case fpu_ftw:
- value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw;
- return true;
- case fpu_fop:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop;
- return true;
- case fpu_ip:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip;
- return true;
- case fpu_cs:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs;
- return true;
- case fpu_dp:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp;
- return true;
- case fpu_ds:
- value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds;
- return true;
- case fpu_mxcsr:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr;
- return true;
- case fpu_mxcsrmask:
- value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask;
- return true;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- memcpy(&value->value.uint8,
- &m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0),
- 10);
- return true;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- memcpy(&value->value.uint8,
- &m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0), 16);
- return true;
- }
+ if (reg > fpu_xmm15 && !(CPUHasAVX() || FORCE_AVX_REGS))
+ return false;
+ switch (reg) {
+
+ case fpu_fcw:
+ value->value.uint16 =
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw));
+ return true;
+ case fpu_fsw:
+ value->value.uint16 =
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw));
+ return true;
+ case fpu_ftw:
+ value->value.uint8 = m_state.context.fpu.no_avx.__fpu_ftw;
+ return true;
+ case fpu_fop:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_fop;
+ return true;
+ case fpu_ip:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_ip;
+ return true;
+ case fpu_cs:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_cs;
+ return true;
+ case fpu_dp:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_dp;
+ return true;
+ case fpu_ds:
+ value->value.uint16 = m_state.context.fpu.no_avx.__fpu_ds;
+ return true;
+ case fpu_mxcsr:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsr;
+ return true;
+ case fpu_mxcsrmask:
+ value->value.uint32 = m_state.context.fpu.no_avx.__fpu_mxcsrmask;
+ return true;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ memcpy(&value->value.uint8,
+ &m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0), 10);
+ return true;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ case fpu_xmm8:
+ case fpu_xmm9:
+ case fpu_xmm10:
+ case fpu_xmm11:
+ case fpu_xmm12:
+ case fpu_xmm13:
+ case fpu_xmm14:
+ case fpu_xmm15:
+ memcpy(&value->value.uint8,
+ &m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0), 16);
+ return true;
+
+ case fpu_ymm0:
+ case fpu_ymm1:
+ case fpu_ymm2:
+ case fpu_ymm3:
+ case fpu_ymm4:
+ case fpu_ymm5:
+ case fpu_ymm6:
+ case fpu_ymm7:
+ case fpu_ymm8:
+ case fpu_ymm9:
+ case fpu_ymm10:
+ case fpu_ymm11:
+ case fpu_ymm12:
+ case fpu_ymm13:
+ case fpu_ymm14:
+ case fpu_ymm15:
+ memcpy(&value->value.uint8,
+ &m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0), 16);
+ memcpy((&value->value.uint8) + 16,
+ &m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0), 16);
+ return true;
}
break;
@@ -2035,188 +1917,108 @@ bool DNBArchImplX86_64::SetRegisterValue(uint32_t set, uint32_t reg,
success = true;
}
break;
-
+ if (reg > fpu_xmm15 && !(CPUHasAVX() || FORCE_AVX_REGS))
+ return false;
case e_regSetFPU:
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- switch (reg) {
- case fpu_fcw:
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fcw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_fsw:
- *((uint16_t *)(&m_state.context.fpu.avx.__fpu_fsw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_ftw:
- m_state.context.fpu.avx.__fpu_ftw = value->value.uint8;
- success = true;
- break;
- case fpu_fop:
- m_state.context.fpu.avx.__fpu_fop = value->value.uint16;
- success = true;
- break;
- case fpu_ip:
- m_state.context.fpu.avx.__fpu_ip = value->value.uint32;
- success = true;
- break;
- case fpu_cs:
- m_state.context.fpu.avx.__fpu_cs = value->value.uint16;
- success = true;
- break;
- case fpu_dp:
- m_state.context.fpu.avx.__fpu_dp = value->value.uint32;
- success = true;
- break;
- case fpu_ds:
- m_state.context.fpu.avx.__fpu_ds = value->value.uint16;
- success = true;
- break;
- case fpu_mxcsr:
- m_state.context.fpu.avx.__fpu_mxcsr = value->value.uint32;
- success = true;
- break;
- case fpu_mxcsrmask:
- m_state.context.fpu.avx.__fpu_mxcsrmask = value->value.uint32;
- success = true;
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- memcpy(&m_state.context.fpu.avx.__fpu_stmm0 + (reg - fpu_stmm0),
- &value->value.uint8, 10);
- success = true;
- break;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_xmm0),
- &value->value.uint8, 16);
- success = true;
- break;
-
- case fpu_ymm0:
- case fpu_ymm1:
- case fpu_ymm2:
- case fpu_ymm3:
- case fpu_ymm4:
- case fpu_ymm5:
- case fpu_ymm6:
- case fpu_ymm7:
- case fpu_ymm8:
- case fpu_ymm9:
- case fpu_ymm10:
- case fpu_ymm11:
- case fpu_ymm12:
- case fpu_ymm13:
- case fpu_ymm14:
- case fpu_ymm15:
- memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0),
- &value->value.uint8, 16);
- memcpy(&m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0),
- (&value->value.uint8) + 16, 16);
- return true;
- }
- } else {
- switch (reg) {
- case fpu_fcw:
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_fsw:
- *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) =
- value->value.uint16;
- success = true;
- break;
- case fpu_ftw:
- m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8;
- success = true;
- break;
- case fpu_fop:
- m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16;
- success = true;
- break;
- case fpu_ip:
- m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32;
- success = true;
- break;
- case fpu_cs:
- m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16;
- success = true;
- break;
- case fpu_dp:
- m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32;
- success = true;
- break;
- case fpu_ds:
- m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16;
- success = true;
- break;
- case fpu_mxcsr:
- m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32;
- success = true;
- break;
- case fpu_mxcsrmask:
- m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32;
- success = true;
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0),
- &value->value.uint8, 10);
- success = true;
- break;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- memcpy(&m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0),
- &value->value.uint8, 16);
- success = true;
- break;
- }
+ switch (reg) {
+ case fpu_fcw:
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fcw)) =
+ value->value.uint16;
+ success = true;
+ break;
+ case fpu_fsw:
+ *((uint16_t *)(&m_state.context.fpu.no_avx.__fpu_fsw)) =
+ value->value.uint16;
+ success = true;
+ break;
+ case fpu_ftw:
+ m_state.context.fpu.no_avx.__fpu_ftw = value->value.uint8;
+ success = true;
+ break;
+ case fpu_fop:
+ m_state.context.fpu.no_avx.__fpu_fop = value->value.uint16;
+ success = true;
+ break;
+ case fpu_ip:
+ m_state.context.fpu.no_avx.__fpu_ip = value->value.uint32;
+ success = true;
+ break;
+ case fpu_cs:
+ m_state.context.fpu.no_avx.__fpu_cs = value->value.uint16;
+ success = true;
+ break;
+ case fpu_dp:
+ m_state.context.fpu.no_avx.__fpu_dp = value->value.uint32;
+ success = true;
+ break;
+ case fpu_ds:
+ m_state.context.fpu.no_avx.__fpu_ds = value->value.uint16;
+ success = true;
+ break;
+ case fpu_mxcsr:
+ m_state.context.fpu.no_avx.__fpu_mxcsr = value->value.uint32;
+ success = true;
+ break;
+ case fpu_mxcsrmask:
+ m_state.context.fpu.no_avx.__fpu_mxcsrmask = value->value.uint32;
+ success = true;
+ break;
+
+ case fpu_stmm0:
+ case fpu_stmm1:
+ case fpu_stmm2:
+ case fpu_stmm3:
+ case fpu_stmm4:
+ case fpu_stmm5:
+ case fpu_stmm6:
+ case fpu_stmm7:
+ memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + (reg - fpu_stmm0),
+ &value->value.uint8, 10);
+ success = true;
+ break;
+
+ case fpu_xmm0:
+ case fpu_xmm1:
+ case fpu_xmm2:
+ case fpu_xmm3:
+ case fpu_xmm4:
+ case fpu_xmm5:
+ case fpu_xmm6:
+ case fpu_xmm7:
+ case fpu_xmm8:
+ case fpu_xmm9:
+ case fpu_xmm10:
+ case fpu_xmm11:
+ case fpu_xmm12:
+ case fpu_xmm13:
+ case fpu_xmm14:
+ case fpu_xmm15:
+ memcpy(&m_state.context.fpu.no_avx.__fpu_xmm0 + (reg - fpu_xmm0),
+ &value->value.uint8, 16);
+ success = true;
+ break;
+
+ case fpu_ymm0:
+ case fpu_ymm1:
+ case fpu_ymm2:
+ case fpu_ymm3:
+ case fpu_ymm4:
+ case fpu_ymm5:
+ case fpu_ymm6:
+ case fpu_ymm7:
+ case fpu_ymm8:
+ case fpu_ymm9:
+ case fpu_ymm10:
+ case fpu_ymm11:
+ case fpu_ymm12:
+ case fpu_ymm13:
+ case fpu_ymm14:
+ case fpu_ymm15:
+ memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + (reg - fpu_ymm0),
+ &value->value.uint8, 16);
+ memcpy(&m_state.context.fpu.avx.__fpu_ymmh0 + (reg - fpu_ymm0),
+ (&value->value.uint8) + 16, 16);
+ return true;
}
break;
@@ -2302,24 +2104,24 @@ nub_size_t DNBArchImplX86_64::GetRegisterContext(void *buf,
memcpy(p, &m_state.context.gpr, sizeof(GPR));
p += sizeof(GPR);
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- // Walk around the gaps in the FPU regs
- memcpy(p, &m_state.context.fpu.avx.__fpu_fcw, 5);
- p += 5;
- memcpy(p, &m_state.context.fpu.avx.__fpu_fop, 8);
- p += 8;
- memcpy(p, &m_state.context.fpu.avx.__fpu_dp, 6);
- p += 6;
- memcpy(p, &m_state.context.fpu.avx.__fpu_mxcsr, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(p, &m_state.context.fpu.avx.__fpu_stmm0 + i, 10);
- p += 10;
- }
+ // Walk around the gaps in the FPU regs
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_fcw, 5);
+ p += 5;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_fop, 8);
+ p += 8;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_dp, 6);
+ p += 6;
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_mxcsr, 8);
+ p += 8;
+
+ // Work around the padding between the stmm registers as they are 16
+ // byte structs with 10 bytes of the value in each
+ for (size_t i = 0; i < 8; ++i) {
+ memcpy(p, &m_state.context.fpu.no_avx.__fpu_stmm0 + i, 10);
+ p += 10;
+ }
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
// Interleave the XMM and YMMH registers to make the YMM registers
for (size_t i = 0; i < 16; ++i) {
memcpy(p, &m_state.context.fpu.avx.__fpu_xmm0 + i, 16);
@@ -2328,23 +2130,6 @@ nub_size_t DNBArchImplX86_64::GetRegisterContext(void *buf,
p += 16;
}
} else {
- // Walk around the gaps in the FPU regs
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_fcw, 5);
- p += 5;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_fop, 8);
- p += 8;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_dp, 6);
- p += 6;
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_mxcsr, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(p, &m_state.context.fpu.no_avx.__fpu_stmm0 + i, 10);
- p += 10;
- }
-
// Copy the XMM registers in a single block
memcpy(p, &m_state.context.fpu.no_avx.__fpu_xmm0, 16 * 16);
p += 16 * 16;
@@ -2384,24 +2169,24 @@ nub_size_t DNBArchImplX86_64::SetRegisterContext(const void *buf,
memcpy(&m_state.context.gpr, p, sizeof(GPR));
p += sizeof(GPR);
- if (CPUHasAVX() || FORCE_AVX_REGS) {
- // Walk around the gaps in the FPU regs
- memcpy(&m_state.context.fpu.avx.__fpu_fcw, p, 5);
- p += 5;
- memcpy(&m_state.context.fpu.avx.__fpu_fop, p, 8);
- p += 8;
- memcpy(&m_state.context.fpu.avx.__fpu_dp, p, 6);
- p += 6;
- memcpy(&m_state.context.fpu.avx.__fpu_mxcsr, p, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(&m_state.context.fpu.avx.__fpu_stmm0 + i, p, 10);
- p += 10;
- }
+ // Copy fcw through mxcsrmask as there is no padding
+ memcpy(&m_state.context.fpu.no_avx.__fpu_fcw, p, 5);
+ p += 5;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_fop, p, 8);
+ p += 8;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_dp, p, 6);
+ p += 6;
+ memcpy(&m_state.context.fpu.no_avx.__fpu_mxcsr, p, 8);
+ p += 8;
+
+ // Work around the padding between the stmm registers as they are 16
+ // byte structs with 10 bytes of the value in each
+ for (size_t i = 0; i < 8; ++i) {
+ memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + i, p, 10);
+ p += 10;
+ }
+ if (CPUHasAVX() || FORCE_AVX_REGS) {
// Interleave the XMM and YMMH registers to make the YMM registers
for (size_t i = 0; i < 16; ++i) {
memcpy(&m_state.context.fpu.avx.__fpu_xmm0 + i, p, 16);
@@ -2410,23 +2195,6 @@ nub_size_t DNBArchImplX86_64::SetRegisterContext(const void *buf,
p += 16;
}
} else {
- // Copy fcw through mxcsrmask as there is no padding
- memcpy(&m_state.context.fpu.no_avx.__fpu_fcw, p, 5);
- p += 5;
- memcpy(&m_state.context.fpu.no_avx.__fpu_fop, p, 8);
- p += 8;
- memcpy(&m_state.context.fpu.no_avx.__fpu_dp, p, 6);
- p += 6;
- memcpy(&m_state.context.fpu.no_avx.__fpu_mxcsr, p, 8);
- p += 8;
-
- // Work around the padding between the stmm registers as they are 16
- // byte structs with 10 bytes of the value in each
- for (size_t i = 0; i < 8; ++i) {
- memcpy(&m_state.context.fpu.no_avx.__fpu_stmm0 + i, p, 10);
- p += 10;
- }
-
// Copy the XMM registers in a single block
memcpy(&m_state.context.fpu.no_avx.__fpu_xmm0, p, 16 * 16);
p += 16 * 16;
diff --git a/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h b/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h
index 5ed67611e6ef..60e61262ab69 100644
--- a/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h
+++ b/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h
@@ -86,7 +86,7 @@ typedef struct {
typedef struct { uint8_t __xmm_reg[16]; } __x86_64_xmm_reg;
typedef struct {
- int32_t __fpu_reserved[2];
+ uint32_t __fpu_reserved[2];
__x86_64_fp_control_t __fpu_fcw;
__x86_64_fp_status_t __fpu_fsw;
uint8_t __fpu_ftw;
@@ -125,7 +125,7 @@ typedef struct {
__x86_64_xmm_reg __fpu_xmm14;
__x86_64_xmm_reg __fpu_xmm15;
uint8_t __fpu_rsrv4[6 * 16];
- int32_t __fpu_reserved1;
+ uint32_t __fpu_reserved1;
} __x86_64_float_state_t;
typedef struct {
diff --git a/tools/debugserver/source/RNBRemote.cpp b/tools/debugserver/source/RNBRemote.cpp
index 71c6f717cadf..4c1f27eb1cb8 100644
--- a/tools/debugserver/source/RNBRemote.cpp
+++ b/tools/debugserver/source/RNBRemote.cpp
@@ -3611,15 +3611,10 @@ rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
snprintf(buf, sizeof(buf), "qXfer:features:read+;PacketSize=%x;qEcho+",
max_packet_size);
- // By default, don't enable compression. It's only worth doing when we are
- // working
- // with a low speed communication channel.
bool enable_compression = false;
(void)enable_compression;
-// Enable compression when debugserver is running on a watchOS device where
-// communication may be over Bluetooth.
-#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
+#if (defined (TARGET_OS_WATCH) && TARGET_OS_WATCHOS == 1) || (defined (TARGET_OS_IOS) && TARGET_OS_IOS == 1) || (defined (TARGET_OS_TVOS) && TARGET_OS_TVOS == 1)
enable_compression = true;
#endif
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
index 73f065d4357d..6384d5a92c2c 100644
--- a/tools/driver/CMakeLists.txt
+++ b/tools/driver/CMakeLists.txt
@@ -1,8 +1,25 @@
include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
+ (CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
+ # These targets do not have getopt support, so they rely on the one provided by
+ # liblldb. However, getopt is not a part of the liblldb interface, so we have
+ # to link against the constituent libraries manually. Note that this is
+ # extremely scary as it introduces ODR violations, and it should go away as
+ # soon as possible.
+ set(host_lib lldbHost)
+endif()
+
add_lldb_tool(lldb
Driver.cpp
Platform.cpp
+
+ LINK_LIBS
+ liblldb
+ ${host_lib}
+
+ LINK_COMPONENTS
+ Support
)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
@@ -18,17 +35,3 @@ endif()
if ( LLDB_CAN_USE_DEBUGSERVER )
add_dependencies(lldb debugserver)
endif()
-
-target_link_libraries(lldb liblldb)
-if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
- (CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
- # These targets do not have getopt support, so they rely on the one provided by
- # liblldb. However, getopt is not a part of the liblldb interface, so we have
- # to link against the constituent libraries manually. Note that this is
- # extremely scary as it introduces ODR violations, and it should go away as
- # soon as possible.
- target_link_libraries(lldb ${LLDB_USED_LIBS})
-endif()
-
-set_target_properties(lldb PROPERTIES VERSION ${LLDB_VERSION})
-
diff --git a/tools/driver/Driver.h b/tools/driver/Driver.h
index e6cff5180df9..2be697ccc44c 100644
--- a/tools/driver/Driver.h
+++ b/tools/driver/Driver.h
@@ -11,7 +11,7 @@
#define lldb_Driver_h_
#include "Platform.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Host/PseudoTerminal.h"
#include <bitset>
#include <set>
diff --git a/tools/driver/Platform.h b/tools/driver/Platform.h
index 3af2e19cbc42..521c5a1ccbb5 100644
--- a/tools/driver/Platform.h
+++ b/tools/driver/Platform.h
@@ -15,7 +15,6 @@
#include "lldb/Host/HostGetOpt.h"
#include <io.h>
#if defined(_MSC_VER)
-#include <eh.h>
#include <signal.h>
#endif
#include "lldb/Host/windows/windows.h"
diff --git a/tools/intel-mpx/CMakeLists.txt b/tools/intel-mpx/CMakeLists.txt
new file mode 100644
index 000000000000..29ba9a1cacec
--- /dev/null
+++ b/tools/intel-mpx/CMakeLists.txt
@@ -0,0 +1,15 @@
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+ return ()
+endif ()
+
+include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake)
+
+add_library(lldb-intel-mpxtable SHARED
+ IntelMPXTablePlugin.cpp
+ )
+
+target_link_libraries(lldb-intel-mpxtable
+ PUBLIC liblldb LLVMSupport)
+
+install(TARGETS lldb-intel-mpxtable
+ LIBRARY DESTINATION bin)
diff --git a/tools/intel-mpx/IntelMPXTablePlugin.cpp b/tools/intel-mpx/IntelMPXTablePlugin.cpp
new file mode 100644
index 000000000000..0f86ce661def
--- /dev/null
+++ b/tools/intel-mpx/IntelMPXTablePlugin.cpp
@@ -0,0 +1,427 @@
+//===-- IntelMPXTablePlugin.cpp----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C++ includes
+#include <cerrno>
+#include <string>
+
+// Project includes
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+
+#include "llvm/ADT/Triple.h"
+
+namespace lldb {
+bool PluginInitialize(lldb::SBDebugger debugger);
+}
+
+static bool GetPtr(char *cptr, uint64_t &ptr, lldb::SBFrame &frame,
+ lldb::SBCommandReturnObject &result) {
+ if (!cptr) {
+ result.SetError("Bad argument.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::SBValue ptr_addr = frame.GetValueForVariablePath(cptr);
+ if (!ptr_addr.IsValid()) {
+ result.SetError("Invalid pointer.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+ ptr = ptr_addr.GetLoadAddress();
+ return true;
+}
+
+enum {
+ mpx_base_mask_64 = ~(uint64_t)0xFFFULL,
+ mpx_bd_mask_64 = 0xFFFFFFF00000ULL,
+ bd_r_shift_64 = 20,
+ bd_l_shift_64 = 3,
+ bt_r_shift_64 = 3,
+ bt_l_shift_64 = 5,
+ bt_mask_64 = 0x0000000FFFF8ULL,
+
+ mpx_base_mask_32 = 0xFFFFFFFFFFFFF000ULL,
+ mpx_bd_mask_32 = 0xFFFFF000ULL,
+ bd_r_shift_32 = 12,
+ bd_l_shift_32 = 2,
+ bt_r_shift_32 = 2,
+ bt_l_shift_32 = 4,
+ bt_mask_32 = 0x00000FFCULL,
+};
+
+static void PrintBTEntry(lldb::addr_t lbound, lldb::addr_t ubound,
+ uint64_t value, uint64_t meta,
+ lldb::SBCommandReturnObject &result) {
+ const lldb::addr_t one_cmpl64 = ~((lldb::addr_t)0);
+ const lldb::addr_t one_cmpl32 = ~((uint32_t)0);
+
+ if ((lbound == one_cmpl64 || one_cmpl32) && ubound == 0) {
+ result.Printf("Null bounds on map: pointer value = 0x%lx\n", value);
+ } else {
+ result.Printf(" lbound = 0x%lx,", lbound);
+ result.Printf(" ubound = 0x%lx", ubound);
+ result.Printf(" (pointer value = 0x%lx,", value);
+ result.Printf(" metadata = 0x%lx)\n", meta);
+ }
+}
+
+static bool GetBTEntryAddr(uint64_t bndcfgu, uint64_t ptr,
+ lldb::SBTarget &target, llvm::Triple::ArchType arch,
+ size_t &size, lldb::addr_t &bt_entry_addr,
+ lldb::SBCommandReturnObject &result,
+ lldb::SBError &error) {
+ lldb::addr_t mpx_base_mask;
+ lldb::addr_t mpx_bd_mask;
+ lldb::addr_t bd_r_shift;
+ lldb::addr_t bd_l_shift;
+ lldb::addr_t bt_r_shift;
+ lldb::addr_t bt_l_shift;
+ lldb::addr_t bt_mask;
+
+ if (arch == llvm::Triple::ArchType::x86_64) {
+ mpx_base_mask = mpx_base_mask_64;
+ mpx_bd_mask = mpx_bd_mask_64;
+ bd_r_shift = bd_r_shift_64;
+ bd_l_shift = bd_l_shift_64;
+ bt_r_shift = bt_r_shift_64;
+ bt_l_shift = bt_l_shift_64;
+ bt_mask = bt_mask_64;
+ } else if (arch == llvm::Triple::ArchType::x86) {
+ mpx_base_mask = mpx_base_mask_32;
+ mpx_bd_mask = mpx_bd_mask_32;
+ bd_r_shift = bd_r_shift_32;
+ bd_l_shift = bd_l_shift_32;
+ bt_r_shift = bt_r_shift_32;
+ bt_l_shift = bt_l_shift_32;
+ bt_mask = bt_mask_32;
+ } else {
+ result.SetError("Invalid arch.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ size = target.GetAddressByteSize();
+ lldb::addr_t mpx_bd_base = bndcfgu & mpx_base_mask;
+ lldb::addr_t bd_entry_offset = ((ptr & mpx_bd_mask) >> bd_r_shift)
+ << bd_l_shift;
+ lldb::addr_t bd_entry_addr = mpx_bd_base + bd_entry_offset;
+
+ std::vector<uint8_t> bd_entry_v(size);
+ size_t ret = target.GetProcess().ReadMemory(
+ bd_entry_addr, static_cast<void *>(bd_entry_v.data()), size, error);
+ if (ret != size || !error.Success()) {
+ result.SetError("Failed access to BD entry.");
+ return false;
+ }
+
+ lldb::SBData data;
+ data.SetData(error, bd_entry_v.data(), bd_entry_v.size(),
+ target.GetByteOrder(), size);
+ lldb::addr_t bd_entry = data.GetAddress(error, 0);
+
+ if (!error.Success()) {
+ result.SetError("Failed access to BD entry.");
+ return false;
+ }
+
+ if ((bd_entry & 0x01) == 0) {
+ result.SetError("Invalid bound directory.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ // Clear status bit.
+ //
+ bd_entry--;
+
+ lldb::addr_t bt_addr = bd_entry & ~bt_r_shift;
+ lldb::addr_t bt_entry_offset = ((ptr & bt_mask) >> bt_r_shift) << bt_l_shift;
+ bt_entry_addr = bt_addr + bt_entry_offset;
+
+ return true;
+}
+
+static bool GetBTEntry(uint64_t bndcfgu, uint64_t ptr, lldb::SBTarget &target,
+ llvm::Triple::ArchType arch,
+ lldb::SBCommandReturnObject &result,
+ lldb::SBError &error) {
+ lldb::addr_t bt_entry_addr;
+ size_t size;
+ if (!GetBTEntryAddr(bndcfgu, ptr, target, arch, size, bt_entry_addr, result,
+ error))
+ return false;
+
+ // bt_entry_v must have space to store the 4 elements of the BT entry (lower
+ // boundary,
+ // upper boundary, pointer value and meta data), which all have the same size
+ // 'size'.
+ //
+ std::vector<uint8_t> bt_entry_v(size * 4);
+ size_t ret = target.GetProcess().ReadMemory(
+ bt_entry_addr, static_cast<void *>(bt_entry_v.data()), size * 4, error);
+
+ if ((ret != (size * 4)) || !error.Success()) {
+ result.SetError("Unsuccessful. Failed access to BT entry.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::addr_t lbound;
+ lldb::addr_t ubound;
+ uint64_t value;
+ uint64_t meta;
+ lldb::SBData data;
+ data.SetData(error, bt_entry_v.data(), bt_entry_v.size(),
+ target.GetByteOrder(), size);
+ lbound = data.GetAddress(error, size * 0);
+ ubound = data.GetAddress(error, size * 1);
+ value = data.GetAddress(error, size * 2);
+ meta = data.GetAddress(error, size * 3);
+ // ubound is stored as one's complement.
+ if (arch == llvm::Triple::ArchType::x86) {
+ ubound = (~ubound) & 0x00000000FFFFFFFF;
+ } else {
+ ubound = ~ubound;
+ }
+
+ if (!error.Success()) {
+ result.SetError("Failed access to BT entry.");
+ return false;
+ }
+
+ PrintBTEntry(lbound, ubound, value, meta, result);
+
+ result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
+ return true;
+}
+
+static std::vector<uint8_t> uIntToU8(uint64_t input, size_t size) {
+ std::vector<uint8_t> output;
+ for (size_t i = 0; i < size; i++)
+ output.push_back(
+ static_cast<uint8_t>((input & (0xFFULL << (i * 8))) >> (i * 8)));
+
+ return output;
+}
+
+static bool SetBTEntry(uint64_t bndcfgu, uint64_t ptr, lldb::addr_t lbound,
+ lldb::addr_t ubound, lldb::SBTarget &target,
+ llvm::Triple::ArchType arch,
+ lldb::SBCommandReturnObject &result,
+ lldb::SBError &error) {
+ lldb::addr_t bt_entry_addr;
+ size_t size;
+
+ if (!GetBTEntryAddr(bndcfgu, ptr, target, arch, size, bt_entry_addr, result,
+ error))
+ return false;
+
+ // bt_entry_v must have space to store only 2 elements of the BT Entry, the
+ // lower boundary and the upper boundary, which both have size 'size'.
+ //
+ std::vector<uint8_t> bt_entry_v(size * 2);
+
+ std::vector<uint8_t> lbound_v = uIntToU8(lbound, size);
+ bt_entry_v.insert(bt_entry_v.begin(), lbound_v.begin(), lbound_v.end());
+ std::vector<uint8_t> ubound_v = uIntToU8(~ubound, size);
+ bt_entry_v.insert(bt_entry_v.begin() + size, ubound_v.begin(),
+ ubound_v.end());
+
+ size_t ret = target.GetProcess().WriteMemory(
+ bt_entry_addr, (void *)(bt_entry_v.data()), size * 2, error);
+ if ((ret != (size * 2)) || !error.Success()) {
+ result.SetError("Failed access to BT entry.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
+ return true;
+}
+
+static bool GetInitInfo(lldb::SBDebugger debugger, lldb::SBTarget &target,
+ llvm::Triple::ArchType &arch, uint64_t &bndcfgu,
+ char *arg, uint64_t &ptr,
+ lldb::SBCommandReturnObject &result,
+ lldb::SBError &error) {
+ target = debugger.GetSelectedTarget();
+ if (!target.IsValid()) {
+ result.SetError("Invalid target.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ const std::string triple_s(target.GetTriple());
+ const llvm::Triple triple(triple_s);
+
+ arch = triple.getArch();
+
+ if ((arch != llvm::Triple::ArchType::x86) &&
+ (arch != llvm::Triple::ArchType::x86_64)) {
+ result.SetError("Platform not supported.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::SBFrame frame =
+ target.GetProcess().GetSelectedThread().GetSelectedFrame();
+ if (!frame.IsValid()) {
+ result.SetError("No valid process, thread or frame.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::SBValue bndcfgu_val = frame.FindRegister("bndcfgu");
+ if (!bndcfgu_val.IsValid()) {
+ result.SetError(
+ "Cannot access register BNDCFGU. Does the target support MPX?");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::SBData bndcfgu_data = bndcfgu_val.GetData();
+ bndcfgu = bndcfgu_data.GetUnsignedInt64(error, 0);
+ if (!error.Success()) {
+ result.SetError(error, "Invalid read of register BNDCFGU.");
+ return false;
+ }
+
+ if (!GetPtr(arg, ptr, frame, result))
+ return false;
+
+ return true;
+}
+
+class MPXTableShow : public lldb::SBCommandPluginInterface {
+public:
+ virtual bool DoExecute(lldb::SBDebugger debugger, char **command,
+ lldb::SBCommandReturnObject &result) {
+
+ if (command) {
+ int arg_c = 0;
+ char *arg;
+
+ while (*command) {
+ if (arg_c >= 1) {
+ result.SetError("Too many arguments. See help.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+ arg_c++;
+ arg = *command;
+ command++;
+ }
+
+ if (!debugger.IsValid()) {
+ result.SetError("Invalid debugger.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+
+ lldb::SBTarget target;
+ llvm::Triple::ArchType arch;
+ lldb::SBError error;
+ uint64_t bndcfgu;
+ uint64_t ptr;
+
+ if (!GetInitInfo(debugger, target, arch, bndcfgu, arg, ptr, result,
+ error))
+ return false;
+
+ return GetBTEntry(bndcfgu, ptr, target, arch, result, error);
+ }
+
+ result.SetError("Too few arguments. See help.");
+ result.SetStatus(lldb::eReturnStatusFailed);
+ return false;
+ }
+};
+
+class MPXTableSet : public lldb::SBCommandPluginInterface {
+public:
+ virtual bool DoExecute(lldb::SBDebugger debugger, char **command,
+ lldb::SBCommandReturnObject &result) {
+
+ if (command) {
+ int arg_c = 0;
+ char *arg[3];
+
+ while (*command) {
+ arg[arg_c] = *command;
+ command++;
+ arg_c++;
+ }
+
+ if (arg_c != 3) {
+ result.SetError("Wrong arguments. See help.");
+ return false;
+ }
+
+ if (!debugger.IsValid()) {
+ result.SetError("Invalid debugger.");
+ return false;
+ }
+
+ lldb::SBTarget target;
+ llvm::Triple::ArchType arch;
+ lldb::SBError error;
+ uint64_t bndcfgu;
+ uint64_t ptr;
+
+ if (!GetInitInfo(debugger, target, arch, bndcfgu, arg[0], ptr, result,
+ error))
+ return false;
+
+ char *endptr;
+ errno = 0;
+ uint64_t lbound = std::strtoul(arg[1], &endptr, 16);
+ if (endptr == arg[1] || errno == ERANGE) {
+ result.SetError("Lower Bound: bad argument format.");
+ errno = 0;
+ return false;
+ }
+
+ uint64_t ubound = std::strtoul(arg[2], &endptr, 16);
+ if (endptr == arg[1] || errno == ERANGE) {
+ result.SetError("Upper Bound: bad argument format.");
+ errno = 0;
+ return false;
+ }
+
+ return SetBTEntry(bndcfgu, ptr, lbound, ubound, target, arch, result,
+ error);
+ }
+
+ result.SetError("Too few arguments. See help.");
+ return false;
+ }
+};
+
+bool lldb::PluginInitialize(lldb::SBDebugger debugger) {
+ lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
+ lldb::SBCommand mpxTable = interpreter.AddMultiwordCommand(
+ "mpx-table", "A utility to access the MPX table entries.");
+
+ const char *mpx_show_help = "Show the MPX table entry of a pointer.\n"
+ "mpx-table show <pointer>";
+ mpxTable.AddCommand("show", new MPXTableShow(), mpx_show_help);
+
+ const char *mpx_set_help =
+ "Set the MPX table entry of a pointer.\n"
+ "mpx-table set <pointer> <lower bound> <upper bound>";
+ mpxTable.AddCommand("set", new MPXTableSet(), mpx_set_help);
+
+ return true;
+}
diff --git a/tools/intel-mpx/test/Makefile b/tools/intel-mpx/test/Makefile
new file mode 100644
index 000000000000..b18044407a70
--- /dev/null
+++ b/tools/intel-mpx/test/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../../make
+
+CXX_SOURCES := main.cpp
+
+CFLAGS_EXTRAS += -mmpx -fcheck-pointer-bounds -lmpxwrappers -lmpx -fuse-ld=bfd
+
+include $(LEVEL)/Makefile.rules
diff --git a/tools/intel-mpx/test/README.txt b/tools/intel-mpx/test/README.txt
new file mode 100644
index 000000000000..314e78d3e0eb
--- /dev/null
+++ b/tools/intel-mpx/test/README.txt
@@ -0,0 +1,6 @@
+In order to run this test, create the following directory:
+
+ packages/Python/lldbsuite/test/functionalities/plugins/commands/mpxtablecmd
+
+and copy into it the contents of this direcotry.
+
diff --git a/tools/intel-mpx/test/TestMPXTable.py b/tools/intel-mpx/test/TestMPXTable.py
new file mode 100644
index 000000000000..f2468abd59a1
--- /dev/null
+++ b/tools/intel-mpx/test/TestMPXTable.py
@@ -0,0 +1,168 @@
+"""
+Test mpx-table command.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestMPXTable(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ @skipIf(compiler="clang")
+ @skipIf(oslist=no_match(['linux']))
+ @skipIf(archs=no_match(['i386', 'x86_64']))
+ @skipIf(compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
+ def test_show_command(self):
+ """Test 'mpx-table show' command"""
+ self.build()
+
+ lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+ lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+ plugin_file = os.path.join(lldb_lib_dir, "liblldb-intel-mpxtable.so")
+ if not os.path.isfile(plugin_file):
+ self.skipTest("Intel(R) mpx-table plugin missing.")
+ plugin_command = " "
+ seq = ("plugin", "load", plugin_file)
+ plugin_command = plugin_command.join(seq)
+ self.runCmd(plugin_command)
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.b1 = line_number('main.cpp', '// Break 1.')
+ self.b2 = line_number('main.cpp', '// Break 2.')
+ self.b3 = line_number('main.cpp', '// Break 3.')
+ self.b4 = line_number('main.cpp', '// Break 4.')
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b1, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b2, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b3, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b4, num_expected_locations=1)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ target = self.dbg.GetSelectedTarget()
+ process = target.GetProcess()
+
+ if (process.GetState() == lldb.eStateExited):
+ self.skipTest("Intel(R) MPX is not supported.")
+ else:
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 1."])
+
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 2."])
+
+ # Check that out of scope pointer cannot be reached.
+ #
+ self.expect("mpx-table show a",
+ substrs = ['Invalid pointer.'],
+ error = True)
+
+ self.expect("mpx-table show tmp",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 3."])
+
+ # Check that the pointer value is correctly updated.
+ #
+ self.expect("mpx-table show tmp",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x2',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ self.expect("continue", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 4."])
+
+ # After going back to main(), check that out of scope pointer cannot be
+ # reached.
+ #
+ self.expect("mpx-table show tmp",
+ substrs = ['Invalid pointer.'],
+ error = True)
+
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0x',
+ ', ubound = 0x',
+ '(pointer value = 0x',
+ ', metadata = 0x',
+ ')'],
+ error = False)
+
+ def test_set_command(self):
+ """Test 'mpx-table set' command"""
+ self.build()
+
+ lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"]
+ lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib")
+ plugin_file = os.path.join(lldb_lib_dir, "liblldb-intel-mpxtable.so")
+ if not os.path.isfile(plugin_file):
+ self.skipTest("Intel(R) mpx-table plugin missing.")
+ plugin_command = " "
+ seq = ("plugin", "load", plugin_file)
+ plugin_command = plugin_command.join(seq)
+ self.runCmd(plugin_command)
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.b1 = line_number('main.cpp', '// Break 1.')
+ lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.b1, num_expected_locations=1)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ target = self.dbg.GetSelectedTarget()
+ process = target.GetProcess()
+
+ if (process.GetState() == lldb.eStateExited):
+ self.skipTest("Intel(R) MPX is not supported.")
+ else:
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ["stop reason = breakpoint 1."])
+
+ # Check that the BT Entry doesn't already contain the test values.
+ #
+ self.expect("mpx-table show a", matching=False,
+ substrs = ['lbound = 0xcafecafe',
+ ', ubound = 0xbeefbeef'])
+
+ # Set the test values.
+ #
+ self.expect("mpx-table set a 0xcafecafe 0xbeefbeef", error = False)
+
+ # Verify that the test values have been correctly written in the BT
+ # entry.
+ #
+ self.expect("mpx-table show a",
+ substrs = ['lbound = 0xcafecafe',
+ ', ubound = 0xbeefbeef'],
+ error = False)
+
+
diff --git a/tools/intel-mpx/test/main.cpp b/tools/intel-mpx/test/main.cpp
new file mode 100644
index 000000000000..214332338d87
--- /dev/null
+++ b/tools/intel-mpx/test/main.cpp
@@ -0,0 +1,48 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+////
+//// The LLVM Compiler Infrastructure
+////
+//// This file is distributed under the University of Illinois Open Source
+//// License. See LICENSE.TXT for details.
+////
+////===----------------------------------------------------------------------===//
+//
+
+const int size = 5;
+
+#include <cstddef>
+#include <cstdlib>
+#include <sys/prctl.h>
+
+void func(int *ptr) {
+ int *tmp;
+
+#if defined __GNUC__ && !defined __INTEL_COMPILER
+ __builtin___bnd_store_ptr_bounds ((void**)&ptr, ptr);
+#endif
+ tmp = ptr + size - 1;
+#if defined __GNUC__ && !defined __INTEL_COMPILER
+ __builtin___bnd_store_ptr_bounds ((void**)&tmp, tmp);
+#endif
+ tmp = (int*)0x2; // Break 2.
+
+ return; // Break 3.
+}
+
+int
+main(int argc, char const *argv[])
+{
+ // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
+ if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
+ return -1;
+
+ int* a = (int *) calloc(size, sizeof(int));
+#if defined __GNUC__ && !defined __INTEL_COMPILER
+ __builtin___bnd_store_ptr_bounds ((void**)&a, a);
+#endif
+ func(a); // Break 1.
+
+ free(a); // Break 4.
+
+ return 0;
+}
diff --git a/tools/lldb-mi/CMakeLists.txt b/tools/lldb-mi/CMakeLists.txt
index f7e0581a451d..f3f4c0097efd 100644
--- a/tools/lldb-mi/CMakeLists.txt
+++ b/tools/lldb-mi/CMakeLists.txt
@@ -1,4 +1,16 @@
-set(LLDB_MI_SOURCES
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
+ add_definitions( -DIMPORT_LIBLLDB )
+ list(APPEND extra_libs lldbHost)
+endif ()
+
+if (HAVE_LIBPTHREAD)
+ list(APPEND extra_libs pthread)
+endif ()
+
+# We need to include the llvm components we depend on manually, as liblldb does
+# not re-export those.
+set(LLVM_LINK_COMPONENTS Support)
+add_lldb_tool(lldb-mi
MICmdArgContext.cpp
MICmdArgSet.cpp
MICmdArgValBase.cpp
@@ -72,23 +84,12 @@ set(LLDB_MI_SOURCES
MIUtilString.cpp
MIUtilThreadBaseStd.cpp
MIUtilVariant.cpp
- )
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
- add_definitions( -DIMPORT_LIBLLDB )
- list(APPEND LLDB_MI_SOURCES
- ${LLDB_SOURCE_ROOT}/Host/common/GetOptInc.cpp
- )
-endif ()
+ LINK_LIBS
+ liblldb
+ ${host_lib}
+ ${extra_libs}
-# We need to include the llvm components we depend on manually, as liblldb does
-# not re-export those.
-set(LLVM_LINK_COMPONENTS Support)
-add_lldb_tool(lldb-mi ${LLDB_MI_SOURCES})
-
-target_link_libraries(lldb-mi liblldb)
-if (HAVE_LIBPTHREAD)
- target_link_libraries(lldb-mi pthread)
-endif ()
-
-set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION})
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/tools/lldb-mi/MICmdCmdStack.cpp b/tools/lldb-mi/MICmdCmdStack.cpp
index 9160c401094a..b491027bf80e 100644
--- a/tools/lldb-mi/MICmdCmdStack.cpp
+++ b/tools/lldb-mi/MICmdCmdStack.cpp
@@ -32,6 +32,8 @@
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
+#include <algorithm>
+
//++
//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackInfoDepth constructor.
@@ -757,7 +759,8 @@ bool CMICmdCmdStackListLocals::Execute() {
: thread.GetSelectedFrame();
CMICmnMIValueList miValueList(true);
- const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Locals;
+ const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Locals |
+ CMICmnLLDBDebugSessionInfo::eVariableType_InScope;
if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes,
eVarInfoFormat, miValueList))
return MIstatus::failure;
@@ -929,7 +932,8 @@ bool CMICmdCmdStackListVariables::Execute() {
CMICmnMIValueList miValueList(true);
const MIuint maskVarTypes =
CMICmnLLDBDebugSessionInfo::eVariableType_Arguments |
- CMICmnLLDBDebugSessionInfo::eVariableType_Locals;
+ CMICmnLLDBDebugSessionInfo::eVariableType_Locals |
+ CMICmnLLDBDebugSessionInfo::eVariableType_InScope;
if (!rSessionInfo.MIResponseFormVariableInfo(
frame, maskVarTypes, eVarInfoFormat, miValueList, 10, true))
return MIstatus::failure;
diff --git a/tools/lldb-mi/MICmdCmdVar.cpp b/tools/lldb-mi/MICmdCmdVar.cpp
index 1efbd0b31e75..3396b7231c5c 100644
--- a/tools/lldb-mi/MICmdCmdVar.cpp
+++ b/tools/lldb-mi/MICmdCmdVar.cpp
@@ -38,6 +38,8 @@
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
+#include <algorithm>
+
//++
//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarCreate constructor.
@@ -182,7 +184,7 @@ bool CMICmdCmdVarCreate::Execute() {
const bool bArgs = true;
const bool bLocals = true;
const bool bStatics = true;
- const bool bInScopeOnly = false;
+ const bool bInScopeOnly = true;
const lldb::SBValueList valueList =
frame.GetVariables(bArgs, bLocals, bStatics, bInScopeOnly);
value = valueList.GetFirstValueByName(rStrExpression.c_str());
diff --git a/tools/lldb-mi/MICmnBase.cpp b/tools/lldb-mi/MICmnBase.cpp
index 52100e79c781..63544dc5b9c7 100644
--- a/tools/lldb-mi/MICmnBase.cpp
+++ b/tools/lldb-mi/MICmnBase.cpp
@@ -122,7 +122,7 @@ void CMICmnBase::ClrErrorDescription() const {
// Return: None.
// Throws: None.
//--
-void CMICmnBase::SetErrorDescriptionn(const CMIUtilString vFormat, ...) const {
+void CMICmnBase::SetErrorDescriptionn(const char *vFormat, ...) const {
va_list args;
va_start(args, vFormat);
CMIUtilString strResult = CMIUtilString::FormatValist(vFormat, args);
diff --git a/tools/lldb-mi/MICmnBase.h b/tools/lldb-mi/MICmnBase.h
index f739493cc210..2b604638b2dc 100644
--- a/tools/lldb-mi/MICmnBase.h
+++ b/tools/lldb-mi/MICmnBase.h
@@ -28,7 +28,7 @@ public:
bool HaveErrorDescription() const;
const CMIUtilString &GetErrorDescription() const;
void SetErrorDescription(const CMIUtilString &vrTxt) const;
- void SetErrorDescriptionn(const CMIUtilString vFormat, ...) const;
+ void SetErrorDescriptionn(const char *vFormat, ...) const;
void SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const;
void ClrErrorDescription() const;
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index e975dd6525e5..a61244f92fc2 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -40,6 +40,8 @@
#include "MIUtilDebug.h"
#include "Platform.h" // for PATH_MAX
+#include <algorithm>
+
//++
//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebuggerHandleEvents constructor.
diff --git a/tools/lldb-mi/MIDriver.cpp b/tools/lldb-mi/MIDriver.cpp
index eec37382cbfb..ea8b57297dda 100644
--- a/tools/lldb-mi/MIDriver.cpp
+++ b/tools/lldb-mi/MIDriver.cpp
@@ -509,7 +509,7 @@ bool CMIDriver::StartWorkerThreads() {
const CMIUtilString errMsg = CMIUtilString::Format(
MIRSRC(IDS_THREADMGR_ERR_THREAD_FAIL_CREATE),
CMICmnThreadMgrStd::Instance().GetErrorDescription().c_str());
- SetErrorDescriptionn(errMsg);
+ SetErrorDescription(errMsg);
return MIstatus::failure;
}
diff --git a/tools/lldb-mi/MIUtilString.cpp b/tools/lldb-mi/MIUtilString.cpp
index 3e6911f68189..45196a70398d 100644
--- a/tools/lldb-mi/MIUtilString.cpp
+++ b/tools/lldb-mi/MIUtilString.cpp
@@ -157,7 +157,7 @@ CMIUtilString CMIUtilString::FormatPriv(const CMIUtilString &vrFormat,
// Return: CMIUtilString - Number of splits found in the string data.
// Throws: None.
//--
-CMIUtilString CMIUtilString::Format(const CMIUtilString vFormating, ...) {
+CMIUtilString CMIUtilString::Format(const char *vFormating, ...) {
va_list args;
va_start(args, vFormating);
CMIUtilString strResult = CMIUtilString::FormatPriv(vFormating, args);
diff --git a/tools/lldb-mi/MIUtilString.h b/tools/lldb-mi/MIUtilString.h
index 3b077722f9a9..2639141d0fb2 100644
--- a/tools/lldb-mi/MIUtilString.h
+++ b/tools/lldb-mi/MIUtilString.h
@@ -30,7 +30,7 @@ public:
// Static method:
public:
- static CMIUtilString Format(const CMIUtilString vFormating, ...);
+ static CMIUtilString Format(const char *vFormating, ...);
static CMIUtilString FormatBinary(const MIuint64 vnDecimal);
static CMIUtilString FormatValist(const CMIUtilString &vrFormating,
va_list vArgs);
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.h b/tools/lldb-mi/MIUtilThreadBaseStd.h
index cfff7d459b42..20b8fad9947a 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.h
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.h
@@ -10,9 +10,6 @@
#pragma once
// Third party headers:
-#ifdef _MSC_VER
-#include <eh.h>
-#endif // _MSC_VER
#include <mutex>
#include <thread>
diff --git a/tools/lldb-mi/Platform.h b/tools/lldb-mi/Platform.h
index 1b6ff5549925..ce2de1b6e97d 100644
--- a/tools/lldb-mi/Platform.h
+++ b/tools/lldb-mi/Platform.h
@@ -10,7 +10,6 @@
#if defined(_MSC_VER)
-#include <eh.h>
#include <inttypes.h>
#include <io.h>
#include <signal.h>
diff --git a/tools/lldb-server/Acceptor.cpp b/tools/lldb-server/Acceptor.cpp
index 00a0bda175fb..e6e73f8bdb6b 100644
--- a/tools/lldb-server/Acceptor.cpp
+++ b/tools/lldb-server/Acceptor.cpp
@@ -12,11 +12,10 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ScopedPrinter.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/common/TCPSocket.h"
-
-#include "Utility/UriParser.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/tools/lldb-server/Acceptor.h b/tools/lldb-server/Acceptor.h
index f0638ef1ae69..410970915f1f 100644
--- a/tools/lldb-server/Acceptor.h
+++ b/tools/lldb-server/Acceptor.h
@@ -10,8 +10,8 @@
#define lldb_server_Acceptor_h_
#include "lldb/Core/Connection.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/Socket.h"
+#include "lldb/Utility/Error.h"
#include <functional>
#include <memory>
diff --git a/tools/lldb-server/CMakeLists.txt b/tools/lldb-server/CMakeLists.txt
index c3b405f67b2e..4f76ebd6881c 100644
--- a/tools/lldb-server/CMakeLists.txt
+++ b/tools/lldb-server/CMakeLists.txt
@@ -17,96 +17,13 @@ endif ()
if ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
include_directories(
../../../../llvm/include
+ ../../source/Plugins/Process/NetBSD
../../source/Plugins/Process/POSIX
)
endif ()
include_directories(../../source)
-
-set( LLDB_USED_LIBS
- lldbBase
- lldbBreakpoint
- lldbCommands
- lldbDataFormatters
- lldbHost
- lldbCore
- lldbExpression
- lldbInitialization
- lldbInterpreter
- lldbSymbol
- lldbTarget
- lldbUtility
-
- # Plugins
- lldbPluginDisassemblerLLVM
- lldbPluginSymbolFileDWARF
- lldbPluginSymbolFilePDB
- lldbPluginSymbolFileSymtab
- lldbPluginDynamicLoaderPosixDYLD
-
- lldbPluginCPlusPlusLanguage
- lldbPluginGoLanguage
- lldbPluginJavaLanguage
- lldbPluginObjCLanguage
- lldbPluginObjCPlusPlusLanguage
- lldbPluginOCamlLanguage
-
- lldbPluginObjectFileELF
- lldbPluginObjectFileJIT
- lldbPluginSymbolVendorELF
- lldbPluginPlatformPOSIX
- lldbPluginObjectContainerBSDArchive
- lldbPluginObjectContainerMachOArchive
- lldbPluginProcessGDBRemote
- lldbPluginProcessUtility
- lldbPluginObjectContainerMachOArchive
- lldbPluginObjectContainerBSDArchive
- lldbPluginPlatformMacOSX
- lldbPluginUnwindAssemblyInstEmulation
- lldbPluginUnwindAssemblyX86
- lldbPluginAppleObjCRuntime
- lldbPluginCXXItaniumABI
- lldbPluginInstructionARM
- lldbPluginInstructionARM64
- lldbPluginInstructionMIPS
- lldbPluginInstructionMIPS64
- lldbPluginObjectFilePECOFF
- lldbPluginExpressionParserClang
- lldbPluginExpressionParserGo
- )
-
-# Linux-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginProcessLinux
- lldbPluginProcessPOSIX
- )
-endif ()
-
-# Darwin-only libraries
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
- list(APPEND LLDB_USED_LIBS
- lldbPluginObjectFileMachO
- )
-endif()
-
-set( CLANG_USED_LIBS
- clangAnalysis
- clangAST
- clangBasic
- clangCodeGen
- clangDriver
- clangEdit
- clangFrontend
- clangLex
- clangParse
- clangRewrite
- clangRewriteFrontend
- clangSema
- clangSerialization
- )
-
set(LLDB_SYSTEM_LIBS)
if (NOT LLDB_DISABLE_LIBEDIT)
list(APPEND LLDB_SYSTEM_LIBS edit)
@@ -142,55 +59,24 @@ if (LLVM_BUILD_STATIC)
endif()
endif()
-set(LLVM_LINK_COMPONENTS
- ${LLVM_TARGETS_TO_BUILD}
- interpreter
- asmparser
- bitreader
- bitwriter
- codegen
- demangle
- ipo
- selectiondag
- bitreader
- mc
- mcjit
- core
- mcdisassembler
- executionengine
- runtimedyld
- option
- support
- coverage
- target
- )
-
add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
Acceptor.cpp
lldb-gdbserver.cpp
lldb-platform.cpp
lldb-server.cpp
LLDBServerUtilities.cpp
-)
-# The Darwin linker doesn't understand --start-group/--end-group.
-if (LLDB_LINKER_SUPPORTS_GROUPS)
- target_link_libraries(lldb-server
- -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
- target_link_libraries(lldb-server
- -Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group)
-else()
- target_link_libraries(lldb-server ${LLDB_USED_LIBS})
- target_link_libraries(lldb-server ${CLANG_USED_LIBS})
-endif()
-if(NOT LLVM_LINK_LLVM_DYLIB)
- # This is necessary in !LLVM_LINK_LLVM_DYLIB as LLDB's libs do not track their
- # dependencies properly. It is conditional because in a LLVM_LINK_LLVM_DYLIB
- # build it would introduce duplicate symbols (add_lldb_tool links to libLLVM,
- # and this would add the individual .a files as well).
- llvm_config(lldb-server ${LLVM_LINK_COMPONENTS})
-endif()
+ LINK_LIBS
+ lldbBase
+ lldbCore
+ lldbHost
+ lldbInitialization
+ lldbInterpreter
+ ${EXTRA_LLDB_LIBS}
+ ${LLDB_SYSTEM_LIBS}
+
+ LINK_COMPONENTS
+ Support
+)
target_link_libraries(lldb-server ${LLDB_SYSTEM_LIBS})
-
-set_target_properties(lldb-server PROPERTIES VERSION ${LLDB_VERSION})
diff --git a/tools/lldb-server/LLDBServerUtilities.cpp b/tools/lldb-server/LLDBServerUtilities.cpp
index 86d8469933e7..e784a3a82684 100644
--- a/tools/lldb-server/LLDBServerUtilities.cpp
+++ b/tools/lldb-server/LLDBServerUtilities.cpp
@@ -9,47 +9,55 @@
#include "LLDBServerUtilities.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private::lldb_server;
using namespace llvm;
+static std::shared_ptr<raw_ostream> GetLogStream(StringRef log_file) {
+ if (!log_file.empty()) {
+ std::error_code EC;
+ std::shared_ptr<raw_ostream> stream_sp = std::make_shared<raw_fd_ostream>(
+ log_file, EC, sys::fs::F_Text | sys::fs::F_Append);
+ if (!EC)
+ return stream_sp;
+ errs() << llvm::formatv(
+ "Failed to open log file `{0}`: {1}\nWill log to stderr instead.\n",
+ log_file, EC.message());
+ }
+ // No need to delete the stderr stream.
+ return std::shared_ptr<raw_ostream>(&errs(), [](raw_ostream *) {});
+}
+
bool LLDBServerUtilities::SetupLogging(const std::string &log_file,
const StringRef &log_channels,
uint32_t log_options) {
- lldb::StreamSP log_stream_sp;
- if (log_file.empty()) {
- log_stream_sp.reset(new StreamFile(stdout, false));
- } else {
- uint32_t options = File::eOpenOptionWrite | File::eOpenOptionCanCreate |
- File::eOpenOptionCloseOnExec | File::eOpenOptionAppend;
- if (!(log_options & LLDB_LOG_OPTION_APPEND))
- options |= File::eOpenOptionTruncate;
-
- log_stream_sp.reset(new StreamFile(log_file.c_str(), options));
- }
+
+ auto log_stream_sp = GetLogStream(log_file);
SmallVector<StringRef, 32> channel_array;
log_channels.split(channel_array, ":", /*MaxSplit*/ -1, /*KeepEmpty*/ false);
for (auto channel_with_categories : channel_array) {
- StreamString error_stream;
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
Args channel_then_categories(channel_with_categories);
std::string channel(channel_then_categories.GetArgumentAtIndex(0));
channel_then_categories.Shift(); // Shift off the channel
bool success = Log::EnableLogChannel(
- log_stream_sp, log_options, channel.c_str(),
- channel_then_categories.GetConstArgumentVector(), error_stream);
+ log_stream_sp, log_options, channel,
+ channel_then_categories.GetArgumentArrayRef(), error_stream);
if (!success) {
- fprintf(stderr, "Unable to open log file '%s' for channel \"%s\"\n",
- log_file.c_str(), channel_with_categories.str().c_str());
+ errs() << formatv("Unable to setup logging for channel \"{0}\": {1}",
+ channel, error_stream.str());
return false;
}
}
diff --git a/tools/lldb-server/lldb-gdbserver.cpp b/tools/lldb-server/lldb-gdbserver.cpp
index 5a388722b3c2..59f5a44ce4e3 100644
--- a/tools/lldb-server/lldb-gdbserver.cpp
+++ b/tools/lldb-server/lldb-gdbserver.cpp
@@ -28,7 +28,6 @@
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/HostGetOpt.h"
@@ -36,6 +35,7 @@
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/Error.h"
#ifndef LLGS_PROGRAM_NAME
#define LLGS_PROGRAM_NAME "lldb-server"
@@ -424,11 +424,13 @@ int main_gdbserver(int argc, char *argv[]) {
exit(option_error);
}
- if (!LLDBServerUtilities::SetupLogging(log_file, log_channels,
- LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
+ if (!LLDBServerUtilities::SetupLogging(
+ log_file, log_channels,
+ LLDB_LOG_OPTION_PREPEND_TIMESTAMP |
+ LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION))
return -1;
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(GDBR_LOG_VERBOSE));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(GDBR_LOG_PROCESS));
if (log) {
log->Printf("lldb-server launch");
for (int i = 0; i < argc; i++) {
diff --git a/tools/lldb-server/lldb-platform.cpp b/tools/lldb-server/lldb-platform.cpp
index 1772921b0faf..d9790cdf43a0 100644
--- a/tools/lldb-server/lldb-platform.cpp
+++ b/tools/lldb-server/lldb-platform.cpp
@@ -30,13 +30,12 @@
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
using namespace lldb;
using namespace lldb_private;
@@ -102,29 +101,30 @@ static void display_usage(const char *progname, const char *subcommand) {
static Error save_socket_id_to_file(const std::string &socket_id,
const FileSpec &file_spec) {
FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false);
- auto error = FileSystem::MakeDirectory(temp_file_spec,
- eFilePermissionsDirectoryDefault);
+ Error error(llvm::sys::fs::create_directory(temp_file_spec.GetPath()));
if (error.Fail())
return Error("Failed to create directory %s: %s",
temp_file_spec.GetCString(), error.AsCString());
- llvm::SmallString<PATH_MAX> temp_file_path;
+ llvm::SmallString<64> temp_file_path;
temp_file_spec.AppendPathComponent("port-file.%%%%%%");
- auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetCString(),
+ int FD;
+ auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetPath(), FD,
temp_file_path);
if (err_code)
return Error("Failed to create temp file: %s", err_code.message().c_str());
- llvm::FileRemover tmp_file_remover(temp_file_path.c_str());
+ llvm::FileRemover tmp_file_remover(temp_file_path);
{
- std::ofstream temp_file(temp_file_path.c_str(), std::ios::out);
- if (!temp_file.is_open())
- return Error("Failed to open temp file %s", temp_file_path.c_str());
+ llvm::raw_fd_ostream temp_file(FD, true);
temp_file << socket_id;
+ temp_file.close();
+ if (temp_file.has_error())
+ return Error("Failed to write to port file.");
}
- err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath());
+ err_code = llvm::sys::fs::rename(temp_file_path, file_spec.GetPath());
if (err_code)
return Error("Failed to rename file %s to %s: %s", temp_file_path.c_str(),
file_spec.GetPath().c_str(), err_code.message().c_str());
diff --git a/unittests/Breakpoint/BreakpointIDTest.cpp b/unittests/Breakpoint/BreakpointIDTest.cpp
index a449d40a335a..a84fa5439527 100644
--- a/unittests/Breakpoint/BreakpointIDTest.cpp
+++ b/unittests/Breakpoint/BreakpointIDTest.cpp
@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include "lldb/Breakpoint/BreakpointID.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/StringRef.h"
diff --git a/unittests/Breakpoint/CMakeLists.txt b/unittests/Breakpoint/CMakeLists.txt
index ca1c282aaa66..e3715e55f0d7 100644
--- a/unittests/Breakpoint/CMakeLists.txt
+++ b/unittests/Breakpoint/CMakeLists.txt
@@ -1,3 +1,9 @@
add_lldb_unittest(LLDBBreakpointTests
BreakpointIDTest.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ LINK_COMPONENTS
+ Support
)
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index a865dbe244f8..f4c735e78e34 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -2,6 +2,7 @@ add_custom_target(LLDBUnitTests)
set_target_properties(LLDBUnitTests PROPERTIES FOLDER "LLDB tests")
include_directories(${LLDB_SOURCE_ROOT})
+include_directories(${LLDB_PROJECT_ROOT})
set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/gtest_common.h)
if (MSVC)
@@ -21,9 +22,17 @@ if (LLDB_BUILT_STANDALONE)
endif()
function(add_lldb_unittest test_name)
+ cmake_parse_arguments(ARG
+ ""
+ ""
+ "LINK_LIBS;LINK_COMPONENTS"
+ ${ARGN})
+
+ list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
+
add_unittest(LLDBUnitTests
${test_name}
- ${ARGN}
+ ${ARG_UNPARSED_ARGUMENTS}
)
add_custom_command(
@@ -31,9 +40,7 @@ function(add_lldb_unittest test_name)
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
- lldb_link_common_libs(${test_name} EXE)
- target_link_libraries(${test_name} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
- llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})
+ target_link_libraries(${test_name} ${ARG_LINK_LIBS} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
endfunction()
function(add_unittest_inputs test_name inputs)
@@ -53,10 +60,17 @@ add_subdirectory(Expression)
add_subdirectory(Host)
add_subdirectory(Interpreter)
add_subdirectory(Language)
+add_subdirectory(ObjectFile)
add_subdirectory(Platform)
add_subdirectory(Process)
add_subdirectory(ScriptInterpreter)
+add_subdirectory(Signals)
add_subdirectory(Symbol)
add_subdirectory(SymbolFile)
+add_subdirectory(Target)
add_subdirectory(UnwindAssembly)
add_subdirectory(Utility)
+
+if(LLDB_CAN_USE_DEBUGSERVER)
+ add_subdirectory(debugserver)
+endif() \ No newline at end of file
diff --git a/unittests/Core/BroadcasterTest.cpp b/unittests/Core/BroadcasterTest.cpp
index e3795822f9ac..1613d0806009 100644
--- a/unittests/Core/BroadcasterTest.cpp
+++ b/unittests/Core/BroadcasterTest.cpp
@@ -10,6 +10,7 @@
#include "gtest/gtest.h"
#include "lldb/Core/Broadcaster.h"
+#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/Predicate.h"
diff --git a/unittests/Core/CMakeLists.txt b/unittests/Core/CMakeLists.txt
index 980bc5b9f9ae..73dd0d83fee3 100644
--- a/unittests/Core/CMakeLists.txt
+++ b/unittests/Core/CMakeLists.txt
@@ -2,9 +2,16 @@ add_lldb_unittest(LLDBCoreTests
ArchSpecTest.cpp
BroadcasterTest.cpp
DataExtractorTest.cpp
- ErrorTest.cpp
ListenerTest.cpp
ScalarTest.cpp
+ StateTest.cpp
+ StreamCallbackTest.cpp
StructuredDataTest.cpp
TimerTest.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ LINK_COMPONENTS
+ Support
)
diff --git a/unittests/Core/DataExtractorTest.cpp b/unittests/Core/DataExtractorTest.cpp
index d474e21dc0c3..213d5a7b43fd 100644
--- a/unittests/Core/DataExtractorTest.cpp
+++ b/unittests/Core/DataExtractorTest.cpp
@@ -7,16 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
-
#include "gtest/gtest.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataExtractor.h"
using namespace lldb_private;
diff --git a/unittests/Core/ScalarTest.cpp b/unittests/Core/ScalarTest.cpp
index b79854f97ae3..3c4995c49086 100644
--- a/unittests/Core/ScalarTest.cpp
+++ b/unittests/Core/ScalarTest.cpp
@@ -7,20 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
-
#include "gtest/gtest.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
diff --git a/unittests/Core/StateTest.cpp b/unittests/Core/StateTest.cpp
new file mode 100644
index 000000000000..76cdaac82055
--- /dev/null
+++ b/unittests/Core/StateTest.cpp
@@ -0,0 +1,21 @@
+//===-- StateTest.cpp -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/State.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(StateTest, Formatv) {
+ EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str());
+ EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str());
+ EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str());
+}
diff --git a/unittests/Core/StreamCallbackTest.cpp b/unittests/Core/StreamCallbackTest.cpp
new file mode 100644
index 000000000000..d3ccd0211a4e
--- /dev/null
+++ b/unittests/Core/StreamCallbackTest.cpp
@@ -0,0 +1,28 @@
+//===-- StreamCallbackTest.cpp ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/StreamCallback.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static char test_baton;
+static size_t callback_count = 0;
+static void TestCallback(const char *data, void *baton) {
+ EXPECT_STREQ("Foobar", data);
+ EXPECT_EQ(&test_baton, baton);
+ ++callback_count;
+}
+
+TEST(StreamCallbackTest, Callback) {
+ StreamCallback stream(TestCallback, &test_baton);
+ stream << "Foobar";
+ EXPECT_EQ(1u, callback_count);
+}
diff --git a/unittests/Core/StructuredDataTest.cpp b/unittests/Core/StructuredDataTest.cpp
index 8e10d571fbfa..cac330304179 100644
--- a/unittests/Core/StructuredDataTest.cpp
+++ b/unittests/Core/StructuredDataTest.cpp
@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/Support/MachO.h"
diff --git a/unittests/Core/TimerTest.cpp b/unittests/Core/TimerTest.cpp
index d37d281f61af..7e7eeef0a361 100644
--- a/unittests/Core/TimerTest.cpp
+++ b/unittests/Core/TimerTest.cpp
@@ -7,16 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when exceptions are disabled.
-#include <eh.h>
-#endif
-
#include "lldb/Core/Timer.h"
#include "gtest/gtest.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/StreamString.h"
#include <thread>
using namespace lldb_private;
diff --git a/unittests/Editline/CMakeLists.txt b/unittests/Editline/CMakeLists.txt
index eaa21c490d98..4f656f6cc350 100644
--- a/unittests/Editline/CMakeLists.txt
+++ b/unittests/Editline/CMakeLists.txt
@@ -1,3 +1,8 @@
add_lldb_unittest(EditlineTests
EditlineTest.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbUtility
)
diff --git a/unittests/Editline/EditlineTest.cpp b/unittests/Editline/EditlineTest.cpp
index 55dae525ddc3..f4976a348198 100644
--- a/unittests/Editline/EditlineTest.cpp
+++ b/unittests/Editline/EditlineTest.cpp
@@ -19,11 +19,11 @@
#include "gtest/gtest.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Host/Editline.h"
#include "lldb/Host/Pipe.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Host/PseudoTerminal.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StringList.h"
namespace {
const size_t TIMEOUT_MILLIS = 5000;
diff --git a/unittests/Expression/CMakeLists.txt b/unittests/Expression/CMakeLists.txt
index 04bad141170b..c0a701da4f3d 100644
--- a/unittests/Expression/CMakeLists.txt
+++ b/unittests/Expression/CMakeLists.txt
@@ -1,3 +1,7 @@
add_lldb_unittest(ExpressionTests
GoParserTest.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbPluginExpressionParserGo
)
diff --git a/unittests/Expression/GoParserTest.cpp b/unittests/Expression/GoParserTest.cpp
index de489e43ef22..710dc5e4e86f 100644
--- a/unittests/Expression/GoParserTest.cpp
+++ b/unittests/Expression/GoParserTest.cpp
@@ -8,19 +8,12 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
-
#include <sstream>
#include "gtest/gtest.h"
#include "Plugins/ExpressionParser/Go/GoParser.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
using namespace lldb_private;
diff --git a/unittests/Host/CMakeLists.txt b/unittests/Host/CMakeLists.txt
index 4c20f820e3c8..3396f45da4f3 100644
--- a/unittests/Host/CMakeLists.txt
+++ b/unittests/Host/CMakeLists.txt
@@ -1,7 +1,21 @@
-add_lldb_unittest(HostTests
+set (FILES
FileSpecTest.cpp
FileSystemTest.cpp
SocketAddressTest.cpp
SocketTest.cpp
SymbolsTest.cpp
+)
+
+if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
+ list(APPEND FILES
+ linux/HostTest.cpp
+ linux/SupportTest.cpp
+ )
+endif()
+
+add_lldb_unittest(HostTests
+ ${FILES}
+ LINK_LIBS
+ lldbCore
+ lldbHost
)
diff --git a/unittests/Host/FileSpecTest.cpp b/unittests/Host/FileSpecTest.cpp
index 55a66b3b37eb..cb6877e7b622 100644
--- a/unittests/Host/FileSpecTest.cpp
+++ b/unittests/Host/FileSpecTest.cpp
@@ -9,7 +9,7 @@
#include "gtest/gtest.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
using namespace lldb_private;
@@ -109,6 +109,28 @@ TEST(FileSpecTest, CopyByAppendingPathComponent) {
EXPECT_STREQ("bar", fs.GetFilename().GetCString());
}
+TEST(FileSpecTest, PrependPathComponent) {
+ FileSpec fs_posix("foo", false, FileSpec::ePathSyntaxPosix);
+ fs_posix.PrependPathComponent("/bar");
+ EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
+
+ FileSpec fs_posix_2("foo/bar", false, FileSpec::ePathSyntaxPosix);
+ fs_posix_2.PrependPathComponent("/baz");
+ EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
+
+ FileSpec fs_windows("baz", false, FileSpec::ePathSyntaxWindows);
+ fs_windows.PrependPathComponent("F:\\bar");
+ EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
+
+ FileSpec fs_posix_root("bar", false, FileSpec::ePathSyntaxPosix);
+ fs_posix_root.PrependPathComponent("/");
+ EXPECT_STREQ("/bar", fs_posix_root.GetCString());
+
+ FileSpec fs_windows_root("bar", false, FileSpec::ePathSyntaxWindows);
+ fs_windows_root.PrependPathComponent("F:\\");
+ EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
+}
+
static void Compare(const FileSpec &one, const FileSpec &two, bool full_match,
bool remove_backup_dots, bool result) {
EXPECT_EQ(result, FileSpec::Equal(one, two, full_match, remove_backup_dots))
@@ -142,6 +164,7 @@ TEST(FileSpecTest, EqualDotsWindows) {
{R"(C:/bar/baz)", R"(C:\foo\..\bar\baz)"},
{R"(C:\bar)", R"(C:\foo\..\bar)"},
{R"(C:\foo\bar)", R"(C:\foo\.\bar)"},
+ {R"(C:\foo\bar)", R"(C:\foo\bar\.)"},
};
for(const auto &test: tests) {
@@ -165,6 +188,7 @@ TEST(FileSpecTest, EqualDotsPosix) {
{R"(/bar/baz)", R"(/foo/../bar/baz)"},
{R"(/bar)", R"(/foo/../bar)"},
{R"(/foo/bar)", R"(/foo/./bar)"},
+ {R"(/foo/bar)", R"(/foo/bar/.)"},
};
for(const auto &test: tests) {
@@ -283,4 +307,4 @@ TEST(FileSpecTest, FormatFileSpec) {
EXPECT_EQ("foo", llvm::formatv("{0}", F).str());
EXPECT_EQ("foo", llvm::formatv("{0:F}", F).str());
EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
-} \ No newline at end of file
+}
diff --git a/unittests/Host/SocketTest.cpp b/unittests/Host/SocketTest.cpp
index 569a4404131e..7abb010a9089 100644
--- a/unittests/Host/SocketTest.cpp
+++ b/unittests/Host/SocketTest.cpp
@@ -7,13 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
-
#include <cstdio>
#include <functional>
#include <thread>
@@ -203,17 +196,14 @@ TEST_F(SocketTest, TCPGetAddress) {
}
TEST_F(SocketTest, UDPConnect) {
- Socket *socket_a;
- Socket *socket_b;
+ Socket *socket;
bool child_processes_inherit = false;
auto error = UDPSocket::Connect("127.0.0.1:0", child_processes_inherit,
- socket_a, socket_b);
+ socket);
- std::unique_ptr<Socket> a_up(socket_a);
- std::unique_ptr<Socket> b_up(socket_b);
+ std::unique_ptr<Socket> socket_up(socket);
EXPECT_TRUE(error.Success());
- EXPECT_TRUE(a_up->IsValid());
- EXPECT_TRUE(b_up->IsValid());
+ EXPECT_TRUE(socket_up->IsValid());
}
diff --git a/unittests/Host/linux/HostTest.cpp b/unittests/Host/linux/HostTest.cpp
new file mode 100644
index 000000000000..36d3fd206dac
--- /dev/null
+++ b/unittests/Host/linux/HostTest.cpp
@@ -0,0 +1,48 @@
+//===-- HostTest.cpp --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+class HostTest : public testing::Test {
+public:
+ static void SetUpTestCase() { HostInfo::Initialize(); }
+ static void TearDownTestCase() { HostInfo::Terminate(); }
+};
+} // namespace
+
+TEST_F(HostTest, GetProcessInfo) {
+ ProcessInstanceInfo Info;
+ ASSERT_FALSE(Host::GetProcessInfo(0, Info));
+
+ ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
+
+ ASSERT_TRUE(Info.ProcessIDIsValid());
+ EXPECT_EQ(lldb::pid_t(getpid()), Info.GetProcessID());
+
+ ASSERT_TRUE(Info.ParentProcessIDIsValid());
+ EXPECT_EQ(lldb::pid_t(getppid()), Info.GetParentProcessID());
+
+ ASSERT_TRUE(Info.EffectiveUserIDIsValid());
+ EXPECT_EQ(geteuid(), Info.GetEffectiveUserID());
+
+ ASSERT_TRUE(Info.EffectiveGroupIDIsValid());
+ EXPECT_EQ(getegid(), Info.GetEffectiveGroupID());
+
+ ASSERT_TRUE(Info.UserIDIsValid());
+ EXPECT_EQ(geteuid(), Info.GetUserID());
+
+ ASSERT_TRUE(Info.GroupIDIsValid());
+ EXPECT_EQ(getegid(), Info.GetGroupID());
+}
diff --git a/unittests/Host/linux/SupportTest.cpp b/unittests/Host/linux/SupportTest.cpp
new file mode 100644
index 000000000000..9b63084827af
--- /dev/null
+++ b/unittests/Host/linux/SupportTest.cpp
@@ -0,0 +1,26 @@
+//===-- SupportTest.cpp -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/linux/Support.h"
+#include "llvm/Support/Threading.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(Support, getProcFile_Pid) {
+ auto BufferOrError = getProcFile(getpid(), "maps");
+ ASSERT_TRUE(BufferOrError);
+ ASSERT_TRUE(*BufferOrError);
+}
+
+TEST(Support, getProcFile_Tid) {
+ auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "comm");
+ ASSERT_TRUE(BufferOrError);
+ ASSERT_TRUE(*BufferOrError);
+}
diff --git a/unittests/Interpreter/CMakeLists.txt b/unittests/Interpreter/CMakeLists.txt
index 4078476bc75a..d884dee62ec5 100644
--- a/unittests/Interpreter/CMakeLists.txt
+++ b/unittests/Interpreter/CMakeLists.txt
@@ -1,5 +1,10 @@
add_lldb_unittest(InterpreterTests
TestArgs.cpp
+ TestCompletion.cpp
+
+ LINK_LIBS
+ lldbInterpreter
+ lldbUtilityMocks
)
target_link_libraries(InterpreterTests
diff --git a/unittests/Interpreter/TestArgs.cpp b/unittests/Interpreter/TestArgs.cpp
index 9dcf09d54aea..2aeed0f542b1 100644
--- a/unittests/Interpreter/TestArgs.cpp
+++ b/unittests/Interpreter/TestArgs.cpp
@@ -169,6 +169,14 @@ TEST(ArgsTest, AppendArguments) {
EXPECT_STREQ("4", args.GetArgumentAtIndex(3));
}
+TEST(ArgsTest, GetArgumentArrayRef) {
+ Args args("foo bar");
+ auto ref = args.GetArgumentArrayRef();
+ ASSERT_EQ(2u, ref.size());
+ EXPECT_STREQ("foo", ref[0]);
+ EXPECT_STREQ("bar", ref[1]);
+}
+
TEST(ArgsTest, StringToBoolean) {
bool success = false;
EXPECT_TRUE(Args::StringToBoolean(llvm::StringRef("true"), false, nullptr));
diff --git a/unittests/Interpreter/TestCompletion.cpp b/unittests/Interpreter/TestCompletion.cpp
new file mode 100644
index 000000000000..0548b93d6f72
--- /dev/null
+++ b/unittests/Interpreter/TestCompletion.cpp
@@ -0,0 +1,307 @@
+//===-- TestCompletion.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "lldb/Interpreter/CommandCompletions.h"
+#include "lldb/Utility/StringList.h"
+#include "lldb/Utility/TildeExpressionResolver.h"
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "unittests/Utility/Mocks/MockTildeExpressionResolver.h"
+
+namespace fs = llvm::sys::fs;
+namespace path = llvm::sys::path;
+using namespace llvm;
+using namespace lldb_private;
+
+#define ASSERT_NO_ERROR(x) \
+ if (std::error_code ASSERT_NO_ERROR_ec = x) { \
+ SmallString<128> MessageStorage; \
+ raw_svector_ostream Message(MessageStorage); \
+ Message << #x ": did not return errc::success.\n" \
+ << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
+ << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
+ GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
+ } else { \
+ }
+
+namespace {
+
+class CompletionTest : public testing::Test {
+protected:
+ /// Unique temporary directory in which all created filesystem entities must
+ /// be placed. It is removed at the end of the test suite.
+ static SmallString<128> BaseDir;
+
+ static SmallString<128> OriginalWorkingDir;
+
+ static SmallString<128> DirFoo;
+ static SmallString<128> DirFooA;
+ static SmallString<128> DirFooB;
+ static SmallString<128> DirFooC;
+ static SmallString<128> DirBar;
+ static SmallString<128> DirBaz;
+ static SmallString<128> DirTestFolder;
+
+ static SmallString<128> FileAA;
+ static SmallString<128> FileAB;
+ static SmallString<128> FileAC;
+ static SmallString<128> FileFoo;
+ static SmallString<128> FileBar;
+ static SmallString<128> FileBaz;
+
+ void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); }
+
+ static void SetUpTestCase() {
+ llvm::sys::fs::current_path(OriginalWorkingDir);
+
+ ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir));
+ const char *DirNames[] = {"foo", "fooa", "foob", "fooc",
+ "bar", "baz", "test_folder"};
+ const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp",
+ "foo1234.tmp", "bar1234.tmp", "baz1234.tmp"};
+ SmallString<128> *Dirs[] = {&DirFoo, &DirFooA, &DirFooB, &DirFooC,
+ &DirBar, &DirBaz, &DirTestFolder};
+ for (auto Dir : llvm::zip(DirNames, Dirs)) {
+ auto &Path = *std::get<1>(Dir);
+ Path = BaseDir;
+ path::append(Path, std::get<0>(Dir));
+ ASSERT_NO_ERROR(fs::create_directory(Path));
+ }
+
+ SmallString<128> *Files[] = {&FileAA, &FileAB, &FileAC,
+ &FileFoo, &FileBar, &FileBaz};
+ for (auto File : llvm::zip(FileNames, Files)) {
+ auto &Path = *std::get<1>(File);
+ Path = BaseDir;
+ path::append(Path, std::get<0>(File));
+ int FD;
+ ASSERT_NO_ERROR(fs::createUniqueFile(Path, FD, Path));
+ ::close(FD);
+ }
+ }
+
+ static void TearDownTestCase() {
+ ASSERT_NO_ERROR(fs::remove_directories(BaseDir));
+ }
+
+ static bool HasEquivalentFile(const Twine &Path, const StringList &Paths) {
+ for (size_t I = 0; I < Paths.GetSize(); ++I) {
+ if (fs::equivalent(Path, Paths[I]))
+ return true;
+ }
+ return false;
+ }
+
+ static bool ContainsExactString(const Twine &Str, const StringList &Paths) {
+ SmallString<16> Storage;
+ StringRef Rendered = Str.toStringRef(Storage);
+ for (size_t I = 0; I < Paths.GetSize(); ++I) {
+ if (Paths[I] == Rendered)
+ return true;
+ }
+ return false;
+ }
+
+ void DoDirCompletions(const Twine &Prefix,
+ StandardTildeExpressionResolver &Resolver,
+ StringList &Results) {
+ // When a partial name matches, it returns all matches. If it matches both
+ // a full name AND some partial names, it returns all of them.
+ uint32_t Count =
+ CommandCompletions::DiskDirectories(Prefix + "foo", Results, Resolver);
+ ASSERT_EQ(4u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirFoo, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooA, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooB, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooC, Results));
+
+ // If it matches only partial names, it still works as expected.
+ Count = CommandCompletions::DiskDirectories(Twine(Prefix) + "b", Results,
+ Resolver);
+ ASSERT_EQ(2u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirBar, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirBaz, Results));
+ }
+};
+
+SmallString<128> CompletionTest::BaseDir;
+SmallString<128> CompletionTest::OriginalWorkingDir;
+
+SmallString<128> CompletionTest::DirFoo;
+SmallString<128> CompletionTest::DirFooA;
+SmallString<128> CompletionTest::DirFooB;
+SmallString<128> CompletionTest::DirFooC;
+SmallString<128> CompletionTest::DirBar;
+SmallString<128> CompletionTest::DirBaz;
+SmallString<128> CompletionTest::DirTestFolder;
+
+SmallString<128> CompletionTest::FileAA;
+SmallString<128> CompletionTest::FileAB;
+SmallString<128> CompletionTest::FileAC;
+SmallString<128> CompletionTest::FileFoo;
+SmallString<128> CompletionTest::FileBar;
+SmallString<128> CompletionTest::FileBaz;
+}
+
+TEST_F(CompletionTest, DirCompletionAbsolute) {
+ // All calls to DiskDirectories() return only directories, even when
+ // there are files which also match. The tests below all check this
+ // by asserting an exact result count, and verifying against known
+ // folders.
+
+ std::string Prefixes[] = {(Twine(BaseDir) + "/").str(), ""};
+
+ StandardTildeExpressionResolver Resolver;
+ StringList Results;
+
+ // When a directory is specified that doesn't end in a slash, it searches
+ // for that directory, not items under it.
+ size_t Count =
+ CommandCompletions::DiskDirectories(BaseDir, Results, Resolver);
+ ASSERT_EQ(1u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(BaseDir, Results));
+
+ // When the same directory ends with a slash, it finds all children.
+ Count = CommandCompletions::DiskDirectories(Prefixes[0], Results, Resolver);
+ ASSERT_EQ(7u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirFoo, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooA, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooB, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooC, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirBar, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirBaz, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirTestFolder, Results));
+
+ DoDirCompletions(Twine(BaseDir) + "/", Resolver, Results);
+ llvm::sys::fs::set_current_path(BaseDir);
+ DoDirCompletions("", Resolver, Results);
+}
+
+TEST_F(CompletionTest, FileCompletionAbsolute) {
+ // All calls to DiskFiles() return both files and directories The tests below
+ // all check this by asserting an exact result count, and verifying against
+ // known folders.
+
+ StandardTildeExpressionResolver Resolver;
+ StringList Results;
+ // When an item is specified that doesn't end in a slash but exactly matches
+ // one item, it returns that item.
+ size_t Count = CommandCompletions::DiskFiles(Twine(BaseDir) + "/fooa",
+ Results, Resolver);
+ ASSERT_EQ(1u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirFooA, Results));
+
+ // The previous check verified a directory match. But it should work for
+ // files too.
+ Count =
+ CommandCompletions::DiskFiles(Twine(BaseDir) + "/aa", Results, Resolver);
+ ASSERT_EQ(1u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(FileAA, Results));
+
+ // When it ends with a slash, it should find all files and directories.
+ Count =
+ CommandCompletions::DiskFiles(Twine(BaseDir) + "/", Results, Resolver);
+ ASSERT_EQ(13u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirFoo, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooA, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooB, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooC, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirBar, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirBaz, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirTestFolder, Results));
+
+ EXPECT_TRUE(HasEquivalentFile(FileAA, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileAB, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileAC, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileFoo, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileBar, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileBaz, Results));
+
+ // When a partial name matches, it returns all file & directory matches.
+ Count =
+ CommandCompletions::DiskFiles(Twine(BaseDir) + "/foo", Results, Resolver);
+ ASSERT_EQ(5u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(HasEquivalentFile(DirFoo, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooA, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooB, Results));
+ EXPECT_TRUE(HasEquivalentFile(DirFooC, Results));
+ EXPECT_TRUE(HasEquivalentFile(FileFoo, Results));
+}
+
+TEST_F(CompletionTest, DirCompletionUsername) {
+ MockTildeExpressionResolver Resolver("James", BaseDir);
+ Resolver.AddKnownUser("Kirk", DirFooB);
+ Resolver.AddKnownUser("Lars", DirFooC);
+ Resolver.AddKnownUser("Jason", DirFoo);
+ Resolver.AddKnownUser("Larry", DirFooA);
+
+ // Just resolving current user's home directory by itself should return the
+ // directory.
+ StringList Results;
+ size_t Count = CommandCompletions::DiskDirectories("~", Results, Resolver);
+ ASSERT_EQ(1u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(ContainsExactString(Twine("~") + path::get_separator(), Results));
+
+ // With a slash appended, it should return all items in the directory.
+ Count = CommandCompletions::DiskDirectories("~/", Results, Resolver);
+ ASSERT_EQ(7u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/foo") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/fooa") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/foob") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/fooc") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/bar") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~/baz") + path::get_separator(), Results));
+ EXPECT_TRUE(ContainsExactString(
+ Twine("~/test_folder") + path::get_separator(), Results));
+
+ // With ~username syntax it should return one match if there is an exact
+ // match.
+ // It shouldn't translate to the actual directory, it should keep the form the
+ // user typed.
+ Count = CommandCompletions::DiskDirectories("~Lars", Results, Resolver);
+ ASSERT_EQ(1u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~Lars") + path::get_separator(), Results));
+
+ // But with a username that is not found, no results are returned.
+ Count = CommandCompletions::DiskDirectories("~Dave", Results, Resolver);
+ ASSERT_EQ(0u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+
+ // And if there are multiple matches, it should return all of them.
+ Count = CommandCompletions::DiskDirectories("~La", Results, Resolver);
+ ASSERT_EQ(2u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~Lars") + path::get_separator(), Results));
+ EXPECT_TRUE(
+ ContainsExactString(Twine("~Larry") + path::get_separator(), Results));
+}
diff --git a/unittests/Language/CPlusPlus/CMakeLists.txt b/unittests/Language/CPlusPlus/CMakeLists.txt
index 6cad97cc6d3c..4882eafc8d85 100644
--- a/unittests/Language/CPlusPlus/CMakeLists.txt
+++ b/unittests/Language/CPlusPlus/CMakeLists.txt
@@ -1,3 +1,6 @@
add_lldb_unittest(LanguageCPlusPlusTests
CPlusPlusLanguageTest.cpp
+
+ LINK_LIBS
+ lldbPluginCPlusPlusLanguage
)
diff --git a/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp b/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
index 26de31d52a33..8c7fade83759 100644
--- a/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ b/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -6,35 +6,153 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-
#include "gtest/gtest.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
using namespace lldb_private;
-TEST(CPlusPlusLanguage, MethodName) {
+TEST(CPlusPlusLanguage, MethodNameParsing) {
struct TestCase {
std::string input;
std::string context, basename, arguments, qualifiers, scope_qualified_name;
};
TestCase test_cases[] = {
- {"foo::bar(baz)", "foo", "bar", "(baz)", "", "foo::bar"},
+ {"main(int, char *[]) ", "", "main", "(int, char *[])", "", "main"},
+ {"foo::bar(baz) const", "foo", "bar", "(baz)", "const", "foo::bar"},
+ {"foo::~bar(baz)", "foo", "~bar", "(baz)", "", "foo::~bar"},
+ {"a::b::c::d(e,f)", "a::b::c", "d", "(e,f)", "", "a::b::c::d"},
+ {"void f(int)", "", "f", "(int)", "", "f"},
+
+ // Operators
{"std::basic_ostream<char, std::char_traits<char> >& "
"std::operator<<<std::char_traits<char> >"
"(std::basic_ostream<char, std::char_traits<char> >&, char const*)",
"std", "operator<<<std::char_traits<char> >",
"(std::basic_ostream<char, std::char_traits<char> >&, char const*)", "",
- "std::operator<<<std::char_traits<char> >"}};
+ "std::operator<<<std::char_traits<char> >"},
+ {"operator delete[](void*, clang::ASTContext const&, unsigned long)", "",
+ "operator delete[]", "(void*, clang::ASTContext const&, unsigned long)",
+ "", "operator delete[]"},
+ {"llvm::Optional<clang::PostInitializer>::operator bool() const",
+ "llvm::Optional<clang::PostInitializer>", "operator bool", "()", "const",
+ "llvm::Optional<clang::PostInitializer>::operator bool"},
+ {"(anonymous namespace)::FactManager::operator[](unsigned short)",
+ "(anonymous namespace)::FactManager", "operator[]", "(unsigned short)",
+ "", "(anonymous namespace)::FactManager::operator[]"},
+ {"const int& std::map<int, pair<short, int>>::operator[](short) const",
+ "std::map<int, pair<short, int>>", "operator[]", "(short)", "const",
+ "std::map<int, pair<short, int>>::operator[]"},
+ {"CompareInsn::operator()(llvm::StringRef, InsnMatchEntry const&)",
+ "CompareInsn", "operator()", "(llvm::StringRef, InsnMatchEntry const&)",
+ "", "CompareInsn::operator()"},
+ {"llvm::Optional<llvm::MCFixupKind>::operator*() const &",
+ "llvm::Optional<llvm::MCFixupKind>", "operator*", "()", "const &",
+ "llvm::Optional<llvm::MCFixupKind>::operator*"},
+ // Internal classes
+ {"operator<<(Cls, Cls)::Subclass::function()",
+ "operator<<(Cls, Cls)::Subclass", "function", "()", "",
+ "operator<<(Cls, Cls)::Subclass::function"},
+ {"SAEC::checkFunction(context&) const::CallBack::CallBack(int)",
+ "SAEC::checkFunction(context&) const::CallBack", "CallBack", "(int)", "",
+ "SAEC::checkFunction(context&) const::CallBack::CallBack"},
+ // Anonymous namespace
+ {"XX::(anonymous namespace)::anon_class::anon_func() const",
+ "XX::(anonymous namespace)::anon_class", "anon_func", "()", "const",
+ "XX::(anonymous namespace)::anon_class::anon_func"},
+
+ // Function pointers
+ {"string (*f(vector<int>&&))(float)", "", "f", "(vector<int>&&)", "",
+ "f"},
+ {"void (*&std::_Any_data::_M_access<void (*)()>())()", "std::_Any_data",
+ "_M_access<void (*)()>", "()", "",
+ "std::_Any_data::_M_access<void (*)()>"},
+ {"void (*(*(*(*(*(*(*(* const&func1(int))())())())())())())())()", "",
+ "func1", "(int)", "", "func1"},
+
+ // Decltype
+ {"decltype(nullptr)&& std::forward<decltype(nullptr)>"
+ "(std::remove_reference<decltype(nullptr)>::type&)",
+ "std", "forward<decltype(nullptr)>",
+ "(std::remove_reference<decltype(nullptr)>::type&)", "",
+ "std::forward<decltype(nullptr)>"},
+
+ // Templates
+ {"void llvm::PM<llvm::Module, llvm::AM<llvm::Module>>::"
+ "addPass<llvm::VP>(llvm::VP)",
+ "llvm::PM<llvm::Module, llvm::AM<llvm::Module>>", "addPass<llvm::VP>",
+ "(llvm::VP)", "",
+ "llvm::PM<llvm::Module, llvm::AM<llvm::Module>>::"
+ "addPass<llvm::VP>"},
+ {"void std::vector<Class, std::allocator<Class> >"
+ "::_M_emplace_back_aux<Class const&>(Class const&)",
+ "std::vector<Class, std::allocator<Class> >",
+ "_M_emplace_back_aux<Class const&>", "(Class const&)", "",
+ "std::vector<Class, std::allocator<Class> >::"
+ "_M_emplace_back_aux<Class const&>"},
+ {"unsigned long llvm::countTrailingOnes<unsigned int>"
+ "(unsigned int, llvm::ZeroBehavior)",
+ "llvm", "countTrailingOnes<unsigned int>",
+ "(unsigned int, llvm::ZeroBehavior)", "",
+ "llvm::countTrailingOnes<unsigned int>"},
+ {"std::enable_if<(10u)<(64), bool>::type llvm::isUInt<10u>(unsigned "
+ "long)",
+ "llvm", "isUInt<10u>", "(unsigned long)", "", "llvm::isUInt<10u>"},
+ {"f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>()", "",
+ "f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>", "()", "",
+ "f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>"}};
for (const auto &test : test_cases) {
CPlusPlusLanguage::MethodName method(ConstString(test.input));
- EXPECT_TRUE(method.IsValid());
- EXPECT_EQ(test.context, method.GetContext());
- EXPECT_EQ(test.basename, method.GetBasename());
- EXPECT_EQ(test.arguments, method.GetArguments());
- EXPECT_EQ(test.qualifiers, method.GetQualifiers());
- EXPECT_EQ(test.scope_qualified_name, method.GetScopeQualifiedName());
+ EXPECT_TRUE(method.IsValid()) << test.input;
+ if (method.IsValid()) {
+ EXPECT_EQ(test.context, method.GetContext().str());
+ EXPECT_EQ(test.basename, method.GetBasename().str());
+ EXPECT_EQ(test.arguments, method.GetArguments().str());
+ EXPECT_EQ(test.qualifiers, method.GetQualifiers().str());
+ EXPECT_EQ(test.scope_qualified_name, method.GetScopeQualifiedName());
+ }
+ }
+}
+
+TEST(CPlusPlusLanguage, ExtractContextAndIdentifier) {
+ struct TestCase {
+ std::string input;
+ std::string context, basename;
+ };
+
+ TestCase test_cases[] = {
+ {"main", "", "main"},
+ {"main ", "", "main"},
+ {"foo01::bar", "foo01", "bar"},
+ {"foo::~bar", "foo", "~bar"},
+ {"std::vector<int>::push_back", "std::vector<int>", "push_back"},
+ {"operator<<(Cls, Cls)::Subclass::function",
+ "operator<<(Cls, Cls)::Subclass", "function"},
+ {"std::vector<Class, std::allocator<Class>>"
+ "::_M_emplace_back_aux<Class const&>",
+ "std::vector<Class, std::allocator<Class>>",
+ "_M_emplace_back_aux<Class const&>"}};
+
+ llvm::StringRef context, basename;
+ for (const auto &test : test_cases) {
+ EXPECT_TRUE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+ test.input.c_str(), context, basename));
+ EXPECT_EQ(test.context, context.str());
+ EXPECT_EQ(test.basename, basename.str());
}
+
+ EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier("void", context,
+ basename));
+ EXPECT_FALSE(
+ CPlusPlusLanguage::ExtractContextAndIdentifier("321", context, basename));
+ EXPECT_FALSE(
+ CPlusPlusLanguage::ExtractContextAndIdentifier("", context, basename));
+ EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+ "selector:", context, basename));
+ EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+ "selector:otherField:", context, basename));
+ EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+ "abc::", context, basename));
}
diff --git a/unittests/ObjectFile/CMakeLists.txt b/unittests/ObjectFile/CMakeLists.txt
new file mode 100644
index 000000000000..8a98a9e34e51
--- /dev/null
+++ b/unittests/ObjectFile/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(ELF)
diff --git a/unittests/ObjectFile/ELF/CMakeLists.txt b/unittests/ObjectFile/ELF/CMakeLists.txt
new file mode 100644
index 000000000000..4cae7ab2c0d6
--- /dev/null
+++ b/unittests/ObjectFile/ELF/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_lldb_unittest(ObjectFileELFTests
+ TestELFHeader.cpp
+
+ LINK_LIBS
+ lldbPluginObjectFileELF
+ lldbCore
+ )
diff --git a/unittests/ObjectFile/ELF/TestELFHeader.cpp b/unittests/ObjectFile/ELF/TestELFHeader.cpp
new file mode 100644
index 000000000000..979011f66a27
--- /dev/null
+++ b/unittests/ObjectFile/ELF/TestELFHeader.cpp
@@ -0,0 +1,62 @@
+//===-- TestELFHeader.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/ObjectFile/ELF/ELFHeader.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+TEST(ELFHeader, ParseHeaderExtension) {
+ uint8_t data[] = {
+ // e_ident
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+
+ // e_type, e_machine, e_version, e_entry
+ 0x03, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x90, 0x48, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+
+ // e_phoff, e_shoff
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+
+ // e_flags, e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum,
+ // e_shstrndx
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x38, 0x00, 0xff, 0xff, 0x40, 0x00,
+ 0x00, 0x00, 0xff, 0xff,
+
+ // sh_name, sh_type, sh_flags
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+
+ // sh_addr, sh_offset
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+
+ // sh_size, sh_link, sh_info
+ 0x23, 0x45, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x56, 0x78, 0x00,
+ 0x12, 0x34, 0x56, 0x00,
+
+ // sh_addralign, sh_entsize
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+
+ DataExtractor extractor(data, sizeof data, eByteOrderLittle, 8);
+ elf::ELFHeader header;
+ offset_t offset = 0;
+ ASSERT_TRUE(header.Parse(extractor, &offset));
+ EXPECT_EQ(0x563412u, header.e_phnum);
+ EXPECT_EQ(0x785634u, header.e_shstrndx);
+ EXPECT_EQ(0x674523u, header.e_shnum);
+}
diff --git a/unittests/Platform/CMakeLists.txt b/unittests/Platform/CMakeLists.txt
index af1121dac7b6..3362ca08d60c 100644
--- a/unittests/Platform/CMakeLists.txt
+++ b/unittests/Platform/CMakeLists.txt
@@ -1,3 +1,8 @@
add_lldb_unittest(LLDBPlatformTests
PlatformDarwinTest.cpp
+
+ LINK_LIBS
+ lldbPluginPlatformMacOSX
+ LINK_COMPONENTS
+ Support
)
diff --git a/unittests/Process/gdb-remote/CMakeLists.txt b/unittests/Process/gdb-remote/CMakeLists.txt
index de4cac11b233..694ba182d42f 100644
--- a/unittests/Process/gdb-remote/CMakeLists.txt
+++ b/unittests/Process/gdb-remote/CMakeLists.txt
@@ -2,4 +2,13 @@ add_lldb_unittest(ProcessGdbRemoteTests
GDBRemoteClientBaseTest.cpp
GDBRemoteCommunicationClientTest.cpp
GDBRemoteTestUtils.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbPluginPlatformMacOSX
+ lldbPluginProcessUtility
+ lldbPluginProcessGDBRemote
+ LINK_COMPONENTS
+ Support
)
diff --git a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
index 2cfd52f5767a..5e709815b2d5 100644
--- a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
+++ b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
@@ -6,13 +6,6 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
#include <future>
#include "GDBRemoteTestUtils.h"
@@ -20,7 +13,7 @@
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/gdb-remote/GDBRemoteClientBase.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
-#include "lldb/Core/StreamGDBRemote.h"
+#include "lldb/Utility/StreamGDBRemote.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 4bac9ebd404f..d1eb3a7e9c9e 100644
--- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -6,21 +6,15 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
#include <future>
#include "GDBRemoteTestUtils.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
-#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/DataBuffer.h"
#include "llvm/ADT/ArrayRef.h"
@@ -298,6 +292,7 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
client.Disconnect();
server_thread.join();
+ GTEST_LOG_(INFO) << "Formatted output: " << ss.GetData();
auto object_sp = StructuredData::ParseJSON(ss.GetString());
ASSERT_TRUE(bool(object_sp));
auto dict_sp = object_sp->GetAsDictionary();
@@ -313,3 +308,65 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
<< ss.GetString();
ASSERT_EQ(10, num_packets);
}
+
+TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) {
+ TestClient client;
+ MockServer server;
+ Connect(client, server);
+ if (HasFailure())
+ return;
+
+ const lldb::tid_t tid = 0x47;
+ const uint32_t reg_num = 4;
+ std::future<Error> result = std::async(std::launch::async, [&] {
+ return client.SendSignalsToIgnore({2, 3, 5, 7, 0xB, 0xD, 0x11});
+ });
+
+ HandlePacket(server, "QPassSignals:02;03;05;07;0b;0d;11", "OK");
+ EXPECT_TRUE(result.get().Success());
+
+ result = std::async(std::launch::async, [&] {
+ return client.SendSignalsToIgnore(std::vector<int32_t>());
+ });
+
+ HandlePacket(server, "QPassSignals:", "OK");
+ EXPECT_TRUE(result.get().Success());
+}
+
+TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
+ TestClient client;
+ MockServer server;
+ Connect(client, server);
+ if (HasFailure())
+ return;
+
+ const lldb::addr_t addr = 0xa000;
+ MemoryRegionInfo region_info;
+ std::future<Error> result = std::async(std::launch::async, [&] {
+ return client.GetMemoryRegionInfo(addr, region_info);
+ });
+
+ // name is: /foo/bar.so
+ HandlePacket(server,
+ "qMemoryRegionInfo:a000",
+ "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;");
+ EXPECT_TRUE(result.get().Success());
+
+}
+
+TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
+ TestClient client;
+ MockServer server;
+ Connect(client, server);
+ if (HasFailure())
+ return;
+
+ const lldb::addr_t addr = 0x4000;
+ MemoryRegionInfo region_info;
+ std::future<Error> result = std::async(std::launch::async, [&] {
+ return client.GetMemoryRegionInfo(addr, region_info);
+ });
+
+ HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;");
+ EXPECT_FALSE(result.get().Success());
+}
diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
index 58cc9f50586a..08501f50f65a 100644
--- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
+++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
@@ -7,13 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Workaround for MSVC standard library bug, which fails to include <thread>
-// when
-// exceptions are disabled.
-#include <eh.h>
-#endif
-
#include "GDBRemoteTestUtils.h"
#include "lldb/Host/common/TCPSocket.h"
diff --git a/unittests/Process/minidump/CMakeLists.txt b/unittests/Process/minidump/CMakeLists.txt
index 10cb8c34f352..2b2df6327e9a 100644
--- a/unittests/Process/minidump/CMakeLists.txt
+++ b/unittests/Process/minidump/CMakeLists.txt
@@ -1,5 +1,14 @@
add_lldb_unittest(LLDBMinidumpTests
MinidumpParserTest.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbTarget
+ lldbPluginProcessUtility
+ lldbPluginProcessMinidump
+ LINK_COMPONENTS
+ Support
)
set(test_inputs
diff --git a/unittests/Process/minidump/MinidumpParserTest.cpp b/unittests/Process/minidump/MinidumpParserTest.cpp
index 83225e88ee03..755095f75918 100644
--- a/unittests/Process/minidump/MinidumpParserTest.cpp
+++ b/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -19,13 +19,15 @@
#include "gtest/gtest.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
// C includes
@@ -46,14 +48,15 @@ public:
llvm::sys::path::append(inputs_folder, "Inputs");
}
- void SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX) {
+ void SetUpData(const char *minidump_filename,
+ uint64_t load_size = UINT64_MAX) {
llvm::SmallString<128> filename = inputs_folder;
llvm::sys::path::append(filename, minidump_filename);
- FileSpec minidump_file(filename.c_str(), false);
- lldb::DataBufferSP data_sp(
- minidump_file.MemoryMapFileContents(0, load_size));
+
+ auto BufferPtr = DataBufferLLVM::CreateSliceFromPath(filename, load_size, 0);
+
llvm::Optional<MinidumpParser> optional_parser =
- MinidumpParser::Create(data_sp);
+ MinidumpParser::Create(BufferPtr);
ASSERT_TRUE(optional_parser.hasValue());
parser.reset(new MinidumpParser(optional_parser.getValue()));
ASSERT_GT(parser->GetData().size(), 0UL);
@@ -450,4 +453,4 @@ TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_wow64) {
REG_VAL32(buf->GetBytes() + reg_info[reg_index].byte_offset));
}
}
-} \ No newline at end of file
+}
diff --git a/unittests/ScriptInterpreter/Python/CMakeLists.txt b/unittests/ScriptInterpreter/Python/CMakeLists.txt
index f011200e6475..891ade25b76b 100644
--- a/unittests/ScriptInterpreter/Python/CMakeLists.txt
+++ b/unittests/ScriptInterpreter/Python/CMakeLists.txt
@@ -2,7 +2,12 @@ add_lldb_unittest(ScriptInterpreterPythonTests
PythonDataObjectsTests.cpp
PythonExceptionStateTests.cpp
PythonTestSuite.cpp
- )
- target_link_libraries(ScriptInterpreterPythonTests lldbPluginScriptInterpreterPython ${PYTHON_LIBRARY})
+ LINK_LIBS
+ lldbHost
+ lldbPluginScriptInterpreterPython
+ ${PYTHON_LIBRARY}
+ LINK_COMPONENTS
+ Support
+ )
\ No newline at end of file
diff --git a/unittests/Signals/CMakeLists.txt b/unittests/Signals/CMakeLists.txt
new file mode 100644
index 000000000000..e3f2e884d930
--- /dev/null
+++ b/unittests/Signals/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_lldb_unittest(SignalsTests
+ UnixSignalsTest.cpp
+
+ LINK_LIBS
+ lldbTarget
+ )
diff --git a/unittests/Signals/UnixSignalsTest.cpp b/unittests/Signals/UnixSignalsTest.cpp
new file mode 100644
index 000000000000..9183aed76aef
--- /dev/null
+++ b/unittests/Signals/UnixSignalsTest.cpp
@@ -0,0 +1,140 @@
+//===-- UnixSignalsTest.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+
+#include "gtest/gtest.h"
+
+#include "lldb/Target/UnixSignals.h"
+#include "llvm/Support/FormatVariadic.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using llvm::None;
+
+class TestSignals : public UnixSignals {
+public:
+ TestSignals() {
+ m_signals.clear();
+ AddSignal(2, "SIG2", false, true, true, "DESC2");
+ AddSignal(4, "SIG4", true, false, true, "DESC4");
+ AddSignal(8, "SIG8", true, true, true, "DESC8");
+ AddSignal(16, "SIG16", true, false, false, "DESC16");
+ }
+};
+
+void ExpectEqArrays(llvm::ArrayRef<int32_t> expected,
+ llvm::ArrayRef<int32_t> observed, const char *file,
+ int line) {
+ std::string location = llvm::formatv("{0}:{1}", file, line);
+ ASSERT_EQ(expected.size(), observed.size()) << location;
+
+ for (size_t i = 0; i < observed.size(); ++i) {
+ ASSERT_EQ(expected[i], observed[i])
+ << "array index: " << i << "location:" << location;
+ }
+}
+
+#define EXPECT_EQ_ARRAYS(expected, observed) \
+ ExpectEqArrays((expected), (observed), __FILE__, __LINE__);
+
+TEST(UnixSignalsTest, Iteration) {
+ TestSignals signals;
+
+ EXPECT_EQ(4, signals.GetNumSignals());
+ EXPECT_EQ(2, signals.GetFirstSignalNumber());
+ EXPECT_EQ(4, signals.GetNextSignalNumber(2));
+ EXPECT_EQ(8, signals.GetNextSignalNumber(4));
+ EXPECT_EQ(16, signals.GetNextSignalNumber(8));
+ EXPECT_EQ(LLDB_INVALID_SIGNAL_NUMBER, signals.GetNextSignalNumber(16));
+}
+
+TEST(UnixSignalsTest, GetInfo) {
+ TestSignals signals;
+
+ bool should_suppress = false, should_stop = false, should_notify = false;
+ int32_t signo = 4;
+ std::string name =
+ signals.GetSignalInfo(signo, should_suppress, should_stop, should_notify);
+ EXPECT_EQ("SIG4", name);
+ EXPECT_EQ(true, should_suppress);
+ EXPECT_EQ(false, should_stop);
+ EXPECT_EQ(true, should_notify);
+
+ EXPECT_EQ(true, signals.GetShouldSuppress(signo));
+ EXPECT_EQ(false, signals.GetShouldStop(signo));
+ EXPECT_EQ(true, signals.GetShouldNotify(signo));
+ EXPECT_EQ(name, signals.GetSignalAsCString(signo));
+}
+
+TEST(UnixSignalsTest, VersionChange) {
+ TestSignals signals;
+
+ int32_t signo = 8;
+ uint64_t ver = signals.GetVersion();
+ EXPECT_GT(ver, 0ull);
+ EXPECT_EQ(true, signals.GetShouldSuppress(signo));
+ EXPECT_EQ(true, signals.GetShouldStop(signo));
+ EXPECT_EQ(true, signals.GetShouldNotify(signo));
+
+ EXPECT_EQ(signals.GetVersion(), ver);
+
+ signals.SetShouldSuppress(signo, false);
+ EXPECT_LT(ver, signals.GetVersion());
+ ver = signals.GetVersion();
+
+ signals.SetShouldStop(signo, true);
+ EXPECT_LT(ver, signals.GetVersion());
+ ver = signals.GetVersion();
+
+ signals.SetShouldNotify(signo, false);
+ EXPECT_LT(ver, signals.GetVersion());
+ ver = signals.GetVersion();
+
+ EXPECT_EQ(false, signals.GetShouldSuppress(signo));
+ EXPECT_EQ(true, signals.GetShouldStop(signo));
+ EXPECT_EQ(false, signals.GetShouldNotify(signo));
+
+ EXPECT_EQ(ver, signals.GetVersion());
+}
+
+TEST(UnixSignalsTest, GetFilteredSignals) {
+ TestSignals signals;
+
+ auto all_signals = signals.GetFilteredSignals(None, None, None);
+ std::vector<int32_t> expected = {2, 4, 8, 16};
+ EXPECT_EQ_ARRAYS(expected, all_signals);
+
+ auto supressed = signals.GetFilteredSignals(true, None, None);
+ expected = {4, 8, 16};
+ EXPECT_EQ_ARRAYS(expected, supressed);
+
+ auto not_supressed = signals.GetFilteredSignals(false, None, None);
+ expected = {2};
+ EXPECT_EQ_ARRAYS(expected, not_supressed);
+
+ auto stopped = signals.GetFilteredSignals(None, true, None);
+ expected = {2, 8};
+ EXPECT_EQ_ARRAYS(expected, stopped);
+
+ auto not_stopped = signals.GetFilteredSignals(None, false, None);
+ expected = {4, 16};
+ EXPECT_EQ_ARRAYS(expected, not_stopped);
+
+ auto notified = signals.GetFilteredSignals(None, None, true);
+ expected = {2, 4, 8};
+ EXPECT_EQ_ARRAYS(expected, notified);
+
+ auto not_notified = signals.GetFilteredSignals(None, None, false);
+ expected = {16};
+ EXPECT_EQ_ARRAYS(expected, not_notified);
+
+ auto signal4 = signals.GetFilteredSignals(true, false, true);
+ expected = {4};
+ EXPECT_EQ_ARRAYS(expected, signal4);
+}
diff --git a/unittests/Symbol/CMakeLists.txt b/unittests/Symbol/CMakeLists.txt
index 75cabddba5c4..dca5f17b15de 100644
--- a/unittests/Symbol/CMakeLists.txt
+++ b/unittests/Symbol/CMakeLists.txt
@@ -1,4 +1,8 @@
add_lldb_unittest(SymbolTests
TestClangASTContext.cpp
TestType.cpp
+
+ LINK_LIBS
+ lldbHost
+ lldbSymbol
)
diff --git a/unittests/SymbolFile/DWARF/CMakeLists.txt b/unittests/SymbolFile/DWARF/CMakeLists.txt
index c0e4300dadd7..c764bd477fab 100644
--- a/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -1,5 +1,16 @@
add_lldb_unittest(SymbolFileDWARFTests
SymbolFileDWARFTests.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbPluginObjectFilePECOFF
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFilePDB
+ LINK_COMPONENTS
+ Support
+ DebugInfoPDB
)
set(test_inputs
diff --git a/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp b/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
index 10465d785ac9..8ef6ad05bd54 100644
--- a/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ b/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -19,12 +19,12 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/FileSpec.h"
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
diff --git a/unittests/SymbolFile/PDB/CMakeLists.txt b/unittests/SymbolFile/PDB/CMakeLists.txt
index 37adf39463d4..d9aff4e2eaca 100644
--- a/unittests/SymbolFile/PDB/CMakeLists.txt
+++ b/unittests/SymbolFile/PDB/CMakeLists.txt
@@ -1,5 +1,16 @@
add_lldb_unittest(SymbolFilePDBTests
SymbolFilePDBTests.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbPluginObjectFilePECOFF
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFilePDB
+ LINK_COMPONENTS
+ Support
+ DebugInfoPDB
)
set(test_inputs
diff --git a/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 5aedffecfe90..226057f89369 100644
--- a/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -19,12 +19,12 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/FileSpec.h"
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
@@ -120,7 +120,7 @@ protected:
return false;
}
- uint64_t GetGlobalConstantInteger(const llvm::pdb::IPDBSession &session,
+ uint64_t GetGlobalConstantInteger(llvm::pdb::IPDBSession &session,
llvm::StringRef var) const {
auto global = session.getGlobalScope();
auto results =
@@ -371,7 +371,7 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
@@ -394,7 +394,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
@@ -417,7 +417,7 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
@@ -440,7 +440,7 @@ TEST_F(SymbolFilePDBTests, TestEnumTypes) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
@@ -487,7 +487,7 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
diff --git a/unittests/Target/CMakeLists.txt b/unittests/Target/CMakeLists.txt
new file mode 100644
index 000000000000..e4f6e52b0634
--- /dev/null
+++ b/unittests/Target/CMakeLists.txt
@@ -0,0 +1,15 @@
+add_lldb_unittest(TargetTests
+ MemoryRegionInfoTest.cpp
+ ModuleCacheTest.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbUtility
+ lldbPluginObjectFileELF
+ LINK_COMPONENTS
+ Support
+ )
+
+add_unittest_inputs(TargetTests TestModule.so)
diff --git a/unittests/Utility/Inputs/TestModule.c b/unittests/Target/Inputs/TestModule.c
index 6347f7264944..6347f7264944 100644
--- a/unittests/Utility/Inputs/TestModule.c
+++ b/unittests/Target/Inputs/TestModule.c
diff --git a/unittests/Utility/Inputs/TestModule.so b/unittests/Target/Inputs/TestModule.so
index 9e9bf0b6e17e..9e9bf0b6e17e 100644
--- a/unittests/Utility/Inputs/TestModule.so
+++ b/unittests/Target/Inputs/TestModule.so
Binary files differ
diff --git a/unittests/Target/MemoryRegionInfoTest.cpp b/unittests/Target/MemoryRegionInfoTest.cpp
new file mode 100644
index 000000000000..704f7f8c48c6
--- /dev/null
+++ b/unittests/Target/MemoryRegionInfoTest.cpp
@@ -0,0 +1,20 @@
+//===-- MemoryRegionInfoTest.cpp --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(MemoryRegionInfoTest, Formatv) {
+ EXPECT_EQ("yes", llvm::formatv("{0}", MemoryRegionInfo::eYes).str());
+ EXPECT_EQ("no", llvm::formatv("{0}", MemoryRegionInfo::eNo).str());
+ EXPECT_EQ("don't know", llvm::formatv("{0}", MemoryRegionInfo::eDontKnow).str());
+}
diff --git a/unittests/Utility/ModuleCacheTest.cpp b/unittests/Target/ModuleCacheTest.cpp
index 911c278c1626..09b3edc4148b 100644
--- a/unittests/Utility/ModuleCacheTest.cpp
+++ b/unittests/Target/ModuleCacheTest.cpp
@@ -5,11 +5,11 @@
#include "llvm/Support/Path.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Utility/ModuleCache.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/ModuleCache.h"
extern const char *TestMainArgv0;
diff --git a/unittests/UnwindAssembly/InstEmulation/CMakeLists.txt b/unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
index 5e274a229919..7cc0befa386b 100644
--- a/unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
+++ b/unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
@@ -1,3 +1,15 @@
if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
- add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
+ add_lldb_unittest(InstEmulationTests
+ TestArm64InstEmulation.cpp
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ lldbPluginUnwindAssemblyInstEmulation
+ lldbPluginDisassemblerLLVM
+ lldbPluginInstructionARM64
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
+ ${LLVM_TARGETS_TO_BUILD})
endif()
diff --git a/unittests/UnwindAssembly/x86/CMakeLists.txt b/unittests/UnwindAssembly/x86/CMakeLists.txt
index 7112467b3975..2b5b31f79063 100644
--- a/unittests/UnwindAssembly/x86/CMakeLists.txt
+++ b/unittests/UnwindAssembly/x86/CMakeLists.txt
@@ -1,3 +1,10 @@
add_lldb_unittest(UnwindAssemblyx86Tests
Testx86AssemblyInspectionEngine.cpp
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbPluginUnwindAssemblyX86
+ LINK_COMPONENTS
+ Support
+ ${LLVM_TARGETS_TO_BUILD}
)
diff --git a/unittests/Utility/CMakeLists.txt b/unittests/Utility/CMakeLists.txt
index 15a29825f1da..60868bcb414c 100644
--- a/unittests/Utility/CMakeLists.txt
+++ b/unittests/Utility/CMakeLists.txt
@@ -1,9 +1,20 @@
+add_subdirectory(Mocks)
+
add_lldb_unittest(UtilityTests
- ModuleCacheTest.cpp
+ ConstStringTest.cpp
+ ErrorTest.cpp
+ LogTest.cpp
+ NameMatchesTest.cpp
StringExtractorTest.cpp
TaskPoolTest.cpp
+ TildeExpressionResolverTest.cpp
TimeoutTest.cpp
UriParserTest.cpp
- )
+ VASprintfTest.cpp
-add_unittest_inputs(UtilityTests TestModule.so)
+ LINK_LIBS
+ lldbUtility
+ lldbUtilityMocks
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/unittests/Utility/ConstStringTest.cpp b/unittests/Utility/ConstStringTest.cpp
new file mode 100644
index 000000000000..454f656760ca
--- /dev/null
+++ b/unittests/Utility/ConstStringTest.cpp
@@ -0,0 +1,18 @@
+//===-- ConstStringTest.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/ConstString.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(ConstStringTest, format_provider) {
+ EXPECT_EQ("foo", llvm::formatv("{0}", ConstString("foo")).str());
+}
diff --git a/unittests/Core/ErrorTest.cpp b/unittests/Utility/ErrorTest.cpp
index f3727bbd78ae..a114b26ebe54 100644
--- a/unittests/Core/ErrorTest.cpp
+++ b/unittests/Utility/ErrorTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/Utility/Error.h"
#include "gtest/gtest.h"
-#include "lldb/Core/Error.h"
using namespace lldb_private;
diff --git a/unittests/Utility/LogTest.cpp b/unittests/Utility/LogTest.cpp
new file mode 100644
index 000000000000..61fb6b5e4a5b
--- /dev/null
+++ b/unittests/Utility/LogTest.cpp
@@ -0,0 +1,280 @@
+//===-- LogTest.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Threading.h"
+#include <thread>
+
+using namespace lldb;
+using namespace lldb_private;
+
+enum { FOO = 1, BAR = 2 };
+static constexpr Log::Category test_categories[] = {
+ {{"foo"}, {"log foo"}, FOO}, {{"bar"}, {"log bar"}, BAR},
+};
+static constexpr uint32_t default_flags = FOO;
+
+static Log::Channel test_channel(test_categories, default_flags);
+
+struct LogChannelTest : public ::testing::Test {
+ void TearDown() override { Log::DisableAllLogChannels(); }
+
+ static void SetUpTestCase() {
+ Log::Register("chan", test_channel);
+ }
+
+ static void TearDownTestCase() {
+ Log::Unregister("chan");
+ llvm::llvm_shutdown();
+ }
+};
+
+// Wrap enable, disable and list functions to make them easier to test.
+static bool EnableChannel(std::shared_ptr<llvm::raw_ostream> stream_sp,
+ uint32_t log_options, llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ std::string &error) {
+ error.clear();
+ llvm::raw_string_ostream error_stream(error);
+ return Log::EnableLogChannel(stream_sp, log_options, channel, categories,
+ error_stream);
+}
+
+static bool DisableChannel(llvm::StringRef channel,
+ llvm::ArrayRef<const char *> categories,
+ std::string &error) {
+ error.clear();
+ llvm::raw_string_ostream error_stream(error);
+ return Log::DisableLogChannel(channel, categories, error_stream);
+}
+
+static bool ListCategories(llvm::StringRef channel, std::string &result) {
+ result.clear();
+ llvm::raw_string_ostream result_stream(result);
+ return Log::ListChannelCategories(channel, result_stream);
+}
+
+TEST(LogTest, LLDB_LOG_nullptr) {
+ Log *log = nullptr;
+ LLDB_LOG(log, "{0}", 0); // Shouldn't crash
+}
+
+TEST(LogTest, Register) {
+ llvm::llvm_shutdown_obj obj;
+ Log::Register("chan", test_channel);
+ Log::Unregister("chan");
+ Log::Register("chan", test_channel);
+ Log::Unregister("chan");
+}
+
+TEST(LogTest, Unregister) {
+ llvm::llvm_shutdown_obj obj;
+ Log::Register("chan", test_channel);
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAny(FOO));
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ EXPECT_TRUE(Log::EnableLogChannel(stream_sp, 0, "chan", {"foo"}, llvm::nulls()));
+ EXPECT_NE(nullptr, test_channel.GetLogIfAny(FOO));
+ Log::Unregister("chan");
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAny(FOO));
+}
+
+TEST_F(LogChannelTest, Enable) {
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string error;
+ ASSERT_FALSE(EnableChannel(stream_sp, 0, "chanchan", {}, error));
+ EXPECT_EQ("Invalid log channel 'chanchan'.\n", error);
+
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, error));
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO));
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(BAR));
+
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"bar"}, error));
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO | BAR));
+
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"baz"}, error));
+ EXPECT_NE(std::string::npos, error.find("unrecognized log category 'baz'"))
+ << "error: " << error;
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO | BAR));
+}
+
+TEST_F(LogChannelTest, EnableOptions) {
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string error;
+ EXPECT_TRUE(
+ EnableChannel(stream_sp, LLDB_LOG_OPTION_VERBOSE, "chan", {}, error));
+
+ Log *log = test_channel.GetLogIfAll(FOO);
+ ASSERT_NE(nullptr, log);
+ EXPECT_TRUE(log->GetVerbose());
+}
+
+TEST_F(LogChannelTest, Disable) {
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string error;
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"foo", "bar"}, error));
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO | BAR));
+
+ EXPECT_TRUE(DisableChannel("chan", {"bar"}, error));
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO));
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(BAR));
+
+ EXPECT_TRUE(DisableChannel("chan", {"baz"}, error));
+ EXPECT_NE(std::string::npos, error.find("unrecognized log category 'baz'"))
+ << "error: " << error;
+ EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO));
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(BAR));
+
+ EXPECT_TRUE(DisableChannel("chan", {}, error));
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAny(FOO | BAR));
+}
+
+TEST_F(LogChannelTest, List) {
+ std::string list;
+ EXPECT_TRUE(ListCategories("chan", list));
+ std::string expected =
+ R"(Logging categories for 'chan':
+ all - all available logging categories
+ default - default set of logging categories
+ foo - log foo
+ bar - log bar
+)";
+ EXPECT_EQ(expected, list);
+
+ EXPECT_FALSE(ListCategories("chanchan", list));
+ EXPECT_EQ("Invalid log channel 'chanchan'.\n", list);
+}
+
+static std::string GetLogString(uint32_t log_options, const char *format,
+ int arg) {
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
+ EXPECT_TRUE(
+ Log::EnableLogChannel(stream_sp, log_options, "chan", {}, error_stream));
+
+ Log *log = test_channel.GetLogIfAll(FOO);
+ EXPECT_NE(nullptr, log);
+
+ LLDB_LOG(log, format, arg);
+ EXPECT_TRUE(Log::DisableLogChannel("chan", {}, error_stream));
+
+ return stream_sp->str();
+}
+
+TEST_F(LogChannelTest, log_options) {
+ EXPECT_EQ("Hello World 47\n", GetLogString(0, "Hello World {0}", 47));
+ EXPECT_EQ("Hello World 47\n",
+ GetLogString(LLDB_LOG_OPTION_THREADSAFE, "Hello World {0}", 47));
+
+ {
+ std::string msg =
+ GetLogString(LLDB_LOG_OPTION_PREPEND_SEQUENCE, "Hello World {0}", 47);
+ int seq_no;
+ EXPECT_EQ(1, sscanf(msg.c_str(), "%d Hello World 47", &seq_no));
+ }
+
+ EXPECT_EQ(
+ "LogTest.cpp:GetLogString Hello "
+ "World 47\n",
+ GetLogString(LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION, "Hello World {0}", 47));
+
+ EXPECT_EQ(llvm::formatv("[{0,0+4}/{1,0+4}] Hello World 47\n", ::getpid(),
+ llvm::get_threadid())
+ .str(),
+ GetLogString(LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD,
+ "Hello World {0}", 47));
+}
+
+TEST_F(LogChannelTest, LogThread) {
+ // Test that we are able to concurrently write to a log channel and disable
+ // it.
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string err;
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, err));
+
+ Log *log = test_channel.GetLogIfAll(FOO);
+
+ // Start logging on one thread. Concurrently, try disabling the log channel.
+ std::thread log_thread([log] { LLDB_LOG(log, "Hello World"); });
+ EXPECT_TRUE(DisableChannel("chan", {}, err));
+ log_thread.join();
+
+ // The log thread either managed to write to the log in time, or it didn't. In
+ // either case, we should not trip any undefined behavior (run the test under
+ // TSAN to verify this).
+ EXPECT_TRUE(stream_sp->str() == "" || stream_sp->str() == "Hello World\n")
+ << "str(): " << stream_sp->str();
+}
+
+TEST_F(LogChannelTest, LogVerboseThread) {
+ // Test that we are able to concurrently check the verbose flag of a log
+ // channel and enable it.
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string err;
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, err));
+
+ Log *log = test_channel.GetLogIfAll(FOO);
+
+ // Start logging on one thread. Concurrently, try enabling the log channel
+ // (with different log options).
+ std::thread log_thread([log] { LLDB_LOGV(log, "Hello World"); });
+ EXPECT_TRUE(EnableChannel(stream_sp, LLDB_LOG_OPTION_VERBOSE, "chan",
+ {}, err));
+ log_thread.join();
+ EXPECT_TRUE(DisableChannel("chan", {}, err));
+
+ // The log thread either managed to write to the log, or it didn't. In either
+ // case, we should not trip any undefined behavior (run the test under TSAN to
+ // verify this).
+ EXPECT_TRUE(stream_sp->str() == "" || stream_sp->str() == "Hello World\n")
+ << "str(): " << stream_sp->str();
+}
+
+TEST_F(LogChannelTest, LogGetLogThread) {
+ // Test that we are able to concurrently get mask of a Log object and disable
+ // it.
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ std::string err;
+ EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, err));
+ Log *log = test_channel.GetLogIfAll(FOO);
+
+ // Try fetching the log on one thread. Concurrently, try disabling the log
+ // channel.
+ uint32_t mask;
+ std::thread log_thread([log, &mask] { mask = log->GetMask().Get(); });
+ EXPECT_TRUE(DisableChannel("chan", {}, err));
+ log_thread.join();
+
+ // The mask should be either zero of "FOO". In either case, we should not trip
+ // any undefined behavior (run the test under TSAN to verify this).
+ EXPECT_TRUE(mask == 0 || mask == FOO) << "mask: " << mask;
+}
diff --git a/unittests/Utility/Mocks/CMakeLists.txt b/unittests/Utility/Mocks/CMakeLists.txt
new file mode 100644
index 000000000000..57db5bf3b628
--- /dev/null
+++ b/unittests/Utility/Mocks/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_lldb_library(lldbUtilityMocks
+ MockTildeExpressionResolver.cpp
+
+ LINK_LIBS
+ lldbUtility
+
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp b/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp
new file mode 100644
index 000000000000..832836682b50
--- /dev/null
+++ b/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp
@@ -0,0 +1,80 @@
+//===----------------- MockTildeExpressionResolver.cpp ----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MockTildeExpressionResolver.h"
+#include "llvm/Support/Path.h"
+
+using namespace lldb_private;
+using namespace llvm;
+
+MockTildeExpressionResolver::MockTildeExpressionResolver(StringRef CurrentUser,
+ StringRef HomeDir)
+ : CurrentUser(CurrentUser) {
+ UserDirectories.insert(std::make_pair(CurrentUser, HomeDir));
+}
+
+void MockTildeExpressionResolver::AddKnownUser(StringRef User,
+ StringRef HomeDir) {
+ assert(UserDirectories.find(User) == UserDirectories.end());
+ UserDirectories.insert(std::make_pair(User, HomeDir));
+}
+
+void MockTildeExpressionResolver::Clear() {
+ CurrentUser = StringRef();
+ UserDirectories.clear();
+}
+
+void MockTildeExpressionResolver::SetCurrentUser(StringRef User) {
+ assert(UserDirectories.find(User) != UserDirectories.end());
+ CurrentUser = User;
+}
+
+bool MockTildeExpressionResolver::ResolveExact(StringRef Expr,
+ SmallVectorImpl<char> &Output) {
+ Output.clear();
+
+ assert(!llvm::any_of(
+ Expr, [](char c) { return llvm::sys::path::is_separator(c); }));
+ assert(Expr.empty() || Expr[0] == '~');
+ Expr = Expr.drop_front();
+ if (Expr.empty()) {
+ auto Dir = UserDirectories[CurrentUser];
+ Output.append(Dir.begin(), Dir.end());
+ return true;
+ }
+
+ for (const auto &User : UserDirectories) {
+ if (User.getKey() != Expr)
+ continue;
+ Output.append(User.getValue().begin(), User.getValue().end());
+ return true;
+ }
+ return false;
+}
+
+bool MockTildeExpressionResolver::ResolvePartial(StringRef Expr,
+ StringSet<> &Output) {
+ Output.clear();
+
+ assert(!llvm::any_of(
+ Expr, [](char c) { return llvm::sys::path::is_separator(c); }));
+ assert(Expr.empty() || Expr[0] == '~');
+ Expr = Expr.drop_front();
+
+ SmallString<16> QualifiedName("~");
+ for (const auto &User : UserDirectories) {
+ if (!User.getKey().startswith(Expr))
+ continue;
+ QualifiedName.resize(1);
+ QualifiedName.append(User.getKey().begin(), User.getKey().end());
+ Output.insert(QualifiedName);
+ }
+
+ return !Output.empty();
+}
diff --git a/unittests/Utility/Mocks/MockTildeExpressionResolver.h b/unittests/Utility/Mocks/MockTildeExpressionResolver.h
new file mode 100644
index 000000000000..7ae5623f839a
--- /dev/null
+++ b/unittests/Utility/Mocks/MockTildeExpressionResolver.h
@@ -0,0 +1,37 @@
+//===--------------------- TildeExpressionResolver.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_UNITTESTS_UTILITY_MOCKS_MOCK_TILDE_EXPRESSION_RESOLVER_H
+#define LLDB_UNITTESTS_UTILITY_MOCKS_MOCK_TILDE_EXPRESSION_RESOLVER_H
+
+#include "lldb/Utility/TildeExpressionResolver.h"
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
+
+namespace lldb_private {
+class MockTildeExpressionResolver : public TildeExpressionResolver {
+ llvm::StringRef CurrentUser;
+ llvm::StringMap<llvm::StringRef> UserDirectories;
+
+public:
+ MockTildeExpressionResolver(llvm::StringRef CurrentUser,
+ llvm::StringRef HomeDir);
+
+ void AddKnownUser(llvm::StringRef User, llvm::StringRef HomeDir);
+ void Clear();
+ void SetCurrentUser(llvm::StringRef User);
+
+ bool ResolveExact(llvm::StringRef Expr,
+ llvm::SmallVectorImpl<char> &Output) override;
+ bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) override;
+};
+}
+
+#endif
diff --git a/unittests/Utility/NameMatchesTest.cpp b/unittests/Utility/NameMatchesTest.cpp
new file mode 100644
index 000000000000..28ae16c7ddd5
--- /dev/null
+++ b/unittests/Utility/NameMatchesTest.cpp
@@ -0,0 +1,58 @@
+//===-- NameMatchesTest.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/NameMatches.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(NameMatchesTest, Ignore) {
+ EXPECT_TRUE(NameMatches("foo", NameMatch::Ignore, "bar"));
+}
+
+TEST(NameMatchesTest, Equals) {
+ EXPECT_TRUE(NameMatches("foo", NameMatch::Equals, "foo"));
+ EXPECT_FALSE(NameMatches("foo", NameMatch::Equals, "bar"));
+}
+
+TEST(NameMatchesTest, Contains) {
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foo"));
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "oob"));
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "bar"));
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::Contains, "foobar"));
+ EXPECT_TRUE(NameMatches("", NameMatch::Contains, ""));
+ EXPECT_FALSE(NameMatches("", NameMatch::Contains, "foo"));
+ EXPECT_FALSE(NameMatches("foobar", NameMatch::Contains, "baz"));
+}
+
+TEST(NameMatchesTest, StartsWith) {
+ EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, "f"));
+ EXPECT_TRUE(NameMatches("foo", NameMatch::StartsWith, ""));
+ EXPECT_TRUE(NameMatches("", NameMatch::StartsWith, ""));
+ EXPECT_FALSE(NameMatches("foo", NameMatch::StartsWith, "b"));
+ EXPECT_FALSE(NameMatches("", NameMatch::StartsWith, "b"));
+}
+
+TEST(NameMatchesTest, EndsWith) {
+ EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, "o"));
+ EXPECT_TRUE(NameMatches("foo", NameMatch::EndsWith, ""));
+ EXPECT_TRUE(NameMatches("", NameMatch::EndsWith, ""));
+ EXPECT_FALSE(NameMatches("foo", NameMatch::EndsWith, "b"));
+ EXPECT_FALSE(NameMatches("", NameMatch::EndsWith, "b"));
+}
+
+TEST(NameMatchesTest, RegularExpression) {
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "foo"));
+ EXPECT_TRUE(NameMatches("foobar", NameMatch::RegularExpression, "f[oa]o"));
+ EXPECT_TRUE(NameMatches("foo", NameMatch::RegularExpression, ""));
+ EXPECT_TRUE(NameMatches("", NameMatch::RegularExpression, ""));
+ EXPECT_FALSE(NameMatches("foo", NameMatch::RegularExpression, "b"));
+ EXPECT_FALSE(NameMatches("", NameMatch::RegularExpression, "b"));
+ EXPECT_FALSE(NameMatches("^a", NameMatch::RegularExpression, "^a"));
+}
diff --git a/unittests/Utility/TildeExpressionResolverTest.cpp b/unittests/Utility/TildeExpressionResolverTest.cpp
new file mode 100644
index 000000000000..fd953390ed5d
--- /dev/null
+++ b/unittests/Utility/TildeExpressionResolverTest.cpp
@@ -0,0 +1,36 @@
+#include "gtest/gtest.h"
+
+#include "Mocks/MockTildeExpressionResolver.h"
+#include "lldb/Utility/TildeExpressionResolver.h"
+
+#include "llvm/ADT/SmallString.h"
+
+using namespace llvm;
+using namespace lldb_private;
+
+TEST(TildeExpressionResolver, ResolveFullPath) {
+ MockTildeExpressionResolver Resolver("James", "/james");
+ Resolver.AddKnownUser("Kirk", "/kirk");
+ Resolver.AddKnownUser("Lars", "/lars");
+ Resolver.AddKnownUser("Jason", "/jason");
+ Resolver.AddKnownUser("Larry", "/larry");
+
+ SmallString<32> Result;
+ ASSERT_TRUE(Resolver.ResolveFullPath("~", Result));
+ EXPECT_EQ("/james", Result);
+ ASSERT_TRUE(Resolver.ResolveFullPath("~/", Result));
+ EXPECT_EQ("/james/", Result);
+
+ ASSERT_TRUE(Resolver.ResolveFullPath("~James/bar/baz", Result));
+ EXPECT_EQ("/james/bar/baz", Result);
+
+ ASSERT_TRUE(Resolver.ResolveFullPath("~Jason/", Result));
+ EXPECT_EQ("/jason/", Result);
+
+ ASSERT_TRUE(Resolver.ResolveFullPath("~Lars", Result));
+ EXPECT_EQ("/lars", Result);
+
+ ASSERT_FALSE(Resolver.ResolveFullPath("~Jaso", Result));
+ ASSERT_FALSE(Resolver.ResolveFullPath("", Result));
+ ASSERT_FALSE(Resolver.ResolveFullPath("Jason", Result));
+}
diff --git a/unittests/Utility/TimeoutTest.cpp b/unittests/Utility/TimeoutTest.cpp
index a30c616d411b..d1002fb840da 100644
--- a/unittests/Utility/TimeoutTest.cpp
+++ b/unittests/Utility/TimeoutTest.cpp
@@ -8,15 +8,23 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/Timeout.h"
+#include "llvm/Support/FormatVariadic.h"
#include "gtest/gtest.h"
using namespace lldb_private;
using namespace std::chrono;
TEST(TimeoutTest, Construction) {
- ASSERT_FALSE(Timeout<std::micro>(llvm::None));
- ASSERT_TRUE(bool(Timeout<std::micro>(seconds(0))));
- ASSERT_EQ(seconds(0), *Timeout<std::micro>(seconds(0)));
- ASSERT_EQ(seconds(3), *Timeout<std::micro>(seconds(3)));
- ASSERT_TRUE(bool(Timeout<std::micro>(Timeout<std::milli>(seconds(0)))));
+ EXPECT_FALSE(Timeout<std::micro>(llvm::None));
+ EXPECT_TRUE(bool(Timeout<std::micro>(seconds(0))));
+ EXPECT_EQ(seconds(0), *Timeout<std::micro>(seconds(0)));
+ EXPECT_EQ(seconds(3), *Timeout<std::micro>(seconds(3)));
+ EXPECT_TRUE(bool(Timeout<std::micro>(Timeout<std::milli>(seconds(0)))));
+}
+
+TEST(TimeoutTest, Format) {
+ EXPECT_EQ("<infinite>",
+ llvm::formatv("{0}", Timeout<std::milli>(llvm::None)).str());
+ EXPECT_EQ("1000 ms",
+ llvm::formatv("{0}", Timeout<std::milli>(seconds(1))).str());
}
diff --git a/unittests/Utility/UriParserTest.cpp b/unittests/Utility/UriParserTest.cpp
index 8b08e63eb8c7..c07d59a55e01 100644
--- a/unittests/Utility/UriParserTest.cpp
+++ b/unittests/Utility/UriParserTest.cpp
@@ -1,9 +1,7 @@
-#include "Utility/UriParser.h"
+#include "lldb/Utility/UriParser.h"
#include "gtest/gtest.h"
-namespace {
-class UriParserTest : public ::testing::Test {};
-}
+using namespace lldb_private;
// result strings (scheme/hostname/port/path) passed into UriParser::Parse
// are initialized to kAsdf so we can verify that they are unmodified if the
@@ -41,12 +39,12 @@ public:
EXPECT_EQ(testCase.m_port, port); \
EXPECT_STREQ(testCase.m_path, path.str().c_str());
-TEST_F(UriParserTest, Minimal) {
+TEST(UriParserTest, Minimal) {
const UriTestCase testCase("x://y", "x", "y", -1, "/");
VALIDATE
}
-TEST_F(UriParserTest, MinimalPort) {
+TEST(UriParserTest, MinimalPort) {
const UriTestCase testCase("x://y:1", "x", "y", 1, "/");
llvm::StringRef scheme(kAsdf);
llvm::StringRef hostname(kAsdf);
@@ -61,28 +59,28 @@ TEST_F(UriParserTest, MinimalPort) {
EXPECT_STREQ(testCase.m_path, path.str().c_str());
}
-TEST_F(UriParserTest, MinimalPath) {
+TEST(UriParserTest, MinimalPath) {
const UriTestCase testCase("x://y/", "x", "y", -1, "/");
VALIDATE
}
-TEST_F(UriParserTest, MinimalPortPath) {
+TEST(UriParserTest, MinimalPortPath) {
const UriTestCase testCase("x://y:1/", "x", "y", 1, "/");
VALIDATE
}
-TEST_F(UriParserTest, LongPath) {
+TEST(UriParserTest, LongPath) {
const UriTestCase testCase("x://y/abc/def/xyz", "x", "y", -1, "/abc/def/xyz");
VALIDATE
}
-TEST_F(UriParserTest, TypicalPortPath) {
+TEST(UriParserTest, TypicalPortPath) {
const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
"192.168.100.132", 5432, "/");
VALIDATE;
}
-TEST_F(UriParserTest, BracketedHostnamePort) {
+TEST(UriParserTest, BracketedHostnamePort) {
const UriTestCase testCase("connect://[192.168.100.132]:5432/", "connect",
"192.168.100.132", 5432, "/");
llvm::StringRef scheme(kAsdf);
@@ -98,54 +96,54 @@ TEST_F(UriParserTest, BracketedHostnamePort) {
EXPECT_STREQ(testCase.m_path, path.str().c_str());
}
-TEST_F(UriParserTest, BracketedHostname) {
+TEST(UriParserTest, BracketedHostname) {
const UriTestCase testCase("connect://[192.168.100.132]", "connect",
"192.168.100.132", -1, "/");
VALIDATE
}
-TEST_F(UriParserTest, BracketedHostnameWithColon) {
+TEST(UriParserTest, BracketedHostnameWithColon) {
const UriTestCase testCase("connect://[192.168.100.132:5555]:1234", "connect",
"192.168.100.132:5555", 1234, "/");
VALIDATE
}
-TEST_F(UriParserTest, SchemeHostSeparator) {
+TEST(UriParserTest, SchemeHostSeparator) {
const UriTestCase testCase("x:/y");
VALIDATE
}
-TEST_F(UriParserTest, SchemeHostSeparator2) {
+TEST(UriParserTest, SchemeHostSeparator2) {
const UriTestCase testCase("x:y");
VALIDATE
}
-TEST_F(UriParserTest, SchemeHostSeparator3) {
+TEST(UriParserTest, SchemeHostSeparator3) {
const UriTestCase testCase("x//y");
VALIDATE
}
-TEST_F(UriParserTest, SchemeHostSeparator4) {
+TEST(UriParserTest, SchemeHostSeparator4) {
const UriTestCase testCase("x/y");
VALIDATE
}
-TEST_F(UriParserTest, BadPort) {
+TEST(UriParserTest, BadPort) {
const UriTestCase testCase("x://y:a/");
VALIDATE
}
-TEST_F(UriParserTest, BadPort2) {
+TEST(UriParserTest, BadPort2) {
const UriTestCase testCase("x://y:5432a/");
VALIDATE
}
-TEST_F(UriParserTest, Empty) {
+TEST(UriParserTest, Empty) {
const UriTestCase testCase("");
VALIDATE
}
-TEST_F(UriParserTest, PortOverflow) {
+TEST(UriParserTest, PortOverflow) {
const UriTestCase testCase("x://"
"y:"
"0123456789012345678901234567890123456789012345678"
diff --git a/unittests/Utility/VASprintfTest.cpp b/unittests/Utility/VASprintfTest.cpp
new file mode 100644
index 000000000000..0b440942eb5a
--- /dev/null
+++ b/unittests/Utility/VASprintfTest.cpp
@@ -0,0 +1,59 @@
+//===-- VASprintfTest.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/VASPrintf.h"
+#include "llvm/ADT/SmallString.h"
+
+#include "gtest/gtest.h"
+
+#include <locale.h>
+
+using namespace lldb_private;
+using namespace llvm;
+
+static bool Sprintf(llvm::SmallVectorImpl<char> &Buffer, const char *Fmt, ...) {
+ va_list args;
+ va_start(args, Fmt);
+ bool Result = VASprintf(Buffer, Fmt, args);
+ va_end(args);
+ return Result;
+}
+
+TEST(VASprintfTest, NoBufferResize) {
+ std::string TestStr("small");
+
+ llvm::SmallString<32> BigBuffer;
+ ASSERT_TRUE(Sprintf(BigBuffer, "%s", TestStr.c_str()));
+ EXPECT_STREQ(TestStr.c_str(), BigBuffer.c_str());
+ EXPECT_EQ(TestStr.size(), BigBuffer.size());
+}
+
+TEST(VASprintfTest, BufferResize) {
+ std::string TestStr("bigger");
+ llvm::SmallString<4> SmallBuffer;
+ ASSERT_TRUE(Sprintf(SmallBuffer, "%s", TestStr.c_str()));
+ EXPECT_STREQ(TestStr.c_str(), SmallBuffer.c_str());
+ EXPECT_EQ(TestStr.size(), SmallBuffer.size());
+}
+
+TEST(VASprintfTest, EncodingError) {
+ // Save the current locale first.
+ std::string Current(::setlocale(LC_ALL, nullptr));
+
+ setlocale(LC_ALL, ".932");
+
+ wchar_t Invalid[2];
+ Invalid[0] = 0x100;
+ Invalid[1] = 0;
+ llvm::SmallString<32> Buffer;
+ EXPECT_FALSE(Sprintf(Buffer, "%ls", Invalid));
+ EXPECT_EQ("<Encoding error>", Buffer);
+
+ setlocale(LC_ALL, Current.c_str());
+}
diff --git a/unittests/debugserver/CMakeLists.txt b/unittests/debugserver/CMakeLists.txt
new file mode 100644
index 000000000000..cfb520a0dc76
--- /dev/null
+++ b/unittests/debugserver/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Note: debugserver is a Darwin-only implementation of a remote debugging
+# server. It is not intended to be used on other platforms. The tests are here
+# because using the LLDB Host API is convienent and allows testing of both parts
+# of the debugserver communication path. If you are looking for a non-darwin
+# remote debugging server, please use lldb-server.
+
+include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source
+ ${LLDB_SOURCE_DIR}/tools/debugserver/source/MacOSX)
+
+add_lldb_unittest(debugserverTests
+ RNBSocketTest.cpp
+ debugserver_LogCallback.cpp
+
+ LINK_LIBS
+ lldbDebugserverCommon
+ lldbHost
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/unittests/debugserver/RNBSocketTest.cpp b/unittests/debugserver/RNBSocketTest.cpp
new file mode 100644
index 000000000000..997041f6154b
--- /dev/null
+++ b/unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,133 @@
+//===-- RNBSocketTest.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+
+#include <arpa/inet.h>
+#include <sys/sysctl.h>
+#include <unistd.h>
+
+#include "RNBDefs.h"
+#include "RNBSocket.h"
+#include "lldb/Host/Socket.h"
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+using namespace lldb_private;
+
+std::string hello = "Hello, world!";
+std::string goodbye = "Goodbye!";
+
+static void ServerCallbackv4(const void *baton, in_port_t port) {
+ auto child_pid = fork();
+ if (child_pid == 0) {
+ Socket *client_socket;
+ char addr_buffer[256];
+ sprintf(addr_buffer, "%s:%d", baton, port);
+ Error err = Socket::TcpConnect(addr_buffer, false, client_socket);
+ if (err.Fail())
+ abort();
+ char buffer[32];
+ size_t read_size = 32;
+ err = client_socket->Read((void *)&buffer[0], read_size);
+ if (err.Fail())
+ abort();
+ std::string Recv(&buffer[0], read_size);
+ if (Recv != hello)
+ abort();
+ size_t write_size = goodbye.length();
+ err = client_socket->Write(goodbye.c_str(), write_size);
+ if (err.Fail())
+ abort();
+ if (write_size != goodbye.length())
+ abort();
+ delete client_socket;
+ exit(0);
+ }
+}
+
+void TestSocketListen(const char *addr) {
+ RNBSocket server_socket;
+ auto result =
+ server_socket.Listen(addr, 0, ServerCallbackv4, (const void *)addr);
+ ASSERT_TRUE(result == rnb_success);
+ result = server_socket.Write(hello.c_str(), hello.length());
+ ASSERT_TRUE(result == rnb_success);
+ std::string bye;
+ result = server_socket.Read(bye);
+ ASSERT_TRUE(result == rnb_success);
+ ASSERT_EQ(bye, goodbye);
+
+ int exit_status;
+ wait(&exit_status);
+ ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackListenIPv4) { TestSocketListen("127.0.0.1"); }
+
+void TestSocketConnect(const char *addr) {
+ char addr_wrap[256];
+ sprintf(addr_wrap, "%s:0", addr);
+
+ Socket *server_socket;
+ Predicate<uint16_t> port_predicate;
+ port_predicate.SetValue(0, eBroadcastNever);
+ Error err =
+ Socket::TcpListen(addr_wrap, false, server_socket, &port_predicate);
+ ASSERT_FALSE(err.Fail());
+
+ auto port = ((TCPSocket *)server_socket)->GetLocalPortNumber();
+ auto child_pid = fork();
+ if (child_pid != 0) {
+ RNBSocket client_socket;
+ auto result = client_socket.Connect(addr, port);
+ ASSERT_TRUE(result == rnb_success);
+ result = client_socket.Write(hello.c_str(), hello.length());
+ ASSERT_TRUE(result == rnb_success);
+ std::string bye;
+ result = client_socket.Read(bye);
+ ASSERT_TRUE(result == rnb_success);
+ ASSERT_EQ(bye, goodbye);
+ } else {
+ Socket *connected_socket;
+ err = server_socket->Accept(addr_wrap, false, connected_socket);
+ if (err.Fail()) {
+ llvm::errs() << err.AsCString();
+ abort();
+ }
+ char buffer[32];
+ size_t read_size = 32;
+ err = connected_socket->Read((void *)&buffer[0], read_size);
+ if (err.Fail()) {
+ llvm::errs() << err.AsCString();
+ abort();
+ }
+ std::string Recv(&buffer[0], read_size);
+ if (Recv != hello) {
+ llvm::errs() << err.AsCString();
+ abort();
+ }
+ size_t write_size = goodbye.length();
+ err = connected_socket->Write(goodbye.c_str(), write_size);
+ if (err.Fail()) {
+ llvm::errs() << err.AsCString();
+ abort();
+ }
+ if (write_size != goodbye.length()) {
+ llvm::errs() << err.AsCString();
+ abort();
+ }
+ exit(0);
+ }
+ int exit_status;
+ wait(&exit_status);
+ ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackConnectIPv4) { TestSocketConnect("127.0.0.1"); }
diff --git a/unittests/debugserver/debugserver_LogCallback.cpp b/unittests/debugserver/debugserver_LogCallback.cpp
new file mode 100644
index 000000000000..7a724b419775
--- /dev/null
+++ b/unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//------------------------------------------------------------------------------
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//------------------------------------------------------------------------------
+
+#include <stdint.h>
+#include <stdarg.h>
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
diff --git a/unittests/gtest_common.h b/unittests/gtest_common.h
index c8fe92575941..f61ba9d0c371 100644
--- a/unittests/gtest_common.h
+++ b/unittests/gtest_common.h
@@ -15,12 +15,3 @@
// This header file is force included by all of LLDB's unittest compilation
// units. Be very leary about putting anything in this file.
-
-#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Due to a bug in <thread>, when _HAS_EXCEPTIONS == 0 the header will try to
-// call
-// uncaught_exception() without having a declaration for it. The fix for this
-// is
-// to manually #include <eh.h>, which contains this declaration.
-#include <eh.h>
-#endif
diff --git a/www/build.html b/www/build.html
index 123badf40acc..5734bf9573aa 100755
--- a/www/build.html
+++ b/www/build.html
@@ -62,7 +62,7 @@
versions of Python can be made to work by compiling your own distribution from source,
but this workflow is unsupported and you are own your own.
</li>
- <li><a href="http://martine.github.io/ninja/">Ninja build tool</a> (strongly recommended)</li>
+ <li><a href="https://ninja-build.org/">Ninja build tool</a> (strongly recommended)</li>
<li><a href="http://gnuwin32.sourceforge.net/">GnuWin32</a></li>
<li><a href="http://www.swig.org/download.html">SWIG for Windows (version 3+)</a></li>
</ul>
diff --git a/www/index.html b/www/index.html
index 5d5cd3584adf..83849954aac9 100755
--- a/www/index.html
+++ b/www/index.html
@@ -126,6 +126,8 @@
<a href="http://lists.llvm.org/mailman/listinfo/lldb-commits">lldb-commits</a>
mailing list, and this is also the preferred mailing list for patch
submissions.</p>
+ <p>See the <a href="projects.html">Projects</a> page if you are looking for some interesting areas to contribute
+ to lldb.</p>
</div>
<div class="postfooter"></div>
</div>
diff --git a/www/projects.html b/www/projects.html
new file mode 100755
index 000000000000..b1aeb1021eca
--- /dev/null
+++ b/www/projects.html
@@ -0,0 +1,433 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<link href="style.css" rel="stylesheet" type="text/css" />
+<title>LLDB Projects</title>
+</head>
+
+<body>
+ <div class="www_title">
+ Project ideas for the <strong>LLDB</strong> Debugger
+ </div>
+
+<div id="container">
+ <div id="content">
+ <!--#include virtual="sidebar.incl"-->
+ <div id="middle">
+ <div class="post">
+ <h1 class ="postheader">Projects</h1>
+ <div class="postcontent">
+
+ <p>The following is a mostly unordered set of the ideas for improvements
+ to the LLDB debugger. Some are fairly deep, some would require less
+ effort.
+ </p>
+
+ <ol>
+ <li>
+ Speed up type realization in lldb.  
+ <p>
+ The type of problem I'm addressing here is the situation where you are
+ debugging a large program (lldb built with debug clang/swift will do)
+ and you go to print a simple expression, and lldb goes away for 30 seconds.
+ When you sample it, it is always busily churning through all the CU's in the
+ world looking for something.  The problem isn't that looking for something in
+ particular is slow, but rather that we somehow turned an bounded search
+ (maybe a subtype of "std::string" into an unbounded search (all things with the
+ name of that subtype.)  Or didn't stop when we got a reasonable answer
+ proximate to the context of the search, but let the search leak out globally.
+ And quite likely there are other issues that I haven't guessed yet.
+ But if you end up churning though 3 or 4 Gig of debug info, that's going to be slow
+ no matter how well written your debug reader is...
+ </p>
+ <p>
+ My guess is the work will be more in the general symbol lookup than in the DWARF
+ parser in particular, but it may be a combination of both.
+ </p>
+ <p>
+ As a user debugging a largish program, this is the most obvious lameness of lldb.
+ </p>
+ </li>
+
+ <li>
+ Symbol name completion in the expression parser.
+ <p>
+ This is the other obvious lameness of lldb.  You can do:
+ </p>
+<code><pre><tt>
+(lldb) frame var foo.b<TAB>
+</tt></pre></code>
+ <p>
+ and we will tell you it is "foo.bar". But you can't do that in the expression parser.
+ This will require collaboration with the clang/swift folks to get the right extension
+ points in the compiler. And whatever they are, lldb will need use them to tell the
+ compiler about what names are available. It will be important to avoid the pitfalls
+ of #1 where we wander into the entire DWARF world.
+ </p>
+
+ </li>
+ <li>
+ Make a high speed asynchronous communication channel to replace the gdb-remote protocol.
+ <p>
+ All lldb debugging nowadays is done by talking to a debug agent. We used the
+ gdb-remote protocol because that is universal, and good enough, and you have
+ to support it anyway since so many little devices & JTAG's and VM's etc
+ support it. But it is really old, not terribly high performance, and
+ can't really handle sending or receiving messages while the process is
+ supposedly running. It should have compression built in, remove the hand-built
+ checksums and rely on the robust communication protocols we always have nowadays,
+ allow for out-of-order requests/replies, allow for reconnecting to a temporarily
+ disconnected debug session, regularize all of the packet formatting into JSON or
+ BSON or whatever while including a way to do large binary transfers. It must be
+ possible to come up with something faster, and better tunable for the many
+ communications pathways we end up supporting.
+ </p>
+ </li>
+
+ <li>
+ Fix local variable lookup in the lldb expression parser.
+
+ <p>
+ The injection of local variables into the clang expression parser is
+ currently done incorrectly - it happens too late in the lookup. This results
+ in namespace variables & functions, same named types and ivars shadowing
+ locals when it should be the other way around. An attempt was made to fix
+ this by manually inserting all the visible local variables into wrapper function
+ in the expression text. This mostly gets the job done but that method
+ means you have to realize all the types
+ and locations of all local variables for even the simplest of expressions, and
+ when run on large programs (e.g. lldb) it would cause unacceptable delays. And
+ it was very fragile since an error in realizing any of the locals would cause
+ all expressions run in that context to fail. We need to fix this by adjusting
+ the points where name lookup calls out to lldb in clang.
+ </p>
+ </li>
+ <li>
+ Fix the event handling/process control machinery to support calling SB & Commands
+ everywhere, and to support non-stop debugging
+ <p>
+ There is a fairly ad-hoc system to handle when it is safe to run SB API's and
+ command line commands. This is actually a bit of a tricky problem, since we
+ allow access to the command line and SB API from some funky places in lldb.
+ The Operating System plugins are the most obvious instance, since they get
+ run right after lldb is told by debugserver that the process has stopped, but
+ before it has finished collating the information from the stop for presentation
+ to the higher levels. But breakpoint callbacks have some of the same problems,
+ and other things like the scripted stepping operations and any fancier extension
+ points we want to add to the debugger are going to be hard to implement robustly
+ till we work on a finer-grained and more explicit control over who gets to control
+ the process state.
+ <p>
+ We also won't have any chance of supporting non-stop debugging - which is a useful
+ mode for programs that have a lot of high-priority or real-time worker threads -
+ until we get this sorted out.
+ </p>
+ </li>
+
+ <li>
+ Finish the language abstraction and remove all the unnecessary C++/clang-based API's
+ <p>
+ An important part of making lldb a more useful "debugger toolkit" as opposed to a
+ C/C++/ObjC/Swift debugger is to have a clean abstraction for language support.
+ We did most, but not all, of the physical separation.  We need to finish that.
+ And then by force of necessity the API's really look like the interface to a C++
+ type system with a few swift bits added on.  How you would go about adding a new
+ language is unclear and much more trouble than it is worth at present. But if
+ we made this nice, we could add a lot of value to other language projects.
+ </p>
+ </li>
+
+ <li>
+ Add some syntax to generate data formatters from type definitions
+ <p>
+ Uses of the data formatters fall into two types. There are data formatters for
+ types where the structure elements pretty much tell you how to present the data,
+ you just need a little expression language to express how to turn them into what
+ the user expects to see. Then there are the ones (like pretty much all our
+ Foundation/AppKit/UIKit formatters) that use deep magic to figure out how the type
+ is actually laid out. The latter are pretty much always going to have to be done by hand.
+ </p>
+ <p>
+ But for the ones where the information is expressed in the fields, it would be great
+ to have a way to express the instructions to produce summaries and children in some
+ form you could embed next to the types and have the compiler produce a byte code
+ form of the instructions and then make that available to lldb along with the library.
+ This isn't as simple as having clang run over the headers and produce something from the
+ types directly. After all, clang has no way of knowing that the interesting thing about
+ a std::vector is the elements that you get by calling size (for the summary) and [] for
+ the elements. But it shouldn't be hard to come up with a generic markup to express this.
+ </p>
+ </li>
+
+ <li>
+ Allow the expression parser to access dynamic type/data formatter information
+ <p>
+ This seems like a smaller one. The symptom is your object is Foo child of Bar, and in
+ the Locals view you see all the fields of Foo, but because the static type of the object
+ is Bar, you can't see any of the fields of Foo. But if you could get this working,
+ you could hijack the mechanism to make the results of the value object summaries/synthetic
+ children available to expressions. And if you can do that, you could add other properties
+ to an object externally (through Python or some other extension point) and then have
+ these also available in the expression parser. You could use this to express invariants
+ for data structures, or other more advanced uses of types in the debugger.
+ </p>
+ <p>
+ Another version of this is to allow access to synthetic children in the expression
+ parser. Otherwise you end up in situations like:
+ </p>
+<code><pre><tt>
+(lldb) print return_a_foo()
+(SomeVectorLikeType) $1 = {
+ [0] = 0
+ [1] = 1
+ [2] = 2
+ [3] = 3
+ [4] = 4
+}
+</tt></pre></code>
+
+ <p>
+ That's good but:
+ </p>
+<code><pre><tt>
+(lldb) print return_a_foo()[2]
+</tt></pre></code>
+ <p>
+ fails because the expression parser doesn't know anything about the array-like nature of
+ SomeVectorLikeType that it gets from the synthetic children.
+ </p>
+ </li>
+
+ <li>
+ Recover thread information lazily
+ <p>
+ LLDB stores all the user intentions for a thread in the ThreadPlans stored in
+ the Thread class. That allows us to reliably implement a very natural model for
+ users moving through a debug session. For example, if step-over stops at a breakpoint
+ in an function in a younger region of the stack, continue will complete the step-over
+ rather than having to manually step out. But that means that it is important that
+ the Thread objects live as long as the Threads they represent. For programs with many
+ threads, but only one that you are debugging, that makes stepping less efficient,
+ since now you have to fetch the thread list on every step or stepping doesn't work
+ correctly. This is especially an issue when the threads are provided by an
+ Operating System plugin, where it may take non-trivial work to reconstruct the
+ thread list. It would be better to fetch threads lazily but keep "unseen" threads in
+ a holding area, and only retire them when we know we've fetched the whole thread list
+ and ensured they are no longer alive.
+ </p>
+ </li>
+ <li>
+ Add an extension point in the breakpoint search machinery.
+ <p>
+ This would allow highly customizable, algorithmic breakpoint types, like "break on every
+ use of some particular instruction, or instruction pattern, etc."
+ </p>
+ </li>
+
+ <li>
+ Make Python-backed commands first class citizens
+ <p>
+ As it stands, Python commands have no way to advertise their options. They are
+ required to parse their arguments by hand. That leads to inconsistency, and more
+ importantly means they can't take advantage of auto-generated help and command
+ completion. This leaves python-backed commands feeling worse than built-in ones.
+ </p>
+ <p>
+ As part of this job, it would also be great to hook automatically hook the "type" of an option value
+ or argument (e.g. eArgTypeShlibName) to sensible default completers. You need to be able to
+ over-ride this in more complicated scenarios (like in "break set" where the presence of
+ a "-s" option limits the search for completion of a "-n" option.) But in common cases it is
+ unnecessary busy-work to have to supply the completer AND the type. If this worked, then
+ it would be easier for Python commands to also get correct completers.
+ </p>
+ </li>
+
+ <li>
+ Documentation and better examples
+
+ <p>
+ We need to put the lldb syntax docs in the tutorial somewhere that is more easily accessible.
+ On suggestion is to add non-command based help to the help system, and then have a "help lldb"
+ or "help syntax" type command with this info. Be nice if the non-command based help could
+ be hierarchical so you could make topics.
+ </p>
+
+ <p>
+ There's a fair bit of docs about the SB API's, but it is spotty. Some classes are
+ well documented in the Python "help (lldb.SBWhatever)" and some are not.
+ </p>
+
+
+ <p>
+ We need more conceptual docs. And we need more examples. And we could provide a
+ clean pluggable example for using LLDB standalone from Python. The process_events.py
+ is a start of this, but it just handles process events, and it is really a quick sketch
+ not a polished expandable proto-tool.
+ </p>
+
+ </li>
+
+ <li>
+ Make a more accessible plugin architecture for lldb.
+
+ <p>
+ Right now, you can only use the Python or SB API's to extend an extant lldb. You can't
+ implement any of the actual lldb Plugins as plugins. That means anybody that wants to
+ add new Object file/Process/Language etc support has to build and distribute their own
+ lldb. This is tricky because the API's the plugins use are currently not stable (and
+ recently have been changing quite a lot.) We would have to define a subset of lldb_private
+ that you could use, and some way of telling whether the plugins were compatible with
+ the lldb. But long-term, making this sort of extension possible will make lldb more
+ appealing for research and 3rd party uses.
+ </p>
+ </li>
+
+ <li>
+ Use instruction emulation to avoid the overhead of swapping trap and instruction for breakpoints
+
+ <p>
+ At present, breakpoints are implemented by inserting a trap instruction, then when the trap
+ is hit, replace the trap with the actual instruction and single step. Then swap back and
+ continue. This causes problems for read only text, and also means that no-stop debugging
+ ust either stop all threads briefly to handle this two-step or risk missing some
+ breakpoint hits. If you emulated the instruction and wrote back the results, you wouldn't
+ have these problems, and it would also save a stop per breakpoint hit. Since we use breakpoints
+ to implement stepping, this savings could be significant on slow connections.
+ </p>
+ </li>
+ <li>
+ Use the JIT to speed up conditional breakpoint evaluation
+
+ <p>
+ We already JIT and cache the conditional expressions for breakpoints for the C family of
+ languages, so we aren't re-compiling every time you hit the breakpoint. And if we couldn't
+ IR interpret the expression, we leave the JIT'ed code in place for reuse. But it would
+ be even better if we could also insert the "stop or not" decision into the code at the
+ breakpoint, so you would only actually stop the process when the condition was true.
+ Greg's idea was that if you had a conditional breakpoint set when you started the
+ debug session, Xcode could rebuild and insert enough no-ops that we could instrument
+ the breakpoint site and call the conditional expression, and only trap if the conditional was true.
+ </p>
+ </li>
+
+ <li>
+ Broaden the idea in "target stop-hook" to cover more events in the debugger
+
+ <p>
+ Shared library loads, command execution, User directed memory/register reads and writes
+ are all places where you would reasonably want to hook into the debugger.
+ </p>
+ </li>
+
+ <li>
+ Mock classes for testing
+ <p>
+ We need "ProcessMock" and "ObjectFileMock" and the like. These would be real
+ plugin implementations for their underlying lldb classes, with the addition
+ that you can prime them from some sort of text based input files. For classes
+ that manage changes over time (like process) you would need to program the state
+ at StopPoint 0, StopPoint 1, etc. These could then be used for testing reactions
+ to complex threading
+ problems & the like, and also for simulating hard-to-test environments (like bare
+ board debugging).
+ </p>
+ </li>
+
+ <li>
+ A Bug-Trapper infrastructure
+ <p>
+ We very often have bugs that can't be reproduced locally. So having a bug-report-trapper
+ that can gather enough information from the
+ surroundings of a bug so that we can replay the session locally would be a big help
+ tracking down issues in this situation. This is tricky because you
+ can't necessarily require folks to leak information about their code in order to
+ file bug reports. So not only will you have to figure out what state to gather,
+ you're also going to have to anonymize it somehow. But we very often have bugs
+ from people that can't reduce the problem to a simple test case and can't give us
+ our code, and we often just can't help them as things stand now. Note that adding
+ the ProcessMock would be a good first stage towards this, since you could make a ProcessMock
+ creator/serializer from the current lldb state.
+ </p>
+ </li>
+
+ <li>
+ Expression parser needs syntax for "{symbol,type} A in CU B.cpp" etc.
+
+ <p>
+ Sometimes you need to specify non-visible or ambiguous types to the expression parser.
+ We were planning to do $b_dot_cpp$A or something like. You might want to specify a
+ static in a function, in a source file, or in a shared library. So the syntax should
+ support all these.
+ </p>
+ </li>
+
+ <li>
+ Add a "testButDontAbort" style test to the UnitTest framework.
+
+ <p>
+ The way we use unittest now (maybe this is the only way it can work, I don't know)
+ you can't report a real failure and continue with the test. That is appropriate
+ in some cases: if I'm supposed to hit breakpoint A before I evaluate an expression,
+ and don't hit breakpoint A, the test should fail. But it means that if I want to
+ test five different expressions, I can either do it in one test, which is good
+ because it means I only have to fire up one process, attach to it, and get it to
+ a certain point. But it also means if the first test fails, the other four don't
+ even get run. So though at first we wrote a bunch of test like this, as time went
+ on we switched more to writing "one at a time" tests because they were more robust
+ against a single failure. That makes the test suite run much more slowly. It
+ would be great to add a "test_but_dont_abort" variant of the tests, then we could
+ gang tests that all drive to the same place and do similar things. As an added
+ benefit, it would allow us to be more thorough in writing tests, since each
+ test would have lower costs.
+ </p>
+ </li>
+
+ <li>
+ Unify Watchpoint's & Breakpoints.
+ <p>
+ Option handling isn't shared, and more importantly the PerformAction's have a lot
+ of duplicated common code, most of which works less well on the Watchpoint side.
+ </p>
+ </li>
+
+ <li>
+ Reverse debugging.
+ <p>
+ This is kind of a holy grail, it's hard to support for complex apps (many
+ threads, shared memory, etc.) But it would be SO nice to have...
+ </p>
+ </li>
+
+ <li>
+ Non-stop debugging.
+
+ <p>
+ By this I mean allowing some threads in the target program to run while stopping
+ other threads. This is supported in name in lldb at present, but lldb makes the
+ assumption "If I get a stop, I won't get another stop unless I actually run the
+ program." in a bunch of places so getting it to work reliably will be some a
+ good bit of work. And figuring out how to present this in the UI will also be tricky.
+ </p>
+ </li>
+
+ <li>
+ Fix and continue.
+ <p>
+ We did this in gdb without a real JIT. The implementation shouldn't be that hard,
+ especially if you can build the executable for fix and continue. The tricky part is
+ how to verify that the user can only do the kinds of fixes that are safe to do.
+ No changing object sizes is easy to detect, but there were many more subtle changes
+ (function you are fixing is on the stack...) that take more work to prevent.
+ And then you have to explain these conditions the user in some helpful way.
+ </p>
+ </li>
+ </ol>
+ </div>
+ <div class="postfooter"></div>
+ </div>
+ </div>
+ </div>
+</div>
+</body>
+</html>
diff --git a/www/sidebar.incl b/www/sidebar.incl
index 17beaaddfec0..184a022790e2 100644
--- a/www/sidebar.incl
+++ b/www/sidebar.incl
@@ -8,6 +8,7 @@
<li><a href="/goals.html">Goals</a></li>
<li><a href="/features.html">Features</a></li>
<li><a href="/status.html">Status</a></li>
+ <li><a href="/projects.html">Projects</a></li>
</ul>
</div>
<div class="menu">
diff --git a/www/test.html b/www/test.html
index 60a5df51fbb9..5ffa82fd184b 100644
--- a/www/test.html
+++ b/www/test.html
@@ -46,7 +46,7 @@
built with a custom version of clang, do:
</p>
<code>
- <br />&gt; cmake -DLLDB_TEST_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja
+ <br />&gt; cmake -DLLDB_TEST_USER_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja
<br />&gt; ninja check-lldb
</code>
<p>Note that multiple -A and -C flags can be specified to <tt>LLDB_TEST_USER_ARGS</tt>.</p>
diff --git a/www/varformats.html b/www/varformats.html
index 78c996e57ee7..c4c1d8efb568 100755
--- a/www/varformats.html
+++ b/www/varformats.html
@@ -1068,6 +1068,7 @@ def function (valobj,internal_dict):<br/>
<sup>[2]</sup> This method is optional (starting with SVN rev166495/LLDB-175). While implementing it in terms of <code>num_children</code> is acceptable, implementors are encouraged to look for optimized coding alternatives whenever reasonable.
<br/>
<sup>[3]</sup> This method is optional (starting with SVN revision 219330). The SBValue you return here will most likely be a numeric type (int, float, ...) as its value bytes will be used as-if they were the value of the root SBValue proper. As a shortcut for this, you can inherit from lldb.SBSyntheticValueProvider, and just define get_value as other methods are defaulted in the superclass as returning default no-children responses.
+<p>If a synthetic child provider supplies a special child named <code>$$dereference$$</code> then it will be used when evaluating <code>opertaor*</code> and <code>operator-&gt;</code> in the <code>frame variable</code> command and related SB API functions.</p>
<p>For examples of how synthetic children are created, you are encouraged to look at <a href="http://llvm.org/svn/llvm-project/lldb/trunk/examples/synthetic/">examples/synthetic</a> in the LLDB trunk. Please, be aware that the code in those files (except bitfield/)
is legacy code and is not maintained.
You may especially want to begin looking at <a href="http://llvm.org/svn/llvm-project/lldb/trunk/examples/synthetic/bitfield">this example</a> to get