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>

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
 
llvm::Expected< std::optional< uint64_t > > FindLowestTSC ()
 

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.
 
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.
 
TraceIntelPTSP GetTrace ()
 

Private Attributes

std::weak_ptr< TraceIntelPTm_trace_wp
 
std::set< lldb::tid_tm_tids
 
std::optional< llvm::DenseMap< lldb::tid_t, std::vector< IntelPTThreadContinousExecution > > > m_continuous_executions_per_thread
 
llvm::DenseMap< lldb::tid_t, DecodedThreadSPm_decoded_threads
 
std::optional< std::string > m_setup_error
 This variable will not be std::nullopt if a severe error happened during the setup of the decoder and we don't want decoding to be reattempted.
 
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 32 of file TraceIntelPTMultiCpuDecoder.h.

Constructor & Destructor Documentation

◆ TraceIntelPTMultiCpuDecoder()

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

Definition at line 19 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 177 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 59 of file TraceIntelPTMultiCpuDecoder.cpp.

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

◆ DoCorrelateContextSwitchesAndIntelPtTraces()

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

◆ FindLowestTSC()

Expected< std::optional< uint64_t > > TraceIntelPTMultiCpuDecoder::FindLowestTSC ( )
Returns
The lowest TSC value in this trace if available, std::nullopt if the trace is empty or the trace contains no timing information, or an llvm::Error if it was not possible to set up the decoder.

Definition at line 37 of file TraceIntelPTMultiCpuDecoder.cpp.

References lldb_private::trace_intel_pt::FindLowestTSCInTrace(), GetTrace(), and lldb_private::IntelPTDataKinds::kIptTrace.

◆ 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 220 of file TraceIntelPTMultiCpuDecoder.cpp.

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

◆ GetNumContinuousExecutionsForThread()

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

Definition at line 200 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 210 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 236 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 232 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 33 of file TraceIntelPTMultiCpuDecoder.cpp.

References m_tids.

Member Data Documentation

◆ m_continuous_executions_per_thread

std::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 99 of file TraceIntelPTMultiCpuDecoder.h.

Referenced by Decode().

◆ m_setup_error

std::optional<std::string> lldb_private::trace_intel_pt::TraceIntelPTMultiCpuDecoder::m_setup_error
private

This variable will not be std::nullopt if a severe error happened during the setup of the decoder and we don't want decoding to be reattempted.

Definition at line 102 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 95 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 94 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: