Bug 12659 - info register with multiple user registers mangles output
Summary: info register with multiple user registers mangles output
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.2
: P2 minor
Target Milestone: 7.5
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-09 18:14 UTC by Jeremy Bennett
Modified: 2012-02-15 19:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Bennett 2011-04-09 18:14:28 UTC
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.
Comment 1 Tom Tromey 2012-02-15 19:01:10 UTC
Testing a fix.
Comment 2 Sourceware Commits 2012-02-15 19:13:21 UTC
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
Comment 3 Tom Tromey 2012-02-15 19:14:48 UTC
Fixed.