Skip to content

Conversation

jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Jul 21, 2025

Add a file explorer to the debugger that allows exploring the filesystem
of the current container. It will show directory contents, file
contents, and symlink destinations. It will also show the file mode
associated with a file.

The file explorer defaults to marking itself as an expensive operation
so the debugger doesn't automatically retrieve the information.

Screenshot 2025-07-21 at 1 49 21 PM Screenshot 2025-07-25 at 2 44 49 PM

Copy link

@rcjsuen rcjsuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

If an error occurs, the file system tree node is showing an error message instead of the contents.

@jsternberg
Copy link
Collaborator Author

I'll have to try and fix that. The reason is because it's trying to reevaluate the build that just failed to read the filesystem which, predictably, fails. Need to grab the filesystem from right before the failure happens.

@rcjsuen
Copy link

rcjsuen commented Jul 22, 2025

I'll have to try and fix that. The reason is because it's trying to reevaluate the build that just failed to read the filesystem which, predictably, fails. Need to grab the filesystem from right before the failure happens.

If we can't show anything that's fine too. I think either a) the tree node shouldn't even appear or b) clearly state why the tree node is empty with some appropriately worded "error message" reason.

@jsternberg
Copy link
Collaborator Author

I think we can but it might be easier if I build this on top of the change in #3325 since the method I would use to get the state before the error is already done in that PR but isn't done on master so I'd have to redo it here in a different way.

dap/variables.go Outdated
Comment on lines 215 to 313
func statf(st *types.Stat) string {
mode := fs.FileMode(st.Mode)
modTime := time.Unix(0, st.ModTime).UTC()
return fmt.Sprintf("%s\t%d\t%d\t%s", mode, st.Uid, st.Gid, modTime.Format("Jan 2 15:04:05 2006"))
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tabs might be hit-or-miss depending on the client... 🤔

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I don't think the tabs are likely a good idea. I'll look into another way of representing this.

@jsternberg jsternberg force-pushed the dap-fs-inspect branch 2 times, most recently from 3f1a4cd to 4af8cf6 Compare July 25, 2025 19:48
@jsternberg
Copy link
Collaborator Author

I've updated the PR. Files will now contain their content. The file reading doesn't currently have any restrictions, but it uses a basic heuristic that mimics Perl to determine whether something is a binary file and avoids reading those. Symlinks will show where they link to. File nodes show up as a tab to open. Directories will have their contents and the mode and other stat information for the directory entry are attached to a fake . entry.

I think this should end up being both easy to use and also provide enough information to limit the need for using exec to check files.

Add a file explorer to the debugger that allows exploring the filesystem
of the current container. It will show directory contents, file
contents, and symlink destinations. It will also show the file mode
associated with a file.

The file explorer defaults to marking itself as an expensive operation
so the debugger doesn't automatically retrieve the information.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Copy link
Collaborator

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@rcjsuen
Copy link

rcjsuen commented Jul 29, 2025

Thanks for the updates, Jonathan. It looks like this now.

image

@jsternberg jsternberg merged commit 5c27294 into docker:master Aug 5, 2025
138 checks passed
@jsternberg jsternberg deleted the dap-fs-inspect branch August 5, 2025 16:06
@crazy-max crazy-max added this to the v0.27.0 milestone Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants