previous incarnation of this process. */
no_shared_libraries (nullptr, 0);
- struct inferior *inf = current_inferior ();
+ inferior *execing_inferior = current_inferior ();
+ inferior *following_inferior;
if (follow_exec_mode_string == follow_exec_mode_new)
{
inferior's pid. Having two inferiors with the same pid would confuse
find_inferior_p(t)id. Transfer the terminal state and info from the
old to the new inferior. */
- inferior *new_inferior = add_inferior_with_spaces ();
-
- swap_terminal_info (new_inferior, inf);
- exit_inferior_silent (inf);
+ following_inferior = add_inferior_with_spaces ();
- new_inferior->pid = pid;
- target_follow_exec (new_inferior, ptid, exec_file_target);
+ swap_terminal_info (following_inferior, execing_inferior);
+ exit_inferior_silent (execing_inferior);
- /* We continue with the new inferior. */
- inf = new_inferior;
+ following_inferior->pid = pid;
}
else
{
+ /* follow-exec-mode is "same", we continue execution in the execing
+ inferior. */
+ following_inferior = execing_inferior;
+
/* The old description may no longer be fit for the new image.
E.g, a 64-bit process exec'ed a 32-bit process. Clear the
old description; we'll read a new one below. No need to do
around (its description is later cleared/refetched on
restart). */
target_clear_description ();
- target_follow_exec (inf, ptid, exec_file_target);
}
- gdb_assert (current_inferior () == inf);
- gdb_assert (current_program_space == inf->pspace);
+ target_follow_exec (following_inferior, ptid, exec_file_target);
+
+ gdb_assert (current_inferior () == following_inferior);
+ gdb_assert (current_program_space == following_inferior->pspace);
/* Attempt to open the exec file. SYMFILE_DEFER_BP_RESET is used
because the proper displacement for a PIE (Position Independent
Executable) main symbol file will only be computed by
solib_create_inferior_hook below. breakpoint_re_set would fail
to insert the breakpoints with the zero displacement. */
- try_open_exec_file (exec_file_host.get (), inf, SYMFILE_DEFER_BP_RESET);
+ try_open_exec_file (exec_file_host.get (), following_inferior,
+ SYMFILE_DEFER_BP_RESET);
/* If the target can specify a description, read it. Must do this
after flipping to the new executable (because the target supplied
registers. */
target_find_description ();
- gdb::observers::inferior_execd.notify (inf);
+ gdb::observers::inferior_execd.notify (execing_inferior, following_inferior);
breakpoint_re_set ();
}
static void
-infrun_inferior_execd (inferior *inf)
+infrun_inferior_execd (inferior *exec_inf, inferior *follow_inf)
{
/* If some threads where was doing a displaced step in this inferior at the
moment of the exec, they no longer exist. Even if the exec'ing thread
doing a displaced step, we don't want to to any fixup nor restore displaced
stepping buffer bytes. */
- inf->displaced_step_state.reset ();
+ follow_inf->displaced_step_state.reset ();
- for (thread_info *thread : inf->threads ())
+ for (thread_info *thread : follow_inf->threads ())
thread->displaced_step_state.reset ();
/* Since an in-line step is done with everything else stopped, if there was
thread. */
clear_step_over_info ();
- inf->thread_waiting_for_vfork_done = nullptr;
+ follow_inf->thread_waiting_for_vfork_done = nullptr;
}
/* If ON, and the architecture supports it, GDB will use displaced
}
}
-/* Register any already created translations. */
+/* Looks for the descriptor and registration symbols and breakpoints
+ the registration function. If it finds both, it registers all the
+ already JITed code. If it has already found the symbols, then it
+ doesn't try again. */
static void
jit_inferior_init (inferior *inf)
}
}
-/* Looks for the descriptor and registration symbols and breakpoints
- the registration function. If it finds both, it registers all the
- already JITed code. If it has already found the symbols, then it
- doesn't try again. */
+/* inferior_created observer. */
static void
jit_inferior_created_hook (inferior *inf)
jit_inferior_init (inf);
}
+/* inferior_execd observer. */
+
+static void
+jit_inferior_execd_hook (inferior *exec_inf, inferior *follow_inf)
+{
+ jit_inferior_init (follow_inf);
+}
+
/* Exported routine to call to re-set the jit breakpoints,
e.g. when a program is rerun. */
&maintenanceinfolist);
gdb::observers::inferior_created.attach (jit_inferior_created_hook, "jit");
- gdb::observers::inferior_execd.attach (jit_inferior_created_hook, "jit");
+ gdb::observers::inferior_execd.attach (jit_inferior_execd_hook, "jit");
gdb::observers::inferior_exit.attach (jit_inferior_exit_hook, "jit");
gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted, "jit");