Struct linux_perf_data::PerfFileReader
source · [−]pub struct PerfFileReader<'a, R: Read> { /* private fields */ }Implementations
sourceimpl<'a, C: Read + Seek> PerfFileReader<'a, C>
impl<'a, C: Read + Seek> PerfFileReader<'a, C>
pub fn parse_file(cursor: &'a mut C) -> Result<Self, Error>
sourceimpl<'a, R: Read> PerfFileReader<'a, R>
impl<'a, R: Read> PerfFileReader<'a, R>
pub fn endian(&self) -> Endianness
pub fn has_feature(&self, feature: FlagFeature) -> bool
pub fn feature_section(&self, feature: FlagFeature) -> Option<&[u8]>
sourcepub fn build_ids(&self) -> Result<HashMap<DsoKey, DsoBuildId>, Error>
pub fn build_ids(&self) -> Result<HashMap<DsoKey, DsoBuildId>, Error>
Returns a map of build ID entries. perf record creates these records for any DSOs
which it thinks have been “hit” in the profile. They supplement Mmap events
the perf event stream; those usually don’t come with build IDs.
This method returns a HashMap so that you can easily look up the right build ID from the DsoKey in an Mmap event. For some DSOs, the path in the raw Mmap event can be different from the path in the build ID record; for example, the Mmap event for the kernel (“vmlinux”) image could have the path “[kernel.kallsyms]_text”, whereas the corresponding build ID record might have the path “[kernel.kallsyms]” (without the trailing “_text”), or it could even have the full absolute path to a vmlinux file. The DsoKey canonicalizes those differences away.
Having the build ID for a DSO allows you to do the following:
- If the DSO file has changed in the time since the perf.data file was captured, you can detect this change because the new file will have a different build ID.
- If debug symbols are installed for the DSO, you can sometimes find the debug symbol file using the build ID. For example, you might find it at /usr/lib/debug/.build-id/b8/037b6260865346802321dd2256b8ad1d857e63.debug
- If the original DSO file is gone, or you’re trying to read the perf.data file on an entirely different machine, you can sometimes retrieve the original DSO file just from its build ID, for example from a debuginfod server.
- This also works for DSOs which are not present on the file system at all; specifically, the vDSO file is a bit of a pain to obtain. With the build ID you can instead obtain it from, say, https://debuginfod.elfutils.org/buildid/0d82ee4bd7f9609c367095ba0bedf155b71cb058/executable
This method is a bit lossy. We discard the pid, because it seems to be always -1 in
the files I’ve tested. We also discard any entries for which we fail to create a DsoKey.
pub fn hostname(&self) -> Result<Option<&str>, Error>
pub fn os_release(&self) -> Result<Option<&str>, Error>
pub fn perf_version(&self) -> Result<Option<&str>, Error>
pub fn arch(&self) -> Result<Option<&str>, Error>
pub fn nr_cpus(&self) -> Result<Option<NrCpus>, Error>
pub fn is_stats(&self) -> bool
sourcepub fn next_record(&mut self) -> Result<Option<ParsedRecord<'_>>, Error>
pub fn next_record(&mut self) -> Result<Option<ParsedRecord<'_>>, Error>
Emits records in the correct order (sorted by time).
It buffers records until it sees a FINISHED_ROUND record; then it sorts the buffered records and emits them one by one.
Auto Trait Implementations
impl<'a, R> RefUnwindSafe for PerfFileReader<'a, R> where
R: RefUnwindSafe,
impl<'a, R> Send for PerfFileReader<'a, R> where
R: Send,
impl<'a, R> Sync for PerfFileReader<'a, R> where
R: Sync,
impl<'a, R> Unpin for PerfFileReader<'a, R>
impl<'a, R> !UnwindSafe for PerfFileReader<'a, R>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more