Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dwarf-regs.c
Go to the documentation of this file.
1 /*
2  * Mapping of DWARF debug register numbers into register names.
3  *
4  * Copyright (C) 2010 Ian Munsie, IBM Corporation.
5  *
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.
10  */
11 
12 #include <stdlib.h>
13 #ifndef __UCLIBC__
14 #include <libio.h>
15 #endif
16 #include <dwarf-regs.h>
17 
18 
19 struct pt_regs_dwarfnum {
20  const char *name;
21  unsigned int dwarfnum;
22 };
23 
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}
29 
30 /*
31  * Reference:
32  * http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html
33  */
34 static const struct pt_regs_dwarfnum regdwarfnum_table[] = {
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),
74 };
75 
84 const char *get_arch_regstr(unsigned int n)
85 {
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;
91 }