Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Headers/DebugServer2/GDBRemote/DummySessionDelegateImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class DummySessionDelegateImpl : public SessionDelegate {
uint8_t digest[16]) override;
ErrorCode onFileGetSize(Session &session, std::string const &path,
uint64_t &size) override;
ErrorCode onFileGetMode(Session &session, std::string const &path,
uint32_t &mode) const override;

ErrorCode onQueryProcessList(Session &session, ProcessInfoMatch const &match,
bool first, ProcessInfo &info) const override;
Expand Down
4 changes: 4 additions & 0 deletions Headers/DebugServer2/GDBRemote/Mixins/FileOperationsMixin.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ template <typename T> class FileOperationsMixin : public T {

protected:
ErrorCode onFileExists(Session &session, std::string const &path) override;
ErrorCode onFileGetSize(Session &session, std::string const &path,
uint64_t &size) override;
ErrorCode onFileGetMode(Session &session, std::string const &path,
uint32_t &mode) const override;
ErrorCode onFileRemove(Session &session, std::string const &path) override;

protected:
Expand Down
2 changes: 2 additions & 0 deletions Headers/DebugServer2/GDBRemote/SessionDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class SessionDelegate {
uint8_t digest[16]) = 0;
virtual ErrorCode onFileGetSize(Session &session, std::string const &path,
uint64_t &size) = 0;
virtual ErrorCode onFileGetMode(Session &session, std::string const &path,
uint32_t &mode) const = 0;

virtual ErrorCode onQueryProcessList(Session &session,
ProcessInfoMatch const &match,
Expand Down
1 change: 1 addition & 0 deletions Headers/DebugServer2/Host/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class File {

public:
static ErrorCode fileSize(std::string const &path, uint64_t &size);
static ErrorCode fileMode(std::string const &path, uint32_t &mode);

protected:
int _fd;
Expand Down
2 changes: 2 additions & 0 deletions Sources/GDBRemote/DummySessionDelegateImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ DUMMY_IMPL_EMPTY(onFileComputeMD5, Session &, std::string const &, uint8_t[16])

DUMMY_IMPL_EMPTY(onFileGetSize, Session &, std::string const &, uint64_t &)

DUMMY_IMPL_EMPTY_CONST(onFileGetMode, Session &, std::string const &, uint32_t&)

DUMMY_IMPL_EMPTY_CONST(onQueryProcessList, Session &, ProcessInfoMatch const &,
bool, ProcessInfo &)

Expand Down
13 changes: 13 additions & 0 deletions Sources/GDBRemote/Mixins/FileOperationsMixin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ ErrorCode FileOperationsMixin<T>::onFileExists(Session &,
return Host::Platform::IsFilePresent(path) ? kSuccess : kErrorNotFound;
}

template <typename T>
ErrorCode FileOperationsMixin<T>::onFileGetSize(Session &session, std::string const &path,
uint64_t &size){
return Host::File::fileSize(path, size);
}

template <typename T>
ErrorCode FileOperationsMixin<T>::onFileGetMode(Session &session,
std::string const &path,
uint32_t &mode) const {
return Host::File::fileMode(path, mode);
}

template <typename T>
ErrorCode FileOperationsMixin<T>::onFileRemove(Session &session,
std::string const &path) {
Expand Down
21 changes: 18 additions & 3 deletions Sources/GDBRemote/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2964,6 +2964,7 @@ void Session::Handle_vFile(ProtocolInterpreter::Handler const &,
//
// LLDB: vFile:exists:path
// vFile:size:path
// vFile:mode:path
// vFile:MD5:path
//
bool escaped = false;
Expand Down Expand Up @@ -3093,11 +3094,25 @@ void Session::Handle_vFile(ProtocolInterpreter::Handler const &,
uint64_t size;
ErrorCode error =
_delegate->onFileGetSize(*this, HexToString(&args[op_end]), size);
// Fsize or Exx if error.
// Response is F followed by the file size in base 16 or
// F-1,errno with the errno if an error occurs, base 16.
ss << 'F';
if (error != kSuccess) {
ss << 'E' << std::hex << error;
ss << -1 << std::hex << error;
} else {
ss << 'F' << std::hex << size;
ss << std::hex << size;
}
} else if (op == "mode") {
uint32_t mode;
ErrorCode error =
_delegate->onFileGetMode(*this, HexToString(&args[op_end]), mode);
// Response is F followed by the mode bits in base 16 or
// F-1,errno with the errno if an error occurs, base 16
ss << 'F';
if (error != kSuccess) {
ss << -1 << ',' << std::hex << error;
} else {
ss << std::hex << mode;
}
} else {
sendError(kErrorUnsupported);
Expand Down
9 changes: 9 additions & 0 deletions Sources/Host/POSIX/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,14 @@ ErrorCode File::fileSize(std::string const &path, uint64_t &size) {
size = static_cast<uint64_t>(stbuf.st_size);
return kSuccess;
}

ErrorCode File::fileMode(std::string const &path, uint32_t &mode) {
struct stat stbuf;
if (stat(path.c_str(), &stbuf) < 0)
return Platform::TranslateError();

mode = static_cast<uint32_t>(ALLPERMS & stbuf.st_mode);
return kSuccess;
}
} // namespace Host
} // namespace ds2
5 changes: 5 additions & 0 deletions Sources/Host/Windows/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ ErrorCode File::createDirectory(std::string const &path, uint32_t flags) {
ErrorCode File::fileSize(std::string const &path, uint64_t &size) {
return kErrorUnsupported;
}

ErrorCode File::fileMode(std::string const &path, uint32_t &mode) {
return kErrorUnsupported;
}

} // namespace Host
} // namespace ds2
Loading