aya: Make probe event_alias unique

This fixes issues when trying to attach the same kernel function multiple times on 4.17 and lower (possibly upper too?)
pull/618/head
Mary 1 year ago
parent 3f1a469f06
commit e9be3d9023

@ -4,6 +4,7 @@ use std::{
io::{self, Write},
path::Path,
process,
sync::atomic::{AtomicUsize, Ordering},
};
use crate::{
@ -15,6 +16,8 @@ use crate::{
sys::{kernel_version, perf_event_open_probe, perf_event_open_trace_point},
};
static PROBE_NAME_INDEX: AtomicUsize = AtomicUsize::new(0);
/// Kind of probe program
#[derive(Debug, Copy, Clone)]
pub enum ProbeKind {
@ -158,11 +161,12 @@ fn create_probe_event(
KRetProbe | URetProbe => 'r',
};
let event_alias = format!(
"aya_{}_{}_{}_{:#x}",
"aya_{}_{}_{}_{:#x}_{}",
process::id(),
probe_type_prefix,
fn_name,
offset
offset,
PROBE_NAME_INDEX.fetch_add(1, Ordering::SeqCst)
);
let offset_suffix = match kind {
KProbe => format!("+{offset}"),

Loading…
Cancel
Save