gdb: bool-ify follow_fork

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.
This commit is contained in:
Simon Marchi 2020-03-24 13:44:58 -04:00
parent e11cd7c491
commit 5ab2fbf185
12 changed files with 64 additions and 53 deletions

View 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.

View 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

View 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;

View 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

View 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;

View 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. */

View 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;
}

View 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;

View 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

View 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;
}

View 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);
}

View 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. */