-
Notifications
You must be signed in to change notification settings - Fork 4
Software and Hardware Tracing
Yorick will have two tracing modes:
- Software tracing.
- Hardware tracing.
In software tracing mode, ykrustc inserts calls to a trace recorder at the beginning of each basic block. The arguments to the call identify the (statically known) location of the call-site. At runtime when tracing is enabled the trace recorder stores each location into a trace buffer.
- A MIR pass adds calls to the trace recorder.
- The trace recorder lives in libcore and is implemented in C so that its contents are not recursively traced.
In hardware tracing mode, we will use Intel Processor Trace to do trace collection. The chip gives us a trace of virtual addresses which we then map back to SIR locations.
When you build a Rust project that you want to trace, the binary must be built for a specific tracer backend.
To choose a backend, you pass -C tracer=T
to rustc
, where T
is one of hw
, sw, or
off. Passing
off` is the same as omitting the option altogether.
If you are using cargo
, you will need to add this flag to the RUSTFLAGS
environment:
RUSTFLAGS="-C tracer=hw" cargo build
Note that -C tracer
is a tracked flag: changing it will trigger a rebuild (but bear in mind that your standard library will not be rebuilt. See below).
When you build ykrustc using x.py
you will need to decide what tracing support the standard library should be built with. You must set STD_TRACER_MODE
to hw
, sw
, or off
:
STD_TRACER_MODE=hw ./x.py build --stage 1