From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id DE500386F816 for ; Thu, 14 May 2020 11:16:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DE500386F816 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-V9JgEI1FPmqBOOH1ExN-Lw-1; Thu, 14 May 2020 07:16:50 -0400 X-MC-Unique: V9JgEI1FPmqBOOH1ExN-Lw-1 Received: by mail-wr1-f70.google.com with SMTP id e14so1408582wrv.11 for ; Thu, 14 May 2020 04:16:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=afLK5EeeDgGYJeYbUkITlw2tpEkkOzlWVlDCWzbfDH4=; b=qPrbUSOhJkNu+3ituZ+bHsCB86gmqWOc2d4f+YISivIG1866JjJXwe2cRda55eJ0IN V1dh93Cz3zpe1it9rp8aqS2OCopRmGh9nvTOBz0M0FiZwPqVFO0oJpCATuBFN8rGIkw8 Rph3QOF5z4cqaohCLGouVJzmGqJm0aSQiwu2DLbjo5ufmu/frt9QnGpoa42hgL4D3VkN hU04qn4L3Npc/V8rfPCFIpju+S4BpMkt6g088B5NL2iCNAL4vqxiqpWcEnGpknDLtgYb 37mA4VXYTfQdUnr11iu5YBUF/eQB9E70KwktlwmH1VvBv2U0w+fHu9G0ZDdW7cZ/4/J9 Fgbg== X-Gm-Message-State: AOAM53381BLrYJQXag4gm//mQjWVH3ADMJwxqkmS007hRUNwlgXdLRvl KuYQmILGi0KcWcHipN4sUS8mNvAwLWgOHJXVnRsKz+MJhcYV7FttvnUHjsypSowJfrX1umvjBuY UVB2BfZo6758ltnynkPpB6w== X-Received: by 2002:a5d:438e:: with SMTP id i14mr4859615wrq.413.1589455008338; Thu, 14 May 2020 04:16:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa0WqIEVb5G/Yks4IvYkZXkdUjHA0llYIbUcOgCNft376d0YUKfSSEfcWQZ/dRo+QEzh3jkQ== X-Received: by 2002:a5d:438e:: with SMTP id i14mr4859587wrq.413.1589455008090; Thu, 14 May 2020 04:16:48 -0700 (PDT) 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 b18sm3387984wrn.82.2020.05.14.04.16.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 May 2020 04:16:47 -0700 (PDT) Subject: Re: [PATCH v8 5/6] gdb/infrun: enable/disable thread events of all targets in stop_all_threads To: "Aktemur, Tankut Baris" References: <20200513205338.14233-1-palves@redhat.com> <20200513205338.14233-6-palves@redhat.com> Cc: "Metzger, Markus T" , gdb-patches From: Pedro Alves Message-ID: <060f84c1-4c08-6eb0-de76-bdfdb878c276@redhat.com> Date: Thu, 14 May 2020 12:16:46 +0100 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: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 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: , X-List-Received-Date: Thu, 14 May 2020 11:16:54 -0000 On 5/14/20 9:44 AM, Aktemur, Tankut Baris wrote: > On Wednesday, May 13, 2020 10:54 PM, Pedro Alves wrote: >> diff --git a/gdb/infrun.c b/gdb/infrun.c >> index c5bf2d0ad74..6602bc28d5e 100644 >> --- a/gdb/infrun.c >> +++ b/gdb/infrun.c >> @@ -4769,8 +4769,12 @@ stop_all_threads (void) >> >> scoped_restore_current_thread restore_thread; >> >> - target_thread_events (1); >> - SCOPE_EXIT { target_thread_events (0); }; >> + /* Enable thread events of all targets. */ >> + for (auto *target : all_non_exited_process_targets ()) >> + { >> + switch_to_target_no_thread (target); >> + target_thread_events (true); >> + } >> >> /* Request threads to stop, and then wait for the stops. Because >> threads we already know about can spawn more threads while we're >> @@ -4962,6 +4966,13 @@ stop_all_threads (void) >> } >> } >> >> + /* Disable thread events of all targets. */ >> + for (auto *target : all_non_exited_process_targets ()) >> + { >> + switch_to_target_no_thread (target); >> + target_thread_events (false); >> + } >> + >> if (debug_infrun) >> fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n"); >> } > > In internal communication, Markus pointed out that while the original > SCOPED_EXIT block would run also in the case of exceptions, the new code > does not. Here is an update that uses SCOPED_EXIT for the thread event > disabling loop, too: > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index c5bf2d0ad74..04fcc390d17 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -4769,8 +4769,22 @@ stop_all_threads (void) > > scoped_restore_current_thread restore_thread; > > - target_thread_events (1); > - SCOPE_EXIT { target_thread_events (0); }; > + /* Enable thread events of all targets. */ > + for (auto *target : all_non_exited_process_targets ()) > + { > + switch_to_target_no_thread (target); > + target_thread_events (true); > + } > + > + SCOPE_EXIT > + { > + /* Disable thread events of all targets. */ > + for (auto *target : all_non_exited_process_targets ()) > + { > + switch_to_target_no_thread (target); > + target_thread_events (false); > + } > + }; > Yes, I noticed it too, but forgot to address it. Thanks for bringing it up. I think the: if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n"); bit should also move to within SCOPE_EXIT, since we currently print that before the destructors are run. But that could be seen as an unrelated change. Thanks, Pedro Alves