-
Notifications
You must be signed in to change notification settings - Fork 108
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
Mapping from dwarf registers to processor registers. #200
Comments
We have that table embedded in our documentation: https://docs.rs/gimli/0.13.0/gimli/struct.UnwindTableRow.html#method.register I recall some discussion about the best way to provide the register mapping for the target architecture, but don't think we came up with a good solution. Ideas welcome :) |
Hmmm, I'll have a think about it. I submitted a PR to libc regarding the x86 and x86_64 registers. If the register structs get accepted would you be opposed to adding a libc dependency and leveraging some of the structures it'll provide if it makes a solution nicer? |
Do you have a link to the PR you submitted? |
rust-lang/libc#599 I've just seen it failed the clippy checks with trailing whitespace but I'll fix that when I get home from work |
Is It might be better if a mapping between DWARF register indices and fields in user_regs_struct is kept in whatever crate is using ptrace, since it will have the libc dependency already. Would it help if gimli defined an enumeration for the register indices? |
Also I think core files and the gdb remote protocol. |
It might be worth adding some higher level functionality regarding the user_regs_struct to nix-rust as libc only deals with direct bindings. Then leverage those features from nix-rust. I'm currently away from my development machine for the bank holiday so won't get a chance to look properly into this until Tuesday. My initial thoughts right now are an enum for the register indices for x86_64 registers and dwarf registers with convert to and from functions in rust_nix. And then use the register enum in gimli. |
I hand-rolled some code for handling CPU contexts from minidumps: I was thinking it would be nice to have a standalone crate that defined CPU registers for various architectures and provided ways to map between various representations, but maybe that's overkill. |
That sounds good to me. Could put it in the |
#328 defines some DWARF register numbers. I don't think that mappings to other schemes belong in gimli though. |
The ability to map from dwarf registers to processor registers would be useful when using the debug_frames section. For example if we look at the x86_64 ABI, we can see that dwarf register 7 is the Stack Pointer Register.
Filling in this mapping for the various architectures would definitely make working with the DWARF tables easier and I'd be willing to help implement this if you guys think it would be useful.
Edit: Unsure how to add labels but this would be an enhancement obviously
The text was updated successfully, but these errors were encountered: