public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 2/3] gdb: add remote_state::{is_async_p,can_async_p}
Date: Tue,  3 Oct 2023 22:04:00 -0400	[thread overview]
Message-ID: <20231004020701.260411-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20231004020701.260411-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

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));
+  }
+
+  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));
+  }
+  
 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


  parent reply	other threads:[~2023-10-04  2:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  2:03 [PATCH 0/3] Add assertion when marking the remote async flag Simon Marchi
2023-10-04  2:03 ` [PATCH 1/3] gdb: make remote_state's async token private Simon Marchi
2023-10-09  9:11   ` Andrew Burgess
2023-10-10 14:56     ` Simon Marchi
2023-10-04  2:04 ` Simon Marchi [this message]
2023-10-09  9:20   ` [PATCH 2/3] gdb: add remote_state::{is_async_p,can_async_p} Andrew Burgess
2023-10-10 15:01     ` Simon Marchi
2023-10-04  2:04 ` [PATCH 3/3] gdb: add assertion when marking the remote async flag Simon Marchi
2023-10-06 21:09   ` Terekhov, Mikhail
2023-10-07  1:35     ` Simon Marchi
2023-10-09  9:25   ` Andrew Burgess
2023-10-10 15:01     ` Simon Marchi
2023-10-06 21:28 ` [PATCH 0/3] Add " Terekhov, Mikhail

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004020701.260411-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).