return (fork_list != NULL);
}
+/* Return the last fork in the list. */
+
+static struct fork_info *
+find_last_fork (void)
+{
+ struct fork_info *last;
+
+ if (fork_list == NULL)
+ return NULL;
+
+ for (last = fork_list; last->next != NULL; last = last->next)
+ ;
+ return last;
+}
+
/* Add a fork to the internal fork list. */
struct fork_info *
fp = XCNEW (struct fork_info);
fp->ptid = ptid_build (pid, pid, 0);
fp->num = ++highest_fork_num;
- fp->next = fork_list;
- fork_list = fp;
+
+ if (fork_list == NULL)
+ fork_list = fp;
+ else
+ {
+ struct fork_info *last = find_last_fork ();
+
+ last->next = fp;
+ }
+
return fp;
}
void
linux_fork_mourn_inferior (void)
{
+ struct fork_info *last;
+ int status;
+
/* Wait just one more time to collect the inferior's exit status.
Do not check whether this succeeds though, since we may be
dealing with a process that we attached to. Such a process will
only report its exit status to its original parent. */
- int status;
-
waitpid (ptid_get_pid (inferior_ptid), &status, 0);
/* OK, presumably inferior_ptid is the one who has exited.
inferior_ptid yet. */
gdb_assert (fork_list);
- fork_load_infrun_state (fork_list);
+ last = find_last_fork ();
+ fork_load_infrun_state (last);
printf_filtered (_("[Switching to %s]\n"),
target_pid_to_str (inferior_ptid));
gdb_test "checkpoint" ".*" ""
gdb_test "info checkpoints" \
- " 10 .* 9 .* 8 .* 7 .* 6 .* 5 .* 4 .* 3 .* 2 .* 1 .*" \
+ " 1 .* 2 .* 3 .* 4 .* 5 .* 6 .* 7 .* 8 .* 9 .* 10 .*" \
"info checkpoints one"
delete_breakpoints
# There should be still at least five forks left
#
-gdb_test "info checkpoints" " 5 .* 4 .* 3 .* 2 .* 1 .*" \
+gdb_test "info checkpoints" " 1 .* 2 .* 3 .* 4 .* 5 .*" \
"info checkpoints two"
#