Skip to content

Commit

Permalink
Merge pull request #42 from hermit-os/nightly
Browse files Browse the repository at this point in the history
fix(backend): migrate to `naked_asm!`
  • Loading branch information
mkroening authored Oct 11, 2024
2 parents 9dee139 + 5b5b1ee commit 5f683b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
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

0 comments on commit 5f683b1

Please sign in to comment.