Skip to content

Commit 0507050

Browse files
committed
aya: use Pid for uprobe scope
Update UProbeScope::OneProcess to take Pid instead of exposing NonZeroU32 directly. This keeps the uprobe process scope API aligned with PerfEventScope while preserving the non-zero PID invariant. Update the uprobe scope integration test and public API fixture.
1 parent 03c1090 commit 0507050

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

aya/src/programs/uprobe.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::{
66
fmt::{self, Write},
77
fs,
88
io::{self, BufRead as _, Cursor, Read as _},
9-
num::NonZeroU32,
109
os::unix::ffi::{OsStrExt as _, OsStringExt as _},
1110
path::{Path, PathBuf},
1211
sync::LazyLock,
@@ -19,7 +18,7 @@ use thiserror::Error;
1918
use crate::{
2019
VerifierLogLevel,
2120
programs::{
22-
ProgramData, ProgramError, ProgramType, define_link_wrapper, impl_try_from_fdlink,
21+
Pid, ProgramData, ProgramError, ProgramType, define_link_wrapper, impl_try_from_fdlink,
2322
impl_try_into_fdlink, load_program_without_attach_type,
2423
perf_attach::{PerfLinkIdInner, PerfLinkInner},
2524
probe::{OsStringExt as _, Probe, ProbeKind, attach},
@@ -97,7 +96,7 @@ pub enum UProbeScope {
9796
/// Fire only when the calling process/thread hits the attach point.
9897
CallingProcess,
9998
/// Fire only when the given process hits the attach point.
100-
OneProcess(NonZeroU32),
99+
OneProcess(Pid),
101100
}
102101

103102
impl UProbe {

test/integration-test/src/tests/load.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
use std::{
2-
convert::TryInto as _, fs::remove_file, num::NonZeroU32, path::Path, thread, time::Duration,
3-
};
1+
use std::{convert::TryInto as _, fs::remove_file, path::Path, thread, time::Duration};
42

53
use assert_matches::assert_matches;
64
use aya::{
75
Ebpf,
86
maps::{Array, RingBuf},
97
pin::PinError,
108
programs::{
11-
FlowDissector, KProbe, LinkOrder, ProbeKind, Program, ProgramError, SchedClassifier,
9+
FlowDissector, KProbe, LinkOrder, Pid, ProbeKind, Program, ProgramError, SchedClassifier,
1210
TcAttachType, TracePoint, UProbe, Xdp, XdpFlags,
1311
flow_dissector::{FlowDissectorLink, FlowDissectorLinkId},
1412
kprobe::{KProbeLink, KProbeLinkId},
@@ -370,7 +368,7 @@ fn basic_tracepoint() {
370368
#[test_case(UProbeScope::AllProcesses; "all_processes")]
371369
#[test_case(UProbeScope::CallingProcess; "calling_process")]
372370
#[test_case(
373-
UProbeScope::OneProcess(NonZeroU32::new(std::process::id()).unwrap());
371+
UProbeScope::OneProcess(Pid::current());
374372
"one_process"
375373
)]
376374
#[test_log::test]

xtask/public-api/aya.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4769,7 +4769,7 @@ impl !core::panic::unwind_safe::UnwindSafe for aya::programs::uprobe::UProbeErro
47694769
pub enum aya::programs::uprobe::UProbeScope
47704770
pub aya::programs::uprobe::UProbeScope::AllProcesses
47714771
pub aya::programs::uprobe::UProbeScope::CallingProcess
4772-
pub aya::programs::uprobe::UProbeScope::OneProcess(core::num::nonzero::NonZeroU32)
4772+
pub aya::programs::uprobe::UProbeScope::OneProcess(aya::programs::Pid)
47734773
impl core::clone::Clone for aya::programs::uprobe::UProbeScope
47744774
pub fn aya::programs::uprobe::UProbeScope::clone(&self) -> aya::programs::uprobe::UProbeScope
47754775
impl core::fmt::Debug for aya::programs::uprobe::UProbeScope

0 commit comments

Comments
 (0)