Skip to content

Commit

Permalink
chore: rustfmt
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Nov 29, 2023
1 parent ac77597 commit a114f89
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
pull_request:

jobs:
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt -- --check

c:
name: C
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions examples/hermitrust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern crate hermit_sys;
use std::thread;
use std::time::SystemTime;


fn main() {
let events = rftrace::init(100000, false);

Expand Down Expand Up @@ -55,4 +54,4 @@ fn threads() {
// Wait for the thread to finish. Returns a result.
let _ = child.join();
}
}
}
2 changes: 1 addition & 1 deletion examples/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ fn test2() {

fn test3() {
println!("test3");
}
}
7 changes: 2 additions & 5 deletions rftrace-frontend-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ pub unsafe extern "C" fn rftrace_dump_full_uftrace(
let binary_name = CStr::from_ptr(binary_name).to_string_lossy().into_owned();
let linux = linux_mode != 0;

if rftrace_frontend::dump_full_uftrace(&mut *events, &out_dir, &binary_name, linux).is_err()
{
if rftrace_frontend::dump_full_uftrace(&mut *events, &out_dir, &binary_name, linux).is_err() {
return -1;
}
0
Expand All @@ -55,9 +54,7 @@ pub unsafe extern "C" fn rftrace_dump_trace(events: *mut Events, outfile: *const
0
}



#[no_mangle]
pub extern "C" fn marker() -> u64 {
1337
}
}
9 changes: 6 additions & 3 deletions rftrace-frontend/src/frontend.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::interface::*;
use byteorder::{LittleEndian, WriteBytesExt};
use std::fs::File;
use std::io::{self, prelude::*};
use std::io::prelude::*;
use std::io::{self};

use byteorder::{LittleEndian, WriteBytesExt};

use crate::interface::*;

extern "C" {
fn rftrace_backend_enable();
Expand Down
9 changes: 5 additions & 4 deletions rftrace/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub extern "C" fn mcount_entry(parent_ret: *mut *const usize, child_ret: *const
// This means parent_ret (which is lea 8(%rbp)), will be 8 and we will crash on access.
// Other OS's likely do something similar. Don't deref in that case!
let (hook_return, parent_ret_deref) = if parent_ret as usize <= 0x100 {
(false, 0xD3ADB33F as *const usize)
(false, 0xd3adb33f as *const usize)
} else {
(true, *parent_ret)
};
Expand All @@ -187,7 +187,9 @@ pub extern "C" fn mcount_entry(parent_ret: *mut *const usize, child_ret: *const
}

// TODO: clean up this hack! we check if we are in mcount, or mcount_entry, mcount_return_tampoline or mcount_return
if parent_ret_deref >= (mcount as *const usize) && parent_ret_deref <= (rftrace_backend_get_events_index as *const usize) {
if parent_ret_deref >= (mcount as *const usize)
&& parent_ret_deref <= (rftrace_backend_get_events_index as *const usize)
{
/*unsafe {
*(0 as *mut u8) = 0;
}
Expand All @@ -202,13 +204,12 @@ pub extern "C" fn mcount_entry(parent_ret: *mut *const usize, child_ret: *const
}

events[cidx % events.len()] = Event::Exit(Exit {
time: _rdtsc()+20,
time: _rdtsc() + 20,
from: child_ret,
tid,
});
}


return;
}

Expand Down
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group_imports = "StdExternalCrate"
hex_literal_case = "Lower"
imports_granularity = "Module"

0 comments on commit a114f89

Please sign in to comment.