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

Broken debugging support #147

Open
mkroening opened this issue Jul 16, 2021 · 3 comments
Open

Broken debugging support #147

mkroening opened this issue Jul 16, 2021 · 3 comments
Assignees

Comments

@mkroening
Copy link
Member

5685ca7 broke Rust-level debugging support. While it is still possible to step through assembly code using qemu or uyhve, any operation on a higher level, like setting a breakpoint in Rust code, is broken.

As this is caused by relocated code, which apparently confuses gdb in its current form, there must be a way to properly communicate the relocation details to make it work again.

@mkroening mkroening self-assigned this Jul 16, 2021
@mkroening
Copy link
Member Author

Related uhyve commit: hermit-os/uhyve@a9cae62

@mkroening
Copy link
Member Author

mkroening commented Jul 17, 2021

This can be worked around by using symbol-file [ filename [ -o offset ]] (Files (Debugging with GDB)) with filename being the RustyHermit application and offset being the BootInfo::base set in rusty_loader::boot_kernel and uhyve::load_kernel.

Both of these currently seem to be 0x400000 but that is subject to change. That number can currently be found by running the application once and fetching it from the output. Then the application can be started again using gdb and debugged properly. As the base is planned to be randomized, this would not work anymore. We'd have to support a way of getting the offset in gdb, like having a breakpoint after relocation and then reloading the symbol-file with the at the breakpoint available offset. This is how you can debug u-boot (global_data::relocaddr). There might also be a way to automate that using _dl_debug_state(), which is how ld.so does it according to Stack Overflow.

Currently-working example:

symbol-file target/x86_64-unknown-hermit/debug/rusty_demo -o 0x400000

@mkroening
Copy link
Member Author

mkroening commented Nov 12, 2021

Since hermit-os/uhyve#164 (section_offsets.rs) this works in uhyve again! 🎉

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

No branches or pull requests

1 participant