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

Mapping from dwarf registers to processor registers. #200

Closed
xd009642 opened this issue May 23, 2017 · 10 comments
Closed

Mapping from dwarf registers to processor registers. #200

xd009642 opened this issue May 23, 2017 · 10 comments

Comments

@xd009642
Copy link

xd009642 commented May 23, 2017

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

@fitzgen
Copy link
Member

fitzgen commented May 23, 2017

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 :)

@xd009642
Copy link
Author

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?

@fitzgen
Copy link
Member

fitzgen commented May 23, 2017

Do you have a link to the PR you submitted?

@xd009642
Copy link
Author

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

@philipc
Copy link
Collaborator

philipc commented May 26, 2017

Is user_regs_struct only used with ptrace?

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?

@tromey
Copy link
Member

tromey commented May 26, 2017

Is user_regs_struct only used with ptrace?

Also I think core files and the gdb remote protocol.

@xd009642
Copy link
Author

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.

@luser
Copy link
Contributor

luser commented Jun 8, 2017

I hand-rolled some code for handling CPU contexts from minidumps:
https://github.com/luser/rust-minidump/blob/master/src/context.rs

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.

@fitzgen
Copy link
Member

fitzgen commented Jun 8, 2017

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 gimli org if you wanted. Or not. Either way.

@philipc
Copy link
Collaborator

philipc commented Sep 16, 2018

#328 defines some DWARF register numbers. I don't think that mappings to other schemes belong in gimli though.

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

5 participants