[Lldb-commits] [lldb] [lldb] gdb rsp file error pass fix (PR #106950)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 20 06:31:58 PDT 2024
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/106950
>From 8d3aa3c1210cbecde6df294849c274aac2049e5f Mon Sep 17 00:00:00 2001
From: Daniil Avdeev <daniil.avdeev at syntacore.com>
Date: Fri, 20 Sep 2024 16:04:53 +0300
Subject: [PATCH] [lldb] fix vFile:open, vFile:unlink error codes
This patch makes gdb-server sends only GDB RSP supported error codes
during vFile:open and vFile:unlink handling.
---
.../GDBRemoteCommunicationServerCommon.cpp | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index f9d37490e16aec..e1fa326418e522 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -496,6 +496,17 @@ GDBRemoteCommunicationServerCommon::Handle_qSpeedTest(
return SendErrorResponse(7);
}
+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_Open(
StringExtractorGDBRemote &packet) {
@@ -522,9 +533,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
} else {
response.PutCString("-1");
std::error_code code = errorToErrorCode(file.takeError());
- if (code.category() == std::system_category()) {
- response.Printf(",%x", code.value());
- }
+ response.Printf(",%x", system_errno_to_gdb(code.value()));
}
return SendPacketNoLock(response.GetString());
@@ -534,17 +543,6 @@ 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) {
@@ -727,7 +725,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_unlink(
packet.GetHexByteString(path);
Status error(llvm::sys::fs::remove(path));
StreamString response;
- response.Printf("F%x,%x", error.GetError(), error.GetError());
+ response.Printf("F%x,%x", error.GetError(), system_errno_to_gdb(error.GetError()));
return SendPacketNoLock(response.GetString());
}
More information about the lldb-commits
mailing list