iptr-perf-pt-reader 0.1.0

Perf.data parser for Intel PT data
Documentation
  • Coverage
  • 100%
    24 out of 24 items documented1 out of 5 items with examples
  • Size
  • Source code size: 26.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.99 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Evian-Zhang/iptr
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Evian-Zhang

iptr-perf-pt-reader

iptr-perf-pt-reader is a utility crate of iptr project, providing basic capabilities of extracting Intel-PT-related data from perf.data format.

To use this crate, add this crate to your Cargo.toml:

[dependencies]
iptr-perf-pt-reader = "0.1"

Usage

This crate provides two main APIs: extract_pt_auxtraces and extract_pt_auxtraces_and_mmap_data. The former function extract all raw Intel PT trace from the perf.data, and the latter function additionally extract the mmap-related information for ipr-edge-analyzer to build a memory reader. The usage is very straightforward:

fn parse_perf_data(perf_data: &[u8]) {
    let (pt_traces, mmaped_headers) =
        iptr_perf_pt_reader::extract_pt_auxtraces_and_mmap_data(perf_data).unwrap();
    for pt_trace in pt_traces {
        println!("Get a PT trace with size {}", pt_trace.size);
        // Real data is in pt_trace.auxtrace_data
    }
    for mmaped_header in mmaped_headers {
        println!(
            "During perf, {} is mmaped to the address {:x}",
            mmaped_header.filename,
            mmaped_header.addr,
        );
    }
}

Currently, we only deal with perf.data generated by perf record -e intel_pt. For perf.data generated without Intel PT traces, the results of extraction are not tested.

Alternatives

linux-perf-data crate provides a more general interface for dealing with perf.data. However, this crate's support for AUXTRACE header is not completed, see issue#21.