LLDB mainline
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::process_linux::IntelPTSingleBufferTrace Class Reference

This class wraps a single perf event collecting intel pt data in a single buffer. More...

#include <IntelPTSingleBufferTrace.h>

Public Member Functions

llvm::Expected< std::vector< uint8_t > > GetBinaryData (const TraceGetBinaryDataRequest &request) const
 
llvm::Expected< std::vector< uint8_t > > GetIptTrace ()
 Read the intel pt trace buffer managed by this trace instance.
 
size_t GetIptTraceSize () const
 
llvm::Error Resume ()
 Resume the collection of this trace.
 
llvm::Error Pause ()
 Pause the collection of this trace.
 
const PerfEventGetPerfEvent () const
 

Static Public Member Functions

static llvm::Expected< IntelPTSingleBufferTraceStart (const TraceIntelPTStartRequest &request, std::optional< lldb::tid_t > tid, std::optional< lldb::cpu_id_t > cpu_id=std::nullopt, bool disabled=false, std::optional< int > cgroup_fd=std::nullopt)
 Start tracing using a single Intel PT trace buffer.
 

Private Member Functions

 IntelPTSingleBufferTrace (PerfEvent &&perf_event)
 Construct new IntelPTSingleBufferThreadTrace.
 

Private Attributes

PerfEvent m_perf_event
 perf event configured for IntelPT.
 

Detailed Description

This class wraps a single perf event collecting intel pt data in a single buffer.

Definition at line 25 of file IntelPTSingleBufferTrace.h.

Constructor & Destructor Documentation

◆ IntelPTSingleBufferTrace()

lldb_private::process_linux::IntelPTSingleBufferTrace::IntelPTSingleBufferTrace ( PerfEvent &&  perf_event)
inlineprivate

Construct new IntelPTSingleBufferThreadTrace.

Users are supposed to create instances of this class via the Start() method and not invoke this one directly.

Parameters
[in]perf_eventperf event configured for IntelPT.
[in]collection_stateThe initial collection state for the provided perf_event.

Definition at line 105 of file IntelPTSingleBufferTrace.h.

Member Function Documentation

◆ GetBinaryData()

llvm::Expected< std::vector< uint8_t > > lldb_private::process_linux::IntelPTSingleBufferTrace::GetBinaryData ( const TraceGetBinaryDataRequest request) const
Returns
The bytes requested by a jLLDBTraceGetBinaryData packet that was routed to this trace instace.

◆ GetIptTrace()

Expected< std::vector< uint8_t > > IntelPTSingleBufferTrace::GetIptTrace ( )

Read the intel pt trace buffer managed by this trace instance.

To ensure that the data is up-to-date and is not corrupted by read-write race conditions, the underlying perf_event is paused during read, and later it's returned to its initial state.

Returns
A vector with the requested binary data.

Definition at line 213 of file IntelPTSingleBufferTrace.cpp.

References lldb_private::process_linux::PerfEvent::GetReadOnlyAuxBuffer(), and m_perf_event.

◆ GetIptTraceSize()

size_t IntelPTSingleBufferTrace::GetIptTraceSize ( ) const

◆ GetPerfEvent()

const PerfEvent & IntelPTSingleBufferTrace::GetPerfEvent ( ) const
Returns
The underlying PerfEvent for this trace.

Definition at line 287 of file IntelPTSingleBufferTrace.cpp.

References m_perf_event.

◆ Pause()

Error IntelPTSingleBufferTrace::Pause ( )

Pause the collection of this trace.

Returns
An error if the trace couldn't be paused. If the trace is already paused, this returns Error::success().

Definition at line 205 of file IntelPTSingleBufferTrace.cpp.

References lldb_private::process_linux::PerfEvent::DisableWithIoctl(), and m_perf_event.

Referenced by lldb_private::process_linux::IntelPTMultiCoreTrace::ProcessDidStop().

◆ Resume()

Error IntelPTSingleBufferTrace::Resume ( )

Resume the collection of this trace.

Returns
An error if the trace couldn't be resumed. If the trace is already running, this returns Error::success().

Definition at line 209 of file IntelPTSingleBufferTrace.cpp.

References lldb_private::process_linux::PerfEvent::EnableWithIoctl(), and m_perf_event.

Referenced by lldb_private::process_linux::IntelPTMultiCoreTrace::ProcessWillResume().

◆ Start()

Expected< IntelPTSingleBufferTrace > IntelPTSingleBufferTrace::Start ( const TraceIntelPTStartRequest request,
std::optional< lldb::tid_t tid,
std::optional< lldb::cpu_id_t cpu_id = std::nullopt,
bool  disabled = false,
std::optional< int >  cgroup_fd = std::nullopt 
)
static

Start tracing using a single Intel PT trace buffer.

Parameters
[in]requestIntel PT configuration parameters.
[in]tidThe tid of the thread to be traced. If None, then this traces all threads of all processes.
[in]cpu_idThe CPU core id where to trace. If None, then this traces all CPUs.
[in]disabledIf true, then no data is collected until Resume is invoked. Similarly, if false, data is collected right away until Pause is invoked.
[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
A IntelPTSingleBufferTrace instance if tracing was successful, or an llvm::Error otherwise.

Definition at line 232 of file IntelPTSingleBufferTrace.cpp.

References lldb_private::TraceIntelPTStartRequest::enable_tsc, lldb_private::GetLog(), lldb_private::process_linux::PerfEvent::Init(), lldb_private::TraceIntelPTStartRequest::ipt_trace_size, LLDB_LOG, lldb_private::TraceIntelPTStartRequest::psb_period, and lldb_private::Trace.

Referenced by lldb_private::process_linux::IntelPTMultiCoreTrace::StartOnAllCores(), and lldb_private::process_linux::IntelPTThreadTraceCollection::TraceStart().

Member Data Documentation

◆ m_perf_event

PerfEvent lldb_private::process_linux::IntelPTSingleBufferTrace::m_perf_event
private

perf event configured for IntelPT.

Definition at line 109 of file IntelPTSingleBufferTrace.h.

Referenced by GetIptTrace(), GetIptTraceSize(), GetPerfEvent(), Pause(), and Resume().


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