Linux Perf
perf_regs.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ARCH_PERF_REGS_H
3 #define ARCH_PERF_REGS_H
4 
5 #include <stdlib.h>
6 #include <linux/types.h>
7 #include <asm/perf_regs.h>
8 
9 void perf_regs_load(u64 *regs);
10 
11 #ifndef HAVE_ARCH_X86_64_SUPPORT
12 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
13 #define PERF_REGS_MAX PERF_REG_X86_32_MAX
14 #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32
15 #else
16 #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
17  (1ULL << PERF_REG_X86_ES) | \
18  (1ULL << PERF_REG_X86_FS) | \
19  (1ULL << PERF_REG_X86_GS))
20 #define PERF_REGS_MASK (((1ULL << PERF_REG_X86_64_MAX) - 1) & ~REG_NOSUPPORT)
21 #define PERF_REGS_MAX PERF_REG_X86_64_MAX
22 #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64
23 #endif
24 #define PERF_REG_IP PERF_REG_X86_IP
25 #define PERF_REG_SP PERF_REG_X86_SP
26 
27 static inline const char *perf_reg_name(int id)
28 {
29  switch (id) {
30  case PERF_REG_X86_AX:
31  return "AX";
32  case PERF_REG_X86_BX:
33  return "BX";
34  case PERF_REG_X86_CX:
35  return "CX";
36  case PERF_REG_X86_DX:
37  return "DX";
38  case PERF_REG_X86_SI:
39  return "SI";
40  case PERF_REG_X86_DI:
41  return "DI";
42  case PERF_REG_X86_BP:
43  return "BP";
44  case PERF_REG_X86_SP:
45  return "SP";
46  case PERF_REG_X86_IP:
47  return "IP";
48  case PERF_REG_X86_FLAGS:
49  return "FLAGS";
50  case PERF_REG_X86_CS:
51  return "CS";
52  case PERF_REG_X86_SS:
53  return "SS";
54  case PERF_REG_X86_DS:
55  return "DS";
56  case PERF_REG_X86_ES:
57  return "ES";
58  case PERF_REG_X86_FS:
59  return "FS";
60  case PERF_REG_X86_GS:
61  return "GS";
62 #ifdef HAVE_ARCH_X86_64_SUPPORT
63  case PERF_REG_X86_R8:
64  return "R8";
65  case PERF_REG_X86_R9:
66  return "R9";
67  case PERF_REG_X86_R10:
68  return "R10";
69  case PERF_REG_X86_R11:
70  return "R11";
71  case PERF_REG_X86_R12:
72  return "R12";
73  case PERF_REG_X86_R13:
74  return "R13";
75  case PERF_REG_X86_R14:
76  return "R14";
77  case PERF_REG_X86_R15:
78  return "R15";
79 #endif /* HAVE_ARCH_X86_64_SUPPORT */
80  default:
81  return NULL;
82  }
83 
84  return NULL;
85 }
86 
87 #endif /* ARCH_PERF_REGS_H */
static const char * perf_reg_name(int id)
Definition: perf_regs.h:27
void perf_regs_load(u64 *regs)