diff options
author | Michał Górny <mgorny@moritz.systems> | 2021-08-16 19:33:07 +0200 |
---|---|---|
committer | Michał Górny <mgorny@moritz.systems> | 2021-09-10 14:08:36 +0200 |
commit | 3d3017d344f6514bbb2e5ff49a335d36e31faf55 (patch) | |
tree | dcef5b537d840f6bcc30f7e1666c22f7ae353971 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | |
parent | 3fade9542200c96021522f91ba5afdbff02729e1 (diff) | |
download | llvm-3d3017d344f6514bbb2e5ff49a335d36e31faf55.zip llvm-3d3017d344f6514bbb2e5ff49a335d36e31faf55.tar.gz llvm-3d3017d344f6514bbb2e5ff49a335d36e31faf55.tar.bz2 |
[lldb] [gdb-remote] Use standardized GDB errno values
GDB uses normalized errno values for vFile errors. Implement
the translation between them and system errno values in the gdb-remote
plugin.
Differential Revision: https://reviews.llvm.org/D108148
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 248fd57..d4a753d2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -534,6 +534,17 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open( return SendErrorResponse(18); } +static GDBErrno system_errno_to_gdb(int err) { + switch (err) { +#define HANDLE_ERRNO(name, value) \ + case name: \ + return GDB_##name; +#include "Plugins/Process/gdb-remote/GDBRemoteErrno.def" + default: + return GDB_EUNKNOWN; + } +} + GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServerCommon::Handle_vFile_Close( StringExtractorGDBRemote &packet) { @@ -553,7 +564,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Close( response.PutChar('F'); response.Printf("%x", err); if (save_errno) - response.Printf(",%x", save_errno); + response.Printf(",%x", system_errno_to_gdb(save_errno)); return SendPacketNoLock(response.GetString()); } @@ -584,7 +595,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_pRead( } else { response.PutCString("-1"); if (save_errno) - response.Printf(",%x", save_errno); + response.Printf(",%x", system_errno_to_gdb(save_errno)); } return SendPacketNoLock(response.GetString()); } @@ -616,7 +627,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite( else { response.PutCString("-1"); if (save_errno) - response.Printf(",%x", save_errno); + response.Printf(",%x", system_errno_to_gdb(save_errno)); } } else { response.Printf("-1,%x", EINVAL); @@ -774,7 +785,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_FStat( struct stat file_stats; if (::fstat(fd, &file_stats) == -1) { const int save_errno = errno; - response.Printf("F-1,%x", save_errno); + response.Printf("F-1,%x", system_errno_to_gdb(save_errno)); return SendPacketNoLock(response.GetString()); } |