LLDB mainline
|
Class used to decode a multi-cpu Intel PT trace. More...
#include <TraceIntelPTMultiCpuDecoder.h>
Public Member Functions | |
TraceIntelPTMultiCpuDecoder (TraceIntelPTSP trace_sp) | |
llvm::Expected< DecodedThreadSP > | Decode (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< TraceIntelPT > | m_trace_wp |
std::set< lldb::tid_t > | m_tids |
std::optional< llvm::DenseMap< lldb::tid_t, std::vector< IntelPTThreadContinousExecution > > > | m_continuous_executions_per_thread |
llvm::DenseMap< lldb::tid_t, DecodedThreadSP > | m_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 |
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.
TraceIntelPTMultiCpuDecoder::TraceIntelPTMultiCpuDecoder | ( | TraceIntelPTSP | trace_sp | ) |
[in] | TraceIntelPT | The trace object to be decoded |
Definition at line 19 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_tids.
|
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().
Expected< DecodedThreadSP > TraceIntelPTMultiCpuDecoder::Decode | ( | Thread & | thread | ) |
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.
|
private |
Produce a mapping from thread ids to the list of continuos executions with their associated intel pt subtraces.
Definition at line 113 of file TraceIntelPTMultiCpuDecoder.cpp.
References lldb_private::trace_intel_pt::DecodePerfContextSwitchTrace(), GetPSBBlocksForCPU(), GetTrace(), lldb_private::IntelPTDataKinds::kPerfContextSwitchTrace, m_total_psb_blocks, m_unattributed_psb_blocks, and lldb_private::trace_intel_pt::IntelPTThreadContinousExecution::psb_blocks.
Referenced by CorrelateContextSwitchesAndIntelPtTraces().
Expected< std::optional< uint64_t > > TraceIntelPTMultiCpuDecoder::FindLowestTSC | ( | ) |
Definition at line 37 of file TraceIntelPTMultiCpuDecoder.cpp.
References lldb_private::trace_intel_pt::FindLowestTSCInTrace(), GetTrace(), and lldb_private::IntelPTDataKinds::kIptTrace.
size_t TraceIntelPTMultiCpuDecoder::GePSBBlocksCountForThread | ( | lldb::tid_t | tid | ) | const |
Definition at line 220 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_continuous_executions_per_thread, and lldb_private::trace_intel_pt::IntelPTThreadContinousExecution::psb_blocks.
size_t TraceIntelPTMultiCpuDecoder::GetNumContinuousExecutionsForThread | ( | lldb::tid_t | tid | ) | const |
tid
. Definition at line 200 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_continuous_executions_per_thread.
size_t TraceIntelPTMultiCpuDecoder::GetTotalContinuousExecutionsCount | ( | ) | const |
Definition at line 210 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_continuous_executions_per_thread.
size_t TraceIntelPTMultiCpuDecoder::GetTotalPSBBlocksCount | ( | ) | const |
Definition at line 236 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_total_psb_blocks.
|
private |
Definition at line 29 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_trace_wp.
Referenced by CorrelateContextSwitchesAndIntelPtTraces(), Decode(), DoCorrelateContextSwitchesAndIntelPtTraces(), and FindLowestTSC().
size_t TraceIntelPTMultiCpuDecoder::GetUnattributedPSBBlocksCount | ( | ) | const |
Definition at line 232 of file TraceIntelPTMultiCpuDecoder.cpp.
References m_unattributed_psb_blocks.
bool TraceIntelPTMultiCpuDecoder::TracesThread | ( | lldb::tid_t | tid | ) | const |
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.
|
private |
Definition at line 98 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by CorrelateContextSwitchesAndIntelPtTraces(), GePSBBlocksCountForThread(), GetNumContinuousExecutionsForThread(), and GetTotalContinuousExecutionsCount().
|
private |
Definition at line 99 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by Decode().
|
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().
|
private |
Definition at line 95 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by TraceIntelPTMultiCpuDecoder(), and TracesThread().
|
private |
Definition at line 104 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by DoCorrelateContextSwitchesAndIntelPtTraces(), and GetTotalPSBBlocksCount().
|
private |
Definition at line 94 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by GetTrace().
|
private |
Definition at line 103 of file TraceIntelPTMultiCpuDecoder.h.
Referenced by DoCorrelateContextSwitchesAndIntelPtTraces(), and GetUnattributedPSBBlocksCount().