LLDB mainline
lldb_private::process_linux::IntelPTMultiCoreTrace Class Reference

#include <IntelPTMultiCoreTrace.h>

Inheritance diagram for lldb_private::process_linux::IntelPTMultiCoreTrace:
[legend]

Public Member Functions

void ForEachCore (std::function< void(lldb::cpu_id_t cpu_id, IntelPTSingleBufferTrace &core_trace)> callback)
 Execute the provided callback on each core that is being traced.
void ForEachCore (std::function< void(lldb::cpu_id_t cpu_id, IntelPTSingleBufferTrace &intelpt_trace, ContextSwitchTrace &context_switch_trace)> callback)
 Execute the provided callback on each core that is being traced.
void ProcessDidStop () override
void ProcessWillResume () override
TraceIntelPTGetStateResponse GetState () override
 Construct a minimal jLLDBTraceGetState response for this process trace.
bool TracesThread (lldb::tid_t tid) const override
llvm::Error TraceStart (lldb::tid_t tid) override
 Start tracing the thread given by its tid.
llvm::Error TraceStop (lldb::tid_t tid) override
 Stop tracing the thread given by its tid.
llvm::Expected< std::optional< std::vector< uint8_t > > > TryGetBinaryData (const TraceGetBinaryDataRequest &request) override
Public Member Functions inherited from lldb_private::process_linux::IntelPTProcessTrace
virtual ~IntelPTProcessTrace ()=default

Static Public Member Functions

static llvm::Expected< std::unique_ptr< IntelPTMultiCoreTrace > > StartOnAllCores (const TraceIntelPTStartRequest &request, NativeProcessProtocol &process, std::optional< int > cgroup_fd=std::nullopt)
 Start tracing all CPU cores.

Private Types

using ContextSwitchTrace = PerfEvent

Private Member Functions

 IntelPTMultiCoreTrace (llvm::DenseMap< lldb::cpu_id_t, std::pair< IntelPTSingleBufferTrace, ContextSwitchTrace > > &&traces_per_core, NativeProcessProtocol &process, bool using_cgroup_filtering)
 This assumes that all underlying perf_events for each core are part of the same perf event group.

Private Attributes

llvm::DenseMap< lldb::cpu_id_t, std::pair< IntelPTSingleBufferTrace, ContextSwitchTrace > > m_traces_per_core
NativeProcessProtocolm_process
 The target process.
bool m_using_cgroup_filtering

Detailed Description

Definition at line 24 of file IntelPTMultiCoreTrace.h.

Member Typedef Documentation

◆ ContextSwitchTrace

Constructor & Destructor Documentation

◆ IntelPTMultiCoreTrace()

lldb_private::process_linux::IntelPTMultiCoreTrace::IntelPTMultiCoreTrace ( llvm::DenseMap< lldb::cpu_id_t, std::pair< IntelPTSingleBufferTrace, ContextSwitchTrace > > && traces_per_core,
NativeProcessProtocol & process,
bool using_cgroup_filtering )
inlineprivate

This assumes that all underlying perf_events for each core are part of the same perf event group.

Definition at line 93 of file IntelPTMultiCoreTrace.h.

References m_process, m_traces_per_core, and m_using_cgroup_filtering.

Referenced by StartOnAllCores().

Member Function Documentation

◆ ForEachCore() [1/2]

void lldb_private::process_linux::IntelPTMultiCoreTrace::ForEachCore ( std::function< void(lldb::cpu_id_t cpu_id, IntelPTSingleBufferTrace &core_trace)> callback)

Execute the provided callback on each core that is being traced.

Parameters
[in]callback.cpu_idThe core id that is being traced.
[in]callback.core_traceThe single-buffer trace instance for the given core.

Referenced by GetState(), ProcessDidStop(), and ProcessWillResume().

◆ ForEachCore() [2/2]

void lldb_private::process_linux::IntelPTMultiCoreTrace::ForEachCore ( std::function< void(lldb::cpu_id_t cpu_id, IntelPTSingleBufferTrace &intelpt_trace, ContextSwitchTrace &context_switch_trace)> callback)

Execute the provided callback on each core that is being traced.

Parameters
[in]callback.cpu_idThe core id that is being traced.
[in]callback.intelpt_traceThe single-buffer intel pt trace instance for the given core.
[in]callback.context_switch_traceThe perf event collecting context switches for the given core.

◆ GetState()

◆ ProcessDidStop()

void IntelPTMultiCoreTrace::ProcessDidStop ( )
overridevirtual

◆ ProcessWillResume()

void IntelPTMultiCoreTrace::ProcessWillResume ( )
overridevirtual

◆ StartOnAllCores()

Expected< std::unique_ptr< IntelPTMultiCoreTrace > > IntelPTMultiCoreTrace::StartOnAllCores ( const TraceIntelPTStartRequest & request,
NativeProcessProtocol & process,
std::optional< int > cgroup_fd = std::nullopt )
static

Start tracing all CPU cores.

Parameters
[in]requestIntel PT configuration parameters.
[in]processThe process being debugged.
[in]cgroup_fdA file descriptor in /sys/fs associated with the cgroup of the process to trace. If not std::nullopt, then the trace sesion will use cgroup filtering.
Returns
An IntelPTMultiCoreTrace instance if tracing was successful, or an llvm::Error otherwise.

Definition at line 37 of file IntelPTMultiCoreTrace.cpp.

References lldb_private::process_linux::CreateContextSwitchTracePerfEvent(), createStringError(), lldb_private::process_linux::GetAvailableLogicalCoreIDs(), IncludePerfEventParanoidMessageInError(), IntelPTMultiCoreTrace(), IsTotalBufferLimitReached(), and lldb_private::process_linux::IntelPTSingleBufferTrace::Start().

Referenced by lldb_private::process_linux::IntelPTCollector::TraceStart().

◆ TraceStart()

llvm::Error IntelPTMultiCoreTrace::TraceStart ( lldb::tid_t tid)
overridevirtual

Start tracing the thread given by its tid.

Returns
An error if the operation failed.

Implements lldb_private::process_linux::IntelPTProcessTrace.

Definition at line 134 of file IntelPTMultiCoreTrace.cpp.

References createStringError(), and TracesThread().

◆ TracesThread()

bool IntelPTMultiCoreTrace::TracesThread ( lldb::tid_t tid) const
overridevirtual

Implements lldb_private::process_linux::IntelPTProcessTrace.

Definition at line 129 of file IntelPTMultiCoreTrace.cpp.

References m_process.

Referenced by TraceStart().

◆ TraceStop()

Error IntelPTMultiCoreTrace::TraceStop ( lldb::tid_t tid)
overridevirtual

Stop tracing the thread given by its tid.

Returns
An error if the given thread is not being traced or tracing couldn't be stopped.

Implements lldb_private::process_linux::IntelPTProcessTrace.

Definition at line 143 of file IntelPTMultiCoreTrace.cpp.

References createStringError().

◆ TryGetBinaryData()

Expected< std::optional< std::vector< uint8_t > > > IntelPTMultiCoreTrace::TryGetBinaryData ( const TraceGetBinaryDataRequest & request)
overridevirtual
Returns
std::nullopt if this instance doesn't support the requested data, an llvm::Error if this isntance supports it but fails at fetching it, and Error::success() otherwise.

Implements lldb_private::process_linux::IntelPTProcessTrace.

Definition at line 150 of file IntelPTMultiCoreTrace.cpp.

References lldb_private::TraceGetBinaryDataRequest::cpu_id, createStringError(), lldb_private::TraceGetBinaryDataRequest::kind, lldb_private::IntelPTDataKinds::kIptTrace, lldb_private::IntelPTDataKinds::kPerfContextSwitchTrace, and m_traces_per_core.

Member Data Documentation

◆ m_process

NativeProcessProtocol& lldb_private::process_linux::IntelPTMultiCoreTrace::m_process
private

The target process.

Definition at line 106 of file IntelPTMultiCoreTrace.h.

Referenced by GetState(), IntelPTMultiCoreTrace(), and TracesThread().

◆ m_traces_per_core

llvm::DenseMap<lldb::cpu_id_t, std::pair<IntelPTSingleBufferTrace, ContextSwitchTrace> > lldb_private::process_linux::IntelPTMultiCoreTrace::m_traces_per_core
private

Definition at line 103 of file IntelPTMultiCoreTrace.h.

Referenced by IntelPTMultiCoreTrace(), and TryGetBinaryData().

◆ m_using_cgroup_filtering

bool lldb_private::process_linux::IntelPTMultiCoreTrace::m_using_cgroup_filtering
private

Definition at line 107 of file IntelPTMultiCoreTrace.h.

Referenced by GetState(), and IntelPTMultiCoreTrace().


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