From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SRgHF4PigWTUkSEAWB0awg (envelope-from ) for ; Thu, 08 Jun 2023 10:15:31 -0400 Received: by simark.ca (Postfix, from userid 112) id 498571E124; Thu, 8 Jun 2023 10:15:31 -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=uxoeaw6j; 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 3A6EC1E0D4 for ; Thu, 8 Jun 2023 10:15:29 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6FCB8385735E for ; Thu, 8 Jun 2023 14:15:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FCB8385735E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686233727; bh=KwCvAkYfQ0aCiSaqJjn2alSHG759DPWItXMbUcHc1bs=; 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=uxoeaw6jFL2PINPNJnVWtw2Wt/gAbjWzF1jMesDAssp+8NVkO63J5yOgtJpQKF51C ARZExMeyaFZR0sWE2w2x1PfTCIK/Xscu6ZdrhkwwXLSUm3Cza86RKUdpMj4FZjKS5f qxaOloH4Udel84QAK3xxHZU9h9dsPPveG1uICMAQ= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4E7953858C62 for ; Thu, 8 Jun 2023 14:15:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E7953858C62 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-hc3x1eEqPAibusgvvXmfcg-1; Thu, 08 Jun 2023 10:15:00 -0400 X-MC-Unique: hc3x1eEqPAibusgvvXmfcg-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-30e4943ca7fso265173f8f.3 for ; Thu, 08 Jun 2023 07:15:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686233699; x=1688825699; 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=KwCvAkYfQ0aCiSaqJjn2alSHG759DPWItXMbUcHc1bs=; b=Jx6IncHaKTXb2JhD7yNvlap7PrPFk7xpj41p9plylPDpt+BwyEVkQGIwUptcRX6K57 J6ylLAmMe989eGLVV0NkrijV0/xBlhXszV0n9VAnZZZkwvSWODRPewJmidxUJ+y1jWiZ cHSMUJDMYla7eO6qTqJFe3Ou1yp3TLXmMEsyZB+o0nZ+l/t+DL6WpKYVjdgH3PC0xNrh Mh6m1C8t1JBTlHsnUN/w3/wQeVYzwXrN7oBADJchpmNtEDimEg53kdKZpOwHsCFnlsCD gWHx1wn62K55EYoq+O46kzEOH/nzE2BqygvEEae6VLwa+QdgUiP72fsjvyT8JLtHHGME n1Rw== X-Gm-Message-State: AC+VfDyWDEEars/GIg4pkCY+xWhTtx3q7xHZvJ5wqngISJjx78Yn9Dr0 TFJjSVeEvdRDEPUgirWvv7hmu3nbHq/M4Xxr3VpVu33JnC8RX29t+i3SZBTGzemYGYkOSKaH9Ti eu6dr7FLOlSi4+6k6CK6WrWz87vCShQ== X-Received: by 2002:a5d:680d:0:b0:2f4:9f46:6865 with SMTP id w13-20020a5d680d000000b002f49f466865mr6825708wru.30.1686233699259; Thu, 08 Jun 2023 07:14:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6AW8Q9OSGIO4xoatoZ+kW0iZcCFdz8KPeP8QepJOCFGdyQ0lHyNHx6vXTYZhQ6b+zx6sHDWg== X-Received: by 2002:a5d:680d:0:b0:2f4:9f46:6865 with SMTP id w13-20020a5d680d000000b002f49f466865mr6825697wru.30.1686233698936; Thu, 08 Jun 2023 07:14:58 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id p4-20020a5d48c4000000b0030903d44dbcsm1718654wrs.33.2023.06.08.07.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 07:14:58 -0700 (PDT) To: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH 18/31] Implement GDB_THREAD_OPTION_EXIT support for Linux GDBserver In-Reply-To: <20221212203101.1034916-19-pedro@palves.net> References: <20221212203101.1034916-1-pedro@palves.net> <20221212203101.1034916-19-pedro@palves.net> Date: Thu, 08 Jun 2023 15:14:57 +0100 Message-ID: <87o7lqyra6.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" Pedro Alves writes: > This implements support for the new GDB_THREAD_OPTION_EXIT thread > option for Linux GDBserver. LGTM. Reviewed-By: Andrew Burgess Thanks, Andrew > > Change-Id: I96b719fdf7fee94709e98bb3a90751d8134f3a38 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27338 > --- > gdbserver/linux-low.cc | 38 +++++++++++++++++++++++++------------- > gdbserver/linux-low.h | 9 +++++---- > 2 files changed, 30 insertions(+), 17 deletions(-) > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index 8c0d3103398..ebc3bf34127 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -144,6 +144,18 @@ is_leader (thread_info *thread) > return ptid.pid () == ptid.lwp (); > } > > +/* Return true if we should report thread exit events to GDB, for > + THR. */ > + > +static bool > +report_exit_events_for (thread_info *thr) > +{ > + client_state &cs = get_client_state (); > + > + return (cs.report_thread_events > + || (thr->thread_options & GDB_THREAD_OPTION_EXIT) != 0); > +} > + > /* LWP accessors. */ > > /* See nat/linux-nat.h. */ > @@ -2230,7 +2242,6 @@ linux_low_ptrace_options (int attached) > void > linux_process_target::filter_event (int lwpid, int wstat) > { > - client_state &cs = get_client_state (); > struct lwp_info *child; > struct thread_info *thread; > int have_stop_pc = 0; > @@ -2317,7 +2328,7 @@ linux_process_target::filter_event (int lwpid, int wstat) > /* If this is not the leader LWP, then the exit signal was not > the end of the debugged application and should be ignored, > unless GDB wants to hear about thread exits. */ > - if (cs.report_thread_events || is_leader (thread)) > + if (report_exit_events_for (thread) || is_leader (thread)) > { > /* Since events are serialized to GDB core, and we can't > report this one right now. Leave the status pending for > @@ -2879,13 +2890,20 @@ ptid_t > linux_process_target::filter_exit_event (lwp_info *event_child, > target_waitstatus *ourstatus) > { > - client_state &cs = get_client_state (); > struct thread_info *thread = get_lwp_thread (event_child); > ptid_t ptid = ptid_of (thread); > > + /* Note we must filter TARGET_WAITKIND_SIGNALLED as well, otherwise > + if a non-leader thread exits with a signal, we'd report it to the > + core which would interpret it as the whole-process exiting. > + There is no TARGET_WAITKIND_THREAD_SIGNALLED event kind. */ > + if (ourstatus->kind () != TARGET_WAITKIND_EXITED > + && ourstatus->kind () != TARGET_WAITKIND_SIGNALLED) > + return ptid; > + > if (!is_leader (thread)) > { > - if (cs.report_thread_events) > + if (report_exit_events_for (thread)) > ourstatus->set_thread_exited (0); > else > ourstatus->set_ignore (); > @@ -3028,10 +3046,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, > WTERMSIG (w)); > } > > - if (ourstatus->kind () == TARGET_WAITKIND_EXITED) > - return filter_exit_event (event_child, ourstatus); > - > - return ptid_of (current_thread); > + return filter_exit_event (event_child, ourstatus); > } > > /* If step-over executes a breakpoint instruction, in the case of a > @@ -3600,10 +3615,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, > target_pid_to_str (ptid_of (current_thread)).c_str (), > ourstatus->to_string ().c_str ()); > > - if (ourstatus->kind () == TARGET_WAITKIND_EXITED) > - return filter_exit_event (event_child, ourstatus); > - > - return ptid_of (current_thread); > + return filter_exit_event (event_child, ourstatus); > } > > /* Get rid of any pending event in the pipe. */ > @@ -5909,7 +5921,7 @@ linux_process_target::supports_vfork_events () > gdb_thread_options > linux_process_target::supported_thread_options () > { > - return GDB_THREAD_OPTION_CLONE; > + return GDB_THREAD_OPTION_CLONE | GDB_THREAD_OPTION_EXIT; > } > > /* Check if exec events are supported. */ > diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h > index c9f9db71e09..1c1754d2b59 100644 > --- a/gdbserver/linux-low.h > +++ b/gdbserver/linux-low.h > @@ -575,10 +575,11 @@ class linux_process_target : public process_stratum_target > exited. */ > void check_zombie_leaders (); > > - /* Convenience function that is called when the kernel reports an exit > - event. This decides whether to report the event to GDB as a > - process exit event, a thread exit event, or to suppress the > - event. */ > + /* Convenience function that is called when we're about to return an > + event to the core. If the event is an exit or signalled event, > + then this decides whether to report it as process-wide event, as > + a thread exit event, or to suppress it. All other event kinds > + are passed through unmodified. */ > ptid_t filter_exit_event (lwp_info *event_child, > target_waitstatus *ourstatus); > > -- > 2.36.0