LLDB mainline
|
Class that decodes a raw buffer for a single PSB block using the low level libipt library. More...
Public Member Functions | |
PSBBlockDecoder (PtInsnDecoderUP &&decoder_up, const PSBBlock &psb_block, std::optional< lldb::addr_t > next_block_ip, DecodedThread &decoded_thread, TraceIntelPT &trace_intel_pt, std::optional< DecodedThread::TSC > tsc_upper_bound) | |
void | DecodePSBBlock () |
Static Public Member Functions | |
static Expected< PSBBlockDecoder > | Create (TraceIntelPT &trace_intel_pt, const PSBBlock &psb_block, ArrayRef< uint8_t > buffer, Process &process, std::optional< lldb::addr_t > next_block_ip, DecodedThread &decoded_thread, std::optional< DecodedThread::TSC > tsc_upper_bound) |
Private Member Functions | |
bool | AppendInstructionAndDetectAnomalies (const pt_insn &insn) |
Append an instruction and return false if and only if a serious anomaly has been detected. | |
void | DecodeInstructionsAndEvents (int status) |
Decode all the instructions and events of the given PSB block. | |
Error | ProcessPTEventTSC (DecodedThread::TSC tsc) |
Process the TSC of a decoded PT event. | |
int | ProcessPTEvents (int status) |
Before querying instructions, we need to query the events associated with that instruction, e.g. | |
Private Attributes | |
PtInsnDecoderUP | m_decoder_up |
PSBBlock | m_psb_block |
std::optional< lldb::addr_t > | m_next_block_ip |
DecodedThread & | m_decoded_thread |
PSBBlockAnomalyDetector | m_anomaly_detector |
std::optional< DecodedThread::TSC > | m_tsc_upper_bound |
Class that decodes a raw buffer for a single PSB block using the low level libipt library.
It assumes that kernel and user mode instructions are not mixed in the same PSB block.
Throughout this code, the status of the decoder will be used to identify events needed to be processed or errors in the decoder. The values can be
Definition at line 319 of file LibiptDecoder.cpp.
|
inline |
[in] | decoder | A decoder configured to start and end within the boundaries of the given psb_block . |
[in] | psb_block | The PSB block to decode. |
[in] | next_block_ip | The starting ip at the next PSB block of the same thread if available. |
[in] | decoded_thread | A DecodedThread object where the decoded instructions will be appended to. It might have already some instructions. |
[in] | tsc_upper_bound | Maximum allowed value of TSCs decoded from this PSB block. Any of this PSB's data occurring after this TSC will be excluded. |
Definition at line 338 of file LibiptDecoder.cpp.
|
inlineprivate |
Append an instruction and return false if and only if a serious anomaly has been detected.
Definition at line 405 of file LibiptDecoder.cpp.
References lldb_private::trace_intel_pt::DecodedThread::AppendCustomError(), lldb_private::trace_intel_pt::DecodedThread::AppendInstruction(), PSBBlockAnomalyDetector::DetectAnomaly(), m_anomaly_detector, m_decoded_thread, and lldb_private::toString().
Referenced by DecodeInstructionsAndEvents().
|
inlinestatic |
[in] | trace_intel_pt | The main Trace object that own the PSB block. |
[in] | decoder | A decoder configured to start and end within the boundaries of the given psb_block . |
[in] | psb_block | The PSB block to decode. |
[in] | buffer | The raw intel pt trace for this block. |
[in] | process | The process to decode. It provides the memory image to use for decoding. |
[in] | next_block_ip | The starting ip at the next PSB block of the same thread if available. |
[in] | decoded_thread | A DecodedThread object where the decoded instructions will be appended to. It might have already some instructions. |
Definition at line 371 of file LibiptDecoder.cpp.
References CreateInstructionDecoder().
|
inlineprivate |
Decode all the instructions and events of the given PSB block.
The decoding loop might stop abruptly if an infinite decoding loop is detected.
Definition at line 418 of file LibiptDecoder.cpp.
References lldb_private::trace_intel_pt::DecodedThread::AppendError(), AppendInstructionAndDetectAnomalies(), IsEndOfStream(), IsLibiptError(), m_decoded_thread, m_decoder_up, m_next_block_ip, and ProcessPTEvents().
Referenced by DecodePSBBlock().
|
inline |
Definition at line 385 of file LibiptDecoder.cpp.
References DecodeInstructionsAndEvents(), m_decoded_thread, m_decoder_up, m_psb_block, lldb_private::trace_intel_pt::DecodedThread::NotifySyncPoint(), lldb_private::trace_intel_pt::DecodedThread::NotifyTsc(), lldb_private::trace_intel_pt::PSBBlock::psb_offset, and lldb_private::trace_intel_pt::PSBBlock::tsc.
|
inlineprivate |
Before querying instructions, we need to query the events associated with that instruction, e.g.
timing and trace disablement events.
[in] | status | The status gotten from the previous instruction decoding or PSB synchronization. |
Definition at line 508 of file LibiptDecoder.cpp.
References lldb_private::trace_intel_pt::DecodedThread::AppendError(), lldb_private::trace_intel_pt::DecodedThread::AppendEvent(), lldb::eTraceEventDisabledHW, lldb::eTraceEventDisabledSW, HasEvents(), IsLibiptError(), m_decoded_thread, m_decoder_up, and ProcessPTEventTSC().
Referenced by DecodeInstructionsAndEvents().
|
inlineprivate |
Process the TSC of a decoded PT event.
Specifically, check if this TSC is below the TSC upper bound for this PSB. If the TSC exceeds the upper bound, return an error to abort decoding. Otherwise add the it to the underlying DecodedThread and decoding should continue as expected.
[in] | tsc | The TSC of the a decoded event. |
Definition at line 471 of file LibiptDecoder.cpp.
References lldb_private::trace_intel_pt::DecodedThread::AppendCustomError(), IsLibiptError(), m_decoded_thread, m_decoder_up, m_psb_block, m_tsc_upper_bound, lldb_private::trace_intel_pt::DecodedThread::NotifyTsc(), and lldb_private::trace_intel_pt::PSBBlock::size.
Referenced by ProcessPTEvents().
|
private |
Definition at line 557 of file LibiptDecoder.cpp.
Referenced by AppendInstructionAndDetectAnomalies().
|
private |
Definition at line 556 of file LibiptDecoder.cpp.
Referenced by AppendInstructionAndDetectAnomalies(), DecodeInstructionsAndEvents(), DecodePSBBlock(), ProcessPTEvents(), and ProcessPTEventTSC().
|
private |
Definition at line 553 of file LibiptDecoder.cpp.
Referenced by DecodeInstructionsAndEvents(), DecodePSBBlock(), ProcessPTEvents(), and ProcessPTEventTSC().
|
private |
Definition at line 555 of file LibiptDecoder.cpp.
Referenced by DecodeInstructionsAndEvents().
|
private |
Definition at line 554 of file LibiptDecoder.cpp.
Referenced by DecodePSBBlock(), and ProcessPTEventTSC().
|
private |
Definition at line 558 of file LibiptDecoder.cpp.
Referenced by ProcessPTEventTSC().