| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * intel_pt_insn_decoder.c: Intel Processor Trace support |
|---|
| 3 | 4 | * Copyright (c) 2013-2014, Intel Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | |
|---|
| 7 | +#include <linux/kernel.h> |
|---|
| 16 | 8 | #include <stdio.h> |
|---|
| 17 | 9 | #include <string.h> |
|---|
| 18 | 10 | #include <endian.h> |
|---|
| 19 | 11 | #include <byteswap.h> |
|---|
| 12 | +#include "../../../arch/x86/include/asm/insn.h" |
|---|
| 13 | + |
|---|
| 14 | +#include "../../../arch/x86/lib/inat.c" |
|---|
| 15 | +#include "../../../arch/x86/lib/insn.c" |
|---|
| 20 | 16 | |
|---|
| 21 | 17 | #include "event.h" |
|---|
| 22 | | - |
|---|
| 23 | | -#include "insn.h" |
|---|
| 24 | | - |
|---|
| 25 | | -#include "inat.c" |
|---|
| 26 | | -#include "insn.c" |
|---|
| 27 | 18 | |
|---|
| 28 | 19 | #include "intel-pt-insn-decoder.h" |
|---|
| 29 | 20 | #include "dump-insn.h" |
|---|
| .. | .. |
|---|
| 180 | 171 | return 0; |
|---|
| 181 | 172 | } |
|---|
| 182 | 173 | |
|---|
| 174 | +int arch_is_branch(const unsigned char *buf, size_t len, int x86_64) |
|---|
| 175 | +{ |
|---|
| 176 | + struct intel_pt_insn in; |
|---|
| 177 | + if (intel_pt_get_insn(buf, len, x86_64, &in) < 0) |
|---|
| 178 | + return -1; |
|---|
| 179 | + return in.branch != INTEL_PT_BR_NO_BRANCH; |
|---|
| 180 | +} |
|---|
| 181 | + |
|---|
| 183 | 182 | const char *dump_insn(struct perf_insn *x, uint64_t ip __maybe_unused, |
|---|
| 184 | 183 | u8 *inbuf, int inlen, int *lenp) |
|---|
| 185 | 184 | { |
|---|