diff options
Diffstat (limited to 'lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp')
| -rw-r--r-- | lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp index d2dbc049672c..e547032f739d 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp @@ -1,4 +1,4 @@ -//===-- TraceIntelPTMultiCpuDecoder.cpp ----0------------------------------===// +//===-- TraceIntelPTMultiCpuDecoder.cpp -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -39,30 +39,35 @@ Expected<DecodedThreadSP> TraceIntelPTMultiCpuDecoder::Decode(Thread &thread) { 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; + TraceIntelPTSP trace_sp = GetTrace(); - DecodedThreadSP decoded_thread_sp = - std::make_shared<DecodedThread>(thread.shared_from_this()); + 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; - TraceIntelPTSP trace_sp = GetTrace(); + 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); + 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); + return Error::success(); + }); + if (err) + return std::move(err); - m_decoded_threads.try_emplace(thread.GetID(), decoded_thread_sp); - return decoded_thread_sp; + m_decoded_threads.try_emplace(thread.GetID(), decoded_thread_sp); + return decoded_thread_sp; + }); } static Expected<std::vector<IntelPTThreadSubtrace>> @@ -105,6 +110,7 @@ TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() { if (!intel_pt_subtraces) return intel_pt_subtraces.takeError(); + m_total_psb_blocks += intel_pt_subtraces->size(); // We'll be iterating through the thread continuous executions and the intel // pt subtraces sorted by time. auto it = intel_pt_subtraces->begin(); @@ -118,7 +124,7 @@ TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() { if (it->tsc > thread_execution.GetStartTSC()) { execution.intelpt_subtraces.push_back(*it); } else { - m_unattributed_intelpt_subtraces++; + m_unattributed_psb_blocks++; } } continuous_executions_per_thread[thread_execution.tid].push_back( @@ -137,6 +143,8 @@ TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() { }); if (err) return std::move(err); + + m_unattributed_psb_blocks += intel_pt_subtraces->end() - it; } // We now sort the executions of each thread to have them ready for // instruction decoding @@ -153,7 +161,7 @@ Error TraceIntelPTMultiCpuDecoder::CorrelateContextSwitchesAndIntelPtTraces() { 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)); @@ -187,3 +195,24 @@ size_t TraceIntelPTMultiCpuDecoder::GetTotalContinuousExecutionsCount() const { count += kv.second.size(); return count; } + +size_t +TraceIntelPTMultiCpuDecoder::GePSBBlocksCountForThread(lldb::tid_t tid) const { + if (!m_continuous_executions_per_thread) + return 0; + size_t count = 0; + auto it = m_continuous_executions_per_thread->find(tid); + if (it == m_continuous_executions_per_thread->end()) + return 0; + for (const IntelPTThreadContinousExecution &execution : it->second) + count += execution.intelpt_subtraces.size(); + return count; +} + +size_t TraceIntelPTMultiCpuDecoder::GetUnattributedPSBBlocksCount() const { + return m_unattributed_psb_blocks; +} + +size_t TraceIntelPTMultiCpuDecoder::GetTotalPSBBlocksCount() const { + return m_total_psb_blocks; +} |
