From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32586 invoked by alias); 27 Jun 2008 11:59:39 -0000 Received: (qmail 32575 invoked by uid 22791); 27 Jun 2008 11:59:38 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 27 Jun 2008 11:59:20 +0000 Received: (qmail 29547 invoked from network); 27 Jun 2008 11:59:18 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Jun 2008 11:59:18 -0000 From: Pedro Alves To: Daniel Jacobowitz Subject: Re: make the remote target store thread ids in ptid_t.tid Date: Fri, 27 Jun 2008 12:33:00 -0000 User-Agent: KMail/1.9.9 Cc: gdb-patches@sourceware.org References: <200806252351.59167.pedro@codesourcery.com> <20080626022232.GA20206@caradoc.them.org> In-Reply-To: <20080626022232.GA20206@caradoc.them.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_aYNZI8qSj7uFJ6E" Message-Id: <200806271259.22643.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-06/txt/msg00494.txt.bz2 --Boundary-00=_aYNZI8qSj7uFJ6E Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 2540 > > 2008-06-25 Pedro Alves > > > > Use ptid_t.tid to store thread ids instead of ptid_t.pid. > > > > * remote.c (magic_null_ptid, not_sent_ptid, any_thread_ptid): New > > globals. > > (general_thread, continue_thread): Change type to ptid_t. > > (record_currthread): Take a ptid_t parameter instead of an > > integer. > > (MAGIC_NULL_PID): Delete. > > (set_thread): Take a ptid_t parameter and adjust. > > (set_general_thread, set_continue_thread): New. > > (remote_thread_alive, remote_newthread_step) > > (remote_current_thread, remote_find_new_threads) > > (remote_threads_info, remote_start_remote, remote_vcont_resume) > > (remote_resume_1, remote_wait, extended_remote_create_inferior_1) > > (threadalive_test, remote_pid_to_str) > > (remote_get_thread_local_address): Adjust. > > (_initialize_remote): Initialize magic_null_ptid, not_sent_ptid > > and any_thread_ptid. > > Looks OK to me. Thanks, I've checked this in. A Thursday 26 June 2008 03:22:32, Daniel Jacobowitz wrote: > On Wed, Jun 25, 2008 at 11:51:59PM +0100, Pedro Alves wrote: > > I've tested this extensivelly by talking to a native gdbserver, > > and native gdbserver with vCont disabled, and then also with a > > gdbserver with vCont and all thread related packets and fields > > disabled, to simulate old stubs and stubs that don't support > > threads at all. > > These sound useful for testing. Any interest in making them command > line options for gdbserver? Sure, something like this? I don't think we should advertize the options in --help, as this isn't something we want users to be poking with. >./gdbserver --disable-packet Disableable packets: vCont All vCont packets qC Querying the current thread qfThreadInfo Thread listing Tthread Passing the thread specifier in the T stop reply packet threads All of the above >./gdbserver --disable-packet=boo Don't know how to disable "boo". Disableable packets: vCont All vCont packets qC Querying the current thread qfThreadInfo Thread listing Tthread Passing the thread specifier in the T stop reply packet threads All of the above >./gdbserver --disable-packet=vCont :9999 ./gdbserver Process ./gdbserver created; pid = 20022 Listening on port 9999 You can then put the extra options in the board file, say, in the standard native gdbserver board file, it could be: set_board_info gdb_server_prog "../gdbserver/gdbserver --disable-packet=threads" -- Pedro Alves --Boundary-00=_aYNZI8qSj7uFJ6E Content-Type: text/x-diff; charset="iso-8859-1"; name="gdbserver_disable_packets.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdbserver_disable_packets.diff" Content-length: 6958 2008-06-27 Pedro Alves * 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. --- gdb/gdbserver/remote-utils.c | 2 gdb/gdbserver/server.c | 118 +++++++++++++++++++++++++++++++++---------- gdb/gdbserver/server.h | 5 + 3 files changed, 98 insertions(+), 27 deletions(-) Index: src/gdb/gdbserver/remote-utils.c =================================================================== --- src.orig/gdb/gdbserver/remote-utils.c 2008-06-27 12:22:09.000000000 +0100 +++ src/gdb/gdbserver/remote-utils.c 2008-06-27 12:26:42.000000000 +0100 @@ -944,7 +944,7 @@ prepare_resume_reply (char *buf, char st Since thread support relies on qSymbol support anyway, assume GDB can handle threads. */ - if (using_threads) + if (using_threads && !disable_packet_Tthread) { unsigned int gdb_id_from_wait; Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c 2008-06-27 12:22:09.000000000 +0100 +++ src/gdb/gdbserver/server.c 2008-06-27 12:27:15.000000000 +0100 @@ -67,6 +67,14 @@ int terminal_fd; /* TERMINAL_FD's original foreground group. */ 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. */ static void @@ -475,12 +483,12 @@ handle_query (char *own_buf, int packet_ static struct inferior_list_entry *thread_ptr; /* Reply the current thread id. */ - if (strcmp ("qC", own_buf) == 0) + if (strcmp ("qC", own_buf) == 0 && !disable_packet_qC) { require_running (own_buf); thread_ptr = all_threads.head; sprintf (own_buf, "QC%x", - thread_to_gdb_id ((struct thread_info *)thread_ptr)); + thread_to_gdb_id ((struct thread_info *)thread_ptr)); return; } @@ -493,28 +501,31 @@ handle_query (char *own_buf, int packet_ return; } - if (strcmp ("qfThreadInfo", own_buf) == 0) + if (!disable_packet_qfThreadInfo) { - require_running (own_buf); - thread_ptr = all_threads.head; - sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); - thread_ptr = thread_ptr->next; - return; - } - - if (strcmp ("qsThreadInfo", own_buf) == 0) - { - require_running (own_buf); - if (thread_ptr != NULL) + if (strcmp ("qfThreadInfo", own_buf) == 0) { + require_running (own_buf); + thread_ptr = all_threads.head; sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } - else + + if (strcmp ("qsThreadInfo", own_buf) == 0) { - sprintf (own_buf, "l"); - return; + require_running (own_buf); + if (thread_ptr != NULL) + { + sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); + thread_ptr = thread_ptr->next; + return; + } + else + { + sprintf (own_buf, "l"); + return; + } } } @@ -1098,17 +1109,20 @@ void handle_v_requests (char *own_buf, char *status, int *signal, int packet_len, int *new_packet_len) { - if (strncmp (own_buf, "vCont;", 6) == 0) + if (!disable_packet_vCont) { - require_running (own_buf); - handle_v_cont (own_buf, status, signal); - return; - } + if (strncmp (own_buf, "vCont;", 6) == 0) + { + require_running (own_buf); + handle_v_cont (own_buf, status, signal); + return; + } - if (strncmp (own_buf, "vCont?", 6) == 0) - { - strcpy (own_buf, "vCont;c;C;s;S"); - return; + if (strncmp (own_buf, "vCont?", 6) == 0) + { + strcpy (own_buf, "vCont;c;C;s;S"); + return; + } } if (strncmp (own_buf, "vFile:", 6) == 0 @@ -1203,6 +1217,18 @@ gdbserver_usage (FILE *stream) 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 #define require_running(BUF) \ if (!target_running ()) \ @@ -1263,6 +1289,46 @@ main (int argc, char *argv[]) } else if (strcmp (*next_arg, "--debug") == 0) debug_threads = 1; + else if (strcmp (*next_arg, "--disable-packet") == 0) + { + gdbserver_show_disableable (stdout); + exit (1); + } + 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 { fprintf (stderr, "Unknown argument: %s\n", *next_arg); Index: src/gdb/gdbserver/server.h =================================================================== --- src.orig/gdb/gdbserver/server.h 2008-06-27 12:22:09.000000000 +0100 +++ src/gdb/gdbserver/server.h 2008-06-27 12:26:42.000000000 +0100 @@ -156,6 +156,11 @@ extern int pass_signals[]; 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. */ extern int handle_vFile (char *, int, int *); --Boundary-00=_aYNZI8qSj7uFJ6E--