From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 840063858D1E for ; Mon, 9 Oct 2023 09:20:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 840063858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696843210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0A6BBocqUG5LHcVgNksmXsiqH1OP7HvJlx0GXPSb0m0=; b=dxKfAO+SwxSIu7WmlJSlcOd7qeNd/yeorY46u1Y2geecMAnxIqlKKKfsbNyNvZUnkq7wdV obHKrq/f4z+Rm743N1FaJI/VAu74jHy816CMbsGRfmYUJaBi/CnvY2v6517wOx9eFohkN7 JqsbJh50ZHFxWMtKgiGoq+ZBJXM7fh0= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-ZX04usUSO0ulGPLn7gYR0w-1; Mon, 09 Oct 2023 05:20:08 -0400 X-MC-Unique: ZX04usUSO0ulGPLn7gYR0w-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-52310058f1eso6118366a12.0 for ; Mon, 09 Oct 2023 02:20:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696843207; x=1697448007; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0A6BBocqUG5LHcVgNksmXsiqH1OP7HvJlx0GXPSb0m0=; b=l5YVDP+ydPma4gx6FantxPosWLIkWbEv3/2XNMWDGr06qooh2plNO/aRWDAgc/K5c/ XNpqsUZLld7VlKL2ILkpUqKkdlQO4R1+XGOqRfB4B0MDvnyKkaqwYhv/6cyc/qpwWa1N Nfiw2ABrMjBgxfDJonLh4Apq4ggo9H1A+64i2KXn1c9quyACnWEoK8xxpLePcd57S6qN YpCitc3BO3BXo2zh9fQLRkN8/IqLGeOF99L2FqH8/NPnFhLhOWZ+LZ5f2+6majb2hHsS xZJk4mKRry518XmNd6iUulCIXSAEZp/xJY2XxE9mi0O5biia/Y1Egssweh0kfBVRZnBF HmcA== X-Gm-Message-State: AOJu0Yxu14FyNdA8Wqt7ymp+OOHXzr0qEPy3+jKOCAxMjdqCQUMKLEm+ zkwurW9Oac6y10W9uHRDM7WXzcmoz4hsI5/9m0F6To21yl0cI2s8xiFyzCufnvenBko/qkY/DL8 DtuAmL95aTsp6t1UTfftaRI/uDmdrhg== X-Received: by 2002:a05:6402:2687:b0:530:8b92:b69d with SMTP id w7-20020a056402268700b005308b92b69dmr10331453edd.10.1696843207079; Mon, 09 Oct 2023 02:20:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxtciB8jwNg03aRJQr9WLfa7qxyD7sgJ5uCz+gIS81NnlmDggrthG4qDsvQP300TTFwC0WKQ== X-Received: by 2002:a05:6402:2687:b0:530:8b92:b69d with SMTP id w7-20020a056402268700b005308b92b69dmr10331440edd.10.1696843206741; Mon, 09 Oct 2023 02:20:06 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id u15-20020aa7d98f000000b00533bab9d9f1sm5881674eds.1.2023.10.09.02.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:20:06 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 2/3] gdb: add remote_state::{is_async_p,can_async_p} In-Reply-To: <20231004020701.260411-3-simon.marchi@polymtl.ca> References: <20231004020701.260411-1-simon.marchi@polymtl.ca> <20231004020701.260411-3-simon.marchi@polymtl.ca> Date: Mon, 09 Oct 2023 10:20:05 +0100 Message-ID: <87cyxoduey.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: Simon Marchi via Gdb-patches writes: > From: Simon Marchi > > A subsequent patch will want to know if the remote is async within a > remote_state method. Add a helper method for that, and for "can async" > as well, for symmetry. > > Change-Id: Id0f648ee4896736479fa942f5453eeeb0e5d4352 > --- > gdb/remote.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index 2deba06d7d47..38d0027dbf9e 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -438,6 +438,20 @@ class remote_state > ::delete_async_event_handler (&m_async_event_handler_token); > } > > + bool is_async_p () const > + { > + /* We're async whenever the serial device is. */ > + return (this->remote_desc > + != nullptr && serial_is_async_p (this->remote_desc)); This seems like an off choice for line wrapping. I'd expect the newline to start with the '&&'. But... do we ever expect to ask is_async_p() before the remote_desc has been initialised? Does the answer even make sense in such a context? I wonder if we'd be better doing: bool is_async_p () const { gdb_assert (this->remote_desc != nullptr); return serial_is_async_p (this->remote_desc); } I'm thinking, that if we did ask this question before remote_desc was initialised, then when remote_desc was initialised the answer would change, and so we're probably asking to question too early... > + } > + > + bool can_async_p () const > + { > + /* We can async whenever the serial device can. */ > + return (this->remote_desc > + != nullptr && serial_can_async_p (this->remote_desc)); Same here. Thanks, Andrew > + } > + > public: /* data */ > > /* A buffer to use for incoming packets, and its current size. The > @@ -14853,16 +14867,14 @@ remote_target::can_async_p () > gdb_assert (target_async_permitted); > > /* We're async whenever the serial device can. */ > - struct remote_state *rs = get_remote_state (); > - return serial_can_async_p (rs->remote_desc); > + return get_remote_state ()->can_async_p (); > } > > bool > remote_target::is_async_p () > { > /* We're async whenever the serial device is. */ > - struct remote_state *rs = get_remote_state (); > - return serial_is_async_p (rs->remote_desc); > + return get_remote_state ()->is_async_p (); > } > > /* Pass the SERIAL event on and up to the client. One day this code > -- > 2.42.0