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

Add a trait for registers #87

Closed
bjorn3 opened this issue Aug 17, 2020 · 3 comments
Closed

Add a trait for registers #87

bjorn3 opened this issue Aug 17, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bjorn3
Copy link
Contributor

bjorn3 commented Aug 17, 2020

Something like

trait Registers {
    fn ip(&self) -> u64;
    fn set_ip(&mut self, ip: u64);
    fn sp(&self) -> u64;
    fn set_sp(&mut self, sp: u64);
    fn bp(&self) -> Option<u64>; // None if the standard abi on the platform has no base pointer
    #[must_use]
    fn set_bp(&mut self, bp: u64) -> Option<()>; // None if the standard abi on the platform has no base pointer

    fn reg_for_dwarf(&self, reg: gimli::Register) -> Option<u64>; // None when register doesn't exist
    #[must_use]
    fn set_reg_for_dwarf(&mut self, reg: gimli::Register, val: u64) -> Option<()>; // None when register doesn't exist

    fn name_for_dwarf(reg: gimli::Register) -> Option<&'static str>; // None when register doesn't exist
    fn dwarf_for_name(name: &str) -> Option<gimli::Register>; // None when register doesn't exist
}

I am not quite sure how to handle different reg sizes on different architectures and within a single architecture though.

@bjorn3 bjorn3 added the enhancement New feature or request label Aug 17, 2020
@nbaksalyar
Copy link
Member

This is a prerequisite for #96. I'd like to give it a try.

@nbaksalyar nbaksalyar self-assigned this Aug 29, 2020
@nbaksalyar nbaksalyar added this to the Phase 1 milestone Aug 29, 2020
@Stupremee
Copy link
Contributor

Probably we can represent the different register sizes using an Enum with a u64, u32, ... variants and with a bunch of helper methods and TryInto impls it should be easy to get the raw values out of the Enum.

@nbaksalyar
Copy link
Member

Closed by #98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants