Go to file
Simon Marchi 335709bc5a gdb: make "set debug timestamp" work nice with new debug printouts
New in v2:

- implement by modifying vprintf_unfiltered rather than
  debug_prefixed_vprintf.

I tried enabling debug timestamps, and realized that it doesn't play
well with the revamp of the debug printouts I've been working on:

    $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out
    Reading symbols from a.out...
    (gdb) start
    Temporary breakpoint 1 at 0x1131: file test.c, line 2.
    Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out
    939897.769338 [infrun] infrun_async:
    939897.769383 enable=1
    939897.769409
    939897.915218 [infrun] proceed:
    939897.915281 addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0
    939897.915315
    939897.915417 [infrun] start_step_over:
    939897.915464 stealing global queue of threads to step, length = 0
    939897.915502
    939897.915567 [infrun] operator():
    939897.915601 step-over queue now empty
    939897.915633
    939897.915690 [infrun] proceed:
    939897.915729 resuming process 636244
    939897.915768
    939897.915892 [infrun] resume_1:
    939897.915954 step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 636244] at 0x7ffff7fd0100
    939897.915991
    939897.916119 [infrun] prepare_to_wait:
    939897.916153 prepare_to_wait
    939897.916201
    939897.916661 [infrun] target_wait (-1.0.0, status) =
    [infrun]   636244.636244.0 [process 636244],
    [infrun]   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    939897.916734 [infrun] handle_inferior_event:
    939897.916768 status->kind = stopped, signal = GDB_SIGNAL_TRAP
    939897.916799

This is due to debug_prefixed_vprintf being implemented as three
separate calls to debug_printf / debug_vprintf.  Each call gets its own
timestamp and newline, curtesy of vprintf_unfiltered.

My first idea was to add a "line_start" parameter to debug_vprintf,
allowing the caller to say whether the print is the start of the line.
A debug timestamp would only be printed if line_start was true.
However, that was much more invasive than the simple fix implemented in
this patch.

My second idea was to make debug_prefixed_vprintf use string_printf and
issue a single call to debug_printf.  That would however prevent future
use of styling in the debug messages.

What is implemented in this patch is the same as is implemented in
GDBserver: the timestamp-printing code in GDB tracks whether the last
debug output ended with a newline.  If so, it prints a timestamp on the
next debug output.

After the fix, it looks like this:

    $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out
    Reading symbols from a.out...
    (gdb) start
    Temporary breakpoint 1 at 0x1131: file test.c, line 2.
    Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out
    941112.135662 [infrun] infrun_async: enable=1
    941112.279930 [infrun] proceed: addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0
    941112.280064 [infrun] start_step_over: stealing global queue of threads to step, length = 0
    941112.280125 [infrun] operator(): step-over queue now empty
    941112.280194 [infrun] proceed: resuming process 646228
    941112.280332 [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 646228] at 0x7ffff7fd0100
    941112.280480 [infrun] prepare_to_wait: prepare_to_wait
    941112.281004 [infrun] target_wait (-1.0.0, status) =
    [infrun]   646228.646228.0 [process 646228],
    [infrun]   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    941112.281078 [infrun] handle_inferior_event: status->kind = stopped, signal = GDB_SIGNAL_TRAP

gdb/ChangeLog:

	* utils.c (vfprintf_unfiltered): Print timestamp only when
	previous debug output ended with a newline.

Change-Id: Idcfe3acc7e3d0f526a5f0a43a5e0884bf93c41ae
2021-01-04 12:00:07 -05:00
bfd When displaying ARM private file flag bits, use a 0x prefix. 2021-01-04 15:13:57 +00:00
binutils PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
config PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
contrib Import mklog.py from gcc repo 2020-09-25 10:24:44 -04:00
cpu Fix spelling mistakes 2020-10-05 14:20:15 +01:00
elfcpp Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
etc Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
gas PR27102, gas: "section symbols are already global" 2021-01-04 18:58:15 +10:30
gdb gdb: make "set debug timestamp" work nice with new debug printouts 2021-01-04 12:00:07 -05:00
gdbserver Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
gdbsupport Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
gnulib Update copyright year range in all GDB files 2021-01-01 12:12:21 +04:00
gold PR27140, ppc32 segmentation fault in make_stub 2021-01-03 12:49:47 +10:30
gprof PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
include PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
intl
ld PR26822, How to prevent a STT_FILE with absolute path in the linked image 2021-01-04 18:58:15 +10:30
libctf In libctf, make AC_CONFIG_MACRO_DIR consistent with ACLOCAL_AMFLAGS 2021-01-04 11:08:05 +10:30
libdecnumber Run autoreconf -vf throughout 2020-07-29 16:03:55 -04:00
libiberty PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
opcodes PR27116, Spelling errors found by Debian style checker 2021-01-01 14:36:35 +10:30
readline Update readline/README to mention patchlevel 2020-06-30 15:17:07 -06:00
sim sim: common: add align_{up,down} to match gdb 2021-01-02 20:55:21 -05:00
texinfo
zlib
.cvsignore
.gitattributes
.gitignore Add gnu global outputs to .gitignore 2020-12-02 10:00:27 -05:00
ar-lib
ChangeLog [gdb] Print progress for debuginfod 2020-12-16 18:18:40 +01:00
compile
config-ml.in
config.guess
config.rpath
config.sub
configure config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
configure.ac config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def gdb/gdbserver: add dependencies for distclean-gnulib 2020-10-14 15:05:14 +01:00
Makefile.in gdb/gdbserver: add dependencies for distclean-gnulib 2020-10-14 15:05:14 +01:00
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh Use sha256 for hashes in the release process 2020-10-28 10:35:28 -04:00
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.