+2014-08-19 Tom Tromey <tromey@redhat.com>
+ Gary Benson <gbenson@redhat.com>
+
+ * 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.
+
2014-08-19 Gary Benson <gbenson@redhat.com>
* common/common-defs.h: Include print-utils.h.
common/ptid.c common/buffer.c gdb-dlfcn.c common/agent.c \
common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
target/waitstatus.c common/print-utils.c common/rsp-low.c \
- common/errors.c
+ common/errors.c common/common-debug.c
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
ctf.h nat/i386-cpuid.h nat/i386-gcc-cpuid.h target/resume.h \
target/wait.h target/waitstatus.h nat/linux-nat.h nat/linux-waitpid.h \
common/print-utils.h common/rsp-low.h nat/i386-dregs.h x86-linux-nat.h \
-i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h
+i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
+common/common-debug.h
# Header files that already have srcdir in them, or which are in objdir.
gdb_vecs.o jit.o progspace.o skip.o probe.o \
common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \
format.o registry.o btrace.o record-btrace.o waitstatus.o \
- print-utils.o rsp-low.o errors.o
+ print-utils.o rsp-low.o errors.o common-debug.o debug.o
TSOBS = inflow.o
$(COMPILE) $(srcdir)/common/errors.c
$(POSTCOMPILE)
+common-debug.o: ${srcdir}/common/common-debug.c
+ $(COMPILE) $(srcdir)/common/common-debug.c
+ $(POSTCOMPILE)
+
#
# gdb/target/ dependencies
#
int debug_agent = 0;
-#ifdef GDBSERVER
-#define DEBUG_AGENT(fmt, args...) \
- if (debug_agent) \
- fprintf (stderr, fmt, ##args);
-#else
-#define DEBUG_AGENT(fmt, args...) \
- if (debug_agent) \
- fprintf_unfiltered (gdb_stdlog, fmt, ##args);
-#endif
+/* A stdarg wrapper for debug_vprintf. */
+
+static void ATTRIBUTE_PRINTF (1, 2)
+debug_agent_printf (const char *fmt, ...)
+{
+ va_list ap;
+
+ if (!debug_agent)
+ return;
+ va_start (ap, fmt);
+ debug_vprintf (fmt, ap);
+ va_end (ap);
+}
+
+#define DEBUG_AGENT debug_agent_printf
/* Global flag to determine using agent or not. */
int use_agent = 0;
--- /dev/null
+/* Debug printing functions.
+
+ Copyright (C) 2014 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef GDBSERVER
+#include "server.h"
+#else
+#include "defs.h"
+#endif
+#include "common-debug.h"
+
+/* See common/common-debug.h. */
+
+void
+debug_printf (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ debug_vprintf (fmt, ap);
+ va_end (ap);
+}
--- /dev/null
+/* Declarations for debug printing functions.
+
+ Copyright (C) 2014 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef COMMON_DEBUG_H
+#define COMMON_DEBUG_H
+
+/* Print a formatted message to the appropriate channel for
+ debugging output for the client. */
+
+extern void debug_printf (const char *format, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
+/* Print a formatted message to the appropriate channel for
+ debugging output for the client. This function must be
+ provided by the client. */
+
+extern void debug_vprintf (const char *format, va_list ap)
+ ATTRIBUTE_PRINTF (1, 0);
+
+#endif /* COMMON_DEBUG_H */
#include "errors.h"
#include "common-types.h"
#include "print-utils.h"
+#include "common-debug.h"
#endif /* COMMON_DEFS_H */
--- /dev/null
+/* Debug printing functions.
+
+ Copyright (C) 2014 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+
+/* See common/common-debug.h. */
+
+void
+debug_vprintf (const char *fmt, va_list ap)
+{
+ vfprintf_unfiltered (gdb_stdlog, fmt, ap);
+}
+2014-08-19 Tom Tromey <tromey@redhat.com>
+ Gary Benson <gbenson@redhat.com>
+
+ * 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.
+
2014-08-19 Gary Benson <gbenson@redhat.com>
* utils.h: Do not include print-utils.h.
$(srcdir)/common/buffer.c $(srcdir)/nat/linux-btrace.c \
$(srcdir)/common/filestuff.c $(srcdir)/target/waitstatus.c \
$(srcdir)/nat/mips-linux-watch.c $(srcdir)/common/print-utils.c \
- $(srcdir)/common/rsp-low.c $(srcdir)/common/errors.c
+ $(srcdir)/common/rsp-low.c $(srcdir)/common/errors.c \
+ $(srcdir)/common/common-debug.c
DEPFILES = @GDBSERVER_DEPFILES@
target.o waitstatus.o utils.o debug.o version.o vec.o gdb_vecs.o \
mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
- tdesc.o print-utils.o rsp-low.o errors.o $(XML_BUILTIN) $(DEPFILES) \
- $(LIBOBJS)
+ tdesc.o print-utils.o rsp-low.o errors.o common-debug.o \
+ $(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
XM_CLIBS = @LIBS@
errors.o: ../common/errors.c
$(COMPILE) $<
$(POSTCOMPILE)
+common-debug.o: ../common/common-debug.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
waitstatus.o: ../target/waitstatus.c
$(COMPILE) $<
$(POSTCOMPILE)
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;
}
#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
}
extern int debug_threads;
extern int debug_timestamp;
-void debug_printf (const char *msg, ...) ATTRIBUTE_PRINTF (1, 2);
void debug_flush (void);
void do_debug_enter (const char *function_name);
void do_debug_exit (const char *function_name);
#ifndef GDBSERVER
/* Whether or not to print the mirrored debug registers. */
extern int debug_hw_points;
-
-/* Print debugging messages. */
-#define debug_printf(fmt, args...) \
- fprintf_unfiltered (gdb_stdlog, fmt, ##args);
#endif
/* Print the values of the mirrored debug registers. */