Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Dec 6, 2023
1 parent 93ad6ef commit faec11a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
7 changes: 2 additions & 5 deletions clients/drcachesim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
5 changes: 4 additions & 1 deletion clients/drcachesim/tests/burst_syscall_inject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<app_pc>(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,
Expand All @@ -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<app_pc>(PC_SYSCALL_GETTID));
instr_destroy(dr_context, gettid_instr);

trace_entry_t footer = { TRACE_TYPE_THREAD_EXIT, 0, { 1 } };
write_trace_entry(writer, footer);
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<addr_t>(syscall_num) };
{ static_cast<addr_t>(syscall_num) } };
*buf = start_entry;
++buf;
if (!write(tdata, buf_base, buf)) {
Expand Down Expand Up @@ -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<addr_t>(syscall_num) };
trace_entry_t end_entry = { TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_SYSCALL_TRACE_END,
{ static_cast<addr_t>(syscall_num) } };
*buf = end_entry;
++buf;
if (!write(tdata, buf_base, buf)) {
Expand Down Expand Up @@ -728,7 +729,7 @@ raw2trace_t::process_offline_entry(raw2trace_thread_data_t *tdata,
return false;
}
buf = reinterpret_cast<byte *>(buf_base);
if (!write_syscall_template(tdata, marker_val))
if (!write_syscall_template(tdata, static_cast<int>(marker_val)))
return false;
}
}
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions clients/drcachesim/tracer/raw2trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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@[email protected]_syscall_inject.*.dir/raw/syscall_trace_template"
Expand Down

0 comments on commit faec11a

Please sign in to comment.