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.
15 #include <dwarf-regs.h>
16 #include <linux/ptrace.h>
17 #include <linux/kernel.h>
18 #include <linux/stringify.h>
21 struct pt_regs_dwarfnum {
23 unsigned int dwarfnum;
24 unsigned int ptregs_offset;
27 #define REG_DWARFNUM_NAME(r, num) \
28 {.name = __stringify(%)__stringify(r), .dwarfnum = num, \
29 .ptregs_offset = offsetof(struct pt_regs, r)}
30 #define GPR_DWARFNUM_NAME(num) \
31 {.name = __stringify(%gpr##num), .dwarfnum = num, \
32 .ptregs_offset = offsetof(struct pt_regs, gpr[num])}
33 #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0}
37 * http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html
39 static const struct pt_regs_dwarfnum regdwarfnum_table[] = {
50 GPR_DWARFNUM_NAME(10),
51 GPR_DWARFNUM_NAME(11),
52 GPR_DWARFNUM_NAME(12),
53 GPR_DWARFNUM_NAME(13),
54 GPR_DWARFNUM_NAME(14),
55 GPR_DWARFNUM_NAME(15),
56 GPR_DWARFNUM_NAME(16),
57 GPR_DWARFNUM_NAME(17),
58 GPR_DWARFNUM_NAME(18),
59 GPR_DWARFNUM_NAME(19),
60 GPR_DWARFNUM_NAME(20),
61 GPR_DWARFNUM_NAME(21),
62 GPR_DWARFNUM_NAME(22),
63 GPR_DWARFNUM_NAME(23),
64 GPR_DWARFNUM_NAME(24),
65 GPR_DWARFNUM_NAME(25),
66 GPR_DWARFNUM_NAME(26),
67 GPR_DWARFNUM_NAME(27),
68 GPR_DWARFNUM_NAME(28),
69 GPR_DWARFNUM_NAME(29),
70 GPR_DWARFNUM_NAME(30),
71 GPR_DWARFNUM_NAME(31),
72 REG_DWARFNUM_NAME(msr, 66),
73 REG_DWARFNUM_NAME(ctr, 109),
74 REG_DWARFNUM_NAME(link, 108),
75 REG_DWARFNUM_NAME(xer, 101),
76 REG_DWARFNUM_NAME(dar, 119),
77 REG_DWARFNUM_NAME(dsisr, 118),
82 * get_arch_regstr() - lookup register name from it's DWARF register number
83 * @n: the DWARF register number
85 * get_arch_regstr() returns the name of the register in struct
86 * regdwarfnum_table from it's DWARF register number. If the register is not
87 * found in the table, this returns NULL;
89 const char *get_arch_regstr(unsigned int n)
91 const struct pt_regs_dwarfnum *roff;
92 for (roff = regdwarfnum_table; roff->name != NULL; roff++)
93 if (roff->dwarfnum == n)
98 int regs_query_register_offset(const char *name)
100 const struct pt_regs_dwarfnum *roff;
101 for (roff = regdwarfnum_table; roff->name != NULL; roff++)
102 if (!strcmp(roff->name, name))
103 return roff->ptregs_offset;