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 Will Deacon, ARM Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 
11 #include <stdlib.h>
12 #ifndef __UCLIBC__
13 #include <libio.h>
14 #endif
15 #include <dwarf-regs.h>
16 
18  const char *name;
19  unsigned int dwarfnum;
20 };
21 
22 #define STR(s) #s
23 #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
24 #define GPR_DWARFNUM_NAME(num) \
25  {.name = STR(%r##num), .dwarfnum = num}
26 #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
27 
28 /*
29  * Reference:
30  * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040a/IHI0040A_aadwarf.pdf
31  */
32 static const struct pt_regs_dwarfnum regdwarfnum_table[] = {
44  REG_DWARFNUM_NAME("%fp", 11),
45  REG_DWARFNUM_NAME("%ip", 12),
46  REG_DWARFNUM_NAME("%sp", 13),
47  REG_DWARFNUM_NAME("%lr", 14),
48  REG_DWARFNUM_NAME("%pc", 15),
50 };
51 
60 const char *get_arch_regstr(unsigned int n)
61 {
62  const struct pt_regs_dwarfnum *roff;
63  for (roff = regdwarfnum_table; roff->name != NULL; roff++)
64  if (roff->dwarfnum == n)
65  return roff->name;
66  return NULL;
67 }