[pushed] gdb: bool-ify follow_fork
Simon Marchi
simon.marchi@polymtl.ca
Tue Mar 24 17:52:38 GMT 2020
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.
---
gdb/ChangeLog | 18 ++++++++++++++++++
gdb/fbsd-nat.c | 6 +++---
gdb/fbsd-nat.h | 2 +-
gdb/inf-ptrace.c | 6 +++---
gdb/inf-ptrace.h | 2 +-
gdb/infrun.c | 23 +++++++++--------------
gdb/linux-nat.c | 6 +++---
gdb/linux-nat.h | 2 +-
gdb/remote.c | 9 +++++----
gdb/target-delegates.c | 24 ++++++++++++------------
gdb/target.c | 13 +++++--------
gdb/target.h | 6 +++---
12 files changed, 64 insertions(+), 53 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1acd1fddc92f..ced1b6d43fad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 0e4afb29a009..1d189a250136 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -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
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 87ff1b05b334..40117177b15b 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -75,7 +75,7 @@ class fbsd_nat_target : public inf_ptrace_target
#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;
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index a6a77ef9d31a..1fa7aa3f73e9 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -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
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index dea82d005e35..05c1277ec4e2 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -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;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index d672d1a1609b..1fb445aa247e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -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. */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 81af83c4ac59..133b87ca742c 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -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;
}
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index f800e4399790..e224f89120b0 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -133,7 +133,7 @@ class linux_nat_target : public inf_ptrace_target
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;
diff --git a/gdb/remote.c b/gdb/remote.c
index ce60fe400c59..72f1728ecbc4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -674,7 +674,7 @@ class remote_target : public process_stratum_target
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
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 5c2142b63fa1..c28af097183d 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -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;
}
diff --git a/gdb/target.c b/gdb/target.c
index 470ef51d69ef..1abd8ffbc74e 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -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);
}
diff --git a/gdb/target.h b/gdb/target.h
index 26b71cfeb092..96e7210bfa0c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -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. */
--
2.25.2
More information about the Gdb-patches
mailing list