1 // SPDX-License-Identifier: GPL-2.0
2 #include "archinsn.h"
3 #include "event.h"
4 #include "machine.h"
5 #include "thread.h"
6 #include "symbol.h"
7 #include "../../../../arch/x86/include/asm/insn.h"
8
arch_fetch_insn(struct perf_sample * sample,struct thread * thread,struct machine * machine)9 void arch_fetch_insn(struct perf_sample *sample,
10 struct thread *thread,
11 struct machine *machine)
12 {
13 struct insn insn;
14 int len, ret;
15 bool is64bit = false;
16
17 if (!sample->ip)
18 return;
19 len = thread__memcpy(thread, machine, sample->insn, sample->ip, sizeof(sample->insn), &is64bit);
20 if (len <= 0)
21 return;
22
23 ret = insn_decode(&insn, sample->insn, len,
24 is64bit ? INSN_MODE_64 : INSN_MODE_32);
25 if (ret >= 0 && insn.length <= len)
26 sample->insn_len = insn.length;
27 }
28