From 14e306aee0ea655460826bb4d3a7dfb569c5e1b7 Mon Sep 17 00:00:00 2001 From: Abhinav Anil Sharma Date: Fri, 29 Mar 2024 16:04:53 -0400 Subject: [PATCH] i#6745: Fix timestamp gap in -trace_after_instrs Fixes a timestamp gap between the first and second timestamps in the trace caused when -trace_after_instrs is used. Fixes: #6745 --- clients/drcachesim/tracer/instr_counter.cpp | 5 +++-- clients/drcachesim/tracer/output.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clients/drcachesim/tracer/instr_counter.cpp b/clients/drcachesim/tracer/instr_counter.cpp index 43d7b0d0e2f..737e897bb58 100644 --- a/clients/drcachesim/tracer/instr_counter.cpp +++ b/clients/drcachesim/tracer/instr_counter.cpp @@ -129,9 +129,10 @@ hit_instr_count_threshold(app_pc next_pc) return; } if (op_trace_after_instrs.get_value() > 0 && - !reached_trace_after_instrs.load(std::memory_order_acquire)) + !reached_trace_after_instrs.load(std::memory_order_acquire)) { NOTIFY(0, "Hit delay threshold: enabling tracing.\n"); - else { + retrace_start_timestamp.store(instru_t::get_timestamp()); + } else { NOTIFY(0, "Hit retrace threshold: enabling tracing for window #%zd.\n", tracing_window.load(std::memory_order_acquire)); retrace_start_timestamp.store(instru_t::get_timestamp()); diff --git a/clients/drcachesim/tracer/output.cpp b/clients/drcachesim/tracer/output.cpp index 64d4d120fd0..2462a3b59b0 100644 --- a/clients/drcachesim/tracer/output.cpp +++ b/clients/drcachesim/tracer/output.cpp @@ -1059,7 +1059,7 @@ process_and_output_buffer(void *drcontext, bool skip_size_cap) instru->clamp_unit_header_timestamp(data->buf_base + stamp_offs, min_timestamp); } - if (has_tracing_windows()) { + if (has_tracing_windows() || op_trace_after_instrs.get_value() > 0) { min_timestamp = retrace_start_timestamp.load(std::memory_order_acquire); instru->clamp_unit_header_timestamp(data->buf_base + stamp_offs, min_timestamp); }