[binutils-gdb] gdb: add remote_state::{is_async_p,can_async_p}

Simon Marchi simark@sourceware.org
Tue Oct 10 16:42:30 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e84ffe7bcf2f718a492fc3645785a7705fde6d23

commit e84ffe7bcf2f718a492fc3645785a7705fde6d23
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Oct 10 10:53:36 2023 -0400

    gdb: add remote_state::{is_async_p,can_async_p}
    
    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
    Approved-By: Andrew Burgess <aburgess@redhat.com>

Diff:
---
 gdb/remote.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index cc767ef6a8a..5f12f93ef4f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -439,6 +439,20 @@ public:
       ::delete_async_event_handler (&m_async_event_handler_token);
   }
 
+  bool is_async_p () const
+  {
+    /* We're async whenever the serial device is.  */
+    gdb_assert (this->remote_desc != nullptr);
+    return serial_is_async_p (this->remote_desc);
+  }
+
+  bool can_async_p () const
+  {
+    /* We can async whenever the serial device can.  */
+    gdb_assert (this->remote_desc != nullptr);
+    return serial_can_async_p (this->remote_desc);
+  }
+
 public: /* data */
 
   /* A buffer to use for incoming packets, and its current size.  The
@@ -14858,16 +14872,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


More information about the Gdb-cvs mailing list