This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] mips-tdep: info registers
Daniel Jacobowitz wrote:
On Fri, Mar 06, 2009 at 12:00:31AM -0500, Aleksandar Ristovski wrote:
Maybe adding gdbarch_regname_to_regnum or something like that (which would
avoid iterating through the registers and comparing returned register
names).
Let's keep optimization separate from functionality; there's a
function in user-regs.h to do the lookup and if it's too slow it can
be converted to use a hash table.
I didn't really think about optimization, but I did not
understand what/how user-regs is being used. Now I realize
that is the mechanism for adding register aliases.
Here is another try.
(again, tested on in-house gdb variant).
ChangeLog:
* mips-tdep.c (mips_numeric_register_alieses): New definition.
(mips_gdbarch_init): Add user registers from
mips_numeric_register_aliases.
Index: gdb/mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.490
diff -u -p -r1.490 mips-tdep.c
--- gdb/mips-tdep.c 22 Feb 2009 01:02:17 -0000 1.490
+++ gdb/mips-tdep.c 6 Mar 2009 14:43:42 -0000
@@ -143,6 +143,15 @@ const struct register_alias mips_registe
{ "fsr", MIPS_EMBED_FP0_REGNUM + 32 }
};
+const struct register_alias mips_numeric_register_aliases[] = {
+#define R(n) { #n, n }
+ R(0), R(1), R(2), R(3), R(4), R(5), R(6), R(7),
+ R(8), R(9), R(10), R(11), R(12), R(13), R(14), R(15),
+ R(16), R(17), R(18), R(19), R(20), R(21), R(22), R(23),
+ R(24), R(25), R(26), R(27), R(28), R(29), R(30), R(31),
+#undef R
+};
+
#ifndef MIPS_DEFAULT_FPU_TYPE
#define MIPS_DEFAULT_FPU_TYPE MIPS_FPU_DOUBLE
#endif
@@ -6058,6 +6067,11 @@ mips_gdbarch_init (struct gdbarch_info i
user_reg_add (gdbarch, mips_register_aliases[i].name,
value_of_mips_user_reg, &mips_register_aliases[i].regnum);
+ for (i = 0; i < ARRAY_SIZE (mips_numeric_register_aliases); i++)
+ user_reg_add (gdbarch, mips_numeric_register_aliases[i].name,
+ value_of_mips_user_reg,
+ &mips_numeric_register_aliases[i].regnum);
+
return gdbarch;
}