-
Notifications
You must be signed in to change notification settings - Fork 193
crash: port rd command #561
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
Conversation
|
The error on Python 3.8 is rather interesting. The test case intermixes positional arguments and optional arguments. I guess I assumed that would work, but argparse doesn't allow it unless you explicitly use Normally I don't use optional positionals ( We could just enable
We could also allow commands to opt-in to intermixed args via a command line argument, or we could just accept that this is the way it is (and change the test). I honestly don't care too much about intermixed args. Maybe we can chat about it in today's meeting. |
|
For now, I've modified the test to not intermix positional & optional arguments. I also updated the text alignment to match crash's more accurately. |
9bc1710 to
381bfd7
Compare
|
Ok, this PR should be ready. It has every rd option except -m and -f. It supports userspace memory in the way we discussed on Matrix. And while they're not completed, the all-architecture tests are looking pretty good. I'll probably look into adding the |
osandov
left a comment
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.
This is great, thank you. Just a few nitpicks.
The rd command allows reading and formatting kernel memory in a variety of ways. In addition to being its own command, it also provides functionality that other commands (like bt) will use, so it's important to provide an API for its functionality as well. But since it is just implementing crash-compatible behavior, it's not exposed as a helper. Thanks to the recent refactor to identify_address_all(), it is possible to implement the specific behavior that Crash's rd command implements for -sS[S]. Unfortunately, the addresses crash identifies and annotates are a subset of what drgn is capable of annotating. It might be worth including the entire set of drgn annotations with a dedicated option, such as when specifying a third "-S" option. That is not implemneted here. Userspace memory reading is also supported, using the context task to determine the address space. Since it's definitely non-trivial to determine whether an address is user or kernel, we employ a trick: first we try to read memory using prog.read, and if that fails, we try to read via access_process_vm(). Based on that, we can "magically" generate the correct drgn code. Usually the user knows whether they're trying to read user/kernel memory, so it makes sense to pretend we magically knew it as well. The only crash options which are not supported are -m (for Xen host machine addresses) and -f (for dumpfile offsets). Neither of these are likely to be supported by drgn. Signed-off-by: Stephen Brennan <[email protected]>
|
Thanks for the review. I think everything is addressed here. I noticed a funny error on my local tests, but it's reproducing on |
osandov
left a comment
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.
Awesome, thanks!
The new hrtimer command test has been flaky, but I haven't gotten to the bottom of that yet. Is that the one you've seen?
|
No, this is in the It is only reproducing on my Oracle Linux laptop, not my Arch desktop or the Debian rootfs. I'm tracking it down a bit further but will file an issue if it is actually a bug. |
|
#569 :( |
This implements almost every option for crash's rd command. With the
identify_address_all()API it's now trivial to make the symbolized output identical to crash's. There are a lot of formatting options, which I tried to cover with a generic unit test suite that is independent from the kernel tests. And there are also linux kernel crash command tests.The
_print_memory()API will get used by thebtcommand to print the formatted memory between stack frames. I didn't think it merited being an exported helper API because it's so crash-specific. If necessary that can always be changed.The only options missing are:
-fto print dumpfile offsets. This is just too low-level for drgn, and I don't see an easy way to include it. I also have never used it myself.-mto print Xen host machine memory. In 2025 I'm not sure how relevant this is, and I don't think we actually support the Xen dumps necessary for this to even make sense.Userspace memory is supported too, using the trick we discussed on matrix.