LLDB  mainline
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder Class Reference

Class used to decode a multi-cpu Intel PT trace. More...

#include <TraceIntelPTMultiCpuDecoder.h>

Collaboration diagram for lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder:
Collaboration graph
[legend]

Public Member Functions

 TraceIntelPTMultiCpuDecoder (TraceIntelPTSP trace_sp)
 
llvm::Expected< DecodedThreadSPDecode (Thread &thread)
 
bool TracesThread (lldb::tid_t tid) const
 
size_t GetNumContinuousExecutionsForThread (lldb::tid_t tid) const
 
size_t GePSBBlocksCountForThread (lldb::tid_t tid) const
 
size_t GetTotalContinuousExecutionsCount () const
 
size_t GetUnattributedPSBBlocksCount () const
 
size_t GetTotalPSBBlocksCount () const
 

Private Member Functions

llvm::Error CorrelateContextSwitchesAndIntelPtTraces ()
 Traverse the context switch traces and the basic intel pt continuous subtraces and produce a list of continuous executions for each process and thread. More...
 
llvm::Expected< llvm::DenseMap< lldb::tid_t, std::vector< IntelPTThreadContinousExecution > > > DoCorrelateContextSwitchesAndIntelPtTraces ()
 Produce a mapping from thread ids to the list of continuos executions with their associated intel pt subtraces. More...
 
TraceIntelPTSP GetTrace ()
 

Private Attributes

std::weak_ptr< TraceIntelPTm_trace_wp
 
std::set< lldb::tid_tm_tids
 
llvm::Optional< llvm::DenseMap< lldb::tid_t, std::vector< IntelPTThreadContinousExecution > > > m_continuous_executions_per_thread
 
llvm::DenseMap< lldb::tid_t, DecodedThreadSPm_decoded_threads
 
llvm::Optional< std::stringm_setup_error
 This variable will be non-None if a severe error happened during the setup of the decoder and we don't want decoding to be reattempted. More...
 
uint64_t m_unattributed_psb_blocks = 0
 
uint64_t m_total_psb_blocks = 0
 

Detailed Description

Class used to decode a multi-cpu Intel PT trace.

It assumes that each thread could have potentially been executed on different cpu cores. It uses a context switch trace per CPU with timestamps to identify which thread owns each Intel PT decoded instruction and in which order. It also assumes that the Intel PT data and context switches might have gaps in their traces due to contention or race conditions. Finally, it assumes that a tid is not repeated twice for two different threads because of the shortness of the intel pt trace.

This object should be recreated after every stop in the case of live processes.

Definition at line 31 of file TraceIntelPTMultiCpuDecoder.h.

Constructor & Destructor Documentation

◆ TraceIntelPTMultiCpuDecoder()

TraceIntelPTMultiCpuDecoder::TraceIntelPTMultiCpuDecoder ( TraceIntelPTSP  trace_sp)
Parameters
[in]TraceIntelPTThe trace object to be decoded

Definition at line 20 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_tids.

Member Function Documentation

◆ CorrelateContextSwitchesAndIntelPtTraces()

Error TraceIntelPTMultiCpuDecoder::CorrelateContextSwitchesAndIntelPtTraces ( )
private

Traverse the context switch traces and the basic intel pt continuous subtraces and produce a list of continuous executions for each process and thread.

See DoCorrelateContextSwitchesAndIntelPtTraces.

Any errors are stored in m_setup_error.

Definition at line 157 of file TraceIntelPTMultiCpuDecoder.cpp.

References DoCorrelateContextSwitchesAndIntelPtTraces(), GetTrace(), m_continuous_executions_per_thread, m_setup_error, and lldb_private::toString().

Referenced by Decode().

◆ Decode()

Expected< DecodedThreadSP > TraceIntelPTMultiCpuDecoder::Decode ( Thread thread)
Returns
A DecodedThread for the thread by decoding its instructions on all CPUs, sorted by TSCs. An llvm::Error is returned if the decoder couldn't be properly set up.

Definition at line 38 of file TraceIntelPTMultiCpuDecoder.cpp.

References CorrelateContextSwitchesAndIntelPtTraces(), lldb_private::UserID::GetID(), GetTrace(), if(), lldb_private::IntelPTDataKinds::kIptTrace, and m_decoded_threads.

◆ DoCorrelateContextSwitchesAndIntelPtTraces()

Expected< DenseMap< lldb::tid_t, std::vector< IntelPTThreadContinousExecution > > > TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces ( )
private

◆ GePSBBlocksCountForThread()

size_t TraceIntelPTMultiCpuDecoder::GePSBBlocksCountForThread ( lldb::tid_t  tid) const
Returns
The number of PSB blocks for a given thread in all cores.

Definition at line 200 of file TraceIntelPTMultiCpuDecoder.cpp.

References lldb_private::trace_intel_pt::IntelPTThreadContinousExecution::intelpt_subtraces, and m_continuous_executions_per_thread.

◆ GetNumContinuousExecutionsForThread()

size_t TraceIntelPTMultiCpuDecoder::GetNumContinuousExecutionsForThread ( lldb::tid_t  tid) const
Returns
The number of continuous executions found for the given tid.

Definition at line 180 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_continuous_executions_per_thread.

◆ GetTotalContinuousExecutionsCount()

size_t TraceIntelPTMultiCpuDecoder::GetTotalContinuousExecutionsCount ( ) const
Returns
The total number of continuous executions found across CPUs.

Definition at line 190 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_continuous_executions_per_thread.

◆ GetTotalPSBBlocksCount()

size_t TraceIntelPTMultiCpuDecoder::GetTotalPSBBlocksCount ( ) const
Returns
The total number of PSB blocks in all cores.

Definition at line 216 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_total_psb_blocks.

◆ GetTrace()

TraceIntelPTSP TraceIntelPTMultiCpuDecoder::GetTrace ( )
private

◆ GetUnattributedPSBBlocksCount()

size_t TraceIntelPTMultiCpuDecoder::GetUnattributedPSBBlocksCount ( ) const
Returns
The number of psb blocks in all cores that couldn't be matched with a thread execution coming from context switch traces.

Definition at line 212 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_unattributed_psb_blocks.

◆ TracesThread()

bool TraceIntelPTMultiCpuDecoder::TracesThread ( lldb::tid_t  tid) const
Returns
true if the given tid is managed by this decoder, regardless of whether there's tracing data associated to it or not.

Definition at line 34 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_tids.

Member Data Documentation

◆ m_continuous_executions_per_thread

llvm::Optional< llvm::DenseMap<lldb::tid_t, std::vector<IntelPTThreadContinousExecution> > > lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_continuous_executions_per_thread
private

◆ m_decoded_threads

llvm::DenseMap<lldb::tid_t, DecodedThreadSP> lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_decoded_threads
private

Definition at line 92 of file TraceIntelPTMultiCpuDecoder.h.

Referenced by Decode().

◆ m_setup_error

llvm::Optional<std::string> lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_setup_error
private

This variable will be non-None if a severe error happened during the setup of the decoder and we don't want decoding to be reattempted.

Definition at line 95 of file TraceIntelPTMultiCpuDecoder.h.

Referenced by CorrelateContextSwitchesAndIntelPtTraces().

◆ m_tids

std::set<lldb::tid_t> lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_tids
private

Definition at line 88 of file TraceIntelPTMultiCpuDecoder.h.

Referenced by TraceIntelPTMultiCpuDecoder(), and TracesThread().

◆ m_total_psb_blocks

uint64_t lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_total_psb_blocks = 0
private

◆ m_trace_wp

std::weak_ptr<TraceIntelPT> lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_trace_wp
private

Definition at line 87 of file TraceIntelPTMultiCpuDecoder.h.

Referenced by GetTrace().

◆ m_unattributed_psb_blocks

uint64_t lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_unattributed_psb_blocks = 0
private

The documentation for this class was generated from the following files: