diff options
author | Adrian Prantl <aprantl@apple.com> | 2024-08-27 10:59:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 10:59:31 -0700 |
commit | 0642cd768b80665585c8500bed2933a3b99123dc (patch) | |
tree | a412a5eafff54ef9a7cb884e01907a4f521f5140 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | |
parent | acb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff) | |
download | llvm-0642cd768b80665585c8500bed2933a3b99123dc.zip llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.gz llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.bz2 |
[lldb] Turn lldb_private::Status into a value type. (#106163)
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.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 5d0a3e3..50fa11e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -835,7 +835,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, Status GDBRemoteCommunication::StartListenThread(const char *hostname, uint16_t port) { if (m_listen_thread.IsJoinable()) - return Status("listen thread already running"); + return Status::FromErrorString("listen thread already running"); char listen_url[512]; if (hostname && hostname[0]) @@ -1052,10 +1052,10 @@ Status GDBRemoteCommunication::StartDebugserverProcess( if (port) *port = port_; } else { - error.SetErrorString("failed to bind to port 0 on 127.0.0.1"); LLDB_LOGF(log, "GDBRemoteCommunication::%s() failed: %s", __FUNCTION__, error.AsCString()); - return error; + return Status::FromErrorString( + "failed to bind to port 0 on 127.0.0.1"); } } } @@ -1191,7 +1191,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess( JoinListenThread(); } } else { - error.SetErrorStringWithFormat("unable to locate " DEBUGSERVER_BASENAME); + error = Status::FromErrorString("unable to locate " DEBUGSERVER_BASENAME); } if (error.Fail()) { |