xref: /kernel/linux/linux-6.6/tools/perf/arch/x86/util/archinsn.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/tools/perf/arch/x86/util/
162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#include "archinsn.h"
362306a36Sopenharmony_ci#include "event.h"
462306a36Sopenharmony_ci#include "machine.h"
562306a36Sopenharmony_ci#include "thread.h"
662306a36Sopenharmony_ci#include "symbol.h"
762306a36Sopenharmony_ci#include "../../../../arch/x86/include/asm/insn.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_civoid arch_fetch_insn(struct perf_sample *sample,
1062306a36Sopenharmony_ci		     struct thread *thread,
1162306a36Sopenharmony_ci		     struct machine *machine)
1262306a36Sopenharmony_ci{
1362306a36Sopenharmony_ci	struct insn insn;
1462306a36Sopenharmony_ci	int len, ret;
1562306a36Sopenharmony_ci	bool is64bit = false;
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci	if (!sample->ip)
1862306a36Sopenharmony_ci		return;
1962306a36Sopenharmony_ci	len = thread__memcpy(thread, machine, sample->insn, sample->ip, sizeof(sample->insn), &is64bit);
2062306a36Sopenharmony_ci	if (len <= 0)
2162306a36Sopenharmony_ci		return;
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci	ret = insn_decode(&insn, sample->insn, len,
2462306a36Sopenharmony_ci			  is64bit ? INSN_MODE_64 : INSN_MODE_32);
2562306a36Sopenharmony_ci	if (ret >= 0 && insn.length <= len)
2662306a36Sopenharmony_ci		sample->insn_len = insn.length;
2762306a36Sopenharmony_ci}
28

Indexes created Thu Nov 07 10:32:03 CST 2024