* remote-utils.c (prepare_resume_reply): If requested, don't

output "thread:TID" in the T stop reply.

	* server.c (disable_packet_vCont, disable_packet_Tthread)
	(disable_packet_qC, disable_packet_qfThreadInfo): New globals.
	(handle_query): If requested, disable support for qC, qfThreadInfo
	and qsThreadInfo.
	(handle_v_requests): If requested, disable support for vCont.
	(gdbserver_show_disableable): New.
	(main): Handle --disable-packet and --disable-packet=LIST.

	* server.h (disable_packet_vCont, disable_packet_Tthread)
	(disable_packet_qC, disable_packet_qfThreadInfo): Declare.
This commit is contained in:
Pedro Alves 2008-06-27 13:22:15 +00:00
parent c0a2216eb3
commit db42f21025
4 changed files with 114 additions and 27 deletions

View file

@ -1,3 +1,19 @@
2008-06-27 Pedro Alves <pedro@codesourcery.com>
* remote-utils.c (prepare_resume_reply): If requested, don't
output "thread:TID" in the T stop reply.
* server.c (disable_packet_vCont, disable_packet_Tthread)
(disable_packet_qC, disable_packet_qfThreadInfo): New globals.
(handle_query): If requested, disable support for qC, qfThreadInfo
and qsThreadInfo.
(handle_v_requests): If requested, disable support for vCont.
(gdbserver_show_disableable): New.
(main): Handle --disable-packet and --disable-packet=LIST.
* server.h (disable_packet_vCont, disable_packet_Tthread)
(disable_packet_qC, disable_packet_qfThreadInfo): Declare.
2008-06-20 Carlos O'Donell <carlos@codesourcery.com> 2008-06-20 Carlos O'Donell <carlos@codesourcery.com>
* server.c (gdbserver_usage): Mention --version. * server.c (gdbserver_usage): Mention --version.

View file

@ -944,7 +944,7 @@ prepare_resume_reply (char *buf, char status, unsigned char sig)
Since thread support relies on qSymbol support anyway, assume GDB can handle Since thread support relies on qSymbol support anyway, assume GDB can handle
threads. */ threads. */
if (using_threads) if (using_threads && !disable_packet_Tthread)
{ {
unsigned int gdb_id_from_wait; unsigned int gdb_id_from_wait;

View file

@ -67,6 +67,14 @@ int terminal_fd;
/* TERMINAL_FD's original foreground group. */ /* TERMINAL_FD's original foreground group. */
pid_t old_foreground_pgrp; pid_t old_foreground_pgrp;
/* Set if you want to disable optional thread related packets support
in gdbserver, for the sake of testing GDB against stubs that don't
support them. */
int disable_packet_vCont;
int disable_packet_Tthread;
int disable_packet_qC;
int disable_packet_qfThreadInfo;
/* Hand back terminal ownership to the original foreground group. */ /* Hand back terminal ownership to the original foreground group. */
static void static void
@ -475,7 +483,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
static struct inferior_list_entry *thread_ptr; static struct inferior_list_entry *thread_ptr;
/* Reply the current thread id. */ /* Reply the current thread id. */
if (strcmp ("qC", own_buf) == 0) if (strcmp ("qC", own_buf) == 0 && !disable_packet_qC)
{ {
require_running (own_buf); require_running (own_buf);
thread_ptr = all_threads.head; thread_ptr = all_threads.head;
@ -493,6 +501,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return; return;
} }
if (!disable_packet_qfThreadInfo)
{
if (strcmp ("qfThreadInfo", own_buf) == 0) if (strcmp ("qfThreadInfo", own_buf) == 0)
{ {
require_running (own_buf); require_running (own_buf);
@ -517,6 +527,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
return; return;
} }
} }
}
if (the_target->read_offsets != NULL if (the_target->read_offsets != NULL
&& strcmp ("qOffsets", own_buf) == 0) && strcmp ("qOffsets", own_buf) == 0)
@ -1097,6 +1108,8 @@ handle_v_run (char *own_buf, char *status, int *signal)
void void
handle_v_requests (char *own_buf, char *status, int *signal, handle_v_requests (char *own_buf, char *status, int *signal,
int packet_len, int *new_packet_len) int packet_len, int *new_packet_len)
{
if (!disable_packet_vCont)
{ {
if (strncmp (own_buf, "vCont;", 6) == 0) if (strncmp (own_buf, "vCont;", 6) == 0)
{ {
@ -1110,6 +1123,7 @@ handle_v_requests (char *own_buf, char *status, int *signal,
strcpy (own_buf, "vCont;c;C;s;S"); strcpy (own_buf, "vCont;c;C;s;S");
return; return;
} }
}
if (strncmp (own_buf, "vFile:", 6) == 0 if (strncmp (own_buf, "vFile:", 6) == 0
&& handle_vFile (own_buf, packet_len, new_packet_len)) && handle_vFile (own_buf, packet_len, new_packet_len))
@ -1203,6 +1217,18 @@ gdbserver_usage (FILE *stream)
fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO); fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
} }
static void
gdbserver_show_disableable (FILE *stream)
{
fprintf (stream, "Disableable packets:\n"
" vCont \tAll vCont packets\n"
" qC \tQuerying the current thread\n"
" qfThreadInfo\tThread listing\n"
" Tthread \tPassing the thread specifier in the T stop reply packet\n"
" threads \tAll of the above\n");
}
#undef require_running #undef require_running
#define require_running(BUF) \ #define require_running(BUF) \
if (!target_running ()) \ if (!target_running ()) \
@ -1263,6 +1289,46 @@ main (int argc, char *argv[])
} }
else if (strcmp (*next_arg, "--debug") == 0) else if (strcmp (*next_arg, "--debug") == 0)
debug_threads = 1; debug_threads = 1;
else if (strcmp (*next_arg, "--disable-packet") == 0)
{
gdbserver_show_disableable (stdout);
exit (0);
}
else if (strncmp (*next_arg,
"--disable-packet=",
sizeof ("--disable-packet=") - 1) == 0)
{
char *packets, *tok;
packets = *next_arg += sizeof ("--disable-packet=") - 1;
for (tok = strtok (packets, ",");
tok != NULL;
tok = strtok (NULL, ","))
{
if (strcmp ("vCont", tok) == 0)
disable_packet_vCont = 1;
else if (strcmp ("Tthread", tok) == 0)
disable_packet_Tthread = 1;
else if (strcmp ("qC", tok) == 0)
disable_packet_qC = 1;
else if (strcmp ("qfThreadInfo", tok) == 0)
disable_packet_qfThreadInfo = 1;
else if (strcmp ("threads", tok) == 0)
{
disable_packet_vCont = 1;
disable_packet_Tthread = 1;
disable_packet_qC = 1;
disable_packet_qfThreadInfo = 1;
}
else
{
fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
tok);
gdbserver_show_disableable (stderr);
exit (1);
}
}
}
else else
{ {
fprintf (stderr, "Unknown argument: %s\n", *next_arg); fprintf (stderr, "Unknown argument: %s\n", *next_arg);

View file

@ -156,6 +156,11 @@ extern int pass_signals[];
extern jmp_buf toplevel; extern jmp_buf toplevel;
extern int disable_packet_vCont;
extern int disable_packet_Tthread;
extern int disable_packet_qC;
extern int disable_packet_qfThreadInfo;
/* Functions from hostio.c. */ /* Functions from hostio.c. */
extern int handle_vFile (char *, int, int *); extern int handle_vFile (char *, int, int *);