compat: Fix RT signal mask corruption via sigprocmask
[zen-stable.git] / tools / perf / arch / powerpc / util / dwarf-regs.c
blob7cdd61d0e27cd5fecd30c315fbc49724c5696a07
1 /*
2 * Mapping of DWARF debug register numbers into register names.
4 * Copyright (C) 2010 Ian Munsie, IBM Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <stdlib.h>
13 #ifndef __UCLIBC__
14 #include <libio.h>
15 #endif
16 #include <dwarf-regs.h>
19 struct pt_regs_dwarfnum {
20 const char *name;
21 unsigned int dwarfnum;
24 #define STR(s) #s
25 #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
26 #define GPR_DWARFNUM_NAME(num) \
27 {.name = STR(%gpr##num), .dwarfnum = num}
28 #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
31 * Reference:
32 * http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html
34 static const struct pt_regs_dwarfnum regdwarfnum_table[] = {
35 GPR_DWARFNUM_NAME(0),
36 GPR_DWARFNUM_NAME(1),
37 GPR_DWARFNUM_NAME(2),
38 GPR_DWARFNUM_NAME(3),
39 GPR_DWARFNUM_NAME(4),
40 GPR_DWARFNUM_NAME(5),
41 GPR_DWARFNUM_NAME(6),
42 GPR_DWARFNUM_NAME(7),
43 GPR_DWARFNUM_NAME(8),
44 GPR_DWARFNUM_NAME(9),
45 GPR_DWARFNUM_NAME(10),
46 GPR_DWARFNUM_NAME(11),
47 GPR_DWARFNUM_NAME(12),
48 GPR_DWARFNUM_NAME(13),
49 GPR_DWARFNUM_NAME(14),
50 GPR_DWARFNUM_NAME(15),
51 GPR_DWARFNUM_NAME(16),
52 GPR_DWARFNUM_NAME(17),
53 GPR_DWARFNUM_NAME(18),
54 GPR_DWARFNUM_NAME(19),
55 GPR_DWARFNUM_NAME(20),
56 GPR_DWARFNUM_NAME(21),
57 GPR_DWARFNUM_NAME(22),
58 GPR_DWARFNUM_NAME(23),
59 GPR_DWARFNUM_NAME(24),
60 GPR_DWARFNUM_NAME(25),
61 GPR_DWARFNUM_NAME(26),
62 GPR_DWARFNUM_NAME(27),
63 GPR_DWARFNUM_NAME(28),
64 GPR_DWARFNUM_NAME(29),
65 GPR_DWARFNUM_NAME(30),
66 GPR_DWARFNUM_NAME(31),
67 REG_DWARFNUM_NAME("%msr", 66),
68 REG_DWARFNUM_NAME("%ctr", 109),
69 REG_DWARFNUM_NAME("%link", 108),
70 REG_DWARFNUM_NAME("%xer", 101),
71 REG_DWARFNUM_NAME("%dar", 119),
72 REG_DWARFNUM_NAME("%dsisr", 118),
73 REG_DWARFNUM_END,
76 /**
77 * get_arch_regstr() - lookup register name from it's DWARF register number
78 * @n: the DWARF register number
80 * get_arch_regstr() returns the name of the register in struct
81 * regdwarfnum_table from it's DWARF register number. If the register is not
82 * found in the table, this returns NULL;
84 const char *get_arch_regstr(unsigned int n)
86 const struct pt_regs_dwarfnum *roff;
87 for (roff = regdwarfnum_table; roff->name != NULL; roff++)
88 if (roff->dwarfnum == n)
89 return roff->name;
90 return NULL;