0001
0002
0003
0004
0005
0006
0007 #ifndef INCLUDE__INTEL_PT_INSN_DECODER_H__
0008 #define INCLUDE__INTEL_PT_INSN_DECODER_H__
0009
0010 #include <stddef.h>
0011 #include <stdint.h>
0012
0013 #define INTEL_PT_INSN_DESC_MAX 32
0014 #define INTEL_PT_INSN_BUF_SZ 16
0015
0016 enum intel_pt_insn_op {
0017 INTEL_PT_OP_OTHER,
0018 INTEL_PT_OP_CALL,
0019 INTEL_PT_OP_RET,
0020 INTEL_PT_OP_JCC,
0021 INTEL_PT_OP_JMP,
0022 INTEL_PT_OP_LOOP,
0023 INTEL_PT_OP_IRET,
0024 INTEL_PT_OP_INT,
0025 INTEL_PT_OP_SYSCALL,
0026 INTEL_PT_OP_SYSRET,
0027 INTEL_PT_OP_VMENTRY,
0028 };
0029
0030 enum intel_pt_insn_branch {
0031 INTEL_PT_BR_NO_BRANCH,
0032 INTEL_PT_BR_INDIRECT,
0033 INTEL_PT_BR_CONDITIONAL,
0034 INTEL_PT_BR_UNCONDITIONAL,
0035 };
0036
0037 struct intel_pt_insn {
0038 enum intel_pt_insn_op op;
0039 enum intel_pt_insn_branch branch;
0040 bool emulated_ptwrite;
0041 int length;
0042 int32_t rel;
0043 unsigned char buf[INTEL_PT_INSN_BUF_SZ];
0044 };
0045
0046 int intel_pt_get_insn(const unsigned char *buf, size_t len, int x86_64,
0047 struct intel_pt_insn *intel_pt_insn);
0048
0049 const char *intel_pt_insn_name(enum intel_pt_insn_op op);
0050
0051 int intel_pt_insn_desc(const struct intel_pt_insn *intel_pt_insn, char *buf,
0052 size_t buf_len);
0053
0054 int intel_pt_insn_type(enum intel_pt_insn_op op);
0055
0056 #endif