gdb: add debug_prefixed_vprintf

To help ensure that all debug statements have the same format, introduce
the debug_prefixed_vprintf helper.  Implement linux_nat_debug_printf_1
and infrun_debug_printf_1 with it.

I would eventually like to style the module and function name with some
color, to help them stick out, but I don't really know how to do that
yet, it can always be done later.

gdb/ChangeLog:

	* debug.h: New file.
	* debug.c (debug_prefixed_vprintf): New function.
	* infrun.c (infrun_debug_printf_1): Use debug_prefixed_vprintf.
	* linux-nat.c (linux_nat_debug_printf_1): Likewise.

Change-Id: Iccc290a2dc6b5fffcbe1c2866ed8d804ad380764
This commit is contained in:
Simon Marchi
2020-08-24 15:50:19 -04:00
committed by Simon Marchi
parent 1eb8556f5a
commit c426fddb87
5 changed files with 56 additions and 10 deletions

View File

@@ -70,6 +70,7 @@
#include "gdbsupport/selftest.h"
#include "scoped-mock-context.h"
#include "test-target.h"
#include "debug.h"
/* Prototypes for local functions */
@@ -106,14 +107,10 @@ static int infrun_is_async = -1;
void
infrun_debug_printf_1 (const char *func_name, const char *fmt, ...)
{
debug_printf ("[infrun] %s: ", func_name);
va_list ap;
va_start (ap, fmt);
debug_vprintf (fmt, ap);
debug_prefixed_vprintf ("infrun", func_name, fmt, ap);
va_end (ap);
debug_printf ("\n");
}
/* See infrun.h. */