Skip to content

Commit 5588503

Browse files
committed
[lldb] vFile:open unsupported error fix
This patch makes gdb-server sends EUNKNOWN error when server obtains usupported by gdb remote protocol error code during vFile:open handling.
1 parent 0f97b48 commit 5588503

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

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

Lines changed: 12 additions & 14 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) {

0 commit comments

Comments
 (0)