This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] gdb: Respect field width and alignment for 'fmt' fields in CLI output


*** TEST RESULTS FOR COMMIT 1871a62daf0561da0880ba1ad39e8191bc3cf1ac ***

Author: Andrew Burgess <andrew.burgess@embecosm.com>
Branch: master
Commit: 1871a62daf0561da0880ba1ad39e8191bc3cf1ac

gdb: Respect field width and alignment for 'fmt' fields in CLI output

Currently the method 'cli_ui_out::do_field_fmt' has this comment:

  /* This is the only field function that does not align.  */

The reality is even slightly worse, the 'fmt' field type doesn't
respect either the field alignment or the field width.  In at least
one place in GDB we attempt to work around this lack of respect for
field width by adding additional padding manually.  But, as is often
the case, this is leading to knock on problems.

Conside the output for 'info breakpoints' when a breakpoint has
multiple locations.  This example is taken from the testsuite, from
test gdb.opt/inline-break.exp:

  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
  1.1                     y     0x00000000004004ae in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
  1.2                     y     0x0000000000400682 in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64

The miss-alignment of the fields shown here is exactly as GDB
currently produces.

With this patch 'fmt' style fields are now first written into a
temporary buffer, and then written out as a 'string' field.  The
result is that the field width, and alignment should now be respected.
With this patch in place the output from GDB now looks like this:

  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  1       breakpoint     keep y   <MULTIPLE>
  1.1                         y   0x00000000004004ae in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
  1.2                         y   0x0000000000400682 in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64

This patch has been tested on x86-64/Linux with no regressions,
however, the testsuite doesn't always spot broken output formatting or
alignment.  I have also audited all uses of 'fmt' fields that I could
find, and I don't think there are any other places that specifically
try to work around the lack of width/alignment, however, I could have
missed something.

gdb/ChangeLog:

	* breakpoint.c (print_one_breakpoint_location): Reduce whitespace,
	and remove insertion of extra spaces in GDB's output.
	* cli-out.c (cli_ui_out::do_field_fmt): Update header comment.
	Layout field into a temporary buffer, and then output it as a
	string field.

gdb/testsuite/ChangeLog:

	* gdb.opt/inline-break.exp: Add test that info breakpoint output
	is correctly aligned.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]