From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6ACGCYHpfWR5mh4AWB0awg (envelope-from ) for ; Mon, 05 Jun 2023 09:56:17 -0400 Received: by simark.ca (Postfix, from userid 112) id 23AE61E11E; Mon, 5 Jun 2023 09:56:17 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=JY1lbX34; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A48821E111 for ; Mon, 5 Jun 2023 09:56:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 996483831E09 for ; Mon, 5 Jun 2023 13:56:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 996483831E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685973373; bh=+aRPZJJ7TbfRdN903s4wnnujQXi3GFGi+7zJe5nd1M4=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JY1lbX34QhAuQWz4J9jlUCSNLWYRIDL8pWTPTBV9YIc0gvNFYuz1sd1gDVxJp8X5z BnzKM4H7zFMLy+k+Syk7tScyf9mWx1HxtBvdiyT48tR0Os441D4RIaI5Pl39vSFLuw IcJz37UXESeyBfdrzdI0ALz7ycE/38DMOhlx6ieo= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 16F433836E84 for ; Mon, 5 Jun 2023 13:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16F433836E84 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-Hvh0egKNPbqOvo_TXbcCaQ-1; Mon, 05 Jun 2023 09:55:52 -0400 X-MC-Unique: Hvh0egKNPbqOvo_TXbcCaQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f5ec8aac77so28731255e9.3 for ; Mon, 05 Jun 2023 06:55:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685973351; x=1688565351; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+aRPZJJ7TbfRdN903s4wnnujQXi3GFGi+7zJe5nd1M4=; b=gjNQ+C25zQ3JDl2esRbKRd0A5gq85tpXzTISprFEMrzK/fxyZYWAbxZTVuvyYZBtE8 ToTUDoatR9dNah/SH5nFJstn2/N1/4bo6yAIf5540rzRphiZnIAWK86oF9b/Ajb58hLB GvnsPAdNZnV1tTF5KfhorUkqNWC+vDoZJl2aPLPA8LwYHAZAZW/tZGIYhio6Fs+YpUpV Ms5dglfS5kQrlP5XqArFHvZdxi/Nl2uFq+y+Puwp4qs9I4sHUUA3h0/2smDB5g0lwF1w eNQIE+k7uCzallLpvMRMGODVeP/QHQHC3z9Zp3nJ1CVj0tthe9KyHx4cYI5YZSQYZwrI NXxg== X-Gm-Message-State: AC+VfDxvm6ODFFfOSO7t0rbiMHAl/wiPihkGn2TD0RIno6baYSOyo8tY c6wa686kPnZ7LYHZWCiHDx5DFYuBQ27kNleunuF4lZByqJCb16lLhbrJrfMTj4EgnJpAIfnS+dM bqs2tQlSImKGVaiKipBaGWINi8IacCQ== X-Received: by 2002:a1c:4b04:0:b0:3f6:906:1195 with SMTP id y4-20020a1c4b04000000b003f609061195mr7704417wma.35.1685973351398; Mon, 05 Jun 2023 06:55:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4znrEkVS1+yuOmKpAKAVuIbQWKdkLDPf9Vm8LYYf3x0V4YdoqN2pBd96iXGIz6QJBYFh3SFQ== X-Received: by 2002:a1c:4b04:0:b0:3f6:906:1195 with SMTP id y4-20020a1c4b04000000b003f609061195mr7704408wma.35.1685973351053; Mon, 05 Jun 2023 06:55:51 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id m9-20020a7bce09000000b003f7e6d7f71esm1722873wmc.36.2023.06.05.06.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 06:55:50 -0700 (PDT) To: "Aktemur, Tankut Baris" , "gdb-patches@sourceware.org" Subject: RE: [PATCHv7 4/6] gdb/remote: avoid SIGINT after calling remote_target::stop In-Reply-To: References: <9a5d537b06f63d95419bd2c290304b6e881dab6a.1684178293.git.aburgess@redhat.com> Date: Mon, 05 Jun 2023 14:55:49 +0100 Message-ID: <87zg5e2eu2.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" "Aktemur, Tankut Baris" writes: > On Monday, May 15, 2023 9:22 PM, Andrew Burgess wrote: >> Currently, if the remote target is not running in non-stop mode, then, >> when GDB calls remote_target::stop, we end up sending an interrupt >> packet \x03 to the remote target. >> >> If the user interrupts the inferior from the GDB prompt (e.g. by >> typing Ctrl-c), then GDB calls remote_target::interrupt, which also >> ends up sending the interrupt packet. >> >> The problem here is that both of these mechanisms end up sending the >> interrupt packet, which means, when the target stops with a SIGINT, >> and this is reported back to GDB, we have no choice but to report this >> to the user as a SIGINT stop event. >> >> Now maybe this is the correct thing to do, after all the target has >> been stopped with SIGINT. However, this leads to an unfortunate >> change in behaviour when comparing non-stop vs all-stop mode. >> >> When running in non-stop mode, and remote_target::stop is called, the >> target will be stopped with a vCont packet, and this stop is then >> reported back to GDB as GDB_SIGNAL_0, this will cause GDB to print a >> message like: >> >> Program stopped. >> >> Or: >> >> Thread NN "binary name" stopped. >> >> In contrast, when non-stop mode is off, we get messages like: >> >> Program received SIGINT, Segmentation fault. >> >> Or: >> >> Thread NN "binary name" received SIGINT, Segmentation fault. >> >> In this commit I propose making use of thread_info::stop_requested >> within remote.c to know if the stop was triggered by GDB (and the >> SIGINT should be hidden) or if the stop was a user interrupt, and the >> SIGINT should be printed. >> >> In remote_target::process_stop_reply if the inferior stopped with >> SIGINT and the thread_info::stop_requested flag is set, then we change >> the stop signal to GDB_SIGNAL_0. >> >> Two of the tests added in the previous commit exposed this issue. In >> the previous commit the tests looked for either of the above >> patterns. In this commit I've updated these tests to only look for >> the "stopped" based messages. >> >> This commit is the reason why the previous commit took care to set the >> thread_info::stop_requested flag in infcall.c. >> --- >> gdb/remote.c | 10 ++++++++++ >> gdb/testsuite/gdb.base/infcall-timeout.exp | 9 +-------- >> .../gdb.threads/infcall-from-bp-cond-timeout.exp | 9 +-------- >> 3 files changed, 12 insertions(+), 16 deletions(-) >> >> diff --git a/gdb/remote.c b/gdb/remote.c >> index 8eaa1b2c4d1..c61eeeadc52 100644 >> --- a/gdb/remote.c >> +++ b/gdb/remote.c >> @@ -8275,6 +8275,16 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply, >> } >> else >> { >> + /* If this stop was actually requested by GDB then we can hide >> + the SIGINT from the user. */ >> + if (status->kind () == TARGET_WAITKIND_STOPPED >> + && status->sig () == GDB_SIGNAL_INT) >> + { >> + thread_info *thr = this->find_thread (ptid); > > A few lines above, there is > > remote_notice_new_inferior (ptid, false); > remote_thread_info *remote_thr = get_remote_thread_info (this, ptid); > > which first does 'target->find_thread (ptid)' to find the thread_info*. > It is unfortunate that we cannot access the thread_info* directly from > remote_thread_info*. It's not in this patch's scope to add such a backlink. > How about changing > > remote_thread_info *remote_thr = get_remote_thread_info (this, ptid); > > to > > thread_info *thr = this->find_thread (ptid); > remote_thread_info *remote_thr = get_remote_thread_info (thr); > > so that we can reuse 'thr' without having to call 'find_thread' > a second time? Great idea. I've reworked things as you suggest. This now means one of the get_remote_thread_info overloads can be deleted too, which I've done. > > Besides this suggestion, the patch looks fine to me. FWIW > Reviewed-By: Tankut Baris Aktemur I added your reviewed-by tag. Thanks, Andrew > > Thanks > -Baris > > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928