LLDB  mainline
Functions
IntelPTDecoder.cpp File Reference
#include "IntelPTDecoder.h"
#include "llvm/Support/MemoryBuffer.h"
#include "../common/ThreadPostMortemTrace.h"
#include "DecodedThread.h"
#include "TraceIntelPT.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/StringExtractor.h"
Include dependency graph for IntelPTDecoder.cpp:

Go to the source code of this file.

Functions

static int FindNextSynchronizationPoint (pt_insn_decoder &decoder)
 Move the decoder forward to the next synchronization point (i.e. More...
 
static int ProcessPTEvents (pt_insn_decoder &decoder, int errcode)
 Before querying instructions, we need to query the events associated that instruction e.g. More...
 
static std::vector< IntelPTInstructionDecodeInstructions (pt_insn_decoder &decoder)
 Decode all the instructions from a configured decoder. 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 Expected< std::vector< IntelPTInstruction > > DecodeInMemoryTrace (Process &process, TraceIntelPT &trace_intel_pt, MutableArrayRef< uint8_t > buffer)
 
static Expected< std::vector< IntelPTInstruction > > DecodeTraceFile (Process &process, TraceIntelPT &trace_intel_pt, const FileSpec &trace_file, size_t &raw_trace_size)
 
static Expected< std::vector< IntelPTInstruction > > DecodeLiveThread (Thread &thread, TraceIntelPT &trace, size_t &raw_trace_size)
 

Function Documentation

◆ DecodeInMemoryTrace()

static Expected<std::vector<IntelPTInstruction> > DecodeInMemoryTrace ( Process process,
TraceIntelPT trace_intel_pt,
MutableArrayRef< uint8_t >  buffer 
)
static

◆ DecodeInstructions()

static std::vector<IntelPTInstruction> DecodeInstructions ( pt_insn_decoder &  decoder)
static

Decode all the instructions from a configured decoder.

The decoding flow is based on https://github.com/intel/libipt/blob/master/doc/howto_libipt.md#the-instruction-flow-decode-loop but with some relaxation to allow for gaps in the trace.

Error codes returned by libipt while decoding are:

  • negative: actual errors
  • positive or zero: not an error, but a list of bits signaling the status of the decoder
Parameters
[in]decoderA configured libipt pt_insn_decoder.
Returns
The decoded instructions.

Definition at line 108 of file IntelPTDecoder.cpp.

References FindNextSynchronizationPoint(), and ProcessPTEvents().

Referenced by DecodeInMemoryTrace().

◆ DecodeLiveThread()

static Expected<std::vector<IntelPTInstruction> > DecodeLiveThread ( Thread thread,
TraceIntelPT trace,
size_t &  raw_trace_size 
)
static

◆ DecodeTraceFile()

static Expected<std::vector<IntelPTInstruction> > DecodeTraceFile ( Process process,
TraceIntelPT trace_intel_pt,
const FileSpec trace_file,
size_t &  raw_trace_size 
)
static

◆ FindNextSynchronizationPoint()

static int FindNextSynchronizationPoint ( pt_insn_decoder &  decoder)
static

Move the decoder forward to the next synchronization point (i.e.

next PSB packet).

Once the decoder is at that sync. point, it can start decoding instructions.

Returns
A negative number with the libipt error if we couldn't synchronize. Otherwise, a positive number with the synchronization status will be returned.

Definition at line 34 of file IntelPTDecoder.cpp.

Referenced by DecodeInstructions().

◆ ProcessPTEvents()

static int ProcessPTEvents ( pt_insn_decoder &  decoder,
int  errcode 
)
static

Before querying instructions, we need to query the events associated that instruction e.g.

timing events like ptev_tick, or paging events like ptev_paging.

Returns
0 if there were no errors processing the events, or a negative libipt error code in case of errors.

Definition at line 82 of file IntelPTDecoder.cpp.

Referenced by DecodeInstructions().

◆ 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 167 of file IntelPTDecoder.cpp.

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

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