Struct JitDumpReader

Source
pub struct JitDumpReader<R: Read> { /* private fields */ }
Expand description

Parses a jitdump file and allows iterating over records.

This reader works with complete jitdump files as well as with partial files which are still being written to. This makes it useful in live-profiling settings.

The records refer to memory owned by the reader, to minimize copies.

Implementations§

Source§

impl<R: Read> JitDumpReader<R>

Source

pub fn new(reader: R) -> Result<Self, JitDumpError>

Create a new JitDumpReader. JitDumpReader does its own buffering so there is no need to wrap a File into a BufReader.

Source

pub fn new_with_buffer_size( reader: R, buffer_size: usize, ) -> Result<Self, JitDumpError>

Create a new JitDumpReader, with a manually-specified buffer chunk size.

Source

pub fn header(&self) -> &JitDumpHeader

The file header.

Source

pub fn endian(&self) -> Endianness

The file endian.

Source

pub fn next_record_header( &mut self, ) -> Result<Option<JitDumpRecordHeader>, Error>

Returns the header of the next record.

Source

pub fn next_record_timestamp(&mut self) -> Result<Option<u64>, Error>

Returns the timestamp of the next record.

When operating on partial files, None means that not enough bytes for the header of the next record are available. Some means that we have enough bytes for the header but we may not have enough bytes to get the entire record.

If next_record_timestamp returns Ok(Some(...)), the next call to next_record() can still return None!

Source

pub fn next_record_type(&mut self) -> Result<Option<JitDumpRecordType>, Error>

Returns the record type of the next record.

Source

pub fn next_record_offset(&self) -> u64

Returns the file offset at which the next record (specifically its record header) starts.

Source

pub fn next_record(&mut self) -> Result<Option<JitDumpRawRecord<'_>>, Error>

Returns the next record.

When operating on partial files, this will return Ok(None) if the entire record is not available yet. Future calls to next_record may return Ok(Some) if the data has become available in the meantime, because they will call read on R again.

Source§

impl<R: Read + Seek> JitDumpReader<R>

Source

pub fn skip_next_record(&mut self) -> Result<bool, Error>

Skip the upcoming record. If this returns true, the record has been skipped. If false is returned, it means the file could not be seeked far enough to skip the entire record (for example because this is a partial file which has not been fully written), and the next record remains unchanged from before the call to skip_next_record.

You may want to call this if you’ve called next_record_type and have determined that you’re not interested in the upcoming record. It saves having to read the full record into a contiguous slice of memory.

Trait Implementations§

Source§

impl<R: Clone + Read> Clone for JitDumpReader<R>

Source§

fn clone(&self) -> JitDumpReader<R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Debug + Read> Debug for JitDumpReader<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for JitDumpReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for JitDumpReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for JitDumpReader<R>
where R: Send,

§

impl<R> Sync for JitDumpReader<R>
where R: Sync,

§

impl<R> Unpin for JitDumpReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for JitDumpReader<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.