Skip to content

Commit c93e294

Browse files
authored
[lldb] fix vFile:open, vFile:unlink error codes (#106950)
This patch makes gdb-server sends only GDB RSP supported error codes during vFile:open and vFile:unlink handling.
1 parent 706821b commit c93e294

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,17 @@ GDBRemoteCommunicationServerCommon::Handle_qSpeedTest(
496496
return SendErrorResponse(7);
497497
}
498498

499+
static GDBErrno system_errno_to_gdb(int err) {
500+
switch (err) {
501+
#define HANDLE_ERRNO(name, value) \
502+
case name: \
503+
return GDB_##name;
504+
#include "Plugins/Process/gdb-remote/GDBRemoteErrno.def"
505+
default:
506+
return GDB_EUNKNOWN;
507+
}
508+
}
509+
499510
GDBRemoteCommunication::PacketResult
500511
GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
501512
StringExtractorGDBRemote &packet) {
@@ -522,9 +533,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
522533
} else {
523534
response.PutCString("-1");
524535
std::error_code code = errorToErrorCode(file.takeError());
525-
if (code.category() == std::system_category()) {
526-
response.Printf(",%x", code.value());
527-
}
536+
response.Printf(",%x", system_errno_to_gdb(code.value()));
528537
}
529538

530539
return SendPacketNoLock(response.GetString());
@@ -534,17 +543,6 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
534543
return SendErrorResponse(18);
535544
}
536545

537-
static GDBErrno system_errno_to_gdb(int err) {
538-
switch (err) {
539-
#define HANDLE_ERRNO(name, value) \
540-
case name: \
541-
return GDB_##name;
542-
#include "Plugins/Process/gdb-remote/GDBRemoteErrno.def"
543-
default:
544-
return GDB_EUNKNOWN;
545-
}
546-
}
547-
548546
GDBRemoteCommunication::PacketResult
549547
GDBRemoteCommunicationServerCommon::Handle_vFile_Close(
550548
StringExtractorGDBRemote &packet) {
@@ -727,7 +725,8 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_unlink(
727725
packet.GetHexByteString(path);
728726
Status error(llvm::sys::fs::remove(path));
729727
StreamString response;
730-
response.Printf("F%x,%x", error.GetError(), error.GetError());
728+
response.Printf("F%x,%x", error.GetError(),
729+
system_errno_to_gdb(error.GetError()));
731730
return SendPacketNoLock(response.GetString());
732731
}
733732

0 commit comments

Comments
 (0)