-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoverflow.rs
38 lines (34 loc) · 1.06 KB
/
overflow.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use libipt_sys::pt_event__bindgen_ty_1__bindgen_ty_7;
/// Trace overflow
#[derive(Clone, Copy, Debug)]
pub struct Overflow(pub(super) pt_event__bindgen_ty_1__bindgen_ty_7);
impl Overflow {
/// The address at which tracing resumes after overflow.
///
/// This field is not valid, if ip_suppressed is set.
/// In this case, the overflow resolved while tracing was disabled.
pub fn ip(self) -> u64 {
self.0.ip
}
}
#[cfg(test)]
mod test {
use super::super::Payload;
use super::*;
use crate::event::Event;
use libipt_sys::{pt_event, pt_event_type_ptev_overflow};
use std::mem;
#[test]
fn test_overflow_payload() {
let mut evt: pt_event = unsafe { mem::zeroed() };
evt.type_ = pt_event_type_ptev_overflow;
evt.variant.overflow = pt_event__bindgen_ty_1__bindgen_ty_7 { ip: 11 };
let payload: Payload = Event(evt).into();
match payload {
Payload::Overflow(e) => {
assert_eq!(e.ip(), 11);
}
_ => unreachable!("oof"),
}
}
}