Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#6822 unscheduled: Add raw2trace per-record action point #6855

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3432,6 +3432,13 @@ raw2trace_t::insert_post_chunk_encodings(raw2trace_thread_data_t *tdata,
return true;
}

void
raw2trace_t::observe_entry_output(raw2trace_thread_data_t *tls,
const trace_entry_t *entry)
{
// Nothing to do for us: this is for subclasses.
}

// All writes to out_file go through this function, except new chunk headers
// and footers (to do so would cause recursion; we assume those do not need
// extra processing here).
Expand Down Expand Up @@ -3461,6 +3468,7 @@ raw2trace_t::write(raw2trace_thread_data_t *tdata, const trace_entry_t *start,
bool prev_was_encoding = false;
int instr_ordinal = -1;
for (const trace_entry_t *it = start; it < end; ++it) {
observe_entry_output(tdata, it);
tdata->cur_chunk_ref_count += tdata->memref_counter.entry_memref_count(it);
// We wait until we're past the final instr to write, to ensure we
// get all its memrefs, by not stopping until we hit an instr or an
Expand Down Expand Up @@ -3585,6 +3593,7 @@ raw2trace_t::write(raw2trace_thread_data_t *tdata, const trace_entry_t *start,
}
} else {
for (const trace_entry_t *it = start; it < end; ++it) {
observe_entry_output(tdata, it);
if (type_is_instr(static_cast<trace_type_t>(it->type))) {
accumulate_to_statistic(tdata,
RAW2TRACE_STAT_FINAL_TRACE_INSTRUCTION_COUNT, 1);
Expand Down
9 changes: 9 additions & 0 deletions clients/drcachesim/tracer/raw2trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,15 @@ class raw2trace_t {
DR_PARAM_OUT bool *last_bb_handled,
DR_PARAM_OUT bool *flush_decode_cache);

/**
* Called for each record in an output buffer prior to writing out the buffer.
* The entry cannot be modified. A subclass can override this to compute
* per-shard statistics which can then be used for a variety of tasks including
* late removal of shards for targeted filtering.
*/
virtual void
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
observe_entry_output(raw2trace_thread_data_t *tls, const trace_entry_t *entry);

/**
* Performs processing actions for the marker "marker_type" with value
* "marker_val", including writing out a marker record. Further records can also
Expand Down
Loading