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

hermit-sys, with features: instrument but hermit-sys does not have these features #2

Closed
jbreitbart opened this issue Jun 27, 2020 · 7 comments · Fixed by #32
Closed

Comments

@jbreitbart
Copy link

I wanted to try your traces with the demo application of the rusty-hermit repo, however I get the error messaged name in title. Here is what I did:

  1. git clone --recursive https://github.com/hermitcore/rusty-hermit.git
  2. created rust-toolchain file and set it to nightly
  3. cargo build -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit worked fine and I could run the demo with uhyve
  4. made the following changes to demo/Cargo.toml:
index 4cd2726..683ed2b 100644
--- a/demo/Cargo.toml
+++ b/demo/Cargo.toml
@@ -9,7 +9,8 @@ publish = false
 rayon = "1.3.0"
 
 [target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
-hermit-sys = { path = "../hermit-sys", default-features = false, features = ["with_submodule"] }
+hermit-sys = { path = "../hermit-sys", default-features = false, features = ["with_submodule", "instrument"] }
+rftrace = { git = "https://github.com/tlambertz/rftrace" }
 
 [target.'cfg(target_os = "linux")'.dependencies]
 syscalls = { version = "0.2", default-features = false }

If I call cargo build -Z build-std=std,core,alloc,panic_abort,instrument-mcount --target x86_64-unknown-hermit --release I get the following output:

$ cargo build -Z build-std=std,core,alloc,panic_abort,instrument-mcount --target x86_64-unknown-hermit --release
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /home/jbreitbart/temp/h/rusty-hermit/demo/Cargo.toml
workspace: /home/jbreitbart/temp/h/rusty-hermit/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /home/jbreitbart/temp/h/rusty-hermit/netbench/Cargo.toml
workspace: /home/jbreitbart/temp/h/rusty-hermit/Cargo.toml
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /home/jbreitbart/temp/h/rusty-hermit/httpd/Cargo.toml
workspace: /home/jbreitbart/temp/h/rusty-hermit/Cargo.toml
    Updating git repository `https://github.com/tlambertz/rftrace`
error: failed to select a version for `hermit-sys`.
    ... required by package `rusty_demo v0.1.0 (/home/jbreitbart/temp/h/rusty-hermit/demo)`
versions that meet the requirements `=0.1.14` are: 0.1.14

the package `rusty_demo` depends on `hermit-sys`, with features: `instrument` but `hermit-sys` does not have these features.


failed to select a version for `hermit-sys` which could resolve this conflict

Do you have an idea why it is not working for me?

@tlambertz
Copy link
Collaborator

I have not published the crate to crates.io yet, so it had to be commented out from hermit-sys cargo file.

The Readme is slightly out of date, the last commits changed some things. Have to revise it and publish it.

Take a look at the basic example to see the current "userland" interface.

In hermit-sys you have to use the backend with autokernel and interruptsafe features afaik

@tlambertz
Copy link
Collaborator

hermit-os/hermit-rs#55 should resolve the issue

@jbreitbart
Copy link
Author

Thanks 😄 I'll give it a try after it was merged.

@jbreitbart
Copy link
Author

It took me a while to get back to this, but I finally found some time. Trace generation seems to be working, but the symbol table generated by nm is missing the offset that is used by hermitcore. I had to run something like awk '{$0="0x"$0; printf "%x", $x+4194304; print substr($0, index($0, " "))}' trace/binaryname-nm.sym >trace/binaryname.sym to fix it. Is it possible to directly fix this when writing the results to file?

@tlambertz
Copy link
Collaborator

I've not been following hermit's development lately, but I guess this is related to the changes to kernel relocation (hermit-os/loader#8).

For the purposes of mapping addresses to functions, uftrace treats all in-memory binaries as relocatable, and uses the sid-00.map file for resolving offsets. Thus you can avoid the complicated awk command by just replacing the offset in the map file:

000000400000-ffffffffffff r-xp 00000000 00:00 0                          test
ffffffffffff-ffffffffffff rw-p 00000000 00:00 0                          [stack]

I am not sure if there is a nice, general fix for this issue. The file is generated by the rftrace-frontend. When using linux mode, the map is directly copied from /proc/self/maps , but hermit does not expose something similar afaik.

I suppose I could just change the offset in rftrace (as rustyhermit is the only usecase for non-linux mode right now), though that seems a bit dirty.

@mkroening
Copy link
Member

Related: hermit-os/hermit-rs#147

@mkroening mkroening linked a pull request Mar 25, 2024 that will close this issue
@mkroening
Copy link
Member

This is now resolved as of #32. 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants