LLDB  mainline
Classes | Typedefs | Functions | Variables
LibiptDecoder.cpp File Reference
#include "LibiptDecoder.h"
#include "TraceIntelPT.h"
#include "lldb/Target/Process.h"
Include dependency graph for LibiptDecoder.cpp:

Go to the source code of this file.

Classes

class  PSBBlockDecoder
 Class that decodes a raw buffer for a single PSB block using the low level libipt library. More...
 

Typedefs

using PtInsnDecoderUP = std::unique_ptr< pt_insn_decoder, decltype(InsnDecoderDeleter)>
 
using PtQueryDecoderUP = std::unique_ptr< pt_query_decoder, decltype(QueryDecoderDeleter)>
 

Functions

bool IsLibiptError (int status)
 
bool IsEndOfStream (int status)
 
bool HasEvents (int status)
 
static Expected< pt_config > CreateBasicLibiptConfig (TraceIntelPT &trace_intel_pt, ArrayRef< uint8_t > buffer)
 Create a basic configuration object limited to a given buffer that can be used for many different decoders. More...
 
static int ReadProcessMemory (uint8_t *buffer, size_t size, const pt_asid *, uint64_t pc, void *context)
 Callback used by libipt for reading the process memory. More...
 
static Error SetupMemoryImage (pt_insn_decoder *decoder, Process &process)
 Set up the memory image callback for the given decoder. More...
 
static Expected< PtInsnDecoderUPCreateInstructionDecoder (TraceIntelPT &trace_intel_pt, ArrayRef< uint8_t > buffer, Process &process)
 Create an instruction decoder for the given buffer and the given process. More...
 
static Expected< PtQueryDecoderUPCreateQueryDecoder (TraceIntelPT &trace_intel_pt, ArrayRef< uint8_t > buffer)
 Create a query decoder for the given buffer. More...
 

Variables

auto InsnDecoderDeleter
 
auto QueryDecoderDeleter
 

Typedef Documentation

◆ PtInsnDecoderUP

using PtInsnDecoderUP = std::unique_ptr<pt_insn_decoder, decltype(InsnDecoderDeleter)>

Definition at line 40 of file LibiptDecoder.cpp.

◆ PtQueryDecoderUP

using PtQueryDecoderUP = std::unique_ptr<pt_query_decoder, decltype(QueryDecoderDeleter)>

Definition at line 43 of file LibiptDecoder.cpp.

Function Documentation

◆ CreateBasicLibiptConfig()

static Expected<pt_config> CreateBasicLibiptConfig ( TraceIntelPT trace_intel_pt,
ArrayRef< uint8_t >  buffer 
)
static

Create a basic configuration object limited to a given buffer that can be used for many different decoders.

Definition at line 47 of file LibiptDecoder.cpp.

References lldb_private::trace_intel_pt::TraceIntelPT::GetCPUInfo(), and IsLibiptError().

Referenced by CreateInstructionDecoder(), and CreateQueryDecoder().

◆ CreateInstructionDecoder()

static Expected<PtInsnDecoderUP> CreateInstructionDecoder ( TraceIntelPT trace_intel_pt,
ArrayRef< uint8_t >  buffer,
Process process 
)
static

Create an instruction decoder for the given buffer and the given process.

Definition at line 96 of file LibiptDecoder.cpp.

References CreateBasicLibiptConfig(), InsnDecoderDeleter, and SetupMemoryImage().

Referenced by PSBBlockDecoder::Create().

◆ CreateQueryDecoder()

static Expected<PtQueryDecoderUP> CreateQueryDecoder ( TraceIntelPT trace_intel_pt,
ArrayRef< uint8_t >  buffer 
)
static

Create a query decoder for the given buffer.

The query decoder is the highest level decoder that operates directly on packets and doesn't perform actual instruction decoding. That's why it can be useful for inspecting a raw trace without pinning it to a particular process.

Definition at line 119 of file LibiptDecoder.cpp.

References CreateBasicLibiptConfig(), and QueryDecoderDeleter.

Referenced by lldb_private::trace_intel_pt::SplitTraceIntoPSBBlock().

◆ HasEvents()

bool HasEvents ( int  status)

◆ IsEndOfStream()

bool IsEndOfStream ( int  status)

Definition at line 19 of file LibiptDecoder.cpp.

Referenced by PSBBlockDecoder::DecodeInstructionsAndEvents().

◆ IsLibiptError()

bool IsLibiptError ( int  status)

◆ ReadProcessMemory()

static int ReadProcessMemory ( uint8_t *  buffer,
size_t  size,
const pt_asid *  ,
uint64_t  pc,
void *  context 
)
static

Callback used by libipt for reading the process memory.

More information can be found in https://github.com/intel/libipt/blob/master/doc/man/pt_image_set_callback.3.md

Definition at line 72 of file LibiptDecoder.cpp.

References error(), pc, and lldb_private::Process::ReadMemory().

Referenced by lldb_private::ProcessDebugger::ReadMemory(), and SetupMemoryImage().

◆ SetupMemoryImage()

static Error SetupMemoryImage ( pt_insn_decoder *  decoder,
Process process 
)
static

Set up the memory image callback for the given decoder.

Definition at line 85 of file LibiptDecoder.cpp.

References IsLibiptError(), and ReadProcessMemory().

Referenced by CreateInstructionDecoder().

Variable Documentation

◆ InsnDecoderDeleter

auto InsnDecoderDeleter
Initial value:
= [](pt_insn_decoder *decoder) {
pt_insn_free_decoder(decoder);
}

Definition at line 31 of file LibiptDecoder.cpp.

Referenced by CreateInstructionDecoder().

◆ QueryDecoderDeleter

auto QueryDecoderDeleter
Initial value:
= [](pt_query_decoder *decoder) {
pt_qry_free_decoder(decoder);
}

Definition at line 35 of file LibiptDecoder.cpp.

Referenced by CreateQueryDecoder().