This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [gdb-remote] Implement fallback to vFile:stat for GetFileSize()
ClosedPublic

Authored by mgorny on Aug 9 2021, 12:28 PM.

Details

Summary

Implement a fallback to getting the file size via vFile:stat packet
when the remote server does not implement vFile:size. This makes it
possible to query file sizes from remote gdbserver.

While at it, add a few tests for the 'platform get-size' command.

Diff Detail

Event Timeline

mgorny requested review of this revision.Aug 9 2021, 12:28 PM
mgorny created this revision.

This covers client side only, I'm going to work on the server side vFile:stat packet later.

mgorny updated this revision to Diff 365408.Aug 10 2021, 3:14 AM

Fix integer-type related warnings.

mgorny updated this revision to Diff 365414.Aug 10 2021, 3:42 AM

Add a helper Stat method to take care of opening and closing the file. Add a cache variable for whether vFile:size is supported.

mgorny updated this revision to Diff 371300.Sep 8 2021, 3:42 AM

Fix lint warnings. Add a note about not-full-replacement as requested in D107811.

labath added inline comments.Sep 8 2021, 4:17 AM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
56–70

If we're going to have a struct for this anyway, then I think we should definitely use llvm's endian-specific types here. Then, instead of playing with DataExtractors, we can just memcpy the data here (the memcpy could go away as well with some changes to the StringExtractorGDBRemote interface)..

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
381

If you make a note here that this is only a convenience wrapper around FStat (which opens the file in read mode), then the other comments are probably unnecessary...

mgorny updated this revision to Diff 371618.Sep 9 2021, 9:12 AM
mgorny marked 2 inline comments as done.

Use LLVM's ubig*_t types. Thanks for the suggestion, @labath!

Also add the comment that Stat() is only a wrapper over open+fstat.

labath accepted this revision.Sep 10 2021, 12:58 AM

cool

This revision is now accepted and ready to land.Sep 10 2021, 12:58 AM
This revision was landed with ongoing or failed builds.Sep 10 2021, 2:09 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2021, 2:09 AM