diff --git a/clients/drcachesim/CMakeLists.txt b/clients/drcachesim/CMakeLists.txt index a3aaa460f9c..ac0cec3b1b5 100644 --- a/clients/drcachesim/CMakeLists.txt +++ b/clients/drcachesim/CMakeLists.txt @@ -1021,16 +1021,13 @@ if (BUILD_TESTS) use_DynamoRIO_static_client(tool.drcacheoff.burst_maps drmemtrace_static) target_link_libraries(tool.drcacheoff.burst_maps test_helpers) add_win32_flags(tool.drcacheoff.burst_maps) - + endif () + if (UNIX) add_executable(tool.drcacheoff.burst_syscall_inject tests/burst_syscall_inject.cpp) configure_DynamoRIO_static(tool.drcacheoff.burst_syscall_inject) use_DynamoRIO_static_client(tool.drcacheoff.burst_syscall_inject drmemtrace_static) target_link_libraries(tool.drcacheoff.burst_syscall_inject drmemtrace_raw2trace drmemtrace_analyzer test_helpers drmemtrace_basic_counts) - if (WIN32) - # Just like for burst_replace + burst_futex, linking together takes effort. - target_link_libraries(tool.drcacheoff.burst_syscall_inject ${static_libc}) - endif () add_win32_flags(tool.drcacheoff.burst_syscall_inject) use_DynamoRIO_drmemtrace_tracer(tool.drcacheoff.burst_syscall_inject) endif () diff --git a/clients/drcachesim/tests/burst_syscall_inject.cpp b/clients/drcachesim/tests/burst_syscall_inject.cpp index 365f07f1608..5ab801ffbae 100644 --- a/clients/drcachesim/tests/burst_syscall_inject.cpp +++ b/clients/drcachesim/tests/burst_syscall_inject.cpp @@ -136,6 +136,7 @@ write_system_call_template(void *dr_context) instr_t *getpid_instr = XINST_CREATE_nop(dr_context); write_instr_entry(dr_context, writer, getpid_instr, reinterpret_cast(PC_SYSCALL_GETPID)); + instr_destroy(dr_context, getpid_instr); // Write the trace template for SYS_gettid. trace_entry_t gettid_marker = { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_SYSCALL, @@ -144,6 +145,7 @@ write_system_call_template(void *dr_context) instr_t *gettid_instr = XINST_CREATE_return(dr_context); write_instr_entry(dr_context, writer, gettid_instr, reinterpret_cast(PC_SYSCALL_GETTID)); + instr_destroy(dr_context, gettid_instr); trace_entry_t footer = { TRACE_TYPE_THREAD_EXIT, 0, { 1 } }; write_trace_entry(writer, footer); @@ -228,7 +230,8 @@ look_for_syscall_trace(void *dr_context, std::string trace_dir) sched_inputs.emplace_back(trace_dir); if (scheduler.init(sched_inputs, 1, scheduler_t::make_scheduler_serial_options()) != scheduler_t::STATUS_SUCCESS) { - FATAL_ERROR("Failed to initialize scheduler: %s\n", scheduler.get_error_string()); + FATAL_ERROR("Failed to initialize scheduler: %s\n", + scheduler.get_error_string().c_str()); } auto *stream = scheduler.get_stream(0); memref_t memref; diff --git a/clients/drcachesim/tracer/raw2trace.cpp b/clients/drcachesim/tracer/raw2trace.cpp index 471ef459e01..eb99d1fbcf7 100644 --- a/clients/drcachesim/tracer/raw2trace.cpp +++ b/clients/drcachesim/tracer/raw2trace.cpp @@ -598,7 +598,7 @@ raw2trace_t::write_syscall_template(raw2trace_thread_data_t *tdata, int syscall_ trace_entry_t *buf = buf_base; trace_entry_t start_entry = { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_SYSCALL_TRACE_START, - static_cast(syscall_num) }; + { static_cast(syscall_num) } }; *buf = start_entry; ++buf; if (!write(tdata, buf_base, buf)) { @@ -641,8 +641,9 @@ raw2trace_t::write_syscall_template(raw2trace_thread_data_t *tdata, int syscall_ } buf = buf_base; } - trace_entry_t end_entry = { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_SYSCALL_TRACE_END, - static_cast(syscall_num) }; + trace_entry_t end_entry = { TRACE_TYPE_MARKER, + TRACE_MARKER_TYPE_SYSCALL_TRACE_END, + { static_cast(syscall_num) } }; *buf = end_entry; ++buf; if (!write(tdata, buf_base, buf)) { @@ -728,7 +729,7 @@ raw2trace_t::process_offline_entry(raw2trace_thread_data_t *tdata, return false; } buf = reinterpret_cast(buf_base); - if (!write_syscall_template(tdata, marker_val)) + if (!write_syscall_template(tdata, static_cast(marker_val))) return false; } } @@ -1421,7 +1422,7 @@ raw2trace_t::read_syscall_template_file() case TRACE_MARKER_TYPE_SYSCALL: last_syscall_num = entry.addr; first_entry_for_syscall = true; - break; + continue; case TRACE_MARKER_TYPE_FILETYPE: // We cannot at this point verify that the trace being post-processed is // of the same arch. We do that later in write_syscall_template. @@ -1434,13 +1435,14 @@ raw2trace_t::read_syscall_template_file() return "System call trace templates without encodings are not " "supported."; } + continue; } - continue; } if (entry.type == TRACE_TYPE_THREAD_EXIT) continue; if (last_syscall_num == -1) continue; + // We expect atmost one template per system call for now. DR_ASSERT(!first_entry_for_syscall || syscall_trace_templates_[last_syscall_num].empty()); syscall_trace_templates_[last_syscall_num].push_back(entry); diff --git a/clients/drcachesim/tracer/raw2trace.h b/clients/drcachesim/tracer/raw2trace.h index 8e6218b1674..1d3a9bc4e29 100644 --- a/clients/drcachesim/tracer/raw2trace.h +++ b/clients/drcachesim/tracer/raw2trace.h @@ -1254,8 +1254,8 @@ class raw2trace_t { read_syscall_template_file(); /** - * Writes the system call template (if any was provided in the system call - * template file) to the output trace. + * Writes the system call template to the output trace, if any was provided in + * the system call template file for the given syscall_num. */ bool write_syscall_template(raw2trace_thread_data_t *tdata, int syscall_num); diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 7e3be36535a..4bddc196732 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -4296,7 +4296,8 @@ if (BUILD_CLIENTS) if (LINUX) set(tool.drcacheoff.burst_maps_nodr ON) torunonly_drcacheoff(burst_maps tool.drcacheoff.burst_maps "" "" "") - + endif () + if (UNIX) set(tool.drcacheoff.burst_syscall_inject_nodr ON) torunonly_drcacheoff(burst_syscall_inject tool.drcacheoff.burst_syscall_inject "" "@-simulator_type@basic_counts@-syscall_template_file@drmemtrace.tool.drcacheoff.burst_syscall_inject.*.dir/raw/syscall_trace_template"