Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Fix support for tracing, add --mapdir to host cli#142

Merged
pchickey merged 3 commits into
mainfrom
pch/trace
Apr 14, 2023
Merged

Fix support for tracing, add --mapdir to host cli#142
pchickey merged 3 commits into
mainfrom
pch/trace

Conversation

@pchickey
Copy link
Copy Markdown
Collaborator

@pchickey pchickey commented Apr 14, 2023

Use the latest wasmtime, which needed the following to make the tracing: true feature in wasmtime-wit-bindgen actually emit something useful: bytecodealliance/wasmtime#6209

Install the tracing_subscriber in host's main.rs, so that RUST_LOG=host=trace works from the cli. (It already worked in tests, via test_log.)

And finally, implement --mapdir as a command line flag, stolen out of the wasmtime cli. I had to rejigger how preopens are constructed slightly to make this work out.

Sample output:

Details
[phickey@pch-tower:src/preview2-prototyping]% RUST_LOG=host=trace cargo run -p host -- read_empty_filename.component.wasm --mapdir /::tmp
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/host read_empty_filename.component.wasm --mapdir '/::tmp'`
2023-04-14T15:22:21.371311Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="preopens" function="get-stdio"}: host::command::wasi::preopens: call
2023-04-14T15:22:21.371359Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="preopens" function="get-stdio"}: host::command::wasi::preopens: return result=Ok(StdioPreopens { stdin: 0, stdout: 1, stderr: 2 })
2023-04-14T15:22:21.371451Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="preopens" function="get-directories"}: host::command::wasi::preopens: call
2023-04-14T15:22:21.371485Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="preopens" function="get-directories"}: host::command::wasi::preopens: return result=Ok([(3, "/")])
2023-04-14T15:22:21.371620Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="open-at"}: host::command::wasi::filesystem: call this=3 path_flags=(SYMLINK_FOLLOW) path="." open_flags=() flags=(READ) modes=(READABLE|WRITEABLE)
2023-04-14T15:22:21.371687Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="open-at"}: host::command::wasi::filesystem: return result=Ok(4)
2023-04-14T15:22:21.371766Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="stat"}: host::command::wasi::filesystem: call this=4
2023-04-14T15:22:21.371806Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="stat"}: host::command::wasi::filesystem: return result=Ok(DescriptorStat { device: 64769, inode: 17304241, type: DescriptorType::Directory, link-count: 2, size: 4096, data-access-timestamp: Datetime { seconds: 1681484998, nanoseconds: 564963481 }, data-modification-timestamp: Datetime { seconds: 1681348594, nanoseconds: 577238733 }, status-change-timestamp: Datetime { seconds: 1681348594, nanoseconds: 577238733 } })
2023-04-14T15:22:21.371896Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="read-via-stream"}: host::command::wasi::filesystem: call this=4 offset=0
2023-04-14T15:22:21.371926Z TRACE wit-bindgen export{module="default" function="main"}:wit-bindgen import{module="filesystem" function="read-via-stream"}: host::command::wasi::filesystem: return result=Ok(5)

@pchickey pchickey requested a review from dicej April 14, 2023 15:23
@pchickey
Copy link
Copy Markdown
Collaborator Author

Closes #141

@pchickey pchickey merged commit f63cd44 into main Apr 14, 2023
@pchickey pchickey deleted the pch/trace branch April 14, 2023 22:15
@yamt yamt mentioned this pull request Apr 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants