Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Software and Hardware Tracing

Lukas Diekmann edited this page Aug 28, 2020 · 5 revisions

Yorick will have two tracing modes:

  • Software tracing.
  • Hardware tracing.

Software 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.

Hardware Tracing

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.

Selecting a Tracing Mode

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).

Considerations when building ykrustc itself.

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