aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-11-24 18:11:22 +0000
committerPedro Alves <palves@redhat.com>2015-11-24 18:37:26 +0000
commit2f341b6e28e27fadd8160d95337c3aa854bcba3b (patch)
tree2b7e0d566bf015e2db673b33f4c19298499f9137
parent7e0aa6aa9983c745aedc203db0cc360a0ad47cac (diff)
downloadgdb-2f341b6e28e27fadd8160d95337c3aa854bcba3b.zip
gdb-2f341b6e28e27fadd8160d95337c3aa854bcba3b.tar.gz
gdb-2f341b6e28e27fadd8160d95337c3aa854bcba3b.tar.bz2
List checkpoints in ascending order
Before: (gdb) info checkpoints 3 process 29132 at 0x4008ad, file foo.c, line 81 2 process 29131 at 0x4008ad, file foo.c, line 81 1 process 29130 at 0x4008ad, file foo.c, line 81 * 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81 After: (gdb) info checkpoints * 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81 1 process 29130 at 0x4008ad, file foo.c, line 81 2 process 29131 at 0x4008ad, file foo.c, line 81 3 process 29132 at 0x4008ad, file foo.c, line 81 gdb/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * printcmd.c (display_command): Append new display at the end of the list. gdb/testsuite/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.base/display.exp: Expect displays to be sorted in ascending order. Use multi_line. * gdb.base/solib-display.exp: Likewise.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/linux-fork.c35
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/checkpoint.exp4
4 files changed, 45 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 63a8d70..760aa80 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,12 @@
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
+ * printcmd.c (display_command): Append new display at the end of
+ the list.
+
+2015-11-24 Pedro Alves <palves@redhat.com>
+
+ PR 17539
* inferior.c (add_inferior_silent): Append the new inferior to the
end of the list.
* progspace.c (add_program_space): Append the new pspace to the
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 9a469d4..786670a 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -63,6 +63,21 @@ forks_exist_p (void)
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 *
@@ -83,8 +98,16 @@ add_fork (pid_t pid)
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;
}
@@ -353,12 +376,13 @@ linux_fork_killall (void)
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.
@@ -371,7 +395,8 @@ linux_fork_mourn_inferior (void)
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));
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9e050c2..36bc829 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,6 +1,13 @@
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
+ * gdb.base/display.exp: Expect displays to be sorted in ascending
+ order. Use multi_line.
+ * gdb.base/solib-display.exp: Likewise.
+
+2015-11-24 Pedro Alves <palves@redhat.com>
+
+ PR 17539
* gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and
threads in ascending order.
* gdb.base/foll-fork.exp: Likewise.
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 4a476be..e76d711 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -87,7 +87,7 @@ gdb_test "continue 10" "breakpoint 1.*" "break1 ten"
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
@@ -294,7 +294,7 @@ gdb_test "continue" \
# 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"
#