Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/6] List checkpoints in ascending order
Date: Thu, 22 Oct 2015 10:57:00 -0000	[thread overview]
Message-ID: <1445507944-9197-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1445507944-9197-1-git-send-email-palves@redhat.com>

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-10-22  Pedro Alves  <palves@redhat.com>

	PR 17539
        * printcmd.c (display_command): Append new display at the end of
        the list.

gdb/testsuite/ChangeLog:
2015-10-22  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.
---
 gdb/linux-fork.c                      | 35 ++++++++++++++++++++++++++++++-----
 gdb/testsuite/gdb.base/checkpoint.exp |  4 ++--
 2 files changed, 32 insertions(+), 7 deletions(-)

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/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"
 
 #
-- 
1.9.3


  reply	other threads:[~2015-10-22  9:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22 10:56 [PATCH 0/6] PR 17539 - inferiors/threads etc. print in reverse order Pedro Alves
2015-10-22 10:57 ` Pedro Alves [this message]
2015-10-22 10:58 ` [PATCH 2/6] Linux: dump the signalled thread first Pedro Alves
2015-10-22 11:07 ` [PATCH 3/6] List inferiors/threads/pspaces in ascending order Pedro Alves
2015-10-22 16:03   ` Eli Zaretskii
2016-01-08 20:39   ` Regression for gdb.threads/fork-plus-threads.exp [Re: [PATCH 3/6] List inferiors/threads/pspaces in ascending order] Jan Kratochvil
2016-01-11 14:40     ` Pedro Alves
2016-01-12 11:22       ` Pedro Alves
2016-01-13  0:37         ` Pedro Alves
2015-10-22 11:23 ` [PATCH 1/6] Make gdb.python/py-inferior.exp test names unique Pedro Alves
2015-10-22 11:50 ` [PATCH 6/6] NEWS: "info" commands now list in ascending order Pedro Alves
2015-10-22 16:00   ` Eli Zaretskii
2015-10-22 16:06     ` Pedro Alves
2015-10-22 16:16       ` Eli Zaretskii
2015-10-22 12:36 ` [PATCH 5/6] List displays " Pedro Alves
2015-11-24 18:44 ` [PATCH 0/6] PR 17539 - inferiors/threads etc. print in reverse order Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445507944-9197-5-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox