Fix new inferior events output
authorPedro Alves <palves@redhat.com>
Wed, 25 Apr 2018 16:28:25 +0000 (17:28 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 25 Apr 2018 16:28:25 +0000 (17:28 +0100)
Since f67c0c917150 ("Enable 'set print inferior-events' and improve
detach/fork/kill/exit messages"), when detaching a remote process, we
get, for detach against a remote target:

 (gdb) detach
 Detaching from program: ...., process 5388
 Ending remote debugging.
 [Inferior 1 (Thread 5388.5388) detached]
              ^^^^^^^^^^^^^^^^

That is incorrect, for it is printing a thread id as string while we
should be printing the process id instead.  I.e., either one of:

 [Inferior 1 (process 5388) detached]
 [Inferior 1 (Remote target) detached]

depending on remote stub support for the multi-process extensions.

Similarly, after killing a process, we're printing thread ids while we
should be printing process ids.  E.g., on native GNU/Linux:

 (gdb) k
 Kill the program being debugged? (y or n) y
 [Inferior 1 (Thread 0x7ffff7faa8c0 (LWP 30721)) has been killed]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

while it should have been:

 Kill the program being debugged? (y or n) y
 [Inferior 1 (process 30721) has been killed]
              ^^^^^^^^^^^^^

There's a wording inconsistency between detach and kill:

 [Inferior 1 (process 30721) has been killed]
 [Inferior 1 (process 30721) detached]

Given we were already saying "detached" instead of "has been
detached", and we used to say just "exited", and given that the "has
been" doesn't really add any information, this commit changes the
message to just "killed":

 [Inferior 1 (process 30721) killed]

gdb/ChangeLog:
2018-04-25  Pedro Alves  <palves@redhat.com>

* infcmd.c (kill_command): Print the pid as string, not the whole
thread's ptid.  Add comment.  s/has been killed/killed/ in output
message.
* remote.c (remote_detach_1): Print the pid as string, not the
whole thread's ptid.

gdb/testsuite/ChangeLog:
2018-04-25  Pedro Alves  <palves@redhat.com>

* gdb.base/hook-stop.exp: Expect "killed" instead of "has been
killed".
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.threads/kill.exp: Likewise.

gdb/ChangeLog
gdb/infcmd.c
gdb/remote.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/hook-stop.exp
gdb/testsuite/gdb.base/kill-after-signal.exp
gdb/testsuite/gdb.threads/kill.exp

index 2cd21edc12b61a6573fb9496ec753c9d5e578980..a5cb3bbd82523cb9dc7f0fe95a312dab95a67cab 100644 (file)
@@ -1,3 +1,11 @@
+2018-04-25  Pedro Alves  <palves@redhat.com>
+
+       * infcmd.c (kill_command): Print the pid as string, not the whole
+       thread's ptid.  Add comment.  s/has been killed/killed/ in output
+       message.
+       * remote.c (remote_detach_1): Print the pid as string, not the
+       whole thread's ptid.
+
 2018-04-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Sergio Durigan Junior  <sergiodj@redhat.com>
            Pedro Alves  <palves@redhat.com>
index 6c9f885badd7943baa8296772a886d610967590f..21772b6cff0a104f551992351a69951cfabd69b9 100644 (file)
@@ -2596,13 +2596,16 @@ kill_command (const char *arg, int from_tty)
   if (!query (_("Kill the program being debugged? ")))
     error (_("Not confirmed."));
 
-  std::string pid_str = target_pid_to_str (inferior_ptid);
+  int pid = current_inferior ()->pid;
+  /* Save the pid as a string before killing the inferior, since that
+     may unpush the current target, and we need the string after.  */
+  std::string pid_str = target_pid_to_str (pid_to_ptid (pid));
   int infnum = current_inferior ()->num;
 
   target_kill ();
 
   if (print_inferior_events)
-    printf_unfiltered (_("[Inferior %d (%s) has been killed]\n"),
+    printf_unfiltered (_("[Inferior %d (%s) killed]\n"),
                       infnum, pid_str.c_str ());
 
   /* If we still have other inferiors to debug, then don't mess with
index 61d1dcb5738197f2fb54b093d702f91fac7198a1..193037b6e7a64658ca15390977b3ddebf22afb8b 100644 (file)
@@ -5138,7 +5138,9 @@ remote_detach_1 (int from_tty, inferior *inf)
      breakpoints that should be available for the followed inferior.  */
   if (!is_fork_parent)
     {
-      std::string infpid = target_pid_to_str (inferior_ptid);
+      /* Save the pid as a string before mourning, since that will
+        unpush the remote target, and we need the string after.  */
+      std::string infpid = target_pid_to_str (pid_to_ptid (pid));
 
       target_mourn_inferior (inferior_ptid);
       if (print_inferior_events)
index 19735fce2138edfc93447610c3ec87c031fe06d3..9ee76068bb8abff580d9db13ebdda608766ce807 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-25  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/hook-stop.exp: Expect "killed" instead of "has been
+       killed".
+       * gdb.base/kill-after-signal.exp: Likewise.
+       * gdb.threads/kill.exp: Likewise.
+
 2018-04-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Sergio Durigan Junior  <sergiodj@redhat.com>
            Pedro Alves  <palves@redhat.com>
index 5717f94fc2a06e5de5a9f04657ff4b6c7601d2a7..b3f4084af1e3d7f59d402d7a03f7c45c8e98f1ac 100644 (file)
@@ -86,7 +86,7 @@ proc hook_stop_kill {} {
 
        set test "run hook-stop"
        gdb_test_multiple "continue" "$test" {
-           -re "Continuing.\r\n\\\[Inferior $decimal \\(.*\\) has been killed\\\]\r\n${gdb_prompt} $" {
+           -re "Continuing.\r\n\\\[Inferior $decimal \\(.*\\) killed\\\]\r\n${gdb_prompt} $" {
                pass $test
            }
        }
index 67e6f627504a062f4d698e08f338cc5cc976df34..8830d49238385d791b199a092007d39662cc14f7 100644 (file)
@@ -39,6 +39,6 @@ gdb_test "continue" "Program received signal SIGUSR1, .*"
 gdb_test "stepi" "\r\nhandler .*"
 gdb_test_multiple "kill" "kill" {
     -re "Kill the program being debugged\\? \\(y or n\\) $" {
-       gdb_test "y" "\\\[Inferior $decimal \\(.*\\) has been killed\\\]" "kill"
+       gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
     }
 }
index aea4a986c64d17a0679b3d007a55ed9e98c0bc70..82f221eef67e6eb7394a7253971a2ba07305bf9c 100644 (file)
@@ -70,7 +70,7 @@ proc test {threaded} {
 
        gdb_test_multiple "kill" "kill" {
            -re "Kill the program being debugged\\? \\(y or n\\) $" {
-               gdb_test "y" "\\\[Inferior $decimal \\(.*\\) has been killed\\\]" "kill"
+               gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
            }
        }
     }
This page took 0.039521 seconds and 4 git commands to generate.