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

fix(backend): migrate to naked_asm! #42

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Replay
run: uftrace replay --data=tracedir --output-fields=tid | tee ci.snap
- name: Compare to snapshot
run: diff ci.snap out.snap
run: diff -u out.snap ci.snap

rust:
name: Rust
Expand All @@ -70,4 +70,4 @@ jobs:
- name: Replay
run: uftrace replay --data=tracedir --output-fields=tid | tee ci.snap
- name: Compare to snapshot
run: diff ci.snap out.snap
run: diff -u out.snap ci.snap
10 changes: 10 additions & 0 deletions examples/rust/out.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@
[ 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