From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 0643F3858294 for ; Wed, 20 Jul 2022 20:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0643F3858294 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AD6E11E21F; Wed, 20 Jul 2022 16:38:27 -0400 (EDT) Message-ID: <36415f8d-2e4c-fd4f-4e6d-f260463ddd71@simark.ca> Date: Wed, 20 Jul 2022 16:38:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 02/29] linux-nat: introduce pending_status_str Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org References: <20220713222433.374898-1-pedro@palves.net> <20220713222433.374898-3-pedro@palves.net> From: Simon Marchi In-Reply-To: <20220713222433.374898-3-pedro@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_PASS, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2022 20:38:29 -0000 On 2022-07-13 18:24, Pedro Alves wrote: > 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 | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c > index 0a93ab5c6ae..57cab4ce50a 100644 > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -255,6 +255,17 @@ 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) > +{ > + if (lp->waitstatus.kind () != TARGET_WAITKIND_IGNORE) > + return lp->waitstatus.to_string (); > + else > + return status_to_str (lp->status); > +} IIUC, it is a precondition of this function that LP must have a pending status? Otherwise, it would enter status_to_str and return some bogus string and be really confusing. I would suggest either: - Adding an assert with lwp_status_pending_p. - Handling the case where LP does not have a pending status, and return a string like "none". That would allow us to use that function without having to check with lwp_status_pending_p first. Otherwise, LGTM. Simon