[Lldb-commits] [lldb] [lldb] fix vFile:open, vFile:unlink error codes (PR #106950)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 20 06:37:43 PDT 2024
https://github.com/dlav-sc updated https://github.com/llvm/llvm-project/pull/106950
>From 7a6bb5e10a11f9693003daa48e2f8ca51df2c727 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 | 29 +++++++++----------
1 file changed, 14 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..324db3db7eb4c7 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,8 @@ 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