gdb: bool-ify follow_fork
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 24 Mar 2020 17:44:58 +0000 (13:44 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 24 Mar 2020 17:45:21 +0000 (13:45 -0400)
Change parameters and return value of the various follow_fork
functions/methods from int to bool.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_nat_target::follow_fork): Change bool to int.
* fbsd-nat.h (class fbsd_nat_target) <follow_fork>: Likewise.
* inf-ptrace.c (inf_ptrace_target::follow_fork): Likewise.
* inf-ptrace.h (struct inf_ptrace_target) <follow_fork>: Likewise.
* infrun.c (follow_fork): Likewise.
(follow_fork_inferior): Likewise.
* linux-nat.c (linux_nat_target::follow_fork): Likewise.
* linux-nat.h (class linux_nat_target): Likewise.
* remote.c (class remote_target) <follow_fork>: Likewise.
(remote_target::follow_fork): Likewise.
* target-delegates.c: Re-generate.
* target.c (default_follow_fork): Likewise.
(target_follow_fork): Likewise.
* target.h (struct target_ops) <follow_fork>: Likewise.
(target_follow_fork): Likewise.

12 files changed:
gdb/ChangeLog
gdb/fbsd-nat.c
gdb/fbsd-nat.h
gdb/inf-ptrace.c
gdb/inf-ptrace.h
gdb/infrun.c
gdb/linux-nat.c
gdb/linux-nat.h
gdb/remote.c
gdb/target-delegates.c
gdb/target.c
gdb/target.h

index 1acd1fddc92f0c4c2946a75bbb79ed22e3e8c4c8..ced1b6d43fadfac9dc68a64ad4612fef499e94a7 100644 (file)
@@ -1,3 +1,21 @@
+2020-03-24  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * fbsd-nat.c (fbsd_nat_target::follow_fork): Change bool to int.
+       * fbsd-nat.h (class fbsd_nat_target) <follow_fork>: Likewise.
+       * inf-ptrace.c (inf_ptrace_target::follow_fork): Likewise.
+       * inf-ptrace.h (struct inf_ptrace_target) <follow_fork>: Likewise.
+       * infrun.c (follow_fork): Likewise.
+       (follow_fork_inferior): Likewise.
+       * linux-nat.c (linux_nat_target::follow_fork): Likewise.
+       * linux-nat.h (class linux_nat_target): Likewise.
+       * remote.c (class remote_target) <follow_fork>: Likewise.
+       (remote_target::follow_fork): Likewise.
+       * target-delegates.c: Re-generate.
+       * target.c (default_follow_fork): Likewise.
+       (target_follow_fork): Likewise.
+       * target.h (struct target_ops) <follow_fork>: Likewise.
+       (target_follow_fork): Likewise.
+
 2020-03-24  Tom de Vries  <tdevries@suse.de>
 
        * psymtab.c (maintenance_info_psymtabs): Print user field.
index 0e4afb29a009f05be79c9940cf495930cff89bfa..1d189a250136525244ea0adfe8071b6500fdcdaf 100644 (file)
@@ -1548,8 +1548,8 @@ fbsd_nat_target::supports_stopped_by_sw_breakpoint ()
 /* Target hook for follow_fork.  On entry and at return inferior_ptid is
    the ptid of the followed inferior.  */
 
-int
-fbsd_nat_target::follow_fork (int follow_child, int detach_fork)
+bool
+fbsd_nat_target::follow_fork (bool follow_child, bool detach_fork)
 {
   if (!follow_child && detach_fork)
     {
@@ -1592,7 +1592,7 @@ fbsd_nat_target::follow_fork (int follow_child, int detach_fork)
 #endif
     }
 
-  return 0;
+  return false;
 }
 
 int
index 87ff1b05b334dff689fcbbfb7eefee0746a88215..40117177b15bbe4eec7276df7c58b04eed72534a 100644 (file)
@@ -75,7 +75,7 @@ public:
 #endif
 
 #ifdef TDP_RFPPWAIT
-  int follow_fork (int, int) override;
+  bool follow_fork (bool, bool) override;
 
   int insert_fork_catchpoint (int) override;
   int remove_fork_catchpoint (int) override;
index a6a77ef9d31a9e47a35bdde25000deea3206d804..1fa7aa3f73e996024ef9df7c09477fc223b93cc4 100644 (file)
@@ -73,8 +73,8 @@ inf_ptrace_target::~inf_ptrace_target ()
 /* Target hook for follow_fork.  On entry and at return inferior_ptid is
    the ptid of the followed inferior.  */
 
-int
-inf_ptrace_target::follow_fork (int follow_child, int detach_fork)
+bool
+inf_ptrace_target::follow_fork (bool follow_child, bool detach_fork)
 {
   if (!follow_child)
     {
@@ -88,7 +88,7 @@ inf_ptrace_target::follow_fork (int follow_child, int detach_fork)
        perror_with_name (("ptrace"));
     }
 
-  return 0;
+  return false;
 }
 
 int
index dea82d005e35adeda4bcf4b82c348b0fbe48d9a8..05c1277ec4e24789c4a9de772bb2a9e3684c3b95 100644 (file)
@@ -44,7 +44,7 @@ struct inf_ptrace_target : public inf_child_target
   void create_inferior (const char *, const std::string &,
                        char **, int) override;
 #ifdef PT_GET_PROCESS_STATE
-  int follow_fork (int, int) override;
+  bool follow_fork (bool, bool) override;
 
   int insert_fork_catchpoint (int) override;
 
index d672d1a1609b83856dbff08d0af396c1e27b7dd1..1fb445aa247eee33e03b05f44bfbb07f22ce9256 100644 (file)
@@ -73,10 +73,6 @@ static void sig_print_info (enum gdb_signal);
 
 static void sig_print_header (void);
 
-static int follow_fork (void);
-
-static int follow_fork_inferior (int follow_child, int detach_fork);
-
 static void follow_inferior_reset_breakpoints (void);
 
 static int currently_stepping (struct thread_info *tp);
@@ -411,8 +407,8 @@ show_follow_fork_mode_string (struct ui_file *file, int from_tty,
    the fork parent.  At return inferior_ptid is the ptid of the
    followed inferior.  */
 
-static int
-follow_fork_inferior (int follow_child, int detach_fork)
+static bool
+follow_fork_inferior (bool follow_child, bool detach_fork)
 {
   int has_vforked;
   ptid_t parent_ptid, child_ptid;
@@ -669,11 +665,11 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
    if the inferior should be resumed; false, if the target for some
    reason decided it's best not to resume.  */
 
-static int
-follow_fork (void)
+static bool
+follow_fork ()
 {
-  int follow_child = (follow_fork_mode_string == follow_fork_mode_child);
-  int should_resume = 1;
+  bool follow_child = (follow_fork_mode_string == follow_fork_mode_child);
+  bool should_resume = true;
   struct thread_info *tp;
 
   /* Copy user stepping state to the new inferior thread.  FIXME: the
@@ -714,7 +710,7 @@ follow_fork (void)
             happened.  */
          thread_info *wait_thread = find_thread_ptid (wait_target, wait_ptid);
          switch_to_thread (wait_thread);
-         should_resume = 0;
+         should_resume = false;
        }
     }
 
@@ -5428,8 +5424,7 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
         watchpoints, for example, always appear in the bpstat.  */
       if (!bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
        {
-         int should_resume;
-         int follow_child
+         bool follow_child
            = (follow_fork_mode_string == follow_fork_mode_child);
 
          ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
@@ -5437,7 +5432,7 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
          process_stratum_target *targ
            = ecs->event_thread->inf->process_target ();
 
-         should_resume = follow_fork ();
+         bool should_resume = follow_fork ();
 
          /* Note that one of these may be an invalid pointer,
             depending on detach_fork.  */
index 81af83c4ac59559f4da28ea085cf3a88221903a1..133b87ca742cf00f3481673a20e8b80f41aaf746 100644 (file)
@@ -440,8 +440,8 @@ typedef std::unique_ptr<struct lwp_info, lwp_deleter> lwp_info_up;
    ptid of the followed inferior.  At return, inferior_ptid will be
    unchanged.  */
 
-int
-linux_nat_target::follow_fork (int follow_child, int detach_fork)
+bool
+linux_nat_target::follow_fork (bool follow_child, bool detach_fork)
 {
   if (!follow_child)
     {
@@ -611,7 +611,7 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork)
       check_for_thread_db ();
     }
 
-  return 0;
+  return false;
 }
 
 \f
index f800e4399790a952f3d599d303904d40552e90ff..e224f89120b01e1976281e0f9322a666a2b98044 100644 (file)
@@ -133,7 +133,7 @@ public:
 
   void post_attach (int) override;
 
-  int follow_fork (int, int) override;
+  bool follow_fork (bool, bool) override;
 
   std::vector<static_tracepoint_marker>
     static_tracepoint_markers_by_strid (const char *id) override;
index ce60fe400c592c16fec83b4ab058414fda465d63..72f1728ecbc4434e1c6e134c8a7a84ac1b2589fb 100644 (file)
@@ -674,7 +674,7 @@ public:
 
   const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
   bool augmented_libraries_svr4_read () override;
-  int follow_fork (int, int) override;
+  bool follow_fork (bool, bool) override;
   void follow_exec (struct inferior *, const char *) override;
   int insert_fork_catchpoint (int) override;
   int remove_fork_catchpoint (int) override;
@@ -5766,8 +5766,8 @@ extended_remote_target::detach (inferior *inf, int from_tty)
    it is named remote_follow_fork in anticipation of using it for the
    remote target as well.  */
 
-int
-remote_target::follow_fork (int follow_child, int detach_fork)
+bool
+remote_target::follow_fork (bool follow_child, bool detach_fork)
 {
   struct remote_state *rs = get_remote_state ();
   enum target_waitkind kind = inferior_thread ()->pending_follow.kind;
@@ -5793,7 +5793,8 @@ remote_target::follow_fork (int follow_child, int detach_fork)
          remote_detach_pid (child_pid);
        }
     }
-  return 0;
+
+  return false;
 }
 
 /* Target follow-exec function for remote targets.  Save EXECD_PATHNAME
index 5c2142b63fa115f911c3d9fb54d6ca242384cdbb..c28af097183d5bd628879e92eb9824354451edd9 100644 (file)
@@ -56,7 +56,7 @@ struct dummy_target : public target_ops
   int remove_fork_catchpoint (int arg0) override;
   int insert_vfork_catchpoint (int arg0) override;
   int remove_vfork_catchpoint (int arg0) override;
-  int follow_fork (int arg0, int arg1) override;
+  bool follow_fork (bool arg0, bool arg1) override;
   int insert_exec_catchpoint (int arg0) override;
   int remove_exec_catchpoint (int arg0) override;
   void follow_exec (struct inferior *arg0, const char *arg1) override;
@@ -225,7 +225,7 @@ struct debug_target : public target_ops
   int remove_fork_catchpoint (int arg0) override;
   int insert_vfork_catchpoint (int arg0) override;
   int remove_vfork_catchpoint (int arg0) override;
-  int follow_fork (int arg0, int arg1) override;
+  bool follow_fork (bool arg0, bool arg1) override;
   int insert_exec_catchpoint (int arg0) override;
   int remove_exec_catchpoint (int arg0) override;
   void follow_exec (struct inferior *arg0, const char *arg1) override;
@@ -1506,30 +1506,30 @@ debug_target::remove_vfork_catchpoint (int arg0)
   return result;
 }
 
-int
-target_ops::follow_fork (int arg0, int arg1)
+bool
+target_ops::follow_fork (bool arg0, bool arg1)
 {
   return this->beneath ()->follow_fork (arg0, arg1);
 }
 
-int
-dummy_target::follow_fork (int arg0, int arg1)
+bool
+dummy_target::follow_fork (bool arg0, bool arg1)
 {
   return default_follow_fork (this, arg0, arg1);
 }
 
-int
-debug_target::follow_fork (int arg0, int arg1)
+bool
+debug_target::follow_fork (bool arg0, bool arg1)
 {
-  int result;
+  bool result;
   fprintf_unfiltered (gdb_stdlog, "-> %s->follow_fork (...)\n", this->beneath ()->shortname ());
   result = this->beneath ()->follow_fork (arg0, arg1);
   fprintf_unfiltered (gdb_stdlog, "<- %s->follow_fork (", this->beneath ()->shortname ());
-  target_debug_print_int (arg0);
+  target_debug_print_bool (arg0);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_int (arg1);
+  target_debug_print_bool (arg1);
   fputs_unfiltered (") = ", gdb_stdlog);
-  target_debug_print_int (result);
+  target_debug_print_bool (result);
   fputs_unfiltered ("\n", gdb_stdlog);
   return result;
 }
index 470ef51d69ef5d712fc51a54f426c1cd3b79c977..1abd8ffbc74e7090b635f1626b66e43809bc6573 100644 (file)
@@ -66,9 +66,6 @@ static void default_rcmd (struct target_ops *, const char *, struct ui_file *);
 static ptid_t default_get_ada_task_ptid (struct target_ops *self,
                                         long lwp, long tid);
 
-static int default_follow_fork (struct target_ops *self, int follow_child,
-                               int detach_fork);
-
 static void default_mourn_inferior (struct target_ops *self);
 
 static int default_search_memory (struct target_ops *ops,
@@ -2165,9 +2162,9 @@ target_program_signals (gdb::array_view<const unsigned char> program_signals)
   current_top_target ()->program_signals (program_signals);
 }
 
-static int
-default_follow_fork (struct target_ops *self, int follow_child,
-                    int detach_fork)
+static bool
+default_follow_fork (struct target_ops *self, bool follow_child,
+                    bool detach_fork)
 {
   /* Some target returned a fork event, but did not know how to follow it.  */
   internal_error (__FILE__, __LINE__,
@@ -2177,8 +2174,8 @@ default_follow_fork (struct target_ops *self, int follow_child,
 /* Look through the list of possible targets for a target that can
    follow forks.  */
 
-int
-target_follow_fork (int follow_child, int detach_fork)
+bool
+target_follow_fork (bool follow_child, bool detach_fork)
 {
   return current_top_target ()->follow_fork (follow_child, detach_fork);
 }
index 26b71cfeb09297156dfaf39ba556a7d733ae3a8b..96e7210bfa0c212f2581ecdb2c692e0dec8d2739 100644 (file)
@@ -622,7 +622,7 @@ struct target_ops
       TARGET_DEFAULT_RETURN (1);
     virtual int remove_vfork_catchpoint (int)
       TARGET_DEFAULT_RETURN (1);
-    virtual int follow_fork (int, int)
+    virtual bool follow_fork (bool, bool)
       TARGET_DEFAULT_FUNC (default_follow_fork);
     virtual int insert_exec_catchpoint (int)
       TARGET_DEFAULT_RETURN (1);
@@ -1660,10 +1660,10 @@ extern void target_load (const char *arg, int from_tty);
    necessary to continue debugging either the parent or child, as
    requested, and releasing the other.  Information about the fork
    or vfork event is available via get_last_target_status ().
-   This function returns 1 if the inferior should not be resumed
+   This function returns true if the inferior should not be resumed
    (i.e. there is another event pending).  */
 
-int target_follow_fork (int follow_child, int detach_fork);
+bool target_follow_fork (bool follow_child, bool detach_fork);
 
 /* Handle the target-specific bookkeeping required when the inferior
    makes an exec call.  INF is the exec'd inferior.  */
This page took 0.051426 seconds and 4 git commands to generate.