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
Fix filesystem paths for debugging process in containers #897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Could you maybe add an example on how you debug a target in a container to our docs? Do you use --pid=host
?
That's right. What about something of this form in the FAQ: How can I use GEF to debug a process in a container?GEF can attach to a process running in a container using
Please note that cross-container debugging may have unexpected issues. Installing gdb and GEF inside the container, or using the official GEF docker image may improve results. |
Yes that's great. |
The patch looks great, thx @clubby789 Can you add some tests in |
|
I think installing |
Correct, the last commit on dev fixed that. |
Are there any changes you'd like made here? Otherwise rerunning the CI should pass now |
just pull the latest changes from dev into your branch, then push it. it'll trigger the github actions again, which should pass yes |
If the path *begins* with `target:`, replace only the first occurrence with the real root.
353126b
to
6e48fa1
Compare
Rebased onto latest dev |
Test on 18.04 not passing. |
That's weird. Locally, the PID of the process running under Qemu-user was 1, but that's not what happens on 18.04? Maybe testing for /proc/[0-9]+/root would be better. I'll try and reproduce locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This removes some warnings but I get this error when attaching to gdbserver running in a container
Debugging works anyway so it's just a cosmetic issue. |
Running |
EDIT: Thanks for the hint that this is unsupported. Sorry for the inconvenience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Great PR, thanks!
No problem, the warning was actually added very recently because too many people were complaining that |
Description/Motivation/Screenshots
When attaching to a process in a container, GDB prefixes file paths with
target:
, which means files can't be resolved. This also causes usage issues with output likeThis PR properly resolves file paths using
/proc/$PID/root
to access the process's filesystem root directory, making cross-container debugging much more usable.Against which architecture was this tested ?
"Tested" indicates that the PR works and the unit test (i.e.
make test
) run passes without issue.Note: I'm not sure if this can be reasonably tested automatically, as it would require being able to spawn extra containers in CI or use of
chroot
which may not be available in the CI. If testing is required please let me know how I can go about implementing a test.Checklist
dev
branch, notmain
.