std::chrono::milliseconds duration) {
s.Format(" {0}: {1:2}s\n", name, duration.count() / 1000.0);
};
- GetTimer().ForThread(tid).ForEachTimedTask(print_duration);
+ GetThreadTimer(tid).ForEachTimedTask(print_duration);
s << "\n Timing for global tasks:\n";
- GetTimer().ForGlobal().ForEachTimedTask(print_duration);
+ GetGlobalTimer().ForEachTimedTask(print_duration);
}
// Instruction events stats
}
TaskTimer &TraceIntelPT::GetTimer() { return GetUpdatedStorage().task_timer; }
+
+ScopedTaskTimer &TraceIntelPT::GetThreadTimer(lldb::tid_t tid) {
+ return GetTimer().ForThread(tid);
+}
+
+ScopedTaskTimer &TraceIntelPT::GetGlobalTimer() {
+ return GetTimer().ForGlobal();
+}
if (Error err = CorrelateContextSwitchesAndIntelPtTraces())
return std::move(err);
- auto it = m_decoded_threads.find(thread.GetID());
- if (it != m_decoded_threads.end())
- return it->second;
-
- DecodedThreadSP decoded_thread_sp =
- std::make_shared<DecodedThread>(thread.shared_from_this());
-
TraceIntelPTSP trace_sp = GetTrace();
- Error err = trace_sp->OnAllCpusBinaryDataRead(
- IntelPTDataKinds::kIptTrace,
- [&](const DenseMap<cpu_id_t, ArrayRef<uint8_t>> &buffers) -> Error {
- auto it = m_continuous_executions_per_thread->find(thread.GetID());
- if (it != m_continuous_executions_per_thread->end())
- return DecodeSystemWideTraceForThread(*decoded_thread_sp, *trace_sp,
- buffers, it->second);
-
- return Error::success();
+ return trace_sp
+ ->GetThreadTimer(thread.GetID())
+ .TimeTask("Decoding instructions", [&]() -> Expected<DecodedThreadSP> {
+ auto it = m_decoded_threads.find(thread.GetID());
+ if (it != m_decoded_threads.end())
+ return it->second;
+
+ DecodedThreadSP decoded_thread_sp =
+ std::make_shared<DecodedThread>(thread.shared_from_this());
+
+ Error err = trace_sp->OnAllCpusBinaryDataRead(
+ IntelPTDataKinds::kIptTrace,
+ [&](const DenseMap<cpu_id_t, ArrayRef<uint8_t>> &buffers) -> Error {
+ auto it =
+ m_continuous_executions_per_thread->find(thread.GetID());
+ if (it != m_continuous_executions_per_thread->end())
+ return DecodeSystemWideTraceForThread(
+ *decoded_thread_sp, *trace_sp, buffers, it->second);
+
+ return Error::success();
+ });
+ if (err)
+ return std::move(err);
+
+ m_decoded_threads.try_emplace(thread.GetID(), decoded_thread_sp);
+ return decoded_thread_sp;
});
- if (err)
- return std::move(err);
-
- m_decoded_threads.try_emplace(thread.GetID(), decoded_thread_sp);
- return decoded_thread_sp;
}
static Expected<std::vector<IntelPTThreadSubtrace>>
if (m_continuous_executions_per_thread)
return Error::success();
- Error err = GetTrace()->GetTimer().ForGlobal().TimeTask<Error>(
+ Error err = GetTrace()->GetGlobalTimer().TimeTask(
"Context switch and Intel PT traces correlation", [&]() -> Error {
if (auto correlation = DoCorrelateContextSwitchesAndIntelPtTraces()) {
m_continuous_executions_per_thread.emplace(std::move(*correlation));