From 0bf3cd8b28c171db3691dd8c398559fd69318db0 Mon Sep 17 00:00:00 2001 From: Abhinav Anil Sharma Date: Wed, 3 Apr 2024 10:50:44 -0400 Subject: [PATCH] Move func to conditional compiled block --- .../drcachesim/tests/burst_syscall_inject.cpp | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/clients/drcachesim/tests/burst_syscall_inject.cpp b/clients/drcachesim/tests/burst_syscall_inject.cpp index 43962982d87..c37816a25c2 100644 --- a/clients/drcachesim/tests/burst_syscall_inject.cpp +++ b/clients/drcachesim/tests/burst_syscall_inject.cpp @@ -145,43 +145,6 @@ write_footer_entries(std::unique_ptr &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(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(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) { @@ -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(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(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) {