[PATCH 1/3] gdb: make "set debug timestamp" work nice with new debug printouts

Tom Tromey tom@tromey.com
Wed Dec 16 15:31:40 GMT 2020


>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> The simplest fix is to make sure a single debug_printf / debug_vprintf
Simon> call is done.

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

How about having the timestamp-printing code only do so when a \n is seen?

Simon> +  /* Do a single debug_printf call.  If we do multiple
Simon> +     debug_printf/debug_vprintf calls and "set debug timestamp" is used in GDB,
Simon> +     each call gets its own timestamp.  */
Simon> +  std::string msg = string_vprintf (format, args);
Simon> +  debug_printf ("[%s] %s: %s\n", module, func, msg.c_str ());

A potential issue with this is that it will lose any styling.
Probably not an issue for the time being, and so I tend to think the
patch is fine as-is.  But, checking for the \n would seem to be better.

Tom


More information about the Gdb-patches mailing list