Skip to content

[lldb] fix vFile:open, vFile:unlink error codes #106950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
}

Expand Down
Loading