Skip to content

Commit

Permalink
i#7113 instr decode cache: move module mapper into raw2trace_shared (#…
Browse files Browse the repository at this point in the history
…7123)

Moves the module mapper and related functionality into raw2trace_shared.

This is in preparation for further changes that include the module
mapper logic in a new library (drmemtrace_instr_decode_cache) that
provides an instr decode cache (instr_decode_cache_t). To avoid having
to pull in the whole drmemtrace_raw2trace implementation into
drmemtrace_instr_decode_cache, which will end up including it in the
invariant checker and everything that depends on, we separate out the
module mapper into raw2trace_shared which is intended for such cases.

This is a pure code move, no changes were made to logic or style.

Issue: #7113
  • Loading branch information
abhinav92003 authored Dec 12, 2024
1 parent 0f97bc5 commit aa4d950
Show file tree
Hide file tree
Showing 6 changed files with 775 additions and 747 deletions.
9 changes: 1 addition & 8 deletions clients/drcachesim/tracer/instru.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@
#include "dr_allocator.h"
#include "dr_api.h"
#include "drvector.h"
#include "raw2trace_shared.h"
#include "trace_entry.h"

namespace dynamorio {
namespace drmemtrace {

#define MINSERT instrlist_meta_preinsert

// Versioning for our drmodtrack custom module fields.
#define CUSTOM_MODULE_VERSION 1

// A std::unordered_set, even using dr_allocator_t, raises transparency risks when
// statically linked on Windows (from lock functions and other non-allocator
// resources). We thus create our own resource-isolated class to track GPR register
Expand Down Expand Up @@ -499,11 +497,6 @@ class offline_instru_t : public instru_t {
label_marks_elidable(instr_t *instr, DR_PARAM_OUT int *opnd_index,
DR_PARAM_OUT int *memopnd_index, DR_PARAM_OUT bool *is_write,
DR_PARAM_OUT bool *needs_base);
static int
print_module_data_fields(char *dst, size_t max_len, const void *custom_data,
size_t custom_size,
int (*user_print_cb)(void *data, char *dst, size_t max_len),
void *user_cb_data);

private:
struct custom_module_data_t {
Expand Down
26 changes: 1 addition & 25 deletions clients/drcachesim/tracer/instru_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "drreg.h"
#include "drutil.h"
#include "drvector.h"
#include "raw2trace_shared.h"
#include "trace_entry.h"
#include "utils.h"
#include "instru.h"
Expand Down Expand Up @@ -186,31 +187,6 @@ offline_instru_t::load_custom_module_data(module_data_t *module, int seg_idx)
return nullptr;
}

int
offline_instru_t::print_module_data_fields(
char *dst, size_t max_len, const void *custom_data, size_t custom_size,
int (*user_print_cb)(void *data, char *dst, size_t max_len), void *user_cb_data)
{
char *cur = dst;
int len = dr_snprintf(dst, max_len, "v#%d,%zu,", CUSTOM_MODULE_VERSION, custom_size);
if (len < 0)
return -1;
cur += len;
if (cur - dst + custom_size > max_len)
return -1;
if (custom_size > 0) {
memcpy(cur, custom_data, custom_size);
cur += custom_size;
}
if (user_print_cb != nullptr) {
int res = (*user_print_cb)(user_cb_data, cur, max_len - (cur - dst));
if (res == -1)
return -1;
cur += res;
}
return (int)(cur - dst);
}

int
offline_instru_t::print_custom_module_data(void *data, char *dst, size_t max_len)
{
Expand Down
Loading

0 comments on commit aa4d950

Please sign in to comment.