dwarf-regs.c revision e6817ec1d8ab31fc7b01906e305f848542df6413
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/* ANDROID_CHANGE_BEGIN */ 12#if 0 13#include <libio.h> 14#include <dwarf-regs.h> 15#else 16#include <stdio.h> 17#include "util/include/dwarf-regs.h" 18#endif 19/* ANDROID_CHANGE_END */ 20 21struct pt_regs_dwarfnum { 22 const char *name; 23 unsigned int dwarfnum; 24}; 25 26#define STR(s) #s 27#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} 28#define GPR_DWARFNUM_NAME(num) \ 29 {.name = STR(%r##num), .dwarfnum = num} 30#define REG_DWARFNUM_END {.name = 0, .dwarfnum = 0} 31 32/* 33 * Reference: 34 * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040a/IHI0040A_aadwarf.pdf 35 */ 36static const struct pt_regs_dwarfnum regdwarfnum_table[] = { 37 GPR_DWARFNUM_NAME(0), 38 GPR_DWARFNUM_NAME(1), 39 GPR_DWARFNUM_NAME(2), 40 GPR_DWARFNUM_NAME(3), 41 GPR_DWARFNUM_NAME(4), 42 GPR_DWARFNUM_NAME(5), 43 GPR_DWARFNUM_NAME(6), 44 GPR_DWARFNUM_NAME(7), 45 GPR_DWARFNUM_NAME(8), 46 GPR_DWARFNUM_NAME(9), 47 GPR_DWARFNUM_NAME(10), 48 REG_DWARFNUM_NAME("%fp", 11), 49 REG_DWARFNUM_NAME("%ip", 12), 50 REG_DWARFNUM_NAME("%sp", 13), 51 REG_DWARFNUM_NAME("%lr", 14), 52 REG_DWARFNUM_NAME("%pc", 15), 53 REG_DWARFNUM_END, 54}; 55 56/** 57 * get_arch_regstr() - lookup register name from it's DWARF register number 58 * @n: the DWARF register number 59 * 60 * get_arch_regstr() returns the name of the register in struct 61 * regdwarfnum_table from it's DWARF register number. If the register is not 62 * found in the table, this returns NULL; 63 */ 64const char *get_arch_regstr(unsigned int n) 65{ 66 const struct pt_regs_dwarfnum *roff; 67 for (roff = regdwarfnum_table; roff->name != NULL; roff++) 68 if (roff->dwarfnum == n) 69 return roff->name; 70 return NULL; 71} 72