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

feat: Use type parameters to allow {get,set}regset to use different register set structs #2373

Merged
merged 1 commit into from Apr 25, 2024

Conversation

hack3ric
Copy link
Contributor

What does this PR do

Previous implementations of {get,set}regset are incorrect when register set value is anything other than NT_PRSTATUS. This PR adds the ability to return corresponding struct to the value using type parameters S: RegisterSet, so the behaviour is correct.

Added NT_PRSTATUS as well as NT_PRFPREG types so we can also probe floating-point registers. Other register sets may be inspected as well, such as arch-specific vector registers, but I don't have a use case right now, and it is easy to implement afterwards with the framework in this PR.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

This is an improvement over #2044, so changelog remains the same.

src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
@TheJonny
Copy link
Contributor

It could be more direct, if the RegisterSet would be implemented on the actual register set types. but the current suggestion has the advantage of having names one could recognize from the man page.

@hack3ric
Copy link
Contributor Author

Sorry for the late response. Reviews have been addressed.

It could be more direct, if the RegisterSet would be implemented on the actual register set types. but the current suggestion has the advantage of having names one could recognize from the man page.

I'd add that it could be confusing to implement RegisterSet on actual register set types. user_regs_struct may be universal, but every platform has its own floating-pointer register space types (see impl RegisterSet for NT_PRFPREG).

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@SteveLauC SteveLauC added this pull request to the merge queue Apr 25, 2024
Merged via the queue into nix-rust:master with commit 213127b Apr 25, 2024
36 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants