Skip to content

Commit

Permalink
Merge branch 'master' into i6643-make-snapshot-private-data
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 authored Feb 22, 2024
2 parents 84865fa + 6a06ccb commit e9285bb
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 37 deletions.
5 changes: 2 additions & 3 deletions clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,8 @@ droption_t<uint64_t> op_trim_after_timestamp(
DROPTION_SCOPE_ALL, "trim_after_timestamp", (std::numeric_limits<uint64_t>::max)(), 0,
(std::numeric_limits<uint64_t>::max)(),
"Trim records after this timestamp (in us) in the trace.",
"Removes all records after the first TRACE_MARKER_TYPE_TIMESTAMP marker with "
"timestamp larger than the specified value (keeps a TRACE_MARKER_TYPE_CPU_ID "
"immediately following the transition timestamp).");
"Removes all records from the first TRACE_MARKER_TYPE_TIMESTAMP marker with "
"timestamp larger than the specified value.");

} // namespace drmemtrace
} // namespace dynamorio
6 changes: 2 additions & 4 deletions clients/drcachesim/tests/offline-trim.templatex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Output 290 entries from 329 entries.
Output 288 entries from 329 entries.
Output format:
<--record#-> <--instr#->: <---tid---> <record details>
------------------------------------------------------------
Expand All @@ -21,9 +21,7 @@ Output format:
215 119: 1992554 ifetch 5 byte\(s\) @ 0x0000000000401021 b8 01 00 00 00 mov \$0x00000001 -> %eax
216 120: 1992554 ifetch 2 byte\(s\) @ 0x0000000000401026 0f 05 syscall -> %rcx %r11
217 120: 1992554 <marker: chunk footer #5>
218 120: 1992554 <marker: timestamp 13352268558646666>
219 120: 1992554 <marker: tid 1992554 on core 10>
220 120: 1992554 <thread 1992554 exited>
218 120: 1992554 <thread 1992554 exited>
View tool results:
120 : total instructions

Expand Down
10 changes: 7 additions & 3 deletions clients/drcachesim/tests/record_filter_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ process_entries_and_check_result(test_record_filter_t *record_filter,
fprintf(stderr, "Filtering exit failed\n");
return false;
}
if (!record_filter->print_results()) {
fprintf(stderr, "Filtering results failed\n");
return false;
}

std::vector<trace_entry_t> filtered = record_filter->get_output_entries();
// Verbose output for easier debugging.
Expand Down Expand Up @@ -683,11 +687,11 @@ test_trim_filter()
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID, { 0 } }, true, { true } },
{ { TRACE_TYPE_ENCODING, 2, { ENCODING_A } }, true, { true } },
{ { TRACE_TYPE_INSTR, 2, { PC_A } }, true, { true } },
// Removal starts right after here.
// Removal starts here.
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_TIMESTAMP, { 200 } },
true,
{ true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID, { 0 } }, true, { true } },
{ false } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID, { 0 } }, true, { false } },
{ { TRACE_TYPE_ENCODING, 2, { ENCODING_B } }, true, { false } },
{ { TRACE_TYPE_INSTR, 2, { PC_B } }, true, { false } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CHUNK_FOOTER, { 0 } },
Expand Down
16 changes: 11 additions & 5 deletions clients/drcachesim/tools/filter/record_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ record_filter_t::parallel_shard_exit(void *shard_data)
// chunk_ordinal is 1 after the init-time call for archives; it
// remains 0 for non-archives.
per_shard->chunk_ordinal <= 1 && per_shard->cur_chunk_instrs == 0) {
per_shard->error = remove_output_file(per_shard);
if (!per_shard->error.empty())
res = false;
// Mark for removal. We delay removal in case it involves global
// operations that might race with other workers.
per_shard->now_empty = true;
}
return res;
}
Expand Down Expand Up @@ -617,15 +617,21 @@ record_filter_t::process_memref(const trace_entry_t &memref)
bool
record_filter_t::print_results()
{
bool res = true;
uint64_t input_entry_count = 0;
uint64_t output_entry_count = 0;
for (const auto &shard : shard_map_) {
input_entry_count += shard.second->input_entry_count;
output_entry_count += shard.second->output_entry_count;
if (shard.second->now_empty) {
error_string_ = remove_output_file(shard.second);
if (!error_string_.empty())
res = false;
} else
output_entry_count += shard.second->output_entry_count;
}
std::cerr << "Output " << output_entry_count << " entries from " << input_entry_count
<< " entries.\n";
return true;
return res;
}

} // namespace drmemtrace
Expand Down
1 change: 1 addition & 0 deletions clients/drcachesim/tools/filter/record_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class record_filter_t : public record_analysis_tool_t {
bool prev_was_output = false;
addr_t filetype = 0;
memref_tid_t tid = 0; // For thread-sharded.
bool now_empty = false;
};

virtual std::string
Expand Down
24 changes: 9 additions & 15 deletions clients/drcachesim/tools/filter/trim_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,18 @@ class trim_filter_t : public record_filter_t::record_filter_func_t {
parallel_shard_filter(trace_entry_t &entry, void *shard_data) override
{
per_shard_t *per_shard = reinterpret_cast<per_shard_t *>(shard_data);
if (per_shard->just_saw_trim_start_after) {
if (entry.type == TRACE_TYPE_MARKER &&
entry.size == TRACE_MARKER_TYPE_CPU_ID) {
// Wait for the next record to start removing.
return true;
}
per_shard->in_removed_region = true;
per_shard->just_saw_trim_start_after = false;
}
if (entry.type == TRACE_TYPE_MARKER &&
entry.size == TRACE_MARKER_TYPE_TIMESTAMP) {
if (entry.addr < trim_before_timestamp_)
// While it seems theoretically nice to keep the timestamp,cpuid that
// is over the threshold so we have a timestamp at the end, that results
// in large time gaps if across a blocking syscall. Trying to edit
// that timestamp a la -align_endpoints is not deal either as it can
// distort syscall durations. The least-bad solution seems to be to
// keep the regular trace content right up to the timestamp and
// throw away the timestamp.
if (entry.addr < trim_before_timestamp_ || entry.addr > trim_after_timestamp_)
per_shard->in_removed_region = true;
else if (entry.addr > trim_after_timestamp_) {
if (!per_shard->in_removed_region)
per_shard->just_saw_trim_start_after = true;
} else
else
per_shard->in_removed_region = false;
}
if (entry.type == TRACE_TYPE_THREAD_EXIT || entry.type == TRACE_TYPE_FOOTER) {
Expand Down Expand Up @@ -116,7 +111,6 @@ class trim_filter_t : public record_filter_t::record_filter_func_t {
private:
struct per_shard_t {
bool in_removed_region = false;
bool just_saw_trim_start_after = false;
};

uint64_t trim_before_timestamp_;
Expand Down
5 changes: 2 additions & 3 deletions clients/drcachesim/tools/record_filter_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ static droption_t<uint64_t> op_trim_after_timestamp(
DROPTION_SCOPE_ALL, "trim_after_timestamp", (std::numeric_limits<uint64_t>::max)(), 0,
(std::numeric_limits<uint64_t>::max)(),
"Trim records after this timestamp (in us) in the trace.",
"Removes all records after the first TRACE_MARKER_TYPE_TIMESTAMP marker with "
"timestamp larger than the specified value (keeps a TRACE_MARKER_TYPE_CPU_ID "
"immediately following the transition timestamp).");
"Removes all records from the first TRACE_MARKER_TYPE_TIMESTAMP marker with "
"timestamp larger than the specified value.");

} // namespace

Expand Down
4 changes: 1 addition & 3 deletions ext/drwrap/drwrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,9 +2021,8 @@ drwrap_in_callee(void *arg1, reg_t xsp _IF_NOT_X86(reg_t lr))
NOTIFY(2, "%s: level %d function " PFX "\n", __FUNCTION__, pt->wrap_level + 1, pc);

app_pc retaddr = IF_X86_ELSE(get_retaddr_from_stack(xsp), (app_pc)lr);
#ifdef X86
if (TEST(DRWRAP_REPLACE_RETADDR, global_flags)) {
/* In case of a tailcall for X86, the return address has already been replaced by
/* In case of a tailcall, the return address has already been replaced by
* the sentinel in the stack, we need to retrieve the return address from the
* outer level.
*/
Expand All @@ -2034,7 +2033,6 @@ drwrap_in_callee(void *arg1, reg_t xsp _IF_NOT_X86(reg_t lr))
pt->wrap_level, retaddr);
}
}
#endif
drwrap_context_init(drcontext, &wrapcxt, pc, &mc, DRWRAP_WHERE_PRE_FUNC, retaddr);

drwrap_in_callee_check_unwind(drcontext, pt, &mc);
Expand Down
2 changes: 1 addition & 1 deletion suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4777,7 +4777,7 @@ if (BUILD_CLIENTS)
endif (BUILD_PT_TRACER AND BUILD_PT_POST_PROCESSOR)
endif (proc_supports_pt)

if (X86)
if ((AARCHXX AND NOT ANDROID) OR X86)
torunonly_drcacheoff(getretaddr_record_replace_retaddr common.getretaddr
"-record_replace_retaddr -record_function tailcall_with_retaddr|1&foo|1"
"@-simulator_type@invariant_checker" "")
Expand Down

0 comments on commit e9285bb

Please sign in to comment.