From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46061 invoked by alias); 27 Feb 2020 19:46:30 -0000 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 Received: (qmail 46053 invoked by uid 89); 27 Feb 2020 19:46:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=forgot, Passing, love X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 19:46:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582832787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ly66T+ofBcjAukT4Bhx57sXBtN0HVm1P+qIL3MHRD+s=; b=BCaHmoCzv0/ThZLA5a9b8BJ6RxMVQyVZ4/fIgFwdpxZnPG8gDCFXNycKCEpYYS2cUBbFTY bWrCO4sjSPhb/yBFXAHQ0xp6mC1FCdXKSsRMhwyE3kXfALVCEjXSF+DA3OfMHP6LmRPY+l mb3gZiNFZZQ9h5GUqocj+/7Sw1jzY5M= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-fVZIQC-CPAO1ytnsezbxlQ-1; Thu, 27 Feb 2020 14:46:17 -0500 Received: by mail-ed1-f71.google.com with SMTP id y8so512014edv.4 for ; Thu, 27 Feb 2020 11:46:17 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id j2sm221697edq.96.2020.02.27.11.46.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Feb 2020 11:46:13 -0800 (PST) Subject: Re: [PATCHv2] gdb/remote: Restore support for 'S' stop reply packet To: Andrew Burgess , gdb-patches@sourceware.org References: <80314590-ba73-26f5-830d-698ff4ecb2d8@redhat.com> <20200227161704.16480-1-andrew.burgess@embecosm.com> From: Pedro Alves Message-ID: <14a8b8f2-f866-fcd8-bf23-c1f67d426421@redhat.com> Date: Thu, 27 Feb 2020 19:46:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20200227161704.16480-1-andrew.burgess@embecosm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg01024.txt.bz2 On 2/27/20 4:17 PM, Andrew Burgess wrote: > The solution I propose in this commit is to use the first non exited > thread of the inferior. s/of the inferior/of the target/ > Additionally, GDB will give a warning if a > multi-threaded target stops without passing a thread-id. > > There's no test included with this commit, if anyone has any ideas for > how we could test this aspect of the remote protocol (short of writing > a new gdbserver) then I'd love to know. I forgot to mention this earlier, but I think we could test this by using gdbserver's --disable-packet=Tthread option (or --disable-packet=threads to disable vCont as well.). This sets the disable_packet_Tthread global in gdbserver, which makes it skip including the thread in the T stop reply. $ 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 I added these options several years ago exactly to exercise support for old non-threaded protocol. ISTR having documented them, ... ... ah, here: https://sourceware.org/ml/gdb-patches/2008-06/msg00501.html doesn't look like that patch was ever merged. :-/ > > - /* If no thread/process was reported by the stub, assume the current > - inferior. */ > + /* If no thread/process was reported by the stub then use the first > + non-exited thread in the current inferior. */ s/current inferior/current target/ > if (ptid == null_ptid) > - ptid = inferior_ptid; > + { > + for (thread_info *thr : all_non_exited_threads (this)) > + { > + if (ptid != null_ptid) > + { > + warning (_("multi-threaded target stopped without sending " > + "a thread-id, using first non-exited thread")); I wonder about making this only warn once, to avoid a flood of warnings. Like: if (!warned) { warned = true; warning (....); } We use that same pattern in other places we only want to warn once. E.g., parse_memory_map. Otherwise LGTM. Thanks, Pedro Alves