gdb: add inferior parameter to breakpoint_init_inferior

By inspection, I believe that breakpoint_init_inferior doesn't call
anything that relies on the current program space or inferior.  So,
add an inferior parameter, to make the current inferior / program space
references bubble up one level.

Change-Id: Ib07b7a6d360e324f6ae1aa502dd314b8cce421b7
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Simon Marchi
2024-02-07 11:53:20 -05:00
committed by Simon Marchi
parent c72348e3b4
commit f592870204
5 changed files with 24 additions and 26 deletions

View File

@@ -4226,33 +4226,21 @@ mark_breakpoints_out (program_space *pspace)
bl->inserted = 0;
}
/* Clear the "inserted" flag in all breakpoints and delete any
breakpoints which should go away between runs of the program.
Plus other such housekeeping that has to be done for breakpoints
between runs.
Note: this function gets called at the end of a run (by
generic_mourn_inferior) and when a run begins (by
init_wait_for_inferior). */
/* See breakpoint.h. */
void
breakpoint_init_inferior (enum inf_context context)
breakpoint_init_inferior (inferior *inf, inf_context context)
{
struct program_space *pspace = current_program_space;
/* If breakpoint locations are shared across processes, then there's
nothing to do. */
if (gdbarch_has_global_breakpoints (current_inferior ()->arch ()))
if (gdbarch_has_global_breakpoints (inf->arch ()))
return;
mark_breakpoints_out (pspace);
mark_breakpoints_out (inf->pspace);
for (breakpoint &b : all_breakpoints_safe ())
{
if (b.has_locations () && b.first_loc ().pspace != pspace)
if (b.has_locations () && b.first_loc ().pspace != inf->pspace)
continue;
switch (b.type)

View File

@@ -1515,7 +1515,17 @@ extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
extern void set_ignore_count (int, int, int);
extern void breakpoint_init_inferior (enum inf_context);
/* Clear the "inserted" flag in all breakpoint locations of INF's program space
and delete any breakpoints which should go away between runs of the program.
Plus other such housekeeping that has to be done for breakpoints
between runs.
Note: this function gets called at the end of a run (by
generic_mourn_inferior) and when a run begins (by
init_wait_for_inferior). */
extern void breakpoint_init_inferior (inferior *inf, inf_context context);
extern void breakpoint_auto_delete (bpstat *);

View File

@@ -2824,14 +2824,14 @@ detach_command (const char *args, int from_tty)
/* Hold a strong reference to the target while (maybe)
detaching the parent. Otherwise detaching could close the
target. */
auto target_ref
= target_ops_ref::new_reference (current_inferior ()->process_target ());
inferior *inf = current_inferior ();
auto target_ref = target_ops_ref::new_reference (inf->process_target ());
/* Save this before detaching, since detaching may unpush the
process_stratum target. */
bool was_non_stop_p = target_is_non_stop_p ();
target_detach (current_inferior (), from_tty);
target_detach (inf, from_tty);
update_previous_thread ();
@@ -2840,11 +2840,11 @@ detach_command (const char *args, int from_tty)
this within target_detach because that is also used when
following child forks, and in that case we will want to transfer
breakpoints to the child, not delete them. */
breakpoint_init_inferior (inf_exited);
breakpoint_init_inferior (inf, inf_exited);
/* If the solist is global across inferiors, don't clear it when we
detach from a single inferior. */
if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
if (!gdbarch_has_global_solist (inf->arch ()))
no_shared_libraries (nullptr, from_tty);
if (deprecated_detach_hook)

View File

@@ -1297,7 +1297,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
/* We've followed the inferior through an exec. Therefore, the
inferior has essentially been killed & reborn. */
breakpoint_init_inferior (inf_execd);
breakpoint_init_inferior (current_inferior (), inf_execd);
gdb::unique_xmalloc_ptr<char> exec_file_host
= exec_file_find (exec_file_target, nullptr);
@@ -3819,7 +3819,7 @@ init_wait_for_inferior (void)
{
/* These are meaningless until the first time through wait_for_inferior. */
breakpoint_init_inferior (inf_starting);
breakpoint_init_inferior (current_inferior (), inf_starting);
clear_proceed_status (0);

View File

@@ -3636,7 +3636,7 @@ generic_mourn_inferior (void)
/* Note this wipes step-resume breakpoints, so needs to be done
after exit_inferior, which ends up referencing the step-resume
breakpoints through clear_thread_inferior_resources. */
breakpoint_init_inferior (inf_exited);
breakpoint_init_inferior (inf, inf_exited);
registers_changed ();