aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3e386aa..7fc56dc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1064,7 +1064,6 @@ show_follow_exec_mode_string (struct ui_file *file, int from_tty,
static void
follow_exec (ptid_t ptid, const char *exec_file_target)
{
- struct inferior *inf = current_inferior ();
int pid = ptid.pid ();
ptid_t process_ptid;
@@ -1167,6 +1166,8 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
previous incarnation of this process. */
no_shared_libraries (NULL, 0);
+ struct inferior *inf = current_inferior ();
+
if (follow_exec_mode_string == follow_exec_mode_new)
{
/* The user wants to keep the old inferior and program spaces
@@ -1176,18 +1177,16 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
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. */
- inf = add_inferior_with_spaces ();
- swap_terminal_info (inf, current_inferior ());
- exit_inferior_silent (current_inferior ());
+ inferior *new_inferior = add_inferior_with_spaces ();
- inf->pid = pid;
- target_follow_exec (inf, exec_file_target);
+ swap_terminal_info (new_inferior, inf);
+ exit_inferior_silent (inf);
- inferior *org_inferior = current_inferior ();
- switch_to_inferior_no_thread (inf);
- inf->push_target (org_inferior->process_target ());
- thread_info *thr = add_thread (inf->process_target (), ptid);
- switch_to_thread (thr);
+ new_inferior->pid = pid;
+ target_follow_exec (new_inferior, ptid, exec_file_target);
+
+ /* We continue with the new inferior. */
+ inf = new_inferior;
}
else
{
@@ -1198,9 +1197,10 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
around (its description is later cleared/refetched on
restart). */
target_clear_description ();
- target_follow_exec (inf, exec_file_target);
+ target_follow_exec (inf, ptid, exec_file_target);
}
+ gdb_assert (current_inferior () == inf);
gdb_assert (current_program_space == inf->pspace);
/* Attempt to open the exec file. SYMFILE_DEFER_BP_RESET is used