From patchwork Mon Mar 2 11:54:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 38366 Received: (qmail 12764 invoked by alias); 2 Mar 2020 11:54:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 12705 invoked by uid 89); 2 Mar 2020 11:54:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Google-Smtp-Source:APXvYqw, HX-Spam-Relays-External:209.85.128.66, H*RU:209.85.128.66, non_stop X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Mar 2020 11:54:16 +0000 Received: by mail-wm1-f66.google.com with SMTP id a141so10373823wme.2 for ; Mon, 02 Mar 2020 03:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RSTmq+7PUQ+6GUoSzZ6GgdgZwfFBHK1Jp7twUcsr0CI=; b=XWfTSNn87MZdk07gaTFiHv356zgyfOryimsiLUZdtvkO4uZZXzPLRXybAZZKMdpRwZ ux24Dyn70o6NY9M42iFxg21TuhDr9ZCrFyZnrVPeVHTQ8XFqBHH5/7iK421DDbyq1mwZ GuogrHkOviJ4tPFmxhOrfXLmbLSRG/71aRoA198Zxq5jUsKV5y3NEUWF3kt3xhqikCs1 Mqkhe0hFw+0yq4qdgFhKI9tdLRrUJmDvHsgC09j+vrRMog536B6W8F989O99v2A6PZNG INb2mozcP68F7iRxKPkZcsXY3SSkseVH7/wplenU1GgfhTfd9pCZUfxLXQtj1iQt/N+s KFgQ== Return-Path: Received: from localhost ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id y12sm27990340wrw.88.2020.03.02.03.54.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Mar 2020 03:54:13 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Pedro Alves , Andrew Burgess Subject: [PATCHv3 1/2] gdbserver: Add mechanism to prevent sending T stop packets Date: Mon, 2 Mar 2020 11:54:09 +0000 Message-Id: <27befec6c761c43f2e1a9e59403644c198cbd75b.1583149853.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: <137d09cf-9f97-fa5e-19a0-71231a3f760a@redhat.com> X-IsSubscribed: yes There is a developer only feature in gdbserver that provides a command line option --disable-packet that prevents some packets from being sent, which is used to increase test coverage within GDB. This commit extends this mechanism to prevent GDBserver from sending the T stop reply packets, instead limiting GDBserver to only send the S stop reply packets. The S stop reply packet is part of the older target control mechanism, which has design flaws that were worked around with the introduction of the newer target control mechanism, which uses the T stop reply packet. Limiting GDBserver to use S stop packets instead of T stop packets will, inevitably, mean that GDBserver doesn't function correctly in many cases involving multiple threads, however, I don't think this is too important, this is a developer only feature, intended to allow us to test GDB. A new test that makes use of this feature will be added in the next commit. gdbserver/ChangeLog: * 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. --- gdbserver/ChangeLog | 8 ++++++++ gdbserver/remote-utils.cc | 20 ++++++++++++++++++++ gdbserver/server.cc | 3 +++ gdbserver/server.h | 1 + 4 files changed, 32 insertions(+) diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index 6b547493a71..1c211e25720 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -1204,6 +1204,26 @@ prepare_resume_reply (char *buf, ptid_t ptid, 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; diff --git a/gdbserver/server.cc b/gdbserver/server.cc index a4cb1eb4181..43962adc86c 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -130,6 +130,7 @@ bool disable_packet_vCont; bool disable_packet_Tthread; bool disable_packet_qC; bool disable_packet_qfThreadInfo; +bool disable_packet_T; static unsigned char *mem_buf; @@ -3649,6 +3650,8 @@ captured_main (int argc, char *argv[]) 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; diff --git a/gdbserver/server.h b/gdbserver/server.h index 3c286862349..5ef48b62c62 100644 --- a/gdbserver/server.h +++ b/gdbserver/server.h @@ -76,6 +76,7 @@ extern bool disable_packet_vCont; 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;