diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1990e0..1da70a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,9 @@ jobs: run: | sudo apt-get update sudo apt-get install uftrace + - uses: taiki-e/install-action@v2 + with: + tool: cargo-binutils - uses: mkroening/rust-toolchain-toml@main with: toolchain: nightly @@ -75,6 +78,7 @@ jobs: run: | mkdir tracedir ../../target/debug/rftrace-rs-test + - run: rust-nm --demangle --numeric-sort ../../target/debug/rftrace-rs-test | tee tracedir/rftrace-rs-test.sym - name: Replay run: uftrace replay --data=tracedir --output-fields=tid | tee ci.snap - name: Compare to snapshot diff --git a/README.md b/README.md index ac08873..b7deeb7 100755 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ The full trace consists of 5+ files, 4 for metadata plus 1 per TID which contain - `/info`: general info about cpu, mem, cmdline, version - `/task.txt`: contains PID, TID, SID<->exename mapping - `/sid-.map`: contains mapping of addr to exename. By default, the memory map is faked. You can enable linux-mode, in which case `/proc/self/maps` is copied. -- `/.sym`: contains symbols of exe, like output of `nm -n` (has to be sorted!). Symbols are never generated and always have to be done by hand. +- `/.sym`: contains symbols of exe, like output of `nm --demangle -n` (has to be sorted!). Symbols are never generated and always have to be done by hand. ### Chrome trace viewer diff --git a/examples/hermitc/makefile b/examples/hermitc/makefile index 904cf47..5622bce 100644 --- a/examples/hermitc/makefile +++ b/examples/hermitc/makefile @@ -44,7 +44,7 @@ run: example sleep 1 sudo chmod 777 /tmp/vhostqemu qemu-system-x86_64 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr -enable-kvm -display none -smp 1 -m 1G -serial stdio -kernel $(RUSTY_LOADER) -initrd $(ROOT_DIR)/example -chardev socket,id=char0,path=/tmp/vhostqemu -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=tracedir -object memory-backend-file,id=mem,size=1G,mem-path=/dev/shm,share=on -numa node,memdev=mem - nm -n $(ROOT_DIR)/example > tracedir/example.sym + nm --demangle -n $(ROOT_DIR)/example > tracedir/example.sym uftrace dump -d tracedir --chrome > tracedir/trace.json .PHONY: default hermit clean run \ No newline at end of file diff --git a/examples/hermitrust/makefile b/examples/hermitrust/makefile index 2a5f93e..8216b00 100644 --- a/examples/hermitrust/makefile +++ b/examples/hermitrust/makefile @@ -19,7 +19,7 @@ run: default sleep 1 sudo chmod 777 /tmp/vhostqemu qemu-system-x86_64 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr -enable-kvm -display none -smp 1 -m 1G -serial stdio -kernel $(RUSTY_LOADER) -initrd $(BINARY) -chardev socket,id=char0,path=/tmp/vhostqemu -device vhost-user-fs-pci,queue-size=1024,chardev=char0,tag=tracedir -object memory-backend-file,id=mem,size=1G,mem-path=/dev/shm,share=on -numa node,memdev=mem - nm -n $(BINARY) > tracedir/test.sym + nm --demangle -n $(BINARY) > tracedir/test.sym uftrace dump -d tracedir --chrome > tracedir/trace.json diff --git a/examples/rust/out.snap b/examples/rust/out.snap index 0720f1d..32589e9 100644 --- a/examples/rust/out.snap +++ b/examples/rust/out.snap @@ -1,11 +1,13 @@ # TID FUNCTION - [ 1] | core::fmt::rt::_::new_const(); + [ 1] | ::from_str(); + [ 1] | __rustc::__rust_no_alloc_shim_is_unstable_v2(); + [ 1] | __rustc::__rust_alloc(); [ 1] | rftrace_rs_test::test1() { - [ 1] | core::fmt::rt::_::new_const(); + [ 1] | ::from_str(); [ 1] | rftrace_rs_test::test2() { - [ 1] | core::fmt::rt::_::new_const(); + [ 1] | ::from_str(); [ 1] | rftrace_rs_test::test3() { - [ 1] | core::fmt::rt::_::new_const(); + [ 1] | ::from_str(); [ 1] | } /* rftrace_rs_test::test3 */ [ 1] | } /* rftrace_rs_test::test2 */ [ 1] | } /* rftrace_rs_test::test1 */ diff --git a/rftrace-frontend/src/frontend.rs b/rftrace-frontend/src/frontend.rs index b8b8e20..075738c 100644 --- a/rftrace-frontend/src/frontend.rs +++ b/rftrace-frontend/src/frontend.rs @@ -71,7 +71,7 @@ pub fn init(max_event_count: usize, overwriting: bool) -> &'static mut Events { /// Dumps the traces with some faked metadata into the given folder. Uses the same format as uftrace, which should be used to parse them. /// -/// Will NOT generate symbols! You can generate them with `nm -n $BINARY > binary_name.sym` +/// Will NOT generate symbols! You can generate them with `nm --demangle -n $BINARY > binary_name.sym` /// /// # Arguments /// @@ -198,7 +198,7 @@ pub fn dump_full_uftrace(events: &mut Events, out_dir: &str, binary_name: &str) if cfg!(target_os = "linux") { println!( - "\nYou should generate symbols with `nm -n $BINARY > {}/$BINARY.sym`", + "\nYou should generate symbols with `nm --demangle -n $BINARY > {}/$BINARY.sym`", out_dir ); println!( @@ -208,7 +208,7 @@ pub fn dump_full_uftrace(events: &mut Events, out_dir: &str, binary_name: &str) println!(" Needs to contain at least [stack] and the binaries you want symbols of."); } else { println!( - "\nYou should generate symbols with `nm -n $BINARY > {}/{}.sym`", + "\nYou should generate symbols with `nm --demangle -n $BINARY > {}/{}.sym`", out_dir, binary_name ); } diff --git a/tools/create_fake_uftrace.py b/tools/create_fake_uftrace.py index c2ecbb0..41eaaa9 100644 --- a/tools/create_fake_uftrace.py +++ b/tools/create_fake_uftrace.py @@ -67,7 +67,7 @@ def create_fake_uftrace(dirname, tracefile, binary=None, PID=123, TID=42, SID=b" # generate symbols if binary: print(" Generating symbols with nm") - nm_cmd = ['nm', '-n', binary] + nm_cmd = ['nm', '--demangle', '-n', binary] with open(f"{dirname}/{EXENAME}.sym", "w") as symbolfile: subprocess.run(nm_cmd, stdout=symbolfile) else: diff --git a/tools/merge.py b/tools/merge.py index 3522d93..be05c2c 100755 --- a/tools/merge.py +++ b/tools/merge.py @@ -266,7 +266,7 @@ def merge(): # if binary is specified, generate symbols for trace if args.binary: print("Generating symbols with nm") - nm_cmd = ['nm', '-n', args.binary] + nm_cmd = ['nm', '--demangle', '-n', args.binary] with open(f"{args.TRACE}/{args.binaryname}.sym", "w") as symbolfile: subprocess.run(nm_cmd, stdout=symbolfile) else: