WIP FPC-III support
[linux/fpc-iii.git] / tools / perf / arch / x86 / util / unwind-libunwind.c
blob47357973b55b208334b651120bd5a832d50861e3
1 // SPDX-License-Identifier: GPL-2.0
3 #include <errno.h>
4 #include "../../util/debug.h"
5 #ifndef REMOTE_UNWIND_LIBUNWIND
6 #include <libunwind.h>
7 #include "perf_regs.h"
8 #include "../../util/unwind.h"
9 #endif
11 #ifdef HAVE_ARCH_X86_64_SUPPORT
12 int LIBUNWIND__ARCH_REG_ID(int regnum)
14 int id;
16 switch (regnum) {
17 case UNW_X86_64_RAX:
18 id = PERF_REG_X86_AX;
19 break;
20 case UNW_X86_64_RDX:
21 id = PERF_REG_X86_DX;
22 break;
23 case UNW_X86_64_RCX:
24 id = PERF_REG_X86_CX;
25 break;
26 case UNW_X86_64_RBX:
27 id = PERF_REG_X86_BX;
28 break;
29 case UNW_X86_64_RSI:
30 id = PERF_REG_X86_SI;
31 break;
32 case UNW_X86_64_RDI:
33 id = PERF_REG_X86_DI;
34 break;
35 case UNW_X86_64_RBP:
36 id = PERF_REG_X86_BP;
37 break;
38 case UNW_X86_64_RSP:
39 id = PERF_REG_X86_SP;
40 break;
41 case UNW_X86_64_R8:
42 id = PERF_REG_X86_R8;
43 break;
44 case UNW_X86_64_R9:
45 id = PERF_REG_X86_R9;
46 break;
47 case UNW_X86_64_R10:
48 id = PERF_REG_X86_R10;
49 break;
50 case UNW_X86_64_R11:
51 id = PERF_REG_X86_R11;
52 break;
53 case UNW_X86_64_R12:
54 id = PERF_REG_X86_R12;
55 break;
56 case UNW_X86_64_R13:
57 id = PERF_REG_X86_R13;
58 break;
59 case UNW_X86_64_R14:
60 id = PERF_REG_X86_R14;
61 break;
62 case UNW_X86_64_R15:
63 id = PERF_REG_X86_R15;
64 break;
65 case UNW_X86_64_RIP:
66 id = PERF_REG_X86_IP;
67 break;
68 default:
69 pr_err("unwind: invalid reg id %d\n", regnum);
70 return -EINVAL;
73 return id;
75 #else
76 int LIBUNWIND__ARCH_REG_ID(int regnum)
78 int id;
80 switch (regnum) {
81 case UNW_X86_EAX:
82 id = PERF_REG_X86_AX;
83 break;
84 case UNW_X86_EDX:
85 id = PERF_REG_X86_DX;
86 break;
87 case UNW_X86_ECX:
88 id = PERF_REG_X86_CX;
89 break;
90 case UNW_X86_EBX:
91 id = PERF_REG_X86_BX;
92 break;
93 case UNW_X86_ESI:
94 id = PERF_REG_X86_SI;
95 break;
96 case UNW_X86_EDI:
97 id = PERF_REG_X86_DI;
98 break;
99 case UNW_X86_EBP:
100 id = PERF_REG_X86_BP;
101 break;
102 case UNW_X86_ESP:
103 id = PERF_REG_X86_SP;
104 break;
105 case UNW_X86_EIP:
106 id = PERF_REG_X86_IP;
107 break;
108 default:
109 pr_err("unwind: invalid reg id %d\n", regnum);
110 return -EINVAL;
113 return id;
115 #endif /* HAVE_ARCH_X86_64_SUPPORT */