From c74d0ad8276928d58b080ecd50eb5026aac49c5d Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Mon, 26 Feb 2007 20:10:18 +0000 Subject: [PATCH] * gdb.texinfo (Monitor commands for gdbserver): New subsection. * remote-utils.c (monitor_output): New function. * server.c (debug_threads): Define here. (monitor_show_help): New function. (handle_query): Handle qRcmd. (main): Do not handle 'd' packet. * server.h (debug_threads, remote_debug, monitor_output): Declare. * linux-low.c, spu-low.c, win32-i386-low.c: Remove definitions of debug_threads. * gdb.server/server-mon.exp: New test. --- gdb/doc/ChangeLog | 4 ++ gdb/doc/gdb.texinfo | 23 ++++++++++++ gdb/gdbserver/ChangeLog | 11 ++++++ gdb/gdbserver/linux-low.c | 2 - gdb/gdbserver/remote-utils.c | 12 ++++++ gdb/gdbserver/server.c | 66 +++++++++++++++++++++++++++++++-- gdb/gdbserver/server.h | 4 ++ gdb/gdbserver/spu-low.c | 1 - gdb/gdbserver/win32-i386-low.c | 1 - gdb/testsuite/ChangeLog | 4 ++ gdb/testsuite/gdb.server/server-mon.exp | 55 +++++++++++++++++++++++++++ 11 files changed, 176 insertions(+), 7 deletions(-) create mode 100644 gdb/testsuite/gdb.server/server-mon.exp diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index f083bb2..10b75ba 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,9 @@ 2007-02-26 Daniel Jacobowitz + * gdb.texinfo (Monitor commands for gdbserver): New subsection. + +2007-02-26 Daniel Jacobowitz + * src/gdb/doc/gdb.texinfo (Standard Target Features): Mention case insensitivity. (ARM Features): Describe org.gnu.gdb.xscale.iwmmxt. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a2d27e3..1324e16 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -12775,6 +12775,29 @@ already on the target. @end table +@subsection Monitor commands for @code{gdbserver} +@cindex monitor commands, for @code{gdbserver} + +During a @value{GDBN} session using @code{gdbserver}, you can use the +@code{monitor} command to send special requests to @code{gdbserver}. +Here are the available commands; they are only of interest when +debugging @value{GDBN} or @code{gdbserver}. + +@table @code +@item monitor help +List the available monitor commands. + +@item monitor set debug 0 +@itemx monitor set debug 1 +Disable or enable general debugging messages. + +@item monitor set remote-debug 0 +@itemx monitor set remote-debug 1 +Disable or enable specific debugging messages associated with the remote +protocol (@pxref{Remote Protocol}). + +@end table + @node Remote configuration @section Remote configuration diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 95070cc..b2dd45c 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2007-02-26 Daniel Jacobowitz + + * remote-utils.c (monitor_output): New function. + * server.c (debug_threads): Define here. + (monitor_show_help): New function. + (handle_query): Handle qRcmd. + (main): Do not handle 'd' packet. + * server.h (debug_threads, remote_debug, monitor_output): Declare. + * linux-low.c, spu-low.c, win32-i386-low.c: Remove definitions + of debug_threads. + 2007-02-25 Pedro Alves * Makefile.in (EXEEXT): New. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 55beebc..790749b 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -77,8 +77,6 @@ struct pending_signals static int use_regsets_p = 1; #endif -int debug_threads = 0; - #define pid_of(proc) ((proc)->head.id) /* FIXME: Delete eventually. */ diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index ffacb6e..6a9a176 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1074,3 +1074,15 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp) return 1; } + +void +monitor_output (char *msg) +{ + char *buf = malloc (strlen (msg) * 2 + 2); + + buf[0] = 'O'; + hexify (buf + 1, msg, 0); + + putpkt (buf); + free (buf); +} diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index b0a957f..70ecd53 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -35,6 +35,10 @@ unsigned long old_thread_from_wait; int extended_protocol; int server_waiting; +/* Enable miscellaneous debugging output. The name is historical - it + was originally used to debug LinuxThreads support. */ +int debug_threads; + int pass_signals[TARGET_SIGNAL_LAST]; jmp_buf toplevel; @@ -235,6 +239,16 @@ get_features_xml (const char *annex) return document; } +void +monitor_show_help (void) +{ + monitor_output ("The following monitor commands are supported:\n"); + monitor_output (" set debug <0|1>\n"); + monitor_output (" Enable general debugging messages\n"); + monitor_output (" set remote-debug <0|1>\n"); + monitor_output (" Enable remote protocol debugging messages\n"); +} + /* Handle all of the extended 'q' packets. */ void handle_query (char *own_buf, int *new_packet_len_p) @@ -442,6 +456,55 @@ handle_query (char *own_buf, int *new_packet_len_p) /* Otherwise, pretend we do not understand this packet. */ } + /* Handle "monitor" commands. */ + if (strncmp ("qRcmd,", own_buf, 6) == 0) + { + char *mon = malloc (PBUFSIZ); + int len = strlen (own_buf + 6); + + if ((len % 1) != 0 || unhexify (mon, own_buf + 6, len / 2) != len / 2) + { + write_enn (own_buf); + free (mon); + return; + } + mon[len / 2] = '\0'; + + write_ok (own_buf); + + if (strcmp (mon, "set debug 1") == 0) + { + debug_threads = 1; + monitor_output ("Debug output enabled.\n"); + } + else if (strcmp (mon, "set debug 0") == 0) + { + debug_threads = 0; + monitor_output ("Debug output disabled.\n"); + } + else if (strcmp (mon, "set remote-debug 1") == 0) + { + remote_debug = 1; + monitor_output ("Protocol debug output enabled.\n"); + } + else if (strcmp (mon, "set remote-debug 0") == 0) + { + remote_debug = 0; + monitor_output ("Protocol debug output disabled.\n"); + } + else if (strcmp (mon, "help") == 0) + monitor_show_help (); + else + { + monitor_output ("Unknown monitor command.\n\n"); + monitor_show_help (); + write_enn (own_buf); + } + + free (mon); + return; + } + /* Otherwise we didn't know what packet it was. Say we didn't understand it. */ own_buf[0] = 0; @@ -738,9 +801,6 @@ main (int argc, char *argv[]) case 'Q': handle_general_set (own_buf); break; - case 'd': - remote_debug = !remote_debug; - break; #ifndef USE_WIN32API /* Skip "detach" support on mingw32, since we don't have waitpid. */ diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index ff5ef3f..462bd68 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -128,12 +128,14 @@ extern unsigned long step_thread; extern unsigned long thread_from_wait; extern unsigned long old_thread_from_wait; extern int server_waiting; +extern int debug_threads; extern int pass_signals[]; extern jmp_buf toplevel; /* From remote-utils.c */ +extern int remote_debug; extern int all_symbols_looked_up; int putpkt (char *buf); @@ -170,6 +172,8 @@ int remote_escape_output (const gdb_byte *buffer, int len, int look_up_one_symbol (const char *name, CORE_ADDR *addrp); +void monitor_output (char *msg); + /* Functions from ``signals.c''. */ enum target_signal target_signal_from_host (int hostsig); int target_signal_to_host_p (enum target_signal oursig); diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c index b5b5f48..0d1c81a 100644 --- a/gdb/gdbserver/spu-low.c +++ b/gdb/gdbserver/spu-low.c @@ -58,7 +58,6 @@ /* These are used in remote-utils.c. */ int using_threads = 0; -int debug_threads = 0; /* Fetch PPU register REGNO. */ diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index 6823b54..b06a31c 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -44,7 +44,6 @@ #define OUTMSG2(X) #endif -int debug_threads; int using_threads = 1; /* Globals. */ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8049665..93e3bff 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2007-02-26 Daniel Jacobowitz + * gdb.server/server-mon.exp: New test. + +2007-02-26 Daniel Jacobowitz + * gdb.cp/cp-relocate.cc, gdb.cp/cp-relocate.exp: New. 2007-02-26 Daniel Jacobowitz diff --git a/gdb/testsuite/gdb.server/server-mon.exp b/gdb/testsuite/gdb.server/server-mon.exp new file mode 100644 index 0000000..579c13e --- /dev/null +++ b/gdb/testsuite/gdb.server/server-mon.exp @@ -0,0 +1,55 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2007 Free Software Foundation, Inc. + +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test gdbserver monitor commands. + +load_lib gdbserver-support.exp + +set testfile "server" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [skip_gdbserver_tests] } { + return 0 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + return -1 +} + +gdb_exit +gdb_start + +gdbserver_load $binfile "" +gdb_reinitialize_dir $srcdir/$subdir + +gdb_test_multiple "monitor help" "" { + -re "Unknown monitor command.*$gdb_prompt $" { + fail "monitor help" + } + -re "The following monitor commands.*$gdb_prompt $" { + pass "monitor help" + } +} + +gdb_test "monitor" "Unknown monitor command.*Protocol error.*" + +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\\." -- 2.7.4