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>

Collaboration diagram for lldb_private::process_linux::IntelPTSingleBufferTrace:
Collaboration graph
[legend]

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. More...
 
size_t GetIptTraceSize () const
 
llvm::Error Resume ()
 Resume the collection of this trace. More...
 
llvm::Error Pause ()
 Pause the collection of this trace. More...
 
const PerfEventGetPerfEvent () const
 

Static Public Member Functions

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

Private Member Functions

 IntelPTSingleBufferTrace (PerfEvent &&perf_event)
 Construct new IntelPTSingleBufferThreadTrace. More...
 

Private Attributes

PerfEvent m_perf_event
 perf event configured for IntelPT. More...
 

Detailed Description

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

Definition at line 28 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 109 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 216 of file IntelPTSingleBufferTrace.cpp.

◆ GetIptTraceSize()

size_t IntelPTSingleBufferTrace::GetIptTraceSize ( ) const
Returns
The total the size in bytes used by the intel pt trace buffer managed by this trace instance.

Definition at line 204 of file IntelPTSingleBufferTrace.cpp.

Referenced by lldb_private::process_linux::IntelPTPerThreadProcessTrace::GetState(), lldb_private::process_linux::IntelPTCollector::GetState(), and lldb_private::process_linux::IntelPTMultiCoreTrace::GetState().

◆ GetPerfEvent()

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

Definition at line 287 of file IntelPTSingleBufferTrace.cpp.

◆ 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 208 of file IntelPTSingleBufferTrace.cpp.

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 212 of file IntelPTSingleBufferTrace.cpp.

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

◆ Start()

Expected< IntelPTSingleBufferTrace > IntelPTSingleBufferTrace::Start ( const TraceIntelPTStartRequest request,
llvm::Optional< lldb::tid_t tid,
llvm::Optional< lldb::cpu_id_t cpu_id = llvm::None,
bool  disabled = false,
llvm::Optional< int >  cgroup_fd = llvm::None 
)
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 llvm::None, then the trace sesion will use cgroup filtering.
Returns
A IntelPTSingleBufferTrace instance if tracing was successful, or an llvm::Error otherwise.

Definition at line 234 of file IntelPTSingleBufferTrace.cpp.

References lldb_private::TraceIntelPTStartRequest::enable_tsc, lldb_private::GetLog(), lldb_private::TraceIntelPTStartRequest::ipt_trace_size, LLDB_LOG, and lldb_private::TraceIntelPTStartRequest::psb_period.

Member Data Documentation

◆ m_perf_event

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

perf event configured for IntelPT.

Definition at line 113 of file IntelPTSingleBufferTrace.h.


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