DynamoRIO
dynamorio::drmemtrace::record_reader_t Class Referenceabstract

#include <record_file_reader.h>

Inheritance diagram for dynamorio::drmemtrace::record_reader_t:
memtrace_stream_t dynamorio::drmemtrace::record_file_reader_t< T >

Public Member Functions

uint64_t get_record_ordinal () const override
 
uint64_t get_instruction_ordinal () const override
 
uint64_t get_last_timestamp () const override
 
uint64_t get_first_timestamp () const override
 
uint64_t get_version () const override
 
uint64_t get_filetype () const override
 
uint64_t get_cache_line_size () const override
 
uint64_t get_chunk_instr_count () const override
 
uint64_t get_page_size () const override
 
- Public Member Functions inherited from memtrace_stream_t
virtual ~memtrace_stream_t ()
 
virtual std::string get_stream_name () const =0
 
virtual bool is_record_synthetic () const
 

Detailed Description

Trace reader that provides the stream of trace_entry_t exactly as present in an offline trace stored on disk. The public API is similar to reader_t, except that it is an iterator over trace_entry_t entries instead of memref_t. This does not yet support iteration over a serialized stream of multiple traces.

TODO i#5727: Convert reader_t and file_reader_t into templates: reader_tmpl_t<RecordType> and file_reader_tmpl_t<T, RecordType> where T is one of gzip_reader_t, zipfile_reader_t, snappy_reader_t, std::ifstream*, and RecordType is one of memref_t, trace_entry_t. Then, typedef the trace_entry_t specializations as record_reader_t and record_file_reader_t<T> respectively. This will allow significant code reuse, particularly for serializing multiple thread traces into a single stream.

Since the current file_reader_t is already a template on T, adding the second template parameter RecordType is complex. Note that we cannot have partial specialization of member functions in C++. This complicates implementation of various file_reader_tmpl_t<T, RecordType> specializations for T, as we would need to duplicate the implementation for each candidate of RecordType.

We have two options:

  1. For each member function specialized for some T, duplicate the definition for file_reader_tmpl_t<T, memref_t> and file_reader_tmpl_t<T, trace_entry_t>. This has the obvious disadvantage of code duplication, which can be mitigated to some extent by extracting common logic in static routines.
  2. For each specialization of T, create a subclass templatized on RecordType that inherits from file_reader_tmpl_t<_, RecordType>. E.g. for T = gzip_reader_t, create class gzip_file_reader_t<RecordType>: public file_reader_tmpl_t<gzip_reader_t, RecordType> This has the disadvantage of breaking backward-compatibility of the existing reader interface. Users that define their own readers outside DR will need to adapt to this change. The advantage of this approach is that it is somewhat cleaner to have proper classes instead of template specializations for file readers.

We prefer Option 2, since it has higher merit.

Currently we do not have any use-case that needs this design, but when we need to support serial iteration over trace_entry_t, we would want to do this to reuse the existing multiple trace serialization code in file_reader_t. file_reader_t hides some trace_entry_t entries today (like TRACE_TYPE_THREAD, TRACE_TYPE_PID, etc); we would also need to avoid doing that since record_reader_t is expected to provide the exact stream of trace_entry_t as stored on disk.

Member Function Documentation

◆ get_cache_line_size()

uint64_t dynamorio::drmemtrace::record_reader_t::get_cache_line_size ( ) const
inlineoverridevirtual

Returns the cache line size from the TRACE_MARKER_TYPE_CACHE_LINE_SIZE record in the trace header.

Implements memtrace_stream_t.

◆ get_chunk_instr_count()

uint64_t dynamorio::drmemtrace::record_reader_t::get_chunk_instr_count ( ) const
inlineoverridevirtual

Returns the chunk instruction count from the TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT record in the trace header.

Implements memtrace_stream_t.

◆ get_filetype()

uint64_t dynamorio::drmemtrace::record_reader_t::get_filetype ( ) const
inlineoverridevirtual

Returns the OFFLINE_FILE_TYPE_* bitfields of type offline_file_type_t identifying the architecture and other key high-level attributes of the trace from the TRACE_MARKER_TYPE_FILETYPE record in the trace header.

Implements memtrace_stream_t.

◆ get_first_timestamp()

uint64_t dynamorio::drmemtrace::record_reader_t::get_first_timestamp ( ) const
inlineoverridevirtual

Returns the value of the first seen TRACE_MARKER_TYPE_TIMESTAMP marker.

Implements memtrace_stream_t.

◆ get_instruction_ordinal()

uint64_t dynamorio::drmemtrace::record_reader_t::get_instruction_ordinal ( ) const
inlineoverridevirtual

Returns the count of instructions from the start of the trace to this point. This includes instructions skipped over and not presented to any tool.

Implements memtrace_stream_t.

◆ get_last_timestamp()

uint64_t dynamorio::drmemtrace::record_reader_t::get_last_timestamp ( ) const
inlineoverridevirtual

Returns the value of the most recently seen TRACE_MARKER_TYPE_TIMESTAMP marker.

Implements memtrace_stream_t.

◆ get_page_size()

uint64_t dynamorio::drmemtrace::record_reader_t::get_page_size ( ) const
inlineoverridevirtual

Returns the page size from the TRACE_MARKER_TYPE_PAGE_SIZE record in the trace header.

Implements memtrace_stream_t.

◆ get_record_ordinal()

uint64_t dynamorio::drmemtrace::record_reader_t::get_record_ordinal ( ) const
inlineoverridevirtual

Returns the count of memref_t records from the start of the trace to this point. This includes records skipped over and not presented to any tool. It does not include synthetic records (see is_record_synthetic()).

Implements memtrace_stream_t.

◆ get_version()

uint64_t dynamorio::drmemtrace::record_reader_t::get_version ( ) const
inlineoverridevirtual

Returns the trace_version_t value from the TRACE_MARKER_TYPE_VERSION record in the trace header.

Implements memtrace_stream_t.


The documentation for this class was generated from the following file:
  • /home/runner/work/dynamorio/dynamorio/build_release-64/clients/include/drmemtrace/record_file_reader.h