+2019-11-22 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * dwarf.c (typedef dwarf_regname_lookup_ftype): New typedef.
+ (dwarf_regnames_lookup_func): New static global.
+ (init_dwarf_regnames_i386): Set dwarf_regnames_lookup_func.
+ (init_dwarf_regnames_iamcu): Likewise.
+ (init_dwarf_regnames_x86_64): Likewise.
+ (init_dwarf_regnames_aarch64): Likewise.
+ (init_dwarf_regnames_s390): Likewise.
+ (init_dwarf_regnames_riscv): Likewise.
+ (init_dwarf_regnames_by_elf_machine_code): Reset
+ dwarf_regnames_lookup_func to NULL.
+ (init_dwarf_regnames_by_bfd_arch_and_mach): Likewise.
+ (regname_internal_by_table_only): New function.
+ (regname): Make use of dwarf_regnames_lookup_func.
+
2019-11-22 Andrew Burgess <andrew.burgess@embecosm.com>
* dwarf.c (init_dwarf_regnames_i386): Make static.
#define MIN(a, b) ((a) < (b) ? (a) : (b))
static const char *regname (unsigned int regno, int row);
+static const char *regname_internal_by_table_only (unsigned int regno);
static int have_frame_base;
static int need_base_address;
}
Frame_Chunk;
+typedef const char *(*dwarf_regname_lookup_ftype) (unsigned int);
+static dwarf_regname_lookup_ftype dwarf_regnames_lookup_func;
static const char *const *dwarf_regnames;
static unsigned int dwarf_regnames_count;
+
/* A marker for a col_type that means this column was never referenced
in the frame info. */
#define DW_CFA_unreferenced (-1)
{
dwarf_regnames = dwarf_regnames_i386;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_i386);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static void
{
dwarf_regnames = dwarf_regnames_iamcu;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_x86_64[] =
{
dwarf_regnames = dwarf_regnames_x86_64;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_x86_64);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_aarch64[] =
{
dwarf_regnames = dwarf_regnames_aarch64;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_aarch64);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_s390[] =
{
dwarf_regnames = dwarf_regnames_s390;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_s390);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
static const char *const dwarf_regnames_riscv[] =
{
dwarf_regnames = dwarf_regnames_riscv;
dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_riscv);
+ dwarf_regnames_lookup_func = regname_internal_by_table_only;
}
void
init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine)
{
+ dwarf_regnames_lookup_func = NULL;
+
switch (e_machine)
{
case EM_386:
init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch,
unsigned long mach)
{
+ dwarf_regnames_lookup_func = NULL;
+
switch (arch)
{
case bfd_arch_i386:
}
static const char *
-regname (unsigned int regno, int row)
+regname_internal_by_table_only (unsigned int regno)
{
- static char reg[64];
-
- if (dwarf_regnames
+ if (dwarf_regnames != NULL
&& regno < dwarf_regnames_count
&& dwarf_regnames [regno] != NULL)
+ return dwarf_regnames [regno];
+
+ return NULL;
+}
+
+static const char *
+regname (unsigned int regno, int name_only_p)
+{
+ static char reg[64];
+
+ const char *name = NULL;
+
+ if (dwarf_regnames_lookup_func != NULL)
+ name = dwarf_regnames_lookup_func (regno);
+
+ if (name != NULL)
{
- if (row)
- return dwarf_regnames [regno];
- snprintf (reg, sizeof (reg), "r%d (%s)", regno,
- dwarf_regnames [regno]);
+ if (name_only_p)
+ return name;
+ snprintf (reg, sizeof (reg), "r%d (%s)", regno, name);
}
else
snprintf (reg, sizeof (reg), "r%d", regno);