GDB has the concept of user registers which are numbered above the usual num_regs + num_pseudo_regs count. This can be used to deal with register names like "pc", "fp" and "sp" if these are not explicitly named in the ordinary registers. "info reg sp" will print out the value of the stack pointer. This printing does not use the standard gdbarch_print_registers_info () function, but is done directly within registers_info () in infcmd.c. The problem is if I try to print multiple user registers. For example "info reg sp fp" will print sp fp: <the value of sp> fp: <the value of fp> I.e. the remainder of the string of register names is printed each time, rather than just the register concerned. The problem is within registers_info (), where the name of the register is printed using printf_filtered ("%s: ", start); either start needs to be temporarily terminated with a NULL at *end (is this string always mutable though), or a clean copy needs to be taken, used and then disposed of. I'll try to work out a patch, but logged here for the time being.
Testing a fix.
CVSROOT: /cvs/src Module name: src Changes by: tromey@sourceware.org 2012-02-15 19:13:14 Modified files: gdb : ChangeLog infcmd.c gdb/testsuite : ChangeLog gdb/testsuite/gdb.base: pc-fp.exp Log message: PR gdb/12659: * infcmd.c (registers_info): Print just the current register's name. gdb/testsuite * gdb.base/pc-fp.exp: Add "info register" tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13831&r2=1.13832 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/infcmd.c.diff?cvsroot=src&r1=1.296&r2=1.297 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3072&r2=1.3073 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/pc-fp.exp.diff?cvsroot=src&r1=1.18&r2=1.19
Fixed.