Skip to content

Commit

Permalink
append_encoding before passing entries to write. Add syscall_mix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Nov 28, 2023
1 parent 626ffab commit d89c89a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 14 deletions.
3 changes: 1 addition & 2 deletions clients/drcachesim/reader/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ reader_t::process_input_entry()
version_ = cur_ref_.marker.marker_value;
else if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_FILETYPE) {
filetype_ = cur_ref_.marker.marker_value;
if (TESTANY(OFFLINE_FILE_TYPE_ENCODINGS, filetype_) &&
!TESTANY(OFFLINE_FILE_TYPE_KERNEL_SYSCALLS, filetype_)) {
if (TESTANY(OFFLINE_FILE_TYPE_ENCODINGS, filetype_)) {
expect_no_encodings_ = false;
}
} else if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_CACHE_LINE_SIZE)
Expand Down
6 changes: 6 additions & 0 deletions clients/drcachesim/tests/offline-kernel-syscall-mix.templatex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Hello, world!
Syscall mix tool results:
syscall count : syscall_num
( *[1-9][0-9]* : *[0-9]*.*)+
syscall trace count : syscall_num
( *[1-9][0-9]* : *[0-9]*.*)+
2 changes: 1 addition & 1 deletion clients/drcachesim/tests/offline-syscall-mix.templatex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hello, world!
Syscall mix tool results:
count : syscall_num
syscall count : syscall_num
( *[1-9][0-9]* : *[0-9]*.*)+
2 changes: 1 addition & 1 deletion clients/drcachesim/tests/syscall-mix.templatex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hello, world!
---- <application exited with code 0> ----
Syscall mix tool results:
count : syscall_num
syscall count : syscall_num
( *[1-9][0-9]* : *[0-9]*.*)+
4 changes: 2 additions & 2 deletions clients/drcachesim/tools/syscall_mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ syscall_mix_t::print_results()
<< keyvals.first << "\n";
}
if (!total.syscall_trace_counts.empty()) {
std::cerr << std::setw(15) << "syscall trace count"
std::cerr << std::setw(20) << "syscall trace count"
<< " : " << std::setw(9) << "syscall_num\n";
std::vector<std::pair<int, int64_t>> sorted_trace(
total.syscall_trace_counts.begin(), total.syscall_trace_counts.end());
std::sort(sorted_trace.begin(), sorted_trace.end(), cmp_second_val);
for (const auto &keyvals : sorted_trace) {
// XXX: It would be nicer to print the system call name string instead
// of its number.
std::cerr << std::setw(15) << keyvals.second << " : " << std::setw(9)
std::cerr << std::setw(20) << keyvals.second << " : " << std::setw(9)
<< keyvals.first << "\n";
}
}
Expand Down
22 changes: 15 additions & 7 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,17 @@ raw2trace_t::process_syscall_pt(raw2trace_thread_data_t *tdata, uint64_t syscall
}

accumulate_to_statistic(tdata, RAW2TRACE_STAT_SYSCALL_TRACES_DECODED, 1);
std::vector<app_pc> decode_pcs;
app_pc saved_decode_pc;
trace_entry_t entries_with_encodings[WRITE_BUFFER_SIZE];
trace_entry_t *buf = entries_with_encodings;
for (const auto &entry : entries) {
if (type_is_instr(static_cast<trace_type_t>(entry.type))) {
if (buf != entries_with_encodings) {
if (!write(tdata, entries_with_encodings, buf, &saved_decode_pc, 1)) {
return false;
}
buf = entries_with_encodings;
}
app_pc instr_pc = reinterpret_cast<app_pc>(entry.addr);
accumulate_to_statistic(tdata, RAW2TRACE_STAT_KERNEL_INSTR_COUNT, 1);
if (tdata->syscall_pc_to_decode_pc_.find(instr_pc) ==
Expand All @@ -1055,14 +1063,14 @@ raw2trace_t::process_syscall_pt(raw2trace_thread_data_t *tdata, uint64_t syscall
"Unknown pc after ir2trace: did ir2trace insert new instr?";
return false;
}
decode_pcs.push_back(tdata->syscall_pc_to_decode_pc_[instr_pc].first);
saved_decode_pc = tdata->syscall_pc_to_decode_pc_[instr_pc].first;
if (!append_encoding(tdata, saved_decode_pc, entry.size, buf,
entries_with_encodings))
return false;
}
*buf = entry;
++buf;
}
if (!write(tdata, entries.data(), entries.data() + entries.size(), decode_pcs.data(),
decode_pcs.size())) {
return false;
}

return true;
}

Expand Down
4 changes: 3 additions & 1 deletion suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4564,8 +4564,10 @@ if (BUILD_CLIENTS)
# tracing flow.
torunonly_drcacheoff_kernel(simple ${ci_shared_app} "-raw_compress none" ""
"@-simulator_type@basic_counts@-ignore_decode_failure")
torunonly_drcacheoff_kernel(opcode_mix ${ci_shared_app} "-raw_compress none" ""
torunonly_drcacheoff_kernel(opcode-mix ${ci_shared_app} "-raw_compress none" ""
"@-simulator_type@opcode_mix@-ignore_decode_failure")
torunonly_drcacheoff_kernel(syscall-mix ${ci_shared_app} "-raw_compress none" ""
"@-simulator_type@syscall_mix")
endif (BUILD_PT_TRACER AND BUILD_PT_POST_PROCESSOR)
endif (proc_supports_pt)

Expand Down

0 comments on commit d89c89a

Please sign in to comment.