Skip to content

Commit

Permalink
fix(backend): migrate to naked_asm!
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Oct 11, 2024
1 parent f6e3aca commit 92880b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions examples/rust/out.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
[ 1] | } /* rftrace_rs_test::test3 */
[ 1] | } /* rftrace_rs_test::test2 */
[ 1] | } /* rftrace_rs_test::test1 */
[ 1] | rftrace_frontend::frontend::dump_full_uftrace() {
[ 1] | rftrace_frontend::frontend::dump_traces() {
[ 1] | rftrace_frontend::frontend::disable();

uftrace stopped tracing with remaining functions
================================================
task: 1
[1] rftrace_frontend::frontend::dump_traces
[0] rftrace_frontend::frontend::dump_full_uftrace
8 changes: 3 additions & 5 deletions rftrace/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::arch::asm;
use core::arch::naked_asm;
use core::arch::x86_64::_rdtsc;
use core::slice;
use core::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
Expand Down Expand Up @@ -87,7 +87,7 @@ pub unsafe extern "C" fn mcount() {
// mcounts ret addr is directly at rsp

// based on https://github.com/namhyung/uftrace/blob/master/arch/x86_64/mcount.S
asm!(
naked_asm!(
// if ENABLED.load(Ordering::Relaxed) {
// return;
// }
Expand Down Expand Up @@ -132,7 +132,6 @@ pub unsafe extern "C" fn mcount() {
"pop rax",
"ret",
// TODO: ENABLED = sym ENABLED,
options(noreturn),
);
}

Expand Down Expand Up @@ -395,7 +394,7 @@ pub unsafe extern "C" fn mcount_return_trampoline() {
RSP +0 rax
*/

asm!(
naked_asm!(
prologue!(),
// always backup return registers
"mov [rsp + 8], rdx",
Expand All @@ -416,7 +415,6 @@ pub unsafe extern "C" fn mcount_return_trampoline() {
restore_sse2!(),
epilogue!(),
"ret",
options(noreturn),
);
}

Expand Down

0 comments on commit 92880b1

Please sign in to comment.