Message ID | 20221212203101.1034916-3-pedro@palves.net |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BAF37384C346 for <patchwork@sourceware.org>; Mon, 12 Dec 2022 20:31:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by sourceware.org (Postfix) with ESMTPS id 3F838384E200 for <gdb-patches@sourceware.org>; Mon, 12 Dec 2022 20:31:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3F838384E200 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso6235521wme.5 for <gdb-patches@sourceware.org>; Mon, 12 Dec 2022 12:31:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r5WAd+MFSJx/2vL/WA1nZBUSn/EC1WtGHCsOO6tAPFk=; b=ThYB/NK40xvye/GHoKih6QtfxIZUCjrUZQYgYkCGdkbPkrGsMNqQ/lc5bF711LL3NN FXH30786l+GYoIxrc6xPhowTXzUl42fg1DeXFhLIVt5kOioQAbe1wH8FaPmJWm1fXJ/r cklhyoah6Zhqyahr8wZ1jDPGpZn8JFVT/Ahr+sBFoNcYF32xESCi9qJMYgAkw8kNafyG XIIgRets3zmm+2nQGpty3r3Z2j6t6Zm0434wmHNlPHpQi/dTYCDl0yPWXo3HTkDZm5VP TnFPMvclda2OMfoHF+cFut8HMC8/igGFqknHVpzmw2JahkcVQROB1L8snvfLMCgA62EI X/OQ== X-Gm-Message-State: ANoB5pkE3Nt7iSWezrcPAIRYKwQyz6kFne5nev/hC4mWSNayr9cLfGqR aVs2wosd/AO9s0VAsGtxm9ApLdJtr5oelw== X-Google-Smtp-Source: AA0mqf6xvugbjNIUMbirciV9wrUTPU98JtxwL/F75YE7k1PBgzx4J41q/IvDbWqDVkgKF7wKpXYkhQ== X-Received: by 2002:a1c:4b0d:0:b0:3c6:e60f:3f63 with SMTP id y13-20020a1c4b0d000000b003c6e60f3f63mr13872665wma.26.1670877059968; Mon, 12 Dec 2022 12:30:59 -0800 (PST) Received: from localhost ([2001:8a0:f912:6700:afd9:8b6d:223f:6170]) by smtp.gmail.com with ESMTPSA id g23-20020a05600c4c9700b003cf4ec90938sm9908243wmp.21.2022.12.12.12.30.59 for <gdb-patches@sourceware.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 12:30:59 -0800 (PST) From: Pedro Alves <pedro@palves.net> To: gdb-patches@sourceware.org Subject: [PATCH 02/31] linux-nat: introduce pending_status_str Date: Mon, 12 Dec 2022 20:30:32 +0000 Message-Id: <20221212203101.1034916-3-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221212203101.1034916-1-pedro@palves.net> References: <20221212203101.1034916-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Step over thread clone and thread exit
|
|
Commit Message
Pedro Alves
Dec. 12, 2022, 8:30 p.m. UTC
I noticed that some debug log output printing an lwp's pending status wasn't considering lp->waitstatus. This fixes it, by introducing a new pending_status_str function. Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980 --- gdb/linux-nat.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
Comments
Pedro Alves <pedro@palves.net> writes: > I noticed that some debug log output printing an lwp's pending status > wasn't considering lp->waitstatus. This fixes it, by introducing a > new pending_status_str function. This patch looks fine. I had one slightly related question: I took a look at the comment on lwp_info::waitstatus in linux-nat.h, which says: /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus for this LWP's last event. This may correspond to STATUS above, or to a local variable in lin_lwp_wait. */ struct target_waitstatus waitstatus; Am I right in thinking that this comment is wrong; it should say TARGET_WAITKIND_IGNORE, not TARGET_WAITKIND_SPURIOUS, right? Thanks, Andrew > > Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980 > --- > gdb/linux-nat.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c > index 17e5dce08c3..9b78fd1f8e8 100644 > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -256,6 +256,19 @@ is_leader (lwp_info *lp) > return lp->ptid.pid () == lp->ptid.lwp (); > } > > +/* Convert an LWP's pending status to a std::string. */ > + > +static std::string > +pending_status_str (lwp_info *lp) > +{ > + gdb_assert (lwp_status_pending_p (lp)); > + > + if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE) > + return lp->waitstatus.to_string (); > + else > + return status_to_str (lp->status); > +} > + > > /* LWP accessors. */ > > @@ -1647,8 +1660,8 @@ linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo) > this thread with a signal? */ > gdb_assert (signo == GDB_SIGNAL_0); > > - linux_nat_debug_printf ("Short circuiting for status 0x%x", > - lp->status); > + linux_nat_debug_printf ("Short circuiting for status %s", > + pending_status_str (lp).c_str ()); > > if (target_can_async_p ()) > { > @@ -3137,7 +3150,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, > if (lp != NULL) > { > linux_nat_debug_printf ("Using pending wait status %s for %s.", > - status_to_str (lp->status).c_str (), > + pending_status_str (lp).c_str (), > lp->ptid.to_string ().c_str ()); > } > > -- > 2.36.0
On 2023-02-03 12:00 p.m., Andrew Burgess wrote: > Pedro Alves <pedro@palves.net> writes: > >> I noticed that some debug log output printing an lwp's pending status >> wasn't considering lp->waitstatus. This fixes it, by introducing a >> new pending_status_str function. > > This patch looks fine. I had one slightly related question: I took a > look at the comment on lwp_info::waitstatus in linux-nat.h, which says: > > /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus > for this LWP's last event. This may correspond to STATUS above, > or to a local variable in lin_lwp_wait. */ > struct target_waitstatus waitstatus; > > Am I right in thinking that this comment is wrong; it should say > TARGET_WAITKIND_IGNORE, not TARGET_WAITKIND_SPURIOUS, right? You're right. I tweaked the comments in linux-nat.h in this new version. Let me know what you think. From 10f88baff2e25fb87f37d1665bf283206171dd42 Mon Sep 17 00:00:00 2001 From: Pedro Alves <pedro@palves.net> Date: Fri, 12 Nov 2021 20:50:29 +0000 Subject: [PATCH] linux-nat: introduce pending_status_str I noticed that some debug log output printing an lwp's pending status wasn't considering lp->waitstatus. This fixes it, by introducing a new pending_status_str function. Also fix the comment in gdb/linux-nat.h describing lwp_info::waitstatus and details the description of lwp_info::status while at it. Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980 --- gdb/linux-nat.c | 19 ++++++++++++++++--- gdb/linux-nat.h | 11 +++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index e5391b9ce35..9d811bbf3ff 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -255,6 +255,19 @@ is_leader (lwp_info *lp) return lp->ptid.pid () == lp->ptid.lwp (); } +/* Convert an LWP's pending status to a std::string. */ + +static std::string +pending_status_str (lwp_info *lp) +{ + gdb_assert (lwp_status_pending_p (lp)); + + if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE) + return lp->waitstatus.to_string (); + else + return status_to_str (lp->status); +} + /* LWP accessors. */ @@ -1647,8 +1660,8 @@ linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo) this thread with a signal? */ gdb_assert (signo == GDB_SIGNAL_0); - linux_nat_debug_printf ("Short circuiting for status 0x%x", - lp->status); + linux_nat_debug_printf ("Short circuiting for status %s", + pending_status_str (lp).c_str ()); if (target_can_async_p ()) { @@ -3137,7 +3150,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, if (lp != NULL) { linux_nat_debug_printf ("Using pending wait status %s for %s.", - status_to_str (lp->status).c_str (), + pending_status_str (lp).c_str (), lp->ptid.to_string ().c_str ()); } diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 45534c92386..770fe924427 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -232,7 +232,9 @@ struct lwp_info : intrusive_list_node<lwp_info> /* The last resume GDB requested on this thread. */ resume_kind last_resume_kind = resume_continue; - /* If non-zero, a pending wait status. */ + /* If non-zero, a pending wait status. A pending process exit is + recorded in WAITSTATUS, because W_EXITCODE(0,0) happens to be + 0. */ int status = 0; /* When 'stopped' is set, this is where the lwp last stopped, with @@ -260,9 +262,10 @@ struct lwp_info : intrusive_list_node<lwp_info> /* Non-zero if we expect a duplicated SIGINT. */ int ignore_sigint = 0; - /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus - for this LWP's last event. This may correspond to STATUS above, - or to a local variable in lin_lwp_wait. */ + /* If WAITSTATUS->KIND != TARGET_WAITKIND_IGNORE, the waitstatus for + this LWP's last event. This usually corresponds to STATUS above, + however because W_EXITCODE(0,0) happens to be 0, a process exit + will be recorded here, while 'status == 0' is ambiguous. */ struct target_waitstatus waitstatus; /* Signal whether we are in a SYSCALL_ENTRY or base-commit: 2562954ede66f32bff7d985e752b8052c2ae5775 prerequisite-patch-id: bbc9918ac5f79de07a29f34ec072794d270f942d
Pedro Alves <pedro@palves.net> writes: > On 2023-02-03 12:00 p.m., Andrew Burgess wrote: >> Pedro Alves <pedro@palves.net> writes: >> >>> I noticed that some debug log output printing an lwp's pending status >>> wasn't considering lp->waitstatus. This fixes it, by introducing a >>> new pending_status_str function. >> >> This patch looks fine. I had one slightly related question: I took a >> look at the comment on lwp_info::waitstatus in linux-nat.h, which says: >> >> /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus >> for this LWP's last event. This may correspond to STATUS above, >> or to a local variable in lin_lwp_wait. */ >> struct target_waitstatus waitstatus; >> >> Am I right in thinking that this comment is wrong; it should say >> TARGET_WAITKIND_IGNORE, not TARGET_WAITKIND_SPURIOUS, right? > > You're right. > > I tweaked the comments in linux-nat.h in this new version. Let me know what > you think. > > From 10f88baff2e25fb87f37d1665bf283206171dd42 Mon Sep 17 00:00:00 2001 > From: Pedro Alves <pedro@palves.net> > Date: Fri, 12 Nov 2021 20:50:29 +0000 > Subject: [PATCH] linux-nat: introduce pending_status_str > > I noticed that some debug log output printing an lwp's pending status > wasn't considering lp->waitstatus. This fixes it, by introducing a > new pending_status_str function. > > Also fix the comment in gdb/linux-nat.h describing > lwp_info::waitstatus and details the description of lwp_info::status > while at it. > > Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980 > --- > gdb/linux-nat.c | 19 ++++++++++++++++--- > gdb/linux-nat.h | 11 +++++++---- > 2 files changed, 23 insertions(+), 7 deletions(-) LGTM. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Thanks, Andrew > > diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c > index e5391b9ce35..9d811bbf3ff 100644 > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -255,6 +255,19 @@ is_leader (lwp_info *lp) > return lp->ptid.pid () == lp->ptid.lwp (); > } > > +/* Convert an LWP's pending status to a std::string. */ > + > +static std::string > +pending_status_str (lwp_info *lp) > +{ > + gdb_assert (lwp_status_pending_p (lp)); > + > + if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE) > + return lp->waitstatus.to_string (); > + else > + return status_to_str (lp->status); > +} > + > > /* LWP accessors. */ > > @@ -1647,8 +1660,8 @@ linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo) > this thread with a signal? */ > gdb_assert (signo == GDB_SIGNAL_0); > > - linux_nat_debug_printf ("Short circuiting for status 0x%x", > - lp->status); > + linux_nat_debug_printf ("Short circuiting for status %s", > + pending_status_str (lp).c_str ()); > > if (target_can_async_p ()) > { > @@ -3137,7 +3150,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, > if (lp != NULL) > { > linux_nat_debug_printf ("Using pending wait status %s for %s.", > - status_to_str (lp->status).c_str (), > + pending_status_str (lp).c_str (), > lp->ptid.to_string ().c_str ()); > } > > diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h > index 45534c92386..770fe924427 100644 > --- a/gdb/linux-nat.h > +++ b/gdb/linux-nat.h > @@ -232,7 +232,9 @@ struct lwp_info : intrusive_list_node<lwp_info> > /* The last resume GDB requested on this thread. */ > resume_kind last_resume_kind = resume_continue; > > - /* If non-zero, a pending wait status. */ > + /* If non-zero, a pending wait status. A pending process exit is > + recorded in WAITSTATUS, because W_EXITCODE(0,0) happens to be > + 0. */ > int status = 0; > > /* When 'stopped' is set, this is where the lwp last stopped, with > @@ -260,9 +262,10 @@ struct lwp_info : intrusive_list_node<lwp_info> > /* Non-zero if we expect a duplicated SIGINT. */ > int ignore_sigint = 0; > > - /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus > - for this LWP's last event. This may correspond to STATUS above, > - or to a local variable in lin_lwp_wait. */ > + /* If WAITSTATUS->KIND != TARGET_WAITKIND_IGNORE, the waitstatus for > + this LWP's last event. This usually corresponds to STATUS above, > + however because W_EXITCODE(0,0) happens to be 0, a process exit > + will be recorded here, while 'status == 0' is ambiguous. */ > struct target_waitstatus waitstatus; > > /* Signal whether we are in a SYSCALL_ENTRY or > > base-commit: 2562954ede66f32bff7d985e752b8052c2ae5775 > prerequisite-patch-id: bbc9918ac5f79de07a29f34ec072794d270f942d > -- > 2.36.0
On 2023-03-16 4:19 p.m., Andrew Burgess wrote: > Pedro Alves <pedro@palves.net> writes: >> I tweaked the comments in linux-nat.h in this new version. Let me know what >> you think. >> >> From 10f88baff2e25fb87f37d1665bf283206171dd42 Mon Sep 17 00:00:00 2001 >> From: Pedro Alves <pedro@palves.net> >> Date: Fri, 12 Nov 2021 20:50:29 +0000 >> Subject: [PATCH] linux-nat: introduce pending_status_str >> >> I noticed that some debug log output printing an lwp's pending status >> wasn't considering lp->waitstatus. This fixes it, by introducing a >> new pending_status_str function. >> >> Also fix the comment in gdb/linux-nat.h describing >> lwp_info::waitstatus and details the description of lwp_info::status >> while at it. >> >> Change-Id: I66e5c7a363d30a925b093b195d72925ce5b6b980 >> --- >> gdb/linux-nat.c | 19 ++++++++++++++++--- >> gdb/linux-nat.h | 11 +++++++---- >> 2 files changed, 23 insertions(+), 7 deletions(-) > > LGTM. > > Reviewed-By: Andrew Burgess <aburgess@redhat.com> > Thanks, I've merged this one as well, as it's pretty much independent/standalone.
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 17e5dce08c3..9b78fd1f8e8 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -256,6 +256,19 @@ is_leader (lwp_info *lp) return lp->ptid.pid () == lp->ptid.lwp (); } +/* Convert an LWP's pending status to a std::string. */ + +static std::string +pending_status_str (lwp_info *lp) +{ + gdb_assert (lwp_status_pending_p (lp)); + + if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE) + return lp->waitstatus.to_string (); + else + return status_to_str (lp->status); +} + /* LWP accessors. */ @@ -1647,8 +1660,8 @@ linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo) this thread with a signal? */ gdb_assert (signo == GDB_SIGNAL_0); - linux_nat_debug_printf ("Short circuiting for status 0x%x", - lp->status); + linux_nat_debug_printf ("Short circuiting for status %s", + pending_status_str (lp).c_str ()); if (target_can_async_p ()) { @@ -3137,7 +3150,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, if (lp != NULL) { linux_nat_debug_printf ("Using pending wait status %s for %s.", - status_to_str (lp->status).c_str (), + pending_status_str (lp).c_str (), lp->ptid.to_string ().c_str ()); }