* 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.
This commit is contained in:
Daniel Jacobowitz
2007-02-26 20:10:18 +00:00
parent 2711e4564f
commit c74d0ad827
11 changed files with 176 additions and 7 deletions

View 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. */