forked from OptimatistOpenSource/perf-event-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
222 additions
and
307 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::{io, result}; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error("PID is invalid: {0}")] | ||
InvalidPid(u32), | ||
#[error("Measures any process on any cpu is invalid")] | ||
InvalidProcessCpu, | ||
#[error("Failed to perform perf_event_open: {0}")] | ||
SyscallFailed(io::Error), | ||
} | ||
|
||
pub type Result<T> = result::Result<T, Error>; | ||
|
||
pub enum Process { | ||
Any, // -1 | ||
Calling, // 0 | ||
Specified(u32), | ||
} | ||
|
||
impl Process { | ||
pub(crate) const fn as_i32(&self) -> Result<i32> { | ||
match self { | ||
Self::Any => Ok(-1), | ||
Self::Calling => Ok(0), | ||
Self::Specified(0) => Err(Error::InvalidPid(0)), | ||
Self::Specified(n) => Ok(*n as _), | ||
} | ||
} | ||
} | ||
|
||
pub enum Cpu { | ||
Any, // -1 | ||
Specified(u32), | ||
} | ||
|
||
impl Cpu { | ||
pub(crate) const fn as_i32(&self) -> i32 { | ||
match self { | ||
Self::Any => -1, | ||
Self::Specified(n) => *n as _, | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
mod builder; | ||
pub mod counting; | ||
pub mod event; | ||
pub mod sampling; | ||
pub mod tracing; | ||
pub mod config; | ||
|
||
use crate::syscall::bindings::perf_event_attr; | ||
pub use builder::*; | ||
pub use event::*; | ||
|
||
type RawAttr = perf_event_attr; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.