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>
impl<R: Read> JitDumpReader<R>
Sourcepub fn new(reader: R) -> Result<Self, JitDumpError>
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
.
Sourcepub fn new_with_buffer_size(
reader: R,
buffer_size: usize,
) -> Result<Self, JitDumpError>
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.
Sourcepub fn header(&self) -> &JitDumpHeader
pub fn header(&self) -> &JitDumpHeader
The file header.
Sourcepub fn endian(&self) -> Endianness
pub fn endian(&self) -> Endianness
The file endian.
Sourcepub fn next_record_header(
&mut self,
) -> Result<Option<JitDumpRecordHeader>, Error>
pub fn next_record_header( &mut self, ) -> Result<Option<JitDumpRecordHeader>, Error>
Returns the header of the next record.
Sourcepub fn next_record_timestamp(&mut self) -> Result<Option<u64>, Error>
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
!
Sourcepub fn next_record_type(&mut self) -> Result<Option<JitDumpRecordType>, Error>
pub fn next_record_type(&mut self) -> Result<Option<JitDumpRecordType>, Error>
Returns the record type of the next record.
Sourcepub fn next_record_offset(&self) -> u64
pub fn next_record_offset(&self) -> u64
Returns the file offset at which the next record (specifically its record header) starts.
Sourcepub fn next_record(&mut self) -> Result<Option<JitDumpRawRecord<'_>>, Error>
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>
impl<R: Read + Seek> JitDumpReader<R>
Sourcepub fn skip_next_record(&mut self) -> Result<bool, Error>
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>
impl<R: Clone + Read> Clone for JitDumpReader<R>
Source§fn clone(&self) -> JitDumpReader<R>
fn clone(&self) -> JitDumpReader<R>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more