-
Notifications
You must be signed in to change notification settings - Fork 132
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 bochs magic breakpoint, read instruction pointer, inline instructions #79
Conversation
…al instructions and various doc changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the pull request! It looks good to me overall, I only have a few suggestions for the read_rip
function.
src/instructions/mod.rs
Outdated
/// Gets the current instruction pointer. Note that this is only approximate as it requires a few | ||
/// instructions to execute. | ||
#[inline] | ||
pub fn read_rip() -> u64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function fits better in the registers
module, given that rip
is a CPU register.
src/instructions/mod.rs
Outdated
|
||
/// Gets the current instruction pointer. Note that this is only approximate as it requires a few | ||
/// instructions to execute. | ||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should probably be inline(always)
. Without always
, this is just a hint to the compiler that this might be useful for inlining. But this function does not make much sense without inlining, as it would always return the same value independent of the calling location.
src/instructions/mod.rs
Outdated
unsafe { | ||
asm!( | ||
"call .next | ||
.next: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if inline assembly does support local labels (prefixed with a dot). With global_asm
, which uses the same syntax, such labels are treated as global labels so that a linker error occurs if another .next
label is defined elsewhere in the program. Could you try whether this is the case for inline assembly too?
In case it is, it might make sense to manually mangle that label name to something less common. Alternatively, it seems that lea rax, [rip]
also works to get the rip
value, without needing any labels.
done |
Thanks! |
#[inline]