Introduce common-debug.h
This introduces common-debug.h. This holds the functions debug_printf and debug_vprintf, two functions that the common code can use to print debugging messages. Clients of the common code are expected to implement debug_vprintf; a debug_vprintf function is written from scratch for GDB, and gdbserver's existing debug_printf is repurposed as debug_vprintf. common/agent.c is changed to use debug_vprintf rather than defining the macro DEBUG_AGENT depending on GDBSERVER. nat/i386-dregs.c is changed to use the externally-implemented debug_printf, rather than defining it itself. gdb/ChangeLog: * common/common-debug.h: New file. * common/common-debug.c: Likewise. * debug.c: Likewise. * Makefile.in (SFILES): Add common/common-debug.c. (HFILES_NO_SRCDIR): Add common/common-debug.h. (COMMON_OBS): Add common-debug.o and debug.o. (common-debug.o): New rule. * common/common-defs.h: Include common-debug.h. * common/agent.c (debug_agent_printf): New function. (DEBUG_AGENT): Redefine. * nat/i386-dregs.c (debug_printf): Undefine. gdb/gdbserver/ChangeLog: * Makefile.in (SFILES): Add common/common-debug.c. (OBS): Add common-debug.o. (common-debug.o): New rule. * debug.h (debug_printf): Don't declare. * debug.c (debug_printf): Renamed and rewritten as... (debug_vprintf): New function.
This commit is contained in:
parent
f6e94d78b2
commit
34abf635b3
12 changed files with 161 additions and 27 deletions
|
@ -33,9 +33,8 @@ int debug_timestamp;
|
|||
previous call ended with "\n". */
|
||||
|
||||
void
|
||||
debug_printf (const char *msg, ...)
|
||||
debug_vprintf (const char *format, va_list ap)
|
||||
{
|
||||
va_list args;
|
||||
#if !defined (IN_PROCESS_AGENT)
|
||||
/* N.B. Not thread safe, and can't be used, as is, with IPA. */
|
||||
static int new_line = 1;
|
||||
|
@ -53,13 +52,11 @@ debug_printf (const char *msg, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
va_start (args, msg);
|
||||
vfprintf (stderr, msg, args);
|
||||
va_end (args);
|
||||
vfprintf (stderr, format, ap);
|
||||
|
||||
#if !defined (IN_PROCESS_AGENT)
|
||||
if (*msg)
|
||||
new_line = msg[strlen (msg) - 1] == '\n';
|
||||
if (*format)
|
||||
new_line = format[strlen (format) - 1] == '\n';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue