[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 26 17:32:08 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Adrian Prantl (adrian-prantl)
<details>
<summary>Changes</summary>
This patch removes all of the Set.* methods from Status.
This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor.
This patch is largely NFC, the more interesting next steps this enables is to:
1. remove Status.Clear()
2. assert that Status::operator=() never overwrites an error
3. remove Status::operator=()
Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form
` ResultTy DoFoo(Status& error)
`
to
` llvm::Expected<ResultTy> DoFoo()
`
How to read this patch?
The interesting changes are in Status.h and Status.cpp, all other changes are mostly
` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source)
`
plus the occasional manual cleanup.
---
Patch is 904.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/106163.diff
260 Files Affected:
- (modified) lldb/bindings/python/python-wrapper.swig (+11-9)
- (modified) lldb/include/lldb/Core/StructuredDataImpl.h (+9-19)
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h (+1-1)
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h (+6-3)
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h (+10-5)
- (modified) lldb/include/lldb/Interpreter/OptionValue.h (+2-1)
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+15-28)
- (modified) lldb/include/lldb/Target/Process.h (+22-47)
- (modified) lldb/include/lldb/Target/ProcessTrace.h (+1-3)
- (modified) lldb/include/lldb/Utility/Status.h (+27-66)
- (modified) lldb/source/API/SBBreakpoint.cpp (+9-8)
- (modified) lldb/source/API/SBBreakpointLocation.cpp (+2-2)
- (modified) lldb/source/API/SBBreakpointName.cpp (+1-1)
- (modified) lldb/source/API/SBDebugger.cpp (+28-24)
- (modified) lldb/source/API/SBError.cpp (+13-6)
- (modified) lldb/source/API/SBFile.cpp (+3-3)
- (modified) lldb/source/API/SBFrame.cpp (+5-5)
- (modified) lldb/source/API/SBPlatform.cpp (+15-17)
- (modified) lldb/source/API/SBProcess.cpp (+44-42)
- (modified) lldb/source/API/SBStructuredData.cpp (+1-1)
- (modified) lldb/source/API/SBTarget.cpp (+7-6)
- (modified) lldb/source/API/SBThread.cpp (+36-34)
- (modified) lldb/source/API/SBTrace.cpp (+16-14)
- (modified) lldb/source/API/SBValue.cpp (+22-21)
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+8-7)
- (modified) lldb/source/Breakpoint/BreakpointID.cpp (+9-7)
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+7-6)
- (modified) lldb/source/Breakpoint/BreakpointOptions.cpp (+19-14)
- (modified) lldb/source/Breakpoint/BreakpointPrecondition.cpp (+2-3)
- (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+11-7)
- (modified) lldb/source/Breakpoint/BreakpointResolverAddress.cpp (+4-2)
- (modified) lldb/source/Breakpoint/BreakpointResolverFileLine.cpp (+10-5)
- (modified) lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp (+5-4)
- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+13-10)
- (modified) lldb/source/Breakpoint/BreakpointResolverScripted.cpp (+2-1)
- (modified) lldb/source/Commands/CommandObjectBreakpointCommand.cpp (+2-3)
- (modified) lldb/source/Commands/CommandObjectCommands.cpp (+111-73)
- (modified) lldb/source/Commands/CommandObjectDisassemble.cpp (+6-5)
- (modified) lldb/source/Commands/CommandObjectExpression.cpp (+13-13)
- (modified) lldb/source/Commands/CommandObjectFrame.cpp (+7-7)
- (modified) lldb/source/Commands/CommandObjectLog.cpp (+4-6)
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+8-8)
- (modified) lldb/source/Commands/CommandObjectPlatform.cpp (+22-22)
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+3-3)
- (modified) lldb/source/Commands/CommandObjectScripting.cpp (+3-3)
- (modified) lldb/source/Commands/CommandObjectSource.cpp (+12-13)
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+21-20)
- (modified) lldb/source/Commands/CommandObjectThread.cpp (+25-21)
- (modified) lldb/source/Commands/CommandObjectType.cpp (+30-28)
- (modified) lldb/source/Commands/CommandObjectWatchpoint.cpp (+2-2)
- (modified) lldb/source/Commands/CommandObjectWatchpointCommand.cpp (+2-3)
- (modified) lldb/source/Commands/CommandOptionsProcessAttach.cpp (+2-2)
- (modified) lldb/source/Commands/CommandOptionsProcessLaunch.cpp (+4-5)
- (modified) lldb/source/Core/Communication.cpp (+3-3)
- (modified) lldb/source/Core/Debugger.cpp (+13-11)
- (modified) lldb/source/Core/FormatEntity.cpp (+21-16)
- (modified) lldb/source/Core/Module.cpp (+9-8)
- (modified) lldb/source/Core/ModuleList.cpp (+15-13)
- (modified) lldb/source/Core/PluginManager.cpp (+3-3)
- (modified) lldb/source/Core/SearchFilter.cpp (+19-12)
- (modified) lldb/source/Core/ThreadedCommunication.cpp (+3-3)
- (modified) lldb/source/Core/UserSettingsController.cpp (+2-6)
- (modified) lldb/source/Core/Value.cpp (+30-25)
- (modified) lldb/source/Core/ValueObject.cpp (+61-53)
- (modified) lldb/source/Core/ValueObjectChild.cpp (+6-5)
- (modified) lldb/source/Core/ValueObjectDynamicValue.cpp (+7-7)
- (modified) lldb/source/Core/ValueObjectMemory.cpp (+1-1)
- (modified) lldb/source/Core/ValueObjectRegister.cpp (+4-4)
- (modified) lldb/source/Core/ValueObjectVTable.cpp (+10-10)
- (modified) lldb/source/Core/ValueObjectVariable.cpp (+8-8)
- (modified) lldb/source/Expression/ExpressionParser.cpp (+6-4)
- (modified) lldb/source/Expression/IRExecutionUnit.cpp (+17-26)
- (modified) lldb/source/Expression/IRInterpreter.cpp (+74-101)
- (modified) lldb/source/Expression/IRMemoryMap.cpp (+41-57)
- (modified) lldb/source/Expression/Materializer.cpp (+100-90)
- (modified) lldb/source/Expression/UserExpression.cpp (+24-23)
- (modified) lldb/source/Expression/UtilityFunction.cpp (+5-4)
- (modified) lldb/source/Host/common/File.cpp (+34-34)
- (modified) lldb/source/Host/common/FileCache.cpp (+13-10)
- (modified) lldb/source/Host/common/Host.cpp (+4-3)
- (modified) lldb/source/Host/common/LockFileBase.cpp (+5-3)
- (modified) lldb/source/Host/common/MonitoringProcessLauncher.cpp (+7-5)
- (modified) lldb/source/Host/common/NativeProcessProtocol.cpp (+19-16)
- (modified) lldb/source/Host/common/NativeRegisterContext.cpp (+21-21)
- (modified) lldb/source/Host/common/ProcessLaunchInfo.cpp (+2-2)
- (modified) lldb/source/Host/common/Socket.cpp (+3-3)
- (modified) lldb/source/Host/common/TCPSocket.cpp (+2-2)
- (modified) lldb/source/Host/common/UDPSocket.cpp (+5-5)
- (modified) lldb/source/Host/macosx/objcxx/Host.mm (+66-59)
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+15-14)
- (modified) lldb/source/Host/posix/DomainSocket.cpp (+2-2)
- (modified) lldb/source/Host/posix/FileSystemPosix.cpp (+9-11)
- (modified) lldb/source/Host/posix/HostProcessPosix.cpp (+3-4)
- (modified) lldb/source/Host/posix/HostThreadPosix.cpp (+4-4)
- (modified) lldb/source/Host/posix/LockFilePosix.cpp (+2-3)
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+4-3)
- (modified) lldb/source/Host/posix/PipePosix.cpp (+11-11)
- (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (+3-3)
- (modified) lldb/source/Host/windows/ConnectionGenericFileWindows.cpp (+1-1)
- (modified) lldb/source/Host/windows/FileSystem.cpp (+3-3)
- (modified) lldb/source/Host/windows/Host.cpp (+10-9)
- (modified) lldb/source/Host/windows/MainLoopWindows.cpp (+7-5)
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+31-23)
- (modified) lldb/source/Interpreter/OptionArgParser.cpp (+12-11)
- (modified) lldb/source/Interpreter/OptionGroupFormat.cpp (+11-10)
- (modified) lldb/source/Interpreter/OptionGroupPlatform.cpp (+6-6)
- (modified) lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp (+7-7)
- (modified) lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp (+12-12)
- (modified) lldb/source/Interpreter/OptionGroupVariable.cpp (+6-3)
- (modified) lldb/source/Interpreter/OptionGroupWatchpoint.cpp (+3-3)
- (modified) lldb/source/Interpreter/OptionValue.cpp (+11-13)
- (modified) lldb/source/Interpreter/OptionValueArch.cpp (+2-2)
- (modified) lldb/source/Interpreter/OptionValueArray.cpp (+28-24)
- (modified) lldb/source/Interpreter/OptionValueBoolean.cpp (+3-3)
- (modified) lldb/source/Interpreter/OptionValueChar.cpp (+2-2)
- (modified) lldb/source/Interpreter/OptionValueDictionary.cpp (+28-22)
- (modified) lldb/source/Interpreter/OptionValueEnumeration.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValueFileColonLine.cpp (+11-10)
- (modified) lldb/source/Interpreter/OptionValueFileSpec.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValueFileSpecList.cpp (+12-9)
- (modified) lldb/source/Interpreter/OptionValueFormatEntity.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValueLanguage.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValuePathMappings.cpp (+18-13)
- (modified) lldb/source/Interpreter/OptionValueProperties.cpp (+2-2)
- (modified) lldb/source/Interpreter/OptionValueRegex.cpp (+2-2)
- (modified) lldb/source/Interpreter/OptionValueSInt64.cpp (+3-3)
- (modified) lldb/source/Interpreter/OptionValueString.cpp (+1-1)
- (modified) lldb/source/Interpreter/OptionValueUInt64.cpp (+3-3)
- (modified) lldb/source/Interpreter/OptionValueUUID.cpp (+2-2)
- (modified) lldb/source/Interpreter/Options.cpp (+9-7)
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+1-1)
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp (+18-14)
- (modified) lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp (+18-14)
- (modified) lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp (+10-9)
- (modified) lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp (+9-8)
- (modified) lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp (+9-8)
- (modified) lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp (+9-8)
- (modified) lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp (+13-11)
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp (+16-20)
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+13-11)
- (modified) lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp (+10-9)
- (modified) lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp (+13-11)
- (modified) lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp (+9-8)
- (modified) lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp (+14-10)
- (modified) lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp (+13-11)
- (modified) lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp (+13-11)
- (modified) lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (+1-1)
- (modified) lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp (+1-2)
- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp (+4-3)
- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (+1-1)
- (modified) lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp (+2-3)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+14-14)
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (+14-14)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (+6-6)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp (+1-1)
- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+13-8)
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+7-6)
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp (+29-25)
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp (+1-1)
- (modified) lldb/source/Plugins/Platform/Android/AdbClient.cpp (+56-37)
- (modified) lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp (+19-13)
- (modified) lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp (+5-6)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp (+9-8)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+4-3)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp (+3-3)
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp (+2-2)
- (modified) lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm (+12-12)
- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+61-46)
- (modified) lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp (+1-1)
- (modified) lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h (+1-1)
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+70-47)
- (modified) lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (+34-36)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm.cpp (+8-7)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp (+8-7)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_mips64.cpp (+12-11)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_powerpc.cpp (+12-11)
- (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp (+23-20)
- (modified) lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.cpp (+4-2)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp (+10-9)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp (+8-7)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp (+8-7)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp (+8-7)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp (+7-6)
- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (+25-22)
- (modified) lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (+15-15)
- (modified) lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (+28-28)
- (modified) lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (+2-2)
- (modified) lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp (+23-20)
- (modified) lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp (+5-4)
- (modified) lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp (+7-7)
- (modified) lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp (+2-6)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp (+7-5)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_WoW64.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_i386.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp (+12-10)
- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp (+9-9)
- (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (+14-13)
- (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+5-5)
- (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.h (+1-3)
- (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+3-3)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (+4-4)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+64-56)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (+3-3)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+27-21)
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (+3-3)
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+82-67)
- (modified) lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp (+3-3)
- (modified) lldb/source/Plugins/Process/minidump/MinidumpTypes.h (+3-6)
- (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp (+3-3)
- (modified) lldb/source/Plugins/Process/minidump/ProcessMinidump.h (+1-3)
- (modified) lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp (+12-11)
- (modified) lldb/source/Plugins/REPL/Clang/ClangREPL.cpp (+1-1)
- (modified) lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp (+3-2)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp (+11-8)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h (+3-4)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (+6-3)
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+51-46)
- (modified) lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (+31-26)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+3-3)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+6-5)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (+9-7)
- (modified) lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp (+1-1)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp (+12-8)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp (+9-6)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp (+7-5)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (+12-8)
- (modified) lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp (+10-10)
- (modified) lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp (+2-2)
- (modified) lldb/source/Symbol/SaveCoreOptions.cpp (+6-5)
- (modified) lldb/source/Symbol/SymbolContext.cpp (+7-7)
- (modified) lldb/source/Symbol/Variable.cpp (+7-7)
- (modified) lldb/source/Target/Memory.cpp (+4-3)
- (modified) lldb/source/Target/ModuleCache.cpp (+24-19)
- (modified) lldb/source/Target/Platform.cpp (+73-60)
- (modified) lldb/source/Target/Process.cpp (+92-77)
- (modified) lldb/source/Target/RegisterContext.cpp (+11-13)
- (modified) lldb/source/Target/ScriptedThreadPlan.cpp (+2-2)
- (modified) lldb/source/Target/StackFrame.cpp (+44-40)
- (modified) lldb/source/Target/Target.cpp (+84-75)
- (modified) lldb/source/Target/TargetList.cpp (+9-8)
- (modified) lldb/source/Target/Thread.cpp (+28-21)
- (modified) lldb/source/Utility/RegisterValue.cpp (+33-32)
- (modified) lldb/source/Utility/Scalar.cpp (+12-13)
- (modified) lldb/source/Utility/SelectHelper.cpp (+8-8)
- (modified) lldb/source/Utility/Status.cpp (+28-103)
- (modified) lldb/source/Utility/StringExtractorGDBRemote.cpp (+2-4)
- (modified) lldb/source/Utility/StructuredData.cpp (+4-4)
- (modified) lldb/test/API/functionalities/interactive_scripted_process/interactive_scripted_process.py (+4-4)
- (modified) lldb/test/API/functionalities/postmortem/FreeBSDKernel/tools/lldb-minimize-processes.patch (+1-1)
- (modified) lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py (+1-1)
- (modified) lldb/tools/lldb-server/Acceptor.cpp (+2-2)
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+7-6)
- (modified) lldb/unittests/Platform/Android/PlatformAndroidTest.cpp (+2-1)
- (modified) lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp (+1-4)
- (modified) lldb/unittests/Target/LocateModuleCallbackTest.cpp (+6-6)
- (modified) lldb/unittests/Target/ModuleCacheTest.cpp (+1-1)
- (modified) lldb/unittests/Utility/StatusTest.cpp (+7-3)
``````````diff
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index 360c392235a866..810673aaec5d19 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -306,11 +306,11 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
const char *session_dictionary_name, const StructuredDataImpl &args_impl,
Status &error) {
if (python_class_name == NULL || python_class_name[0] == '\0') {
- error.SetErrorString("Empty class name.");
+ error = Status::FromErrorString("Empty class name.");
return PythonObject();
}
if (!session_dictionary_name) {
- error.SetErrorString("No session dictionary");
+ error = Status::FromErrorString("No session dictionary");
return PythonObject();
}
@@ -322,7 +322,7 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
python_class_name, dict);
if (!pfunc.IsAllocated()) {
- error.SetErrorStringWithFormat("Could not find class: %s.",
+ error = Status::FromErrorStringWithFormat("Could not find class: %s.",
python_class_name);
return PythonObject();
}
@@ -337,7 +337,7 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
if (auto args_info = callback_func.GetArgInfo()) {
size_t num_args = (*args_info).max_positional_args;
if (num_args != 2) {
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"Wrong number of args for "
"handle_stop callback, should be 2 (excluding self), got: %zu",
num_args);
@@ -345,15 +345,17 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
} else
return result;
} else {
- error.SetErrorString("Couldn't get num arguments for handle_stop "
- "callback.");
+ error = Status::FromErrorString(
+ "Couldn't get num arguments for handle_stop "
+ "callback.");
return PythonObject();
}
return result;
} else {
- error.SetErrorStringWithFormat("Class \"%s\" is missing the required "
- "handle_stop callback.",
- python_class_name);
+ error = Status::FromErrorStringWithFormat(
+ "Class \"%s\" is missing the required "
+ "handle_stop callback.",
+ python_class_name);
}
}
return PythonObject();
diff --git a/lldb/include/lldb/Core/StructuredDataImpl.h b/lldb/include/lldb/Core/StructuredDataImpl.h
index 0e068b4598cdda..fd0a7b94d3a6cf 100644
--- a/lldb/include/lldb/Core/StructuredDataImpl.h
+++ b/lldb/include/lldb/Core/StructuredDataImpl.h
@@ -50,38 +50,28 @@ class StructuredDataImpl {
}
Status GetAsJSON(Stream &stream) const {
- Status error;
-
- if (!m_data_sp) {
- error.SetErrorString("No structured data.");
- return error;
- }
+ if (!m_data_sp)
+ return Status::FromErrorString("No structured data.");
llvm::json::OStream s(stream.AsRawOstream());
m_data_sp->Serialize(s);
- return error;
+ return Status();
}
Status GetDescription(Stream &stream) const {
- Status error;
-
- if (!m_data_sp) {
- error.SetErrorString("Cannot pretty print structured data: "
- "no data to print.");
- return error;
- }
+ if (!m_data_sp)
+ return Status::FromErrorString("Cannot pretty print structured data: "
+ "no data to print.");
// Grab the plugin
lldb::StructuredDataPluginSP plugin_sp = m_plugin_wp.lock();
// If there's no plugin, call underlying data's dump method:
if (!plugin_sp) {
- if (!m_data_sp) {
- error.SetErrorString("No data to describe.");
- return error;
- }
+ if (!m_data_sp)
+ return Status::FromErrorString("No data to describe.");
m_data_sp->GetDescription(stream);
- return error;
+ return Status();
}
// Get the data's description.
return plugin_sp->GetDescription(m_data_sp, stream);
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index 3850edf879ac45..790229bf1b0639 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -48,7 +48,7 @@ class ScriptedInterface {
llvm::Twine(llvm::Twine(" (") + llvm::Twine(detailed_error) +
llvm::Twine(")"))
.str();
- error.SetErrorString(full_error_message);
+ error = Status(full_error_message);
return {};
}
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 7feaa01fe89b86..ac349de57c143d 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -31,15 +31,18 @@ class ScriptedPlatformInterface : virtual public ScriptedInterface {
}
virtual Status AttachToProcess(lldb::ProcessAttachInfoSP attach_info) {
- return Status("ScriptedPlatformInterface cannot attach to a process");
+ return Status::FromErrorString(
+ "ScriptedPlatformInterface cannot attach to a process");
}
virtual Status LaunchProcess(lldb::ProcessLaunchInfoSP launch_info) {
- return Status("ScriptedPlatformInterface cannot launch process");
+ return Status::FromErrorString(
+ "ScriptedPlatformInterface cannot launch process");
}
virtual Status KillProcess(lldb::pid_t pid) {
- return Status("ScriptedPlatformInterface cannot kill process");
+ return Status::FromErrorString(
+ "ScriptedPlatformInterface cannot kill process");
}
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
index 10203b1f8baa7a..076ca43d451118 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
@@ -29,23 +29,28 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
virtual Status Attach(const ProcessAttachInfo &attach_info) {
- return Status("ScriptedProcess did not attach");
+ return Status::FromErrorString("ScriptedProcess did not attach");
}
- virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
+ virtual Status Launch() {
+ return Status::FromErrorString("ScriptedProcess did not launch");
+ }
- virtual Status Resume() { return Status("ScriptedProcess did not resume"); }
+ virtual Status Resume() {
+ return Status::FromErrorString("ScriptedProcess did not resume");
+ }
virtual std::optional<MemoryRegionInfo>
GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) {
- error.SetErrorString("ScriptedProcess have no memory region.");
+ error = Status::FromErrorString("ScriptedProcess have no memory region.");
return {};
}
virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
virtual bool CreateBreakpoint(lldb::addr_t addr, Status &error) {
- error.SetErrorString("ScriptedProcess don't support creating breakpoints.");
+ error = Status::FromErrorString(
+ "ScriptedProcess don't support creating breakpoints.");
return {};
}
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index bfbdbead72c66d..d19c8b8fab6222 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -119,7 +119,8 @@ class OptionValue {
virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
llvm::StringRef name,
Status &error) const {
- error.SetErrorStringWithFormatv("'{0}' is not a valid subvalue", name);
+ error = Status::FromErrorStringWithFormatv("'{0}' is not a valid subvalue",
+ name);
return lldb::OptionValueSP();
}
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 89a480a28880aa..addb1394ab5652 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -176,25 +176,19 @@ class ScriptInterpreter : public PluginInterface {
virtual Status ExecuteMultipleLines(
const char *in_string,
const ExecuteScriptOptions &options = ExecuteScriptOptions()) {
- Status error;
- error.SetErrorString("not implemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
virtual Status
ExportFunctionDefinitionToInterpreter(StringList &function_def) {
- Status error;
- error.SetErrorString("not implemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
virtual Status GenerateBreakpointCommandCallbackData(StringList &input,
std::string &output,
bool has_extra_args,
bool is_callback) {
- Status error;
- error.SetErrorString("not implemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
virtual bool GenerateWatchpointCommandCallbackData(StringList &input,
@@ -280,8 +274,9 @@ class ScriptInterpreter : public PluginInterface {
virtual StructuredData::GenericSP
CreateScriptedStopHook(lldb::TargetSP target_sp, const char *class_name,
const StructuredDataImpl &args_data, Status &error) {
- error.SetErrorString("Creating scripted stop-hooks with the current "
- "script interpreter is not supported.");
+ error =
+ Status::FromErrorString("Creating scripted stop-hooks with the current "
+ "script interpreter is not supported.");
return StructuredData::GenericSP();
}
@@ -308,9 +303,7 @@ class ScriptInterpreter : public PluginInterface {
virtual Status GenerateFunction(const char *signature,
const StringList &input,
bool is_callback) {
- Status error;
- error.SetErrorString("unimplemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
virtual void CollectDataForBreakpointCommandCallback(
@@ -329,18 +322,14 @@ class ScriptInterpreter : public PluginInterface {
virtual Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
const char *callback_text,
bool is_callback) {
- Status error;
- error.SetErrorString("unimplemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
/// This one is for deserialization:
virtual Status SetBreakpointCommandCallback(
BreakpointOptions &bp_options,
std::unique_ptr<BreakpointOptions::CommandData> &data_up) {
- Status error;
- error.SetErrorString("unimplemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
Status SetBreakpointCommandCallbackFunction(
@@ -352,9 +341,7 @@ class ScriptInterpreter : public PluginInterface {
SetBreakpointCommandCallbackFunction(BreakpointOptions &bp_options,
const char *function_name,
StructuredData::ObjectSP extra_args_sp) {
- Status error;
- error.SetErrorString("unimplemented");
- return error;
+ return Status::FromErrorString("not implemented");
}
/// Set a one-liner as the callback for the watchpoint.
@@ -453,33 +440,33 @@ class ScriptInterpreter : public PluginInterface {
virtual bool RunScriptFormatKeyword(const char *impl_function,
Process *process, std::string &output,
Status &error) {
- error.SetErrorString("unimplemented");
+ error = Status::FromErrorString("unimplemented");
return false;
}
virtual bool RunScriptFormatKeyword(const char *impl_function, Thread *thread,
std::string &output, Status &error) {
- error.SetErrorString("unimplemented");
+ error = Status::FromErrorString("unimplemented");
return false;
}
virtual bool RunScriptFormatKeyword(const char *impl_function, Target *target,
std::string &output, Status &error) {
- error.SetErrorString("unimplemented");
+ error = Status::FromErrorString("unimplemented");
return false;
}
virtual bool RunScriptFormatKeyword(const char *impl_function,
StackFrame *frame, std::string &output,
Status &error) {
- error.SetErrorString("unimplemented");
+ error = Status::FromErrorString("unimplemented");
return false;
}
virtual bool RunScriptFormatKeyword(const char *impl_function,
ValueObject *value, std::string &output,
Status &error) {
- error.SetErrorString("unimplemented");
+ error = Status::FromErrorString("unimplemented");
return false;
}
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 9cf6f50558570b..a7de991104434d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -616,10 +616,8 @@ class Process : public std::enable_shared_from_this<Process>,
virtual Status LoadCore();
virtual Status DoLoadCore() {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support loading core files.", GetPluginName());
- return error;
}
/// The "ShadowListener" for a process is just an ordinary Listener that
@@ -990,9 +988,7 @@ class Process : public std::enable_shared_from_this<Process>,
/// \return
/// Returns an error object.
virtual Status DoConnectRemote(llvm::StringRef remote_url) {
- Status error;
- error.SetErrorString("remote connections are not supported");
- return error;
+ return Status::FromErrorString("remote connections are not supported");
}
/// Attach to an existing process using a process ID.
@@ -1011,11 +1007,9 @@ class Process : public std::enable_shared_from_this<Process>,
/// hanming : need flag
virtual Status DoAttachToProcessWithID(lldb::pid_t pid,
const ProcessAttachInfo &attach_info) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support attaching to a process by pid",
GetPluginName());
- return error;
}
/// Attach to an existing process using a partial process name.
@@ -1034,9 +1028,7 @@ class Process : public std::enable_shared_from_this<Process>,
virtual Status
DoAttachToProcessWithName(const char *process_name,
const ProcessAttachInfo &attach_info) {
- Status error;
- error.SetErrorString("attach by name is not supported");
- return error;
+ return Status::FromErrorString("attach by name is not supported");
}
/// Called after attaching a process.
@@ -1101,10 +1093,8 @@ class Process : public std::enable_shared_from_this<Process>,
/// An Status instance indicating success or failure of the
/// operation.
virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support launching processes", GetPluginName());
- return error;
}
/// Called after launching a process.
@@ -1136,10 +1126,8 @@ class Process : public std::enable_shared_from_this<Process>,
/// \see Thread:Step()
/// \see Thread:Suspend()
virtual Status DoResume() {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support resuming processes", GetPluginName());
- return error;
}
/// Called after resuming a process.
@@ -1171,10 +1159,8 @@ class Process : public std::enable_shared_from_this<Process>,
/// Returns \b true if the process successfully halts, \b false
/// otherwise.
virtual Status DoHalt(bool &caused_stop) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support halting processes", GetPluginName());
- return error;
}
/// Called after halting a process.
@@ -1197,11 +1183,9 @@ class Process : public std::enable_shared_from_this<Process>,
/// Returns \b true if the process successfully detaches, \b
/// false otherwise.
virtual Status DoDetach(bool keep_stopped) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support detaching from processes",
GetPluginName());
- return error;
}
/// Called after detaching from a process.
@@ -1228,11 +1212,9 @@ class Process : public std::enable_shared_from_this<Process>,
/// \return
/// Returns an error object.
virtual Status DoSignal(int signal) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support sending signals to processes",
GetPluginName());
- return error;
}
virtual Status WillDestroy() { return Status(); }
@@ -1686,7 +1668,7 @@ class Process : public std::enable_shared_from_this<Process>,
/// The number of bytes that were actually written.
virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
size_t size, Status &error) {
- error.SetErrorStringWithFormatv(
+ error = Status::FromErrorStringWithFormatv(
"error: {0} does not support writing to processes", GetPluginName());
return 0;
}
@@ -1769,7 +1751,7 @@ class Process : public std::enable_shared_from_this<Process>,
virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
Status &error) {
- error.SetErrorStringWithFormatv(
+ error = Status::FromErrorStringWithFormatv(
"error: {0} does not support allocating in the debug process",
GetPluginName());
return LLDB_INVALID_ADDRESS;
@@ -2036,11 +2018,9 @@ class Process : public std::enable_shared_from_this<Process>,
/// \return
/// \b true if the memory was deallocated, \b false otherwise.
virtual Status DoDeallocateMemory(lldb::addr_t ptr) {
- Status error;
- error.SetErrorStringWithFormatv(
+ return Status::FromErrorStringWithFormatv(
"error: {0} does not support deallocating in the debug process",
GetPluginName());
- return error;
}
/// The public interface to deallocating memory in the process.
@@ -2133,7 +2113,7 @@ class Process : public std::enable_shared_from_this<Process>,
/// less than \a buf_size, another call to this function should
/// be made to write the rest of the data.
virtual size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) {
- error.SetErrorString("stdin unsupported");
+ error = Status::FromErrorString("stdin unsupported");
return 0;
}
@@ -2156,17 +2136,13 @@ class Process : public std::enable_shared_from_this<Process>,
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site);
virtual Status EnableBreakpointSite(BreakpointSite *bp_site) {
- Status error;
- error.SetErrorStringW...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/106163
More information about the lldb-commits
mailing list