From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id CB05B384402E for ; Tue, 21 Jul 2020 18:51:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CB05B384402E Received: by mail-oi1-x234.google.com with SMTP id w17so18135374oie.6 for ; Tue, 21 Jul 2020 11:51:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HWpr3yr5fmUjUaLc3P+HrntTe7FvasChYVH+pIXZY00=; b=l8ehZAjcr8QZtzXYDFQmbrZJbEb/LSyysb7YPpVYSpgx9iVIMyuH2nR++J6/ktq3mh D+mF4L6Q7YZX+THFvQn5ojGzxBKNNL2npUhY68wUYyK3MXXcGzAzFb9EmIjNiwk865QV hmyPu9matPTqfsyyiOB7RLwVHLFs1e2Dgc/1FKzuNXpRpN98McJBxzbFO/PTgZY97VpH Tgx94Q0/2B+K4WWcbaAPzQ7z9cPPk+wYnOu9oqz9qsB7hn3NY20q1Y7/ztd2J+TcUrzm k2Do7QsGvMRx+HpArqKrmObM2xPxTPAA6x4eyy/0AFOJurFu7kpzgZx+HVsHdKEEoaXm Vsdg== X-Gm-Message-State: AOAM531SklbAfcRhQVptRAbOvWWzVzWmgi2buOZGYgk8FP2NCgOS/0v3 +mzuasJxnHb3bjPIQAW4/fpb2xoSgOe71yd5k6K4vA== X-Google-Smtp-Source: ABdhPJwgWI8ZQRZgujN5ZA483miflKnFy0PRFBQJN4qhgCvzMX5GfAcciBlqO4d7PfGdlevZPcLh7dg7xXvRoc41rHE= X-Received: by 2002:aca:b689:: with SMTP id g131mr4281081oif.62.1595357486164; Tue, 21 Jul 2020 11:51:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Reuben Thomas Date: Tue, 21 Jul 2020 19:51:15 +0100 Message-ID: Subject: Re: Remote protocol question: the documentation says '?' is not required, but maybe it is? To: "Maciej W. Rozycki" Cc: Christo Crause , Reuben Thomas via Gdb X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2020 18:51:28 -0000 On Tue, 21 Jul 2020 at 12:34, Maciej W. Rozycki wrote: Thanks for chiming in! On Tue, 21 Jul 2020, Reuben Thomas via Gdb wrote: > > > Also, whether or not I send T does not affect GDB's behaviour. In fact, I > > shortened my code by changing it to send an S packet instead, which also > > works fine, but still GDB needs me to implement '?'. The "invalid remote > > reply" is in response to the stub sending an empty reply to "?". > > FYI, I do believe `?' is indeed mandatory, as GDB needs to figure out the > initial state of the remote target as it has connected to it, and there is > no other way. It seems to be more complicated than that. In principle, '?' isn't needed in principle to figure out the initial state: the T packet, or in my current case, the S packet tells GDB the signal, and yet GDB still asks for it again with '?'. The signal that caused the remote to halt is not going to change until the next 'c', so there's no need for GDB to ask for it again; and yet it does. > Documentation may be incomplete/incorrect here, and fallout > from the lack of response (a protocol violation) might be better. > I had a look at `remote.c`, and I found these lines in `remote_target::start_remote` (currently around line 4700 in remote.c): /* Check whether the target is running now. */ putpkt ("?"); The reply is cached, and later parsed in `remote_target::wait_as`, which then complains because it doesn't accept an empty answer (when TRAP or signal 0 was the signal given to GDB, which is the case on startup). It looks indeed as if not supporting '?' will mean trouble. Further, around line 4580, we find: /* Ack any packet which the remote side has already sent. */ remote_serial_write ("+", 1); so it looks as though the first packet the stub sends is ignored. (Presumably it is not ignored in later rounds, when the remote really has issued a 'c' command.) -- https://rrt.sc3d.org