]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdb.texinfo (Monitor commands for gdbserver): New subsection.
authorDaniel Jacobowitz <drow@false.org>
Mon, 26 Feb 2007 20:10:18 +0000 (20:10 +0000)
committerDaniel Jacobowitz <drow@false.org>
Mon, 26 Feb 2007 20:10:18 +0000 (20:10 +0000)
* 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
gdb/doc/gdb.texinfo
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/server.c
gdb/gdbserver/server.h
gdb/gdbserver/spu-low.c
gdb/gdbserver/win32-i386-low.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.server/server-mon.exp [new file with mode: 0644]

index f083bb226d3807ad3f7c94f6ec4ca94fbc31b2e8..10b75ba131c1f796f9fcad506dc1c90997faa5b3 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb.texinfo (Monitor commands for gdbserver): New subsection.
+
 2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * src/gdb/doc/gdb.texinfo (Standard Target Features): Mention
index a2d27e353d904f9ed05f978cc920f38104a48d17..1324e168b1ff59c0c20159b8df8b3d6a09c9fbbb 100644 (file)
@@ -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
 
index 95070ccda2b2b14c856354c767a19d235c6939cc..b2dd45c12aa1622c17b37698feec1ea9c07fd6d8 100644 (file)
@@ -1,3 +1,14 @@
+2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * 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  <pedro_alves@portugalmail.pt>
 
        * Makefile.in (EXEEXT): New.
index 55beebc7bb95515eec6cd1e06d0ed1ecb7d8f56c..790749b2780d007c27d7e6056eb99ced28219062 100644 (file)
@@ -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.  */
index ffacb6e49d5bf6e84f3705e525224730b97b91f1..6a9a176c07e308e9ceb1bc6f8845a68cfad4adb1 100644 (file)
@@ -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);
+}
index b0a957f5cbc77fe6d148297a6160201a86aa76c6..70ecd53cb80731d190a2fb68c4823b3447c502d1 100644 (file)
@@ -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.  */
index ff5ef3f813055bdc1c41da84696cdb4e9f1e0b4d..462bd682bb8ab31db9f6b28a92636757da7616aa 100644 (file)
@@ -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);
index b5b5f484a9c2801b141330baf52ae272ef40b4e1..0d1c81ad92c2de38b19ac2ce4d41f0ca4e5b4dd1 100644 (file)
@@ -58,7 +58,6 @@
 
 /* These are used in remote-utils.c.  */
 int using_threads = 0;
-int debug_threads = 0;
 
 
 /* Fetch PPU register REGNO.  */
index 6823b540b5eb75f57518848a6b21688173e0cc3b..b06a31cfe4d0c672d997f7c53ab05c199df82972 100644 (file)
@@ -44,7 +44,6 @@
 #define OUTMSG2(X)
 #endif
 
-int debug_threads;
 int using_threads = 1;
 
 /* Globals.  */
index 80496656a273774d264dc9d829e767b5df8d8513..93e3bfff4bcd2f42950d7b6ea38bd86d3042291b 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb.server/server-mon.exp: New test.
+
 2007-02-26  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * gdb.cp/cp-relocate.cc, gdb.cp/cp-relocate.exp: New.
diff --git a/gdb/testsuite/gdb.server/server-mon.exp b/gdb/testsuite/gdb.server/server-mon.exp
new file mode 100644 (file)
index 0000000..579c13e
--- /dev/null
@@ -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\\."