perf_event_data/records/
aux_record.rs1use bitflags::bitflags;
2use perf_event_open_sys::bindings;
3
4use crate::prelude::*;
5
6#[derive(Clone, Debug)]
13#[allow(missing_docs)]
14pub struct Aux {
15 pub aux_offset: u64,
16 pub aux_size: u64,
17 pub flags: AuxFlags,
18}
19
20bitflags! {
21 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
29 pub struct AuxFlags : u64 {
30 const TRUNCATED = bindings::PERF_AUX_FLAG_TRUNCATED as _;
32
33 const OVERWRITE = bindings::PERF_AUX_FLAG_OVERWRITE as _;
35
36 const PARTIAL = bindings::PERF_AUX_FLAG_PARTIAL as _;
38
39 const COLLISION = bindings::PERF_AUX_FLAG_COLLISION as _;
41
42 const PMU_FORMAT_MASK = bindings::PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK as _;
44 }
45}
46
47c_enum! {
48 #[derive(Copy, Clone, Eq, PartialEq, Hash)]
50 pub enum AuxPmuFormatType : u8 {
51 CORESIGHT = (bindings::PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT >> 8) as _,
52 CORESIGHT_RAW = (bindings::PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW >> 8) as _,
53 }
54
55 #[allow(missing_docs)]
56 impl {}
57}
58
59impl AuxPmuFormatType {
60 pub const fn new(value: u8) -> Self {
62 Self(value)
63 }
64}
65
66impl AuxFlags {
67 pub fn pmu_format_type(&self) -> AuxPmuFormatType {
69 AuxPmuFormatType(((*self & Self::PMU_FORMAT_MASK).bits() >> 8) as u8)
70 }
71}
72
73impl<'p> Parse<'p> for Aux {
74 fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
75 where
76 E: Endian,
77 B: ParseBuf<'p>,
78 {
79 Ok(Self {
80 aux_offset: p.parse()?,
81 aux_size: p.parse()?,
82 flags: p.parse()?,
83 })
84 }
85}
86
87impl<'p> Parse<'p> for AuxFlags {
88 fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
89 where
90 E: Endian,
91 B: ParseBuf<'p>,
92 {
93 p.parse().map(Self::from_bits_retain)
94 }
95}