Skip to content

Commit

Permalink
i#3129 raw2trace perf: factored trace_converter_t out of raw2trace_t (#…
Browse files Browse the repository at this point in the history
…3149)

Introducing trace_converter_t, a template factoring out of raw2trace_t the functionality necessary for building custom trace converters.

Issue #3129
  • Loading branch information
mtrofin authored Aug 28, 2018
1 parent 35e0316 commit 1965352
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 166 deletions.
1 change: 1 addition & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ Further non-compatibility-affecting changes include:
#raw2trace_t for writing trace metadata: process/thread ids, timestamps, etc.
- Added #trace_metadata_reader_t, a set of utilities for checking and validating
thread start successions of offline entries in a raw data file.
- Added #trace_converter_t, an extensibility mechanism for raw trace conversion.
- Added drmemtrace_get_timestamp_from_offline_trace(), an API for fetching the timestamp
from the beginning of a raw trace bundle (regardless of whether it is a thread start
or just a subsequent bundle).
Expand Down
15 changes: 4 additions & 11 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ const char *(*module_mapper_t::user_parse)(const char *src, OUT void **data) = n
void (*module_mapper_t::user_free)(void *data) = nullptr;
bool module_mapper_t::has_custom_data_global = true;

const char *raw2trace_t::FAULT_INTERRUPTED_BB = "INTERRUPTED";
const thread_id_t raw2trace_t::INVALID_THREAD_ID = 0;

module_mapper_t::module_mapper_t(
const char *module_map_in, const char *(*parse_cb)(const char *src, OUT void **data),
std::string (*process_cb)(drmodtrack_info_t *info, void *data, void *user_data),
Expand Down Expand Up @@ -299,7 +296,7 @@ raw2trace_t::read_and_map_modules()
return err;
}

modvec_ptr = &module_mapper->get_loaded_modules();
set_modvec(&module_mapper->get_loaded_modules());
return module_mapper->get_last_error();
}

Expand Down Expand Up @@ -543,7 +540,7 @@ raw2trace_t::merge_and_process_thread_files()
buf += trace_metadata_writer_t::write_timestamp(buf, (uintptr_t)times[tidx]);
// We have to write this now before we append any bb entries.
size = buf - buf_base;
CHECK((uint)size < MAX_COMBINED_ENTRIES, "Too many entries");
CHECK((uint)size < WRITE_BUFFER_SIZE, "Too many entries");
if (!out_file->write((char *)buf_base, size))
return "Failed to write to output file";
buf = buf_base;
Expand Down Expand Up @@ -780,19 +777,15 @@ raw2trace_t::raw2trace_t(const char *module_map_in,
const std::vector<std::istream *> &thread_files_in,
std::ostream *out_file_in, void *dcontext_in,
unsigned int verbosity_in)
: modmap(module_map_in)
, modvec_ptr(nullptr)
: trace_converter_t(dcontext_in)
, modmap(module_map_in)
, thread_files(thread_files_in)
, out_file(out_file_in)
, dcontext(dcontext_in)
, prev_instr_was_rep_string(false)
, instrs_are_separate(false)
, verbosity(verbosity_in)
, user_process(nullptr)
, user_process_data(nullptr)
{
if (dcontext == NULL) {
dcontext = dr_standalone_init();
#ifdef ARM
// We keep the mode at ARM and rely on LSB=1 offsets in the modoffs fields
// to trigger Thumb decoding.
Expand Down
Loading

0 comments on commit 1965352

Please sign in to comment.