Skip to content

Commit

Permalink
Move func to conditional compiled block
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Apr 3, 2024
1 parent fd8f06e commit 0bf3cd8
Showing 1 changed file with 38 additions and 37 deletions.
75 changes: 38 additions & 37 deletions clients/drcachesim/tests/burst_syscall_inject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,43 +145,6 @@ write_footer_entries(std::unique_ptr<std::ostream> &writer)
write_trace_entry(writer, make_footer());
}

static std::string
write_system_call_template_with_repstr(void *dr_context)
{
// Get path to write the template and an ostream to it.
const char *raw_dir;
drmemtrace_status_t mem_res = drmemtrace_get_output_path(&raw_dir);
assert(mem_res == DRMEMTRACE_SUCCESS);
std::string syscall_trace_template_file =
std::string(raw_dir) + DIRSEP + "syscall_trace_template_repstr";
auto writer =
std::unique_ptr<std::ostream>(new std::ofstream(syscall_trace_template_file));

write_header_entries(writer);

write_trace_entry(writer,
make_marker(TRACE_MARKER_TYPE_SYSCALL_TRACE_START, SYS_gettid));
instr_t *rep_movs = INSTR_CREATE_rep_movs_1(GLOBAL_DCONTEXT);
for (int i = 0; i < REP_MOVS_COUNT; ++i) {
write_instr_entry(dr_context, writer, rep_movs,
reinterpret_cast<app_pc>(PC_SYSCALL_GETTID),
i == 0 ? TRACE_TYPE_INSTR : TRACE_TYPE_INSTR_NO_FETCH);
write_trace_entry(writer,
make_memref(READ_MEMADDR_GETTID, TRACE_TYPE_READ,
opnd_size_in_bytes(OPSZ_PTR)));
write_trace_entry(writer,
make_memref(READ_MEMADDR_GETTID, TRACE_TYPE_WRITE,
opnd_size_in_bytes(OPSZ_PTR)));
}
instr_destroy(dr_context, rep_movs);
write_trace_entry(writer,
make_marker(TRACE_MARKER_TYPE_SYSCALL_TRACE_END, SYS_getpid));

write_footer_entries(writer);

return syscall_trace_template_file;
}

static std::string
write_system_call_template(void *dr_context)
{
Expand Down Expand Up @@ -451,6 +414,44 @@ look_for_syscall_trace(void *dr_context, std::string trace_dir)
}

#ifdef X86

static std::string
write_system_call_template_with_repstr(void *dr_context)
{
// Get path to write the template and an ostream to it.
const char *raw_dir;
drmemtrace_status_t mem_res = drmemtrace_get_output_path(&raw_dir);
assert(mem_res == DRMEMTRACE_SUCCESS);
std::string syscall_trace_template_file =
std::string(raw_dir) + DIRSEP + "syscall_trace_template_repstr";
auto writer =
std::unique_ptr<std::ostream>(new std::ofstream(syscall_trace_template_file));

write_header_entries(writer);

write_trace_entry(writer,
make_marker(TRACE_MARKER_TYPE_SYSCALL_TRACE_START, SYS_gettid));
instr_t *rep_movs = INSTR_CREATE_rep_movs_1(GLOBAL_DCONTEXT);
for (int i = 0; i < REP_MOVS_COUNT; ++i) {
write_instr_entry(dr_context, writer, rep_movs,
reinterpret_cast<app_pc>(PC_SYSCALL_GETTID),
i == 0 ? TRACE_TYPE_INSTR : TRACE_TYPE_INSTR_NO_FETCH);
write_trace_entry(writer,
make_memref(READ_MEMADDR_GETTID, TRACE_TYPE_READ,
opnd_size_in_bytes(OPSZ_PTR)));
write_trace_entry(writer,
make_memref(READ_MEMADDR_GETTID, TRACE_TYPE_WRITE,
opnd_size_in_bytes(OPSZ_PTR)));
}
instr_destroy(dr_context, rep_movs);
write_trace_entry(writer,
make_marker(TRACE_MARKER_TYPE_SYSCALL_TRACE_END, SYS_getpid));

write_footer_entries(writer);

return syscall_trace_template_file;
}

int
test_template_with_repstr(void *dr_context)
{
Expand Down

0 comments on commit 0bf3cd8

Please sign in to comment.