+2020-03-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * remote-utils.cc (prepare_resume_reply): Add ability to convert T
+       reply into an S reply.
+       * server.cc (disable_packet_T): New global.
+       (captured_main): Set new global when appropriate.
+       * server.h (disable_packet_T): Declare.
+
 2020-02-21  Tom Tromey  <tom@tromey.com>
 
        * Makefile.in (mostlyclean): New target.
 
        else
          sprintf (buf, "T%02x", status->value.sig);
 
+       if (disable_packet_T)
+         {
+           /* This is a bit (OK, a lot) of a kludge, however, this isn't
+              really a user feature, but exists only so GDB can use the
+              gdbserver to test handling of the 'S' stop reply packet, so
+              we would rather this code be as simple as possible.
+
+              By this point we've started to build the 'T' stop packet,
+              and it should look like 'Txx....' where 'x' is a hex digit.
+              An 'S' stop packet always looks like 'Sxx', so all we do
+              here is convert the buffer from a T packet to an S packet
+              and the avoid adding any extra content by breaking out.  */
+           gdb_assert (*buf == 'T');
+           gdb_assert (isxdigit (*(buf + 1)));
+           gdb_assert (isxdigit (*(buf + 2)));
+           *buf = 'S';
+           *(buf + 3) = '\0';
+           break;
+         }
+
        buf += strlen (buf);
 
        saved_thread = current_thread;
 
 bool disable_packet_Tthread;
 bool disable_packet_qC;
 bool disable_packet_qfThreadInfo;
+bool disable_packet_T;
 
 static unsigned char *mem_buf;
 
                disable_packet_qC = true;
              else if (strcmp ("qfThreadInfo", tok) == 0)
                disable_packet_qfThreadInfo = true;
+             else if (strcmp ("T", tok) == 0)
+               disable_packet_T = true;
              else if (strcmp ("threads", tok) == 0)
                {
                  disable_packet_vCont = true;
 
 extern bool disable_packet_Tthread;
 extern bool disable_packet_qC;
 extern bool disable_packet_qfThreadInfo;
+extern bool disable_packet_T;
 
 extern bool run_once;
 extern bool non_stop;