Author: Pavel Labath Date: 2024-09-18T14:53:42-07:00 New Revision: a7c174502aef45b2d33291129cce10c085fef944
URL: https://github.com/llvm/llvm-project/commit/a7c174502aef45b2d33291129cce10c085fef944 DIFF: https://github.com/llvm/llvm-project/commit/a7c174502aef45b2d33291129cce10c085fef944.diff LOG: [lldb] Only send "posix" error codes through the gdb-remote protocol The other side has no way of telling which namespace do these codes belong to, so mashing them all together is not very helpful. I'm mainly doing this to simplify some code in a pending patch <https://github.com/llvm/llvm-project/pull/106774/files#r1752628604>, and I've picked the posix error category semi-randomly. If we wanted to be serious about assigning meaning to these error codes, we should create a special error category for "gdb errors". Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 9b72cb00352821..d4aa90b2c7731a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -103,13 +103,14 @@ GDBRemoteCommunicationServer::SendErrorResponse(uint8_t err) { GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServer::SendErrorResponse(const Status &error) { + uint8_t code = error.GetType() == eErrorTypePOSIX ? error.GetError() : 0xff; if (m_send_error_strings) { lldb_private::StreamString packet; - packet.Printf("E%2.2x;", static_cast<uint8_t>(error.GetError())); + packet.Printf("E%2.2x;", code); packet.PutStringAsRawHex8(error.AsCString()); return SendPacketNoLock(packet.GetString()); - } else - return SendErrorResponse(error.GetError()); + } + return SendErrorResponse(code); } GDBRemoteCommunication::PacketResult diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp index 69ca1720c04fc9..ba9ca6ea73e3be 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp @@ -12,6 +12,7 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h" #include "lldb/Utility/Connection.h" #include "lldb/Utility/UnimplementedError.h" +#include "lldb/lldb-enumerations.h" namespace lldb_private { namespace process_gdb_remote { @@ -25,7 +26,7 @@ TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorNumber) { TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_Status) { MockServerWithMockConnection server; - Status status(0x42, lldb::eErrorTypeGeneric, "Test error message"); + Status status(0x42, lldb::eErrorTypePOSIX, "Test error message"); server.SendErrorResponse(status); EXPECT_THAT( _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits