Skip to content
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

Support attaching to QEMU, kgdb, and other gdbstub targets #172

Open
osandov opened this issue Apr 28, 2022 · 3 comments
Open

Support attaching to QEMU, kgdb, and other gdbstub targets #172

osandov opened this issue Apr 28, 2022 · 3 comments

Comments

@osandov
Copy link
Owner

osandov commented Apr 28, 2022

The GDB Remote Serial Protocol is implemented by several debugging targets, including kgdb for the Linux kernel and QEMU. These targets are especially useful for development workflows (as opposed to debugging in production).

Basic support will require implementing alternate backends for at least the following components of drgn:

  • Debug info discovery. (The protocol doesn't allow for automatic discovery, so this will likely need to be somewhat manual and depend on Module API #332).
  • Memory reading.
  • Threads.

The more exciting features will require new interfaces:

@osandov osandov added the help wanted Extra attention is needed label Apr 28, 2022
@bgamari
Copy link

bgamari commented Oct 15, 2022

This would also likely unlock support for https://github.com/rr-debugger/rr, which I have found to be an invaluable tool when debugging user-space issues.

@osandov osandov changed the title Support gdbstub targets Support attaching to QEMU, kgdb, and other gdbstub targets May 22, 2024
@osandov osandov removed the help wanted Extra attention is needed label May 22, 2024
@brenns10
Copy link
Contributor

One of the open questions for many of these options is going to be, how can we get the vmcoreinfo metadata for these targets. With #396, we will be able to let people manually set the vmcoreinfo prior to attaching, but it would be better if drgn could get that information automatically from the target.

Maybe a good place to get started is to add the ability to get vmcoreinfo from some of these backends where possible? EG QEMU's gdbstub could be extended to provide the cached vmcoreinfo if the guest was started with -device vmcoreinfo. I'm sure there must be some place in the GDB protocol to be able to ask for some custom piece of information...

It may be possible to get kgdb to provide a similar management command too?

@osandov
Copy link
Owner Author

osandov commented May 29, 2024

Yeah, exactly, I was hoping that it'd be possible to add a custom GDB protocol message for this.

In the meantime, in addition to manually providing the VMCOREINFO, if KASLR is disabled and we're able to provide a vmlinux earlier in the program initialization process, we can get the vmcoreinfo note from symbols or DWARF. Terrible user experience, but probably unavoidable at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants