[2/4] gdb/remote: merge ::is_async_p and ::can_async_p methods

Message ID 9c8428eee795182bb60ed37752e48db404ea9307.1637676250.git.aburgess@redhat.com
State New
Headers show
Series
  • Improve 'maint set target-async off' for remote targets
Related show

Commit Message

Mike Frysinger via Gdb-patches Nov. 23, 2021, 2:08 p.m.
I spotted in passing that remote_target::is_async_p and
remote_target::can_async_p are identical.  This commit just makes
::is_async_p call ::can_async_p, removing some duplicate code.

There should be no user visible changes after this commit.
---
 gdb/remote.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

-- 
2.25.4

Comments

Simon Marchi Nov. 23, 2021, 9:33 p.m. | #1
On 2021-11-23 9:08 a.m., Andrew Burgess via Gdb-patches wrote:
> I spotted in passing that remote_target::is_async_p and

> remote_target::can_async_p are identical.  This commit just makes

> ::is_async_p call ::can_async_p, removing some duplicate code.

>

> There should be no user visible changes after this commit.

> ---

>  gdb/remote.c | 18 ++++--------------

>  1 file changed, 4 insertions(+), 14 deletions(-)

>

> diff --git a/gdb/remote.c b/gdb/remote.c

> index 61bde5aaa94..0c4cc6bad0b 100644

> --- a/gdb/remote.c

> +++ b/gdb/remote.c

> @@ -546,7 +546,10 @@ class remote_target : public process_stratum_target

>

>    bool can_async_p () override;

>

> -  bool is_async_p () override;

> +  bool is_async_p () override

> +  {

> +    return can_async_p ();

> +  }

>

>    void async (int) override;

>

> @@ -14390,19 +14393,6 @@ remote_target::can_async_p ()

>    return serial_can_async_p (rs->remote_desc);

>  }

>

> -bool

> -remote_target::is_async_p ()

> -{

> -  struct remote_state *rs = get_remote_state ();

> -

> -  if (!target_async_permitted)

> -    /* We only enable async when the user specifically asks for it.  */

> -    return false;

> -

> -  /* We're async whenever the serial device is.  */

> -  return serial_is_async_p (rs->remote_desc);

> -}

> -

>  /* Pass the SERIAL event on and up to the client.  One day this code

>     will be able to delay notifying the client of an event until the

>     point where an entire packet has been received.  */

> --

> 2.25.4

>


Hmm, one calls serial_can_async_p and the other calls serial_is_async_p,
I would guess that the distinction is important.

Simon
Mike Frysinger via Gdb-patches Nov. 24, 2021, 10:14 a.m. | #2
Simon Marchi <simark@simark.ca> writes:

> On 2021-11-23 9:08 a.m., Andrew Burgess via Gdb-patches wrote:

>> I spotted in passing that remote_target::is_async_p and

>> remote_target::can_async_p are identical.  This commit just makes

>> ::is_async_p call ::can_async_p, removing some duplicate code.

>>

>> There should be no user visible changes after this commit.

>> ---

>>  gdb/remote.c | 18 ++++--------------

>>  1 file changed, 4 insertions(+), 14 deletions(-)

>>

>> diff --git a/gdb/remote.c b/gdb/remote.c

>> index 61bde5aaa94..0c4cc6bad0b 100644

>> --- a/gdb/remote.c

>> +++ b/gdb/remote.c

>> @@ -546,7 +546,10 @@ class remote_target : public process_stratum_target

>>

>>    bool can_async_p () override;

>>

>> -  bool is_async_p () override;

>> +  bool is_async_p () override

>> +  {

>> +    return can_async_p ();

>> +  }

>>

>>    void async (int) override;

>>

>> @@ -14390,19 +14393,6 @@ remote_target::can_async_p ()

>>    return serial_can_async_p (rs->remote_desc);

>>  }

>>

>> -bool

>> -remote_target::is_async_p ()

>> -{

>> -  struct remote_state *rs = get_remote_state ();

>> -

>> -  if (!target_async_permitted)

>> -    /* We only enable async when the user specifically asks for it.  */

>> -    return false;

>> -

>> -  /* We're async whenever the serial device is.  */

>> -  return serial_is_async_p (rs->remote_desc);

>> -}

>> -

>>  /* Pass the SERIAL event on and up to the client.  One day this code

>>     will be able to delay notifying the client of an event until the

>>     point where an entire packet has been received.  */

>> --

>> 2.25.4

>>

>

> Hmm, one calls serial_can_async_p and the other calls serial_is_async_p,

> I would guess that the distinction is important.


Thank you for spotting this.  I'm embarrassed that I missed that.

This patch is withdrawn.  The rest of the series is still fine though.

Thanks,
Andrew

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 61bde5aaa94..0c4cc6bad0b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -546,7 +546,10 @@  class remote_target : public process_stratum_target
 
   bool can_async_p () override;
 
-  bool is_async_p () override;
+  bool is_async_p () override
+  {
+    return can_async_p ();
+  }
 
   void async (int) override;
 
@@ -14390,19 +14393,6 @@  remote_target::can_async_p ()
   return serial_can_async_p (rs->remote_desc);
 }
 
-bool
-remote_target::is_async_p ()
-{
-  struct remote_state *rs = get_remote_state ();
-
-  if (!target_async_permitted)
-    /* We only enable async when the user specifically asks for it.  */
-    return false;
-
-  /* We're async whenever the serial device is.  */
-  return serial_is_async_p (rs->remote_desc);
-}
-
 /* Pass the SERIAL event on and up to the client.  One day this code
    will be able to delay notifying the client of an event until the
    point where an entire packet has been received.  */