Linux Perf
|
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include <inttypes.h>
#include <linux/compiler.h>
#include "../cache.h"
#include "../util.h"
#include "intel-pt-insn-decoder.h"
#include "intel-pt-pkt-decoder.h"
#include "intel-pt-decoder.h"
#include "intel-pt-log.h"
Go to the source code of this file.
Classes | |
struct | intel_pt_blk |
struct | intel_pt_stack |
struct | intel_pt_decoder |
struct | intel_pt_pkt_info |
struct | intel_pt_calc_cyc_to_tsc_info |
Macros | |
#define | _GNU_SOURCE |
#define | INTEL_PT_BLK_SIZE 1024 |
#define | BIT63 (((uint64_t)1 << 63)) |
#define | INTEL_PT_RETURN 1 |
#define | INTEL_PT_MAX_LOOPS 10000 |
#define | INTEL_PT_STATE_ERR1 (decoder->pkt_state) |
#define | INTEL_PT_STATE_ERR2 INTEL_PT_STATE_NO_IP |
#define | INTEL_PT_STATE_ERR3 INTEL_PT_STATE_ERR_RESYNC |
#define | INTEL_PT_STATE_ERR4 INTEL_PT_STATE_IN_SYNC |
Typedefs | |
typedef int(* | intel_pt_pkt_cb_t) (struct intel_pt_pkt_info *pkt_info) |
Functions | |
static bool | intel_pt_sample_time (enum intel_pt_pkt_state pkt_state) |
static uint64_t | intel_pt_lower_power_of_2 (uint64_t x) |
static void | intel_pt_setup_period (struct intel_pt_decoder *decoder) |
static uint64_t | multdiv (uint64_t t, uint32_t n, uint32_t d) |
struct intel_pt_decoder * | intel_pt_decoder_new (struct intel_pt_params *params) |
static void | intel_pt_pop_blk (struct intel_pt_stack *stack) |
static uint64_t | intel_pt_pop (struct intel_pt_stack *stack) |
static int | intel_pt_alloc_blk (struct intel_pt_stack *stack) |
static int | intel_pt_push (struct intel_pt_stack *stack, uint64_t ip) |
static void | intel_pt_clear_stack (struct intel_pt_stack *stack) |
static void | intel_pt_free_stack (struct intel_pt_stack *stack) |
void | intel_pt_decoder_free (struct intel_pt_decoder *decoder) |
static int | intel_pt_ext_err (int code) |
int | intel_pt__strerror (int code, char *buf, size_t buflen) |
static uint64_t | intel_pt_calc_ip (const struct intel_pt_pkt *packet, uint64_t last_ip) |
static void | intel_pt_set_last_ip (struct intel_pt_decoder *decoder) |
static void | intel_pt_set_ip (struct intel_pt_decoder *decoder) |
static void | intel_pt_decoder_log_packet (struct intel_pt_decoder *decoder) |
static int | intel_pt_bug (struct intel_pt_decoder *decoder) |
static void | intel_pt_clear_tx_flags (struct intel_pt_decoder *decoder) |
static void | intel_pt_update_in_tx (struct intel_pt_decoder *decoder) |
static int | intel_pt_bad_packet (struct intel_pt_decoder *decoder) |
static int | intel_pt_get_data (struct intel_pt_decoder *decoder) |
static int | intel_pt_get_next_data (struct intel_pt_decoder *decoder) |
static int | intel_pt_get_split_packet (struct intel_pt_decoder *decoder) |
static int | intel_pt_pkt_lookahead (struct intel_pt_decoder *decoder, intel_pt_pkt_cb_t cb, void *data) |
static void | intel_pt_fixup_last_mtc (uint32_t mtc, int mtc_shift, uint32_t *last_mtc) |
static int | intel_pt_calc_cyc_cb (struct intel_pt_pkt_info *pkt_info) |
static void | intel_pt_calc_cyc_to_tsc (struct intel_pt_decoder *decoder, bool from_mtc) |
static int | intel_pt_get_next_packet (struct intel_pt_decoder *decoder) |
static uint64_t | intel_pt_next_period (struct intel_pt_decoder *decoder) |
static uint64_t | intel_pt_next_sample (struct intel_pt_decoder *decoder) |
static void | intel_pt_sample_insn (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_insn (struct intel_pt_decoder *decoder, struct intel_pt_insn *intel_pt_insn, uint64_t ip) |
static bool | intel_pt_fup_event (struct intel_pt_decoder *decoder) |
static bool | intel_pt_fup_with_nlip (struct intel_pt_decoder *decoder, struct intel_pt_insn *intel_pt_insn, uint64_t ip, int err) |
static int | intel_pt_walk_fup (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_tip (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_tnt (struct intel_pt_decoder *decoder) |
static int | intel_pt_mode_tsx (struct intel_pt_decoder *decoder, bool *no_tip) |
static void | intel_pt_calc_tsc_timestamp (struct intel_pt_decoder *decoder) |
static int | intel_pt_overflow (struct intel_pt_decoder *decoder) |
static void | intel_pt_calc_tma (struct intel_pt_decoder *decoder) |
static void | intel_pt_calc_mtc_timestamp (struct intel_pt_decoder *decoder) |
static void | intel_pt_calc_cbr (struct intel_pt_decoder *decoder) |
static void | intel_pt_calc_cyc_timestamp (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_psbend (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_fup_tip (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_trace (struct intel_pt_decoder *decoder) |
static bool | intel_pt_have_ip (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_psb (struct intel_pt_decoder *decoder) |
static int | intel_pt_walk_to_ip (struct intel_pt_decoder *decoder) |
static int | intel_pt_sync_ip (struct intel_pt_decoder *decoder) |
static int | intel_pt_part_psb (struct intel_pt_decoder *decoder) |
static int | intel_pt_rest_psb (struct intel_pt_decoder *decoder, int part_psb) |
static int | intel_pt_get_split_psb (struct intel_pt_decoder *decoder, int part_psb) |
static int | intel_pt_scan_for_psb (struct intel_pt_decoder *decoder) |
static int | intel_pt_sync (struct intel_pt_decoder *decoder) |
static uint64_t | intel_pt_est_timestamp (struct intel_pt_decoder *decoder) |
const struct intel_pt_state * | intel_pt_decode (struct intel_pt_decoder *decoder) |
static bool | intel_pt_next_psb (unsigned char **buf, size_t *len) |
static bool | intel_pt_step_psb (unsigned char **buf, size_t *len) |
static unsigned char * | intel_pt_last_psb (unsigned char *buf, size_t len) |
static bool | intel_pt_next_tsc (unsigned char *buf, size_t len, uint64_t *tsc, size_t *rem) |
static int | intel_pt_tsc_cmp (uint64_t tsc1, uint64_t tsc2) |
static unsigned char * | intel_pt_find_overlap_tsc (unsigned char *buf_a, size_t len_a, unsigned char *buf_b, size_t len_b, bool *consecutive) |
unsigned char * | intel_pt_find_overlap (unsigned char *buf_a, size_t len_a, unsigned char *buf_b, size_t len_b, bool have_tsc, bool *consecutive) |
Variables | |
static const char * | intel_pt_err_msgs [] |
#define _GNU_SOURCE |
Definition at line 17 of file intel-pt-decoder.c.
#define BIT63 (((uint64_t)1 << 63)) |
Definition at line 37 of file intel-pt-decoder.c.
#define INTEL_PT_BLK_SIZE 1024 |
Definition at line 35 of file intel-pt-decoder.c.
#define INTEL_PT_MAX_LOOPS 10000 |
Definition at line 42 of file intel-pt-decoder.c.
#define INTEL_PT_RETURN 1 |
Definition at line 39 of file intel-pt-decoder.c.
#define INTEL_PT_STATE_ERR1 (decoder->pkt_state) |
Definition at line 92 of file intel-pt-decoder.c.
#define INTEL_PT_STATE_ERR2 INTEL_PT_STATE_NO_IP |
Definition at line 93 of file intel-pt-decoder.c.
#define INTEL_PT_STATE_ERR3 INTEL_PT_STATE_ERR_RESYNC |
Definition at line 94 of file intel-pt-decoder.c.
#define INTEL_PT_STATE_ERR4 INTEL_PT_STATE_IN_SYNC |
Definition at line 95 of file intel-pt-decoder.c.
typedef int(* intel_pt_pkt_cb_t) (struct intel_pt_pkt_info *pkt_info) |
Definition at line 576 of file intel-pt-decoder.c.
enum intel_pt_pkt_state |
Definition at line 55 of file intel-pt-decoder.c.
int intel_pt__strerror | ( | int | code, |
char * | buf, | ||
size_t | buflen | ||
) |
Definition at line 392 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
Definition at line 452 of file intel-pt-decoder.c.
|
static |
Definition at line 1474 of file intel-pt-decoder.c.
|
static |
|
static |
Definition at line 1487 of file intel-pt-decoder.c.
|
static |
|
static |
Definition at line 400 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
|
static |
|
inlinestatic |
Definition at line 459 of file intel-pt-decoder.c.
const struct intel_pt_state* intel_pt_decode | ( | struct intel_pt_decoder * | decoder | ) |
void intel_pt_decoder_free | ( | struct intel_pt_decoder * | decoder | ) |
|
static |
Definition at line 446 of file intel-pt-decoder.c.
struct intel_pt_decoder* intel_pt_decoder_new | ( | struct intel_pt_params * | params | ) |
|
static |
Definition at line 2319 of file intel-pt-decoder.c.
|
static |
Definition at line 353 of file intel-pt-decoder.c.
unsigned char* intel_pt_find_overlap | ( | unsigned char * | buf_a, |
size_t | len_a, | ||
unsigned char * | buf_b, | ||
size_t | len_b, | ||
bool | have_tsc, | ||
bool * | consecutive | ||
) |
intel_pt_find_overlap - determine start of non-overlapped trace data. : first buffer : size of first buffer : second buffer : size of second buffer : can use TSC packets to detect overlap : returns true if there is data in buf_b that is consecutive to buf_a
When trace samples or snapshots are recorded there is the possibility that the data overlaps. Note that, for the purposes of decoding, data is only useful if it begins with a PSB packet.
Return: A pointer into from where non-overlapped data starts, or + if there is no non-overlapped data.
Definition at line 2641 of file intel-pt-decoder.c.
|
static |
intel_pt_find_overlap_tsc - determine start of non-overlapped trace data using TSC. : first buffer : size of first buffer : second buffer : size of second buffer : returns true if there is data in buf_b that is consecutive to buf_a
If the trace contains TSC we can look at the last TSC of and the first TSC of in order to determine if the buffers overlap, and then walk forward in until a later TSC is found. A precondition is that and are positioned at a PSB.
Return: A pointer into from where non-overlapped data starts, or + if there is no non-overlapped data.
Definition at line 2580 of file intel-pt-decoder.c.
|
static |
Definition at line 640 of file intel-pt-decoder.c.
|
static |
|
static |
Definition at line 1052 of file intel-pt-decoder.c.
|
inlinestatic |
Definition at line 1103 of file intel-pt-decoder.c.
|
static |
Definition at line 483 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
|
static |
|
inlinestatic |
Definition at line 1951 of file intel-pt-decoder.c.
|
static |
intel_pt_last_psb - find the last PSB packet in a buffer. : buffer : size of buffer
This function finds the last PSB in a buffer.
Return: A pointer to the last PSB in if found, NULL otherwise.
Definition at line 2471 of file intel-pt-decoder.c.
|
static |
Definition at line 184 of file intel-pt-decoder.c.
|
static |
|
static |
Definition at line 887 of file intel-pt-decoder.c.
|
static |
intel_pt_next_psb - move buffer pointer to the start of the next PSB packet. : pointer to buffer pointer : size of buffer
Updates the buffer pointer to point to the start of the next PSB packet if there is one, otherwise the buffer pointer is unchanged. If is updated, is adjusted accordingly.
Return: true if a PSB packet is found, false otherwise.
Definition at line 2421 of file intel-pt-decoder.c.
|
static |
|
static |
intel_pt_next_tsc - find and return next TSC. : buffer : size of buffer : TSC value returned : returns remaining size when TSC is found
Find a TSC packet in and return the TSC value. This function assumes that starts at a PSB and that PSB+ will contain TSC and so stops if a PSBEND packet is found.
Return: true if TSC is found, false otherwise.
Definition at line 2506 of file intel-pt-decoder.c.
|
static |
|
static |
Definition at line 2200 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 2214 of file intel-pt-decoder.c.
|
static |
Definition at line 921 of file intel-pt-decoder.c.
|
inlinestatic |
Definition at line 67 of file intel-pt-decoder.c.
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
intel_pt_step_psb - move buffer pointer to the start of the following PSB packet. : pointer to buffer pointer : size of buffer
Updates the buffer pointer to point to the start of the following PSB packet (skipping the PSB at itself) if there is one, otherwise the buffer pointer is unchanged. If is updated, is adjusted accordingly.
Return: true if a PSB packet is found, false otherwise.
Definition at line 2446 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
intel_pt_tsc_cmp - compare 7-byte TSCs. : first TSC to compare : second TSC to compare
This function compares 7-byte TSC values allowing for the possibility that TSC wrapped around. Generally it is not possible to know if TSC has wrapped around so for that purpose this function assumes the absolute difference is less than half the maximum difference.
Return: %-1 if is before , %0 if == , %1 if is after .
Definition at line 2542 of file intel-pt-decoder.c.
|
inlinestatic |
Definition at line 464 of file intel-pt-decoder.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 205 of file intel-pt-decoder.c.
|
static |
Definition at line 379 of file intel-pt-decoder.c.