Support pid filtering in debugfs

pull/108/head
Dan Everton 3 years ago
parent 1dc75542b4
commit 606c3267c4
No known key found for this signature in database
GPG Key ID: 2AF33A2B189A11B3

@ -151,9 +151,8 @@ fn create_as_trace_point(
),
};
// TODO: pid and cpu handling
let tpid = read_sys_fs_trace_point_id(event_type, &event_alias)?;
let fd = perf_event_open_trace_point(tpid).map_err(|(_code, io_error)| {
let fd = perf_event_open_trace_point(tpid, pid).map_err(|(_code, io_error)| {
ProgramError::SyscallError {
call: "perf_event_open".to_owned(),
io_error,

@ -69,7 +69,7 @@ impl TracePoint {
/// `/sys/kernel/debug/tracing/events`.
pub fn attach(&mut self, category: &str, name: &str) -> Result<LinkRef, ProgramError> {
let id = read_sys_fs_trace_point_id(category, name)?;
let fd = perf_event_open_trace_point(id).map_err(|(_code, io_error)| {
let fd = perf_event_open_trace_point(id, None).map_err(|(_code, io_error)| {
ProgramError::SyscallError {
call: "perf_event_open".to_owned(),
io_error,

@ -93,17 +93,20 @@ pub(crate) fn perf_event_open_probe(
})
}
pub(crate) fn perf_event_open_trace_point(id: u32) -> SysResult {
pub(crate) fn perf_event_open_trace_point(id: u32, pid: Option<pid_t>) -> SysResult {
let mut attr = unsafe { mem::zeroed::<perf_event_attr>() };
attr.size = mem::size_of::<perf_event_attr>() as u32;
attr.type_ = PERF_TYPE_TRACEPOINT as u32;
attr.config = id as u64;
let cpu = if pid.is_some() { -1 } else { 0 };
let pid = pid.unwrap_or(-1);
syscall(Syscall::PerfEventOpen {
attr,
pid: -1,
cpu: 0,
pid,
cpu,
group: -1,
flags: PERF_FLAG_FD_CLOEXEC,
})

Loading…
Cancel
Save