[01/12] gdb: int to bool conversion for normal_stop

Message ID a9080ba356eb554dda923a301dc2191f2b120752.1666341010.git.aburgess@redhat.com
State New
Headers
Series Infcalls from B/P conditions in multi-threaded inferiors |

Commit Message

Andrew Burgess Oct. 21, 2022, 8:43 a.m. UTC
  Change the return type of normal_stop (infrun.c) from int to bool.
Update callers.

There should be no user visible changes after this commit.
---
 gdb/infcmd.c | 2 +-
 gdb/infrun.c | 6 +++---
 gdb/infrun.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
  

Comments

Lancelot SIX Nov. 4, 2022, 12:20 p.m. UTC | #1
Hi Andrew,

I believe there is one more callsite which can be updated in
infrun.c:fetch_inferior_event:

    diff --git a/gdb/infrun.c b/gdb/infrun.c
    index 3660272ef11..666c1c17f15 100644
    --- a/gdb/infrun.c
    +++ b/gdb/infrun.c
    @@ -4248,7 +4248,7 @@ fetch_inferior_event ()
            else
              {
                bool should_notify_stop = true;
    -           int proceeded = 0;
    +           bool proceeded = false;
    
                stop_all_threads_if_all_stop_mode ();

Otherwise, this looks good to me.

Best,
Lancelot.


On Fri, Oct 21, 2022 at 09:43:37AM +0100, Andrew Burgess via Gdb-patches wrote:
> Change the return type of normal_stop (infrun.c) from int to bool.
> Update callers.
> 
> There should be no user visible changes after this commit.
> ---
>  gdb/infcmd.c | 2 +-
>  gdb/infrun.c | 6 +++---
>  gdb/infrun.h | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> index d729732c81c..6af11ac0cb6 100644
> --- a/gdb/infcmd.c
> +++ b/gdb/infcmd.c
> @@ -873,7 +873,7 @@ step_1 (int skip_subroutines, int single_inst, const char *count_string)
>      proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
>    else
>      {
> -      int proceeded;
> +      bool proceeded;
>  
>        /* Stepped into an inline frame.  Pretend that we've
>  	 stopped.  */
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index cdfe02393f5..39840ef32c8 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -8614,7 +8614,7 @@ stop_context::changed () const
>  
>  /* See infrun.h.  */
>  
> -int
> +bool
>  normal_stop (void)
>  {
>    struct target_waitstatus last;
> @@ -8774,7 +8774,7 @@ normal_stop (void)
>       the observers would print a stop for the wrong
>       thread/inferior.  */
>    if (saved_context.changed ())
> -    return 1;
> +    return true;
>  
>    /* Notify observers about the stop.  This is where the interpreters
>       print the stop event.  */
> @@ -8796,7 +8796,7 @@ normal_stop (void)
>  	breakpoint_auto_delete (inferior_thread ()->control.stop_bpstat);
>      }
>  
> -  return 0;
> +  return false;
>  }
>  
>  int
> diff --git a/gdb/infrun.h b/gdb/infrun.h
> index c711b9b21cc..11a18583e68 100644
> --- a/gdb/infrun.h
> +++ b/gdb/infrun.h
> @@ -149,7 +149,7 @@ extern process_stratum_target *user_visible_resume_target (ptid_t resume_ptid);
>     appropriate messages, remove breakpoints, give terminal our modes,
>     and run the stop hook.  Returns true if the stop hook proceeded the
>     target, false otherwise.  */
> -extern int normal_stop (void);
> +extern bool normal_stop (void);
>  
>  /* Return the cached copy of the last target/ptid/waitstatus returned
>     by target_wait().  The data is actually cached by handle_inferior_event(),
> -- 
> 2.25.4
>
  
Andrew Burgess Jan. 13, 2023, 4:35 p.m. UTC | #2
Lancelot SIX <lsix@lancelotsix.com> writes:

> Hi Andrew,
>
> I believe there is one more callsite which can be updated in
> infrun.c:fetch_inferior_event:
>
>     diff --git a/gdb/infrun.c b/gdb/infrun.c
>     index 3660272ef11..666c1c17f15 100644
>     --- a/gdb/infrun.c
>     +++ b/gdb/infrun.c
>     @@ -4248,7 +4248,7 @@ fetch_inferior_event ()
>             else
>               {
>                 bool should_notify_stop = true;
>     -           int proceeded = 0;
>     +           bool proceeded = false;
>     
>                 stop_all_threads_if_all_stop_mode ();
>
> Otherwise, this looks good to me.

Thanks, I made this update and pushed this patch.  The final version
that I pushed is below.

Thanks,
Andrew

---

commit 8dd08de7e48850496321548099ef86d3275679b9
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Mon Oct 17 15:01:24 2022 +0100

    gdb: int to bool conversion for normal_stop
    
    Change the return type of normal_stop (infrun.c) from int to bool.
    Update callers.
    
    I've also converted the (void) to () in the function declaration and
    definition, given I was changing those lines anyway.
    
    There should be no user visible changes after this commit.

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 0497ad05091..7d5ec77ff57 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -885,12 +885,10 @@ step_1 (int skip_subroutines, int single_inst, const char *count_string)
     proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
   else
     {
-      int proceeded;
-
       /* Stepped into an inline frame.  Pretend that we've
 	 stopped.  */
       thr->thread_fsm ()->clean_up (thr);
-      proceeded = normal_stop ();
+      bool proceeded = normal_stop ();
       if (!proceeded)
 	inferior_event_handler (INF_EXEC_COMPLETE);
       all_uis_check_sync_execution_done ();
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 181d961d80d..1a2ef2d078b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4219,7 +4219,7 @@ fetch_inferior_event ()
 	else
 	  {
 	    bool should_notify_stop = true;
-	    int proceeded = 0;
+	    bool proceeded = false;
 
 	    stop_all_threads_if_all_stop_mode ();
 
@@ -8582,8 +8582,8 @@ stop_context::changed () const
 
 /* See infrun.h.  */
 
-int
-normal_stop (void)
+bool
+normal_stop ()
 {
   struct target_waitstatus last;
 
@@ -8742,7 +8742,7 @@ normal_stop (void)
      the observers would print a stop for the wrong
      thread/inferior.  */
   if (saved_context.changed ())
-    return 1;
+    return true;
 
   /* Notify observers about the stop.  This is where the interpreters
      print the stop event.  */
@@ -8764,7 +8764,7 @@ normal_stop (void)
 	breakpoint_auto_delete (inferior_thread ()->control.stop_bpstat);
     }
 
-  return 0;
+  return false;
 }
 
 int
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 19e68155ec4..43fd1b44f5a 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -149,7 +149,7 @@ extern process_stratum_target *user_visible_resume_target (ptid_t resume_ptid);
    appropriate messages, remove breakpoints, give terminal our modes,
    and run the stop hook.  Returns true if the stop hook proceeded the
    target, false otherwise.  */
-extern int normal_stop (void);
+extern bool normal_stop ();
 
 /* Return the cached copy of the last target/ptid/waitstatus returned
    by target_wait().  The data is actually cached by handle_inferior_event(),
  

Patch

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index d729732c81c..6af11ac0cb6 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -873,7 +873,7 @@  step_1 (int skip_subroutines, int single_inst, const char *count_string)
     proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
   else
     {
-      int proceeded;
+      bool proceeded;
 
       /* Stepped into an inline frame.  Pretend that we've
 	 stopped.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index cdfe02393f5..39840ef32c8 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8614,7 +8614,7 @@  stop_context::changed () const
 
 /* See infrun.h.  */
 
-int
+bool
 normal_stop (void)
 {
   struct target_waitstatus last;
@@ -8774,7 +8774,7 @@  normal_stop (void)
      the observers would print a stop for the wrong
      thread/inferior.  */
   if (saved_context.changed ())
-    return 1;
+    return true;
 
   /* Notify observers about the stop.  This is where the interpreters
      print the stop event.  */
@@ -8796,7 +8796,7 @@  normal_stop (void)
 	breakpoint_auto_delete (inferior_thread ()->control.stop_bpstat);
     }
 
-  return 0;
+  return false;
 }
 
 int
diff --git a/gdb/infrun.h b/gdb/infrun.h
index c711b9b21cc..11a18583e68 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -149,7 +149,7 @@  extern process_stratum_target *user_visible_resume_target (ptid_t resume_ptid);
    appropriate messages, remove breakpoints, give terminal our modes,
    and run the stop hook.  Returns true if the stop hook proceeded the
    target, false otherwise.  */
-extern int normal_stop (void);
+extern bool normal_stop (void);
 
 /* Return the cached copy of the last target/ptid/waitstatus returned
    by target_wait().  The data is actually cached by handle_inferior_event(),