New gdbserver option --debug-format=timestamp.

* NEWS: Mention it.

	gdbserver/
	* configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in (SFILES): Add debug.c.
	(OBS): Add debug.o.
	* debug.c: New file.
	* debug.h: New file.
	* linux-aarch64-low.c (*): Update all debugging printfs to use
	debug_printf instead of fprintf.
	* linux-arm-low.c (*): Ditto.
	* linux-cris-low.c (*): Ditto.
	* linux-crisv32-low.c (*): Ditto.
	* linux-m32r-low.c (*): Ditto.
	* linux-sparc-low.c (*): Ditto.
	* linux-x86.c (*): Ditto.
	* linux-low.c (*): Ditto.
	(linux_wait_1): Add calls to debug_enter, debug_exit.
	(linux_wait): Remove redundant debugging printf.
	(stop_all_lwps): Add calls to debug_enter, debug_exit.
	(linux_resume, unstop_all_lwps): Ditto.
	* mem-break.c (*): Update all debugging printfs to use
	debug_printf instead of fprintf.
	* remote-utils.c (*): Ditto.
	* thread-db.c (*): Ditto.
	* server.c #include <ctype.h>, "gdb_vecs.h".
	(debug_threads): Moved to debug.c.
	(*): Update all debugging printfs to use debug_printf instead of
	fprintf.
	(start_inferior): Replace call to fflush with call to debug_flush.
	(monitor_show_help): Mention set debug-format.
	(parse_debug_format_options): New function.
	(handle_monitor_command): Handle "monitor set debug-format".
	(gdbserver_usage): Mention --debug-format.
	(main): Parse --debug-format.
	* server.h (debug_threads): Declaration moved to debug.h.
	#include "debug.h".
	* tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of
	trace_debug_1 that uses debug_printf.
	(tracepoint_look_up_symbols): Update all debugging printfs to use
	debug_printf instead of fprintf.

	doc/
	* gdb.texinfo (Server): Mention --debug-format=all|none|timestamp.
	(gdbserver man): Ditto.

	testsuite/
	* gdb.server/server-mon.exp: Add tests for "set debug-format".
This commit is contained in:
Doug Evans 2014-01-22 14:17:39 -08:00
parent 96b961024c
commit 87ce2a04c5
27 changed files with 792 additions and 381 deletions

View File

@ -1,3 +1,8 @@
2014-01-22 Doug Evans <dje@google.com>
New gdbserver option --debug-format=timestamp.
* NEWS: Mention it.
2014-01-22 Andreas Arnez <arnez@vnet.linux.ibm.com>
* syscalls/s390x-linux.xml: New file.

View File

@ -3,6 +3,14 @@
*** Changes since GDB 7.7
* New features in the GDB remote stub, GDBserver
** New option --debug-format=option1[,option2,...] allows one to add
additional text to each output. At present only timestamps
are supported: --debug-format=timestamps.
Timestamps can also be turned on with the
"monitor set debug-format timestamps" command from GDB.
* The 'record instruction-history' command now starts counting instructions
at one. This also affects the instruction ranges reported by the
'record function-call-history' command when given the /i modifier.

View File

@ -1,3 +1,8 @@
2014-01-22 Doug Evans <dje@google.com>
* gdb.texinfo (Server): Mention --debug-format=all|none|timestamp.
(gdbserver man): Ditto.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* gdb.texinfo: Document limited reverse/replay support

View File

@ -18507,6 +18507,7 @@ connections and even in the @kbd{target extended-remote} mode. The
multiple instances of @code{gdbserver} running on the same host, since each
instance closes its port after the first connection.
@anchor{Other Command-Line Arguments for gdbserver}
@subsubsection Other Command-Line Arguments for @code{gdbserver}
@cindex @option{--debug}, @code{gdbserver} option
@ -18517,6 +18518,23 @@ The @option{--remote-debug} option tells @code{gdbserver} to display
remote protocol debug output. These options are intended for
@code{gdbserver} development and for bug reports to the developers.
@cindex @option{--debug-format}, @code{gdbserver} option
The @option{--debug-format=option1[,option2,...]} option tells
@code{gdbserver} to include additional information in each output.
Possible options are:
@table @code
@item none
Turn off all extra information in debugging output.
@item all
Turn on all extra information in debugging output.
@item timestamps
Include a timestamp in each line of debugging output.
@end table
Options are processed in order. Thus, for example, if @option{none}
appears last then no additional information is added to debugging output.
@cindex @option{--wrapper}, @code{gdbserver} option
The @option{--wrapper} option specifies a wrapper to launch programs
for debugging. The option should be followed by the name of the
@ -18587,6 +18605,22 @@ Disable or enable general debugging messages.
Disable or enable specific debugging messages associated with the remote
protocol (@pxref{Remote Protocol}).
@item monitor set debug-format option1@r{[},option2,...@r{]}
Specify additional text to add to debugging messages.
Possible options are:
@table @code
@item none
Turn off all extra information in debugging output.
@item all
Turn on all extra information in debugging output.
@item timestamps
Include a timestamp in each line of debugging output.
@end table
Options are processed in order. Thus, for example, if @option{none}
appears last then no additional information is added to debugging output.
@item monitor set libthread-db-search-path [PATH]
@cindex gdbserver, search path for @code{libthread_db}
When this command is issued, @var{path} is a colon-separated list of
@ -44342,6 +44376,11 @@ Instruct @code{gdbserver} to display remote protocol debug output.
This option is intended for @code{gdbserver} development and for bug reports to
the developers.
@item --debug-format=option1@r{[},option2,...@r{]}
Instruct @code{gdbserver} to include extra information in each line
of debugging output.
@xref{Other Command-Line Arguments for gdbserver}.
@item --wrapper
Specify a wrapper to launch programs
for debugging. The option should be followed by the name of the

View File

@ -1,3 +1,46 @@
2014-01-22 Doug Evans <dje@google.com>
* configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday.
* configure: Regenerate.
* config.in: Regenerate.
* Makefile.in (SFILES): Add debug.c.
(OBS): Add debug.o.
* debug.c: New file.
* debug.h: New file.
* linux-aarch64-low.c (*): Update all debugging printfs to use
debug_printf instead of fprintf.
* linux-arm-low.c (*): Ditto.
* linux-cris-low.c (*): Ditto.
* linux-crisv32-low.c (*): Ditto.
* linux-m32r-low.c (*): Ditto.
* linux-sparc-low.c (*): Ditto.
* linux-x86.c (*): Ditto.
* linux-low.c (*): Ditto.
(linux_wait_1): Add calls to debug_enter, debug_exit.
(linux_wait): Remove redundant debugging printf.
(stop_all_lwps): Add calls to debug_enter, debug_exit.
(linux_resume, unstop_all_lwps): Ditto.
* mem-break.c (*): Update all debugging printfs to use
debug_printf instead of fprintf.
* remote-utils.c (*): Ditto.
* thread-db.c (*): Ditto.
* server.c #include <ctype.h>, "gdb_vecs.h".
(debug_threads): Moved to debug.c.
(*): Update all debugging printfs to use debug_printf instead of
fprintf.
(start_inferior): Replace call to fflush with call to debug_flush.
(monitor_show_help): Mention set debug-format.
(parse_debug_format_options): New function.
(handle_monitor_command): Handle "monitor set debug-format".
(gdbserver_usage): Mention --debug-format.
(main): Parse --debug-format.
* server.h (debug_threads): Declaration moved to debug.h.
#include "debug.h".
* tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of
trace_debug_1 that uses debug_printf.
(tracepoint_look_up_symbols): Update all debugging printfs to use
debug_printf instead of fprintf.
2014-01-20 Baruch Siach <baruch@tkos.co.il>
* linux-xtensa-low.c: Include asm/ptrace.h instead of

View File

@ -141,7 +141,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
$(srcdir)/mem-break.c $(srcdir)/proc-service.c \
$(srcdir)/proc-service.list $(srcdir)/regcache.c \
$(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
$(srcdir)/thread-db.c $(srcdir)/utils.c \
$(srcdir)/thread-db.c $(srcdir)/utils.c $(srcdir)/debug.c \
$(srcdir)/linux-arm-low.c $(srcdir)/linux-bfin-low.c \
$(srcdir)/linux-cris-low.c $(srcdir)/linux-crisv32-low.c \
${srcdir}/i386-low.c $(srcdir)/i387-fp.c \
@ -173,7 +173,7 @@ SOURCES = $(SFILES)
TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS}
OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
target.o waitstatus.o utils.o version.o vec.o gdb_vecs.o \
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 $(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)

View File

@ -66,6 +66,9 @@
/* Define to 1 if you have the `getrlimit' function. */
#undef HAVE_GETRLIMIT
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

View File

@ -4728,7 +4728,7 @@ fi
done
for ac_func in pread pwrite pread64 readlink
for ac_func in gettimeofday pread pwrite pread64 readlink
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -82,7 +82,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
errno.h fcntl.h signal.h sys/file.h malloc.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h)
AC_CHECK_FUNCS(pread pwrite pread64 readlink)
AC_CHECK_FUNCS(gettimeofday pread pwrite pread64 readlink)
AC_REPLACE_FUNCS(vasprintf vsnprintf)
GDB_AC_COMMON

98
gdb/gdbserver/debug.c Normal file
View File

@ -0,0 +1,98 @@
/* Debugging routines for the remote server for GDB.
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 "server.h"
#include <sys/time.h>
/* Enable miscellaneous debugging output. The name is historical - it
was originally used to debug LinuxThreads support. */
int debug_threads;
/* Include timestamps in debugging output. */
int debug_timestamp;
/* Print a debugging message.
If the text begins a new line it is preceded by a timestamp, if the
system has gettimeofday.
We don't get fancy with newline checking, we just check whether the
previous call ended with "\n". */
void
debug_printf (const char *msg, ...)
{
va_list args;
#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
/* N.B. Not thread safe, and can't be used, as is, with IPA. */
static int new_line = 1;
if (debug_timestamp && new_line)
{
struct timeval tm;
gettimeofday (&tm, NULL);
/* If gettimeofday doesn't exist, and as a portability solution it has
been replaced with, e.g., time, then it doesn't make sense to print
the microseconds field. Is there a way to check for that? */
fprintf (stderr, "%ld:%06ld ", (long) tm.tv_sec, (long) tm.tv_usec);
}
#endif
va_start (args, msg);
vfprintf (stderr, msg, args);
va_end (args);
#if defined (HAVE_GETTIMEOFDAY) && !defined (IN_PROCESS_AGENT)
if (*msg)
new_line = msg[strlen (msg) - 1] == '\n';
#endif
}
/* Flush debugging output.
This is called, for example, when starting an inferior to ensure all debug
output thus far appears before any inferior output. */
void
debug_flush (void)
{
fflush (stderr);
}
/* Notify the user that the code is entering FUNCTION_NAME.
FUNCTION_NAME is the name of the calling function, or NULL if unknown.
This is intended to be called via the debug_enter macro. */
void
do_debug_enter (const char *function_name)
{
if (function_name != NULL)
debug_printf (">>>> entering %s\n", function_name);
}
/* Notify the user that the code is exiting FUNCTION_NAME.
FUNCTION_NAME is the name of the calling function, or NULL if unknown.
This is intended to be called via the debug_exit macro. */
void
do_debug_exit (const char *function_name)
{
if (function_name != NULL)
debug_printf ("<<<< exiting %s\n", function_name);
}

55
gdb/gdbserver/debug.h Normal file
View File

@ -0,0 +1,55 @@
/* Debugging routines for the remote server for GDB.
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 DEBUG_H
#define DEBUG_H
/* We declare debug format variables here, and debug_threads but no other
debug content variables (e.g., not remote_debug) because while this file
is not currently used by IPA it may be some day, and IPA may have its own
set of debug content variables. It's ok to declare debug_threads here
because it is misnamed - a better name is debug_basic or some such,
which can work for any program, gdbserver or IPA. If/when this file is
used with IPA it is recommended to fix debug_thread's name. */
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);
/* These macros are for use in major functions that produce a lot of
debugging output. They help identify in the mass of debugging output
when these functions enter and exit. debug_enter is intended to be
called at the start of a function, before any other debugging output.
debug_exit is intended to be called at the end of the same function,
after all debugging output. */
#ifdef FUNCTION_NAME
#define debug_enter() \
do { do_debug_enter (FUNCTION_NAME); } while (0)
#define debug_exit() \
do { do_debug_exit (FUNCTION_NAME); } while (0)
#else
#define debug_enter() \
do { } while (0)
#define debug_exit() \
do { } while (0)
#endif
#endif /* DEBUG_H */

View File

@ -323,7 +323,7 @@ aarch64_get_pc (struct regcache *regcache)
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

View File

@ -256,7 +256,7 @@ arm_get_pc (struct regcache *regcache)
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

View File

@ -67,7 +67,7 @@ cris_get_pc (struct regcache *regcache, void)
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

View File

@ -63,7 +63,7 @@ cris_get_pc (struct regcache *regcache)
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,7 @@ m32r_get_pc (struct regcache *regcache)
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

View File

@ -231,7 +231,7 @@ sparc_get_pc (struct regcache *regcache)
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
fprintf (stderr, "stop pc is %08lx\n", pc);
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}

View File

@ -2027,8 +2027,8 @@ add_insns (unsigned char *start, int len)
CORE_ADDR buildaddr = current_insn_ptr;
if (debug_threads)
fprintf (stderr, "Adding %d bytes of insn at %s\n",
len, paddress (buildaddr));
debug_printf ("Adding %d bytes of insn at %s\n",
len, paddress (buildaddr));
append_insns (&buildaddr, len, start);
current_insn_ptr = buildaddr;

View File

@ -197,10 +197,9 @@ set_raw_breakpoint_at (CORE_ADDR where)
if (err != 0)
{
if (debug_threads)
fprintf (stderr,
"Failed to read shadow memory of"
" breakpoint at 0x%s (%s).\n",
paddress (where), strerror (err));
debug_printf ("Failed to read shadow memory of"
" breakpoint at 0x%s (%s).\n",
paddress (where), strerror (err));
free (bp);
return NULL;
}
@ -211,9 +210,8 @@ set_raw_breakpoint_at (CORE_ADDR where)
if (err != 0)
{
if (debug_threads)
fprintf (stderr,
"Failed to insert breakpoint at 0x%s (%s).\n",
paddress (where), strerror (err));
debug_printf ("Failed to insert breakpoint at 0x%s (%s).\n",
paddress (where), strerror (err));
free (bp);
return NULL;
}
@ -334,10 +332,9 @@ delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel)
*bp_link = prev_bp_link;
if (debug_threads)
fprintf (stderr,
"Failed to uninsert fast tracepoint jump "
"at 0x%s (%s) while deleting it.\n",
paddress (bp->pc), strerror (ret));
debug_printf ("Failed to uninsert fast tracepoint jump "
"at 0x%s (%s) while deleting it.\n",
paddress (bp->pc), strerror (ret));
return ret;
}
@ -398,10 +395,9 @@ set_fast_tracepoint_jump (CORE_ADDR where,
if (err != 0)
{
if (debug_threads)
fprintf (stderr,
"Failed to read shadow memory of"
" fast tracepoint at 0x%s (%s).\n",
paddress (where), strerror (err));
debug_printf ("Failed to read shadow memory of"
" fast tracepoint at 0x%s (%s).\n",
paddress (where), strerror (err));
free (jp);
return NULL;
}
@ -424,9 +420,8 @@ set_fast_tracepoint_jump (CORE_ADDR where,
if (err != 0)
{
if (debug_threads)
fprintf (stderr,
"Failed to insert fast tracepoint jump at 0x%s (%s).\n",
paddress (where), strerror (err));
debug_printf ("Failed to insert fast tracepoint jump at 0x%s (%s).\n",
paddress (where), strerror (err));
/* Unlink it. */
proc->fast_tracepoint_jumps = jp->next;
@ -450,10 +445,9 @@ uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
if (debug_threads)
fprintf (stderr,
"Could not find fast tracepoint jump at 0x%s "
"in list (uninserting).\n",
paddress (pc));
debug_printf ("Could not find fast tracepoint jump at 0x%s "
"in list (uninserting).\n",
paddress (pc));
return;
}
@ -480,9 +474,9 @@ uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc)
jp->inserted = 1;
if (debug_threads)
fprintf (stderr,
"Failed to uninsert fast tracepoint jump at 0x%s (%s).\n",
paddress (pc), strerror (err));
debug_printf ("Failed to uninsert fast tracepoint jump at"
" 0x%s (%s).\n",
paddress (pc), strerror (err));
}
}
}
@ -500,10 +494,9 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
/* This can happen when we remove breakpoints when a tracepoint
hit causes a tracing stop, while handling a step-over. */
if (debug_threads)
fprintf (stderr,
"Could not find fast tracepoint jump at 0x%s "
"in list (reinserting).\n",
paddress (where));
debug_printf ("Could not find fast tracepoint jump at 0x%s "
"in list (reinserting).\n",
paddress (where));
return;
}
@ -528,9 +521,9 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
jp->inserted = 0;
if (debug_threads)
fprintf (stderr,
"Failed to reinsert fast tracepoint jump at 0x%s (%s).\n",
paddress (where), strerror (err));
debug_printf ("Failed to reinsert fast tracepoint jump at"
" 0x%s (%s).\n",
paddress (where), strerror (err));
}
}
@ -598,10 +591,9 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
*bp_link = prev_bp_link;
if (debug_threads)
fprintf (stderr,
"Failed to uninsert raw breakpoint "
"at 0x%s (%s) while deleting it.\n",
paddress (bp->pc), strerror (ret));
debug_printf ("Failed to uninsert raw breakpoint "
"at 0x%s (%s) while deleting it.\n",
paddress (bp->pc), strerror (ret));
return ret;
}
@ -932,9 +924,9 @@ gdb_no_commands_at_breakpoint (CORE_ADDR where)
return 0;
if (debug_threads)
fprintf (stderr, "at 0x%s, bp command_list is 0x%s\n",
paddress (where),
phex_nz ((uintptr_t) bp->command_list, 0));
debug_printf ("at 0x%s, bp command_list is 0x%s\n",
paddress (where),
phex_nz ((uintptr_t) bp->command_list, 0));
return (bp->command_list == NULL);
}
@ -1034,9 +1026,8 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
bp->inserted = 1;
if (debug_threads)
fprintf (stderr,
"Failed to uninsert raw breakpoint at 0x%s (%s).\n",
paddress (bp->pc), strerror (err));
debug_printf ("Failed to uninsert raw breakpoint at 0x%s (%s).\n",
paddress (bp->pc), strerror (err));
}
}
}
@ -1052,10 +1043,9 @@ uninsert_breakpoints_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
if (debug_threads)
fprintf (stderr,
"Could not find breakpoint at 0x%s "
"in list (uninserting).\n",
paddress (pc));
debug_printf ("Could not find breakpoint at 0x%s "
"in list (uninserting).\n",
paddress (pc));
return;
}
@ -1087,9 +1077,8 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp)
if (err == 0)
bp->inserted = 1;
else if (debug_threads)
fprintf (stderr,
"Failed to reinsert breakpoint at 0x%s (%s).\n",
paddress (bp->pc), strerror (err));
debug_printf ("Failed to reinsert breakpoint at 0x%s (%s).\n",
paddress (bp->pc), strerror (err));
}
void
@ -1103,10 +1092,9 @@ reinsert_breakpoints_at (CORE_ADDR pc)
/* This can happen when we remove all breakpoints while handling
a step-over. */
if (debug_threads)
fprintf (stderr,
"Could not find raw breakpoint at 0x%s "
"in list (reinserting).\n",
paddress (pc));
debug_printf ("Could not find raw breakpoint at 0x%s "
"in list (reinserting).\n",
paddress (pc));
return;
}

View File

@ -161,7 +161,7 @@ handle_accept_event (int err, gdb_client_data client_data)
socklen_t tmp;
if (debug_threads)
fprintf (stderr, "handling possible accept event\n");
debug_printf ("handling possible accept event\n");
tmp = sizeof (sockaddr);
remote_desc = accept (listen_desc, (struct sockaddr *) &sockaddr, &tmp);
@ -1315,8 +1315,8 @@ prepare_resume_reply (char *buf, ptid_t ptid,
struct target_waitstatus *status)
{
if (debug_threads)
fprintf (stderr, "Writing resume reply for %s:%d\n",
target_pid_to_str (ptid), status->kind);
debug_printf ("Writing resume reply for %s:%d\n",
target_pid_to_str (ptid), status->kind);
switch (status->kind)
{

View File

@ -22,10 +22,12 @@
#include "notif.h"
#include "tdesc.h"
#include <ctype.h>
#include <unistd.h>
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#include "gdb_vecs.h"
#include "gdb_wait.h"
#include "btrace-common.h"
#include "filestuff.h"
@ -66,10 +68,6 @@ int disable_randomization = 1;
static char **program_argv, **wrapper_argv;
/* Enable miscellaneous debugging output. The name is historical - it
was originally used to debug LinuxThreads support. */
int debug_threads;
/* Enable debugging of h/w breakpoint/watchpoint support. */
int debug_hw_points;
@ -222,8 +220,8 @@ start_inferior (char **argv)
{
int i;
for (i = 0; new_argv[i]; ++i)
fprintf (stderr, "new_argv[%d] = \"%s\"\n", i, new_argv[i]);
fflush (stderr);
debug_printf ("new_argv[%d] = \"%s\"\n", i, new_argv[i]);
debug_flush ();
}
#ifdef SIGTTOU
@ -694,6 +692,13 @@ monitor_show_help (void)
monitor_output (" Enable h/w breakpoint/watchpoint debugging messages\n");
monitor_output (" set remote-debug <0|1>\n");
monitor_output (" Enable remote protocol debugging messages\n");
monitor_output (" set debug-format option1[,option2,...]\n");
monitor_output (" Add additional information to debugging messages\n");
monitor_output (" Options: all, none");
#ifdef HAVE_GETTIMEOFDAY
monitor_output (", timestamp");
#endif
monitor_output ("\n");
monitor_output (" exit\n");
monitor_output (" Quit GDBserver\n");
}
@ -921,6 +926,80 @@ handle_search_memory (char *own_buf, int packet_len)
return; \
}
/* Parse options to --debug-format= and "monitor set debug-format".
ARG is the text after "--debug-format=" or "monitor set debug-format".
IS_MONITOR is non-zero if we're invoked via "monitor set debug-format".
This triggers calls to monitor_output.
The result is NULL if all options were parsed ok, otherwise an error
message which the caller must free.
N.B. These commands affect all debug format settings, they are not
cumulative. If a format is not specified, it is turned off.
However, we don't go to extra trouble with things like
"monitor set debug-format all,none,timestamp".
Instead we just parse them one at a time, in order.
The syntax for "monitor set debug" we support here is not identical
to gdb's "set debug foo on|off" because we also use this function to
parse "--debug-format=foo,bar". */
static char *
parse_debug_format_options (const char *arg, int is_monitor)
{
VEC (char_ptr) *options;
int ix;
char *option;
/* First turn all debug format options off. */
debug_timestamp = 0;
/* First remove leading spaces, for "monitor set debug-format". */
while (isspace (*arg))
++arg;
options = delim_string_to_char_ptr_vec (arg, ',');
for (ix = 0; VEC_iterate (char_ptr, options, ix, option); ++ix)
{
if (strcmp (option, "all") == 0)
{
debug_timestamp = 1;
if (is_monitor)
monitor_output ("All extra debug format options enabled.\n");
}
else if (strcmp (option, "none") == 0)
{
debug_timestamp = 0;
if (is_monitor)
monitor_output ("All extra debug format options disabled.\n");
}
#ifdef HAVE_GETTIMEOFDAY
else if (strcmp (option, "timestamp") == 0)
{
debug_timestamp = 1;
if (is_monitor)
monitor_output ("Timestamps will be added to debug output.\n");
}
#endif
else if (*option == '\0')
{
/* An empty option, e.g., "--debug-format=foo,,bar", is ignored. */
continue;
}
else
{
char *msg = xstrprintf ("Unknown debug-format argument: \"%s\"\n",
option);
free_char_ptr_vec (options);
return msg;
}
}
free_char_ptr_vec (options);
return NULL;
}
/* Handle monitor commands not handled by target-specific handlers. */
static void
@ -956,6 +1035,21 @@ handle_monitor_command (char *mon, char *own_buf)
remote_debug = 0;
monitor_output ("Protocol debug output disabled.\n");
}
else if (strncmp (mon, "set debug-format ",
sizeof ("set debug-format ") - 1) == 0)
{
char *error_msg
= parse_debug_format_options (mon + sizeof ("set debug-format ") - 1,
1);
if (error_msg != NULL)
{
monitor_output (error_msg);
monitor_show_help ();
write_enn (own_buf);
xfree (error_msg);
}
}
else if (strcmp (mon, "help") == 0)
monitor_show_help ();
else if (strcmp (mon, "exit") == 0)
@ -2535,10 +2629,9 @@ queue_stop_reply_callback (struct inferior_list_entry *entry, void *arg)
char *status_string
= target_waitstatus_to_string (&thread->last_status);
fprintf (stderr,
"Reporting thread %s as already stopped with %s\n",
target_pid_to_str (entry->id),
status_string);
debug_printf ("Reporting thread %s as already stopped with %s\n",
target_pid_to_str (entry->id),
status_string);
xfree (status_string);
}
@ -2733,6 +2826,14 @@ gdbserver_usage (FILE *stream)
"\n"
"Options:\n"
" --debug Enable general debugging output.\n"
" --debug-format=opt1[,opt2,...]\n"
" Specify extra content in debugging output.\n"
" Options:\n"
" all\n"
" none\n"
#ifdef HAVE_GETTIMEOFDAY
" timestamp\n"
#endif
" --remote-debug Enable remote protocol debugging output.\n"
" --version Display version information and exit.\n"
" --wrapper WRAPPER -- Run WRAPPER to start new programs.\n"
@ -2908,6 +3009,20 @@ main (int argc, char *argv[])
}
else if (strcmp (*next_arg, "--debug") == 0)
debug_threads = 1;
else if (strncmp (*next_arg,
"--debug-format=",
sizeof ("--debug-format=") - 1) == 0)
{
char *error_msg
= parse_debug_format_options ((*next_arg)
+ sizeof ("--debug-format=") - 1, 0);
if (error_msg != NULL)
{
fprintf (stderr, "%s", error_msg);
exit (1);
}
}
else if (strcmp (*next_arg, "--remote-debug") == 0)
remote_debug = 1;
else if (strcmp (*next_arg, "--disable-packet") == 0)
@ -3204,14 +3319,14 @@ process_point_options (CORE_ADDR point_addr, char **packet)
{
/* Conditional expression. */
if (debug_threads)
fprintf (stderr, "Found breakpoint condition.\n");
debug_printf ("Found breakpoint condition.\n");
add_breakpoint_condition (point_addr, &dataptr);
}
else if (strncmp (dataptr, "cmds:", strlen ("cmds:")) == 0)
{
dataptr += strlen ("cmds:");
if (debug_threads)
fprintf (stderr, "Found breakpoint commands %s.\n", dataptr);
debug_printf ("Found breakpoint commands %s.\n", dataptr);
persist = (*dataptr == '1');
dataptr += 2;
add_breakpoint_commands (point_addr, &dataptr, persist);
@ -3316,7 +3431,7 @@ process_serial_event (void)
if (!non_stop)
{
if (debug_threads)
fprintf (stderr, "Forcing non-stop mode\n");
debug_printf ("Forcing non-stop mode\n");
non_stop = 1;
start_non_stop (1);
@ -3709,7 +3824,7 @@ int
handle_serial_event (int err, gdb_client_data client_data)
{
if (debug_threads)
fprintf (stderr, "handling possible serial event\n");
debug_printf ("handling possible serial event\n");
/* Really handle it. */
if (process_serial_event () < 0)
@ -3728,7 +3843,7 @@ int
handle_target_event (int err, gdb_client_data client_data)
{
if (debug_threads)
fprintf (stderr, "handling possible target event\n");
debug_printf ("handling possible target event\n");
last_ptid = mywait (minus_one_ptid, &last_status,
TARGET_WNOHANG, 1);
@ -3770,10 +3885,10 @@ handle_target_event (int err, gdb_client_data client_data)
struct thread_resume resume_info;
if (debug_threads)
fprintf (stderr,
"GDB not connected; forwarding event %d for [%s]\n",
(int) last_status.kind,
target_pid_to_str (last_ptid));
debug_printf ("GDB not connected; forwarding event %d for"
" [%s]\n",
(int) last_status.kind,
target_pid_to_str (last_ptid));
resume_info.thread = last_ptid;
resume_info.kind = resume_continue;
@ -3781,9 +3896,9 @@ handle_target_event (int err, gdb_client_data client_data)
(*the_target->resume) (&resume_info, 1);
}
else if (debug_threads)
fprintf (stderr, "GDB not connected; ignoring event %d for [%s]\n",
(int) last_status.kind,
target_pid_to_str (last_ptid));
debug_printf ("GDB not connected; ignoring event %d for [%s]\n",
(int) last_status.kind,
target_pid_to_str (last_ptid));
}
else
{

View File

@ -110,7 +110,6 @@ extern ptid_t cont_thread;
extern ptid_t general_thread;
extern int server_waiting;
extern int debug_threads;
extern int debug_hw_points;
extern int pass_signals[];
extern int program_signals[];
@ -146,6 +145,7 @@ extern int handle_target_event (int err, gdb_client_data client_data);
#include "common-utils.h"
#include "utils.h"
#include "debug.h"
#include "gdb_assert.h"

View File

@ -194,7 +194,7 @@ thread_db_create_event (CORE_ADDR where)
fatal ("unexpected thread_db->td_ta_event_getmsg_p == NULL");
if (debug_threads)
fprintf (stderr, "Thread creation event.\n");
debug_printf ("Thread creation event.\n");
/* FIXME: This assumes we don't get another event.
In the LinuxThreads implementation, this is safe,
@ -289,8 +289,8 @@ find_one_thread (ptid_t ptid)
lwpid, thread_db_err_str (err));
if (debug_threads)
fprintf (stderr, "Found thread %ld (LWP %d)\n",
ti.ti_tid, ti.ti_lid);
debug_printf ("Found thread %ld (LWP %d)\n",
ti.ti_tid, ti.ti_lid);
if (lwpid != ti.ti_lid)
{
@ -326,8 +326,8 @@ attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
struct lwp_info *lwp;
if (debug_threads)
fprintf (stderr, "Attaching to thread %ld (LWP %d)\n",
ti_p->ti_tid, ti_p->ti_lid);
debug_printf ("Attaching to thread %ld (LWP %d)\n",
ti_p->ti_tid, ti_p->ti_lid);
linux_attach_lwp (ti_p->ti_lid);
lwp = find_lwp_pid (pid_to_ptid (ti_p->ti_lid));
if (lwp == NULL)
@ -432,8 +432,8 @@ thread_db_find_new_threads (void)
TD_THR_LOWEST_PRIORITY,
TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
if (debug_threads)
fprintf (stderr, "Found %d threads in iteration %d.\n",
new_thread_count, iteration);
debug_printf ("Found %d threads in iteration %d.\n",
new_thread_count, iteration);
if (new_thread_count != 0)
{
@ -546,7 +546,7 @@ thread_db_load_search (void)
if (err != TD_OK)
{
if (debug_threads)
fprintf (stderr, "td_ta_new(): %s\n", thread_db_err_str (err));
debug_printf ("td_ta_new(): %s\n", thread_db_err_str (err));
free (tdb);
proc->private->thread_db = NULL;
return 0;
@ -595,7 +595,7 @@ try_thread_db_load_1 (void *handle)
if ((a) == NULL) \
{ \
if (debug_threads) \
fprintf (stderr, "dlsym: %s\n", dlerror ()); \
debug_printf ("dlsym: %s\n", dlerror ()); \
if (required) \
{ \
free (tdb); \
@ -613,7 +613,7 @@ try_thread_db_load_1 (void *handle)
if (err != TD_OK)
{
if (debug_threads)
fprintf (stderr, "td_ta_new(): %s\n", thread_db_err_str (err));
debug_printf ("td_ta_new(): %s\n", thread_db_err_str (err));
free (tdb);
proc->private->thread_db = NULL;
return 0;
@ -663,13 +663,13 @@ try_thread_db_load (const char *library)
void *handle;
if (debug_threads)
fprintf (stderr, "Trying host libthread_db library: %s.\n",
library);
debug_printf ("Trying host libthread_db library: %s.\n",
library);
handle = dlopen (library, RTLD_NOW);
if (handle == NULL)
{
if (debug_threads)
fprintf (stderr, "dlopen failed: %s.\n", dlerror ());
debug_printf ("dlopen failed: %s.\n", dlerror ());
return 0;
}
@ -786,7 +786,7 @@ thread_db_load_search (void)
free_char_ptr_vec (dir_vec);
if (debug_threads)
fprintf (stderr, "thread_db_load_search returning %d\n", rc);
debug_printf ("thread_db_load_search returning %d\n", rc);
return rc;
}

View File

@ -61,6 +61,8 @@
*/
#ifdef IN_PROCESS_AGENT
static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
static void
@ -81,6 +83,19 @@ trace_vdebug (const char *fmt, ...)
trace_vdebug ((fmt), ##args); \
} while (0)
#else
#define trace_debug_1(level, fmt, args...) \
do { \
if (level <= debug_threads) \
{ \
debug_printf ((fmt), ##args); \
debug_printf ("\n"); \
} \
} while (0)
#endif
#define trace_debug(FMT, args...) \
trace_debug_1 (1, FMT, ##args)
@ -338,7 +353,7 @@ tracepoint_look_up_symbols (void)
if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
{
if (debug_threads)
fprintf (stderr, "symbol `%s' not found\n", symbol_list[i].name);
debug_printf ("symbol `%s' not found\n", symbol_list[i].name);
return;
}
}

View File

@ -1,3 +1,7 @@
2014-01-22 Doug Evans <dje@google.com>
* gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 Andreas Arnez <arnez@vnet.linux.ibm.com>
* gdb.base/catch-syscall.exp: Activate test on s390*-linux.

View File

@ -50,3 +50,7 @@ gdb_test "monitor set debug 1" "Debug output enabled\\."
gdb_test "monitor set debug 0" "Debug output disabled\\."
gdb_test "monitor set remote-debug 1" "Protocol debug output enabled\\."
gdb_test "monitor set remote-debug 0" "Protocol debug output disabled\\."
gdb_test "monitor set debug-format all" \
"All extra debug format options enabled\\."
gdb_test "monitor set debug-format none" \
"All extra debug format options disabled\\."