Blame SOURCES/gdb-rhbz1677918-print-inferior-events.patch

2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/inf-ttrace.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/inf-ttrace.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/inf-ttrace.c
2c2fa1
@@ -459,10 +459,14 @@ inf_ttrace_follow_fork (struct target_op
2c2fa1
       copy_terminal_info (inf, parent_inf);
2c2fa1
       detach_breakpoints (ptid_build (pid, lwpid, 0));
2c2fa1
 
2c2fa1
-      target_terminal_ours ();
2c2fa1
-      fprintf_unfiltered (gdb_stdlog,
2c2fa1
-			  _("Attaching after fork to child process %ld.\n"),
2c2fa1
-			  (long)fpid);
2c2fa1
+      if (print_inferior_events)
2c2fa1
+	{
2c2fa1
+	  target_terminal_ours ();
2c2fa1
+	  fprintf_unfiltered (gdb_stdlog,
2c2fa1
+			      _("[Attaching after %s fork to child %s]\n"),
2c2fa1
+			      target_pid_to_str (pid_to_ptid (pid)),
2c2fa1
+			      target_pid_to_str (pid_to_ptid (fid)));
2c2fa1
+	}
2c2fa1
     }
2c2fa1
   else
2c2fa1
     {
2c2fa1
@@ -473,10 +477,13 @@ inf_ttrace_follow_fork (struct target_op
2c2fa1
       if (tts.tts_event == TTEVT_VFORK)
2c2fa1
 	detach_breakpoints (ptid_build (fpid, flwpid, 0));
2c2fa1
 
2c2fa1
-      target_terminal_ours ();
2c2fa1
-      fprintf_unfiltered (gdb_stdlog,
2c2fa1
-			  _("Detaching after fork from child process %ld.\n"),
2c2fa1
-			  (long)fpid);
2c2fa1
+      if (print_inferior_events)
2c2fa1
+	{
2c2fa1
+	  target_terminal_ours ();
2c2fa1
+	  fprintf_unfiltered (gdb_stdlog,
2c2fa1
+			      _("[Detaching after fork from child %s]\n"),
2c2fa1
+			      target_pid_to_str (pid_to_ptid (fpid)));
2c2fa1
+	}
2c2fa1
     }
2c2fa1
 
2c2fa1
   if (tts.tts_event == TTEVT_VFORK)
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/infcmd.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/infcmd.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/infcmd.c
2c2fa1
@@ -2326,6 +2326,9 @@ vector_info (char *args, int from_tty)
2c2fa1
 static void
2c2fa1
 kill_command (char *arg, int from_tty)
2c2fa1
 {
2c2fa1
+  const char *pid_str;
2c2fa1
+  int infnum, pid;
2c2fa1
+
2c2fa1
   /* FIXME:  This should not really be inferior_ptid (or target_has_execution).
2c2fa1
      It should be a distinct flag that indicates that a target is active, cuz
2c2fa1
      some targets don't have processes!  */
2c2fa1
@@ -2334,8 +2337,19 @@ kill_command (char *arg, int from_tty)
2c2fa1
     error (_("The program is not being run."));
2c2fa1
   if (!query (_("Kill the program being debugged? ")))
2c2fa1
     error (_("Not confirmed."));
2c2fa1
+
2c2fa1
+  pid = current_inferior ()->pid;
2c2fa1
+  /* Save the pid as a string before killing the inferior, since that
2c2fa1
+     may unpush the current target, and we need the string after.  */
2c2fa1
+  pid_str = target_pid_to_str (pid_to_ptid (pid));
2c2fa1
+  infnum = current_inferior ()->num;
2c2fa1
+
2c2fa1
   target_kill ();
2c2fa1
 
2c2fa1
+  if (print_inferior_events)
2c2fa1
+    printf_unfiltered (_("[Inferior %d (%s) killed]\n"),
2c2fa1
+		       infnum, pid_str);
2c2fa1
+
2c2fa1
   /* If we still have other inferiors to debug, then don't mess with
2c2fa1
      with their threads.  */
2c2fa1
   if (!have_inferiors ())
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/inferior.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/inferior.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/inferior.c
2c2fa1
@@ -46,9 +46,8 @@ DEFINE_REGISTRY (inferior, REGISTRY_ACCE
2c2fa1
 struct inferior *inferior_list = NULL;
2c2fa1
 static int highest_inferior_num;
2c2fa1
 
2c2fa1
-/* Print notices on inferior events (attach, detach, etc.), set with
2c2fa1
-   `set print inferior-events'.  */
2c2fa1
-static int print_inferior_events = 0;
2c2fa1
+/* See inferior.h.  */
2c2fa1
+int print_inferior_events = 1;
2c2fa1
 
2c2fa1
 /* The Current Inferior.  */
2c2fa1
 static struct inferior *current_inferior_ = NULL;
2c2fa1
@@ -157,7 +156,9 @@ add_inferior (int pid)
2c2fa1
   struct inferior *inf = add_inferior_silent (pid);
2c2fa1
 
2c2fa1
   if (print_inferior_events)
2c2fa1
-    printf_unfiltered (_("[New inferior %d]\n"), pid);
2c2fa1
+    printf_unfiltered (_("[New inferior %d (%s)]\n"), 
2c2fa1
+		       inf->num,
2c2fa1
+		       target_pid_to_str (pid_to_ptid (pid)));
2c2fa1
 
2c2fa1
   return inf;
2c2fa1
 }
2c2fa1
@@ -286,9 +287,6 @@ exit_inferior (int pid)
2c2fa1
   struct inferior *inf = find_inferior_pid (pid);
2c2fa1
 
2c2fa1
   exit_inferior_1 (inf, 0);
2c2fa1
-
2c2fa1
-  if (print_inferior_events)
2c2fa1
-    printf_unfiltered (_("[Inferior %d exited]\n"), pid);
2c2fa1
 }
2c2fa1
 
2c2fa1
 void
2c2fa1
@@ -315,7 +313,9 @@ detach_inferior (int pid)
2c2fa1
   exit_inferior_1 (inf, 1);
2c2fa1
 
2c2fa1
   if (print_inferior_events)
2c2fa1
-    printf_unfiltered (_("[Inferior %d detached]\n"), pid);
2c2fa1
+    printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
2c2fa1
+		       inf->num,
2c2fa1
+		       target_pid_to_str (pid_to_ptid (pid)));
2c2fa1
 }
2c2fa1
 
2c2fa1
 void
2c2fa1
@@ -991,7 +991,7 @@ initialize_inferiors (void)
2c2fa1
      can only allocate an inferior when all those modules have done
2c2fa1
      that.  Do this after initialize_progspace, due to the
2c2fa1
      current_program_space reference.  */
2c2fa1
-  current_inferior_ = add_inferior (0);
2c2fa1
+  current_inferior_ = add_inferior_silent (0);
2c2fa1
   current_inferior_->pspace = current_program_space;
2c2fa1
   current_inferior_->aspace = current_program_space->aspace;
2c2fa1
   /* The architecture will be initialized shortly, by
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/inferior.h
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/inferior.h
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/inferior.h
2c2fa1
@@ -277,6 +277,10 @@ extern enum stop_stack_kind stop_stack_d
2c2fa1
 
2c2fa1
 extern int stopped_by_random_signal;
2c2fa1
 
2c2fa1
+/* Print notices on inferior events (attach, detach, etc.), set with
2c2fa1
+   `set print inferior-events'.  */
2c2fa1
+extern int print_inferior_events;
2c2fa1
+
2c2fa1
 /* STEP_OVER_ALL means step over all subroutine calls.
2c2fa1
    STEP_OVER_UNDEBUGGABLE means step over calls to undebuggable functions.
2c2fa1
    STEP_OVER_NONE means don't step over any subroutine calls.  */
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/infrun.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/infrun.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/infrun.c
2c2fa1
@@ -718,20 +718,21 @@ handle_vfork_child_exec_or_exit (int exe
2c2fa1
 	  inf->aspace = NULL;
2c2fa1
 	  inf->pspace = NULL;
2c2fa1
 
2c2fa1
-	  if (debug_infrun || info_verbose)
2c2fa1
+	  if (print_inferior_events)
2c2fa1
 	    {
2c2fa1
+	      const char *pidstr
2c2fa1
+		= target_pid_to_str (pid_to_ptid (inf->vfork_parent->pid));
2c2fa1
+
2c2fa1
 	      target_terminal_ours ();
2c2fa1
 
2c2fa1
 	      if (exec)
2c2fa1
 		fprintf_filtered (gdb_stdlog,
2c2fa1
-				  "Detaching vfork parent process "
2c2fa1
-				  "%d after child exec.\n",
2c2fa1
-				  inf->vfork_parent->pid);
2c2fa1
+				  "[Detaching vfork parent %s "
2c2fa1
+				  "after child exec]\n", pidstr);
2c2fa1
 	      else
2c2fa1
 		fprintf_filtered (gdb_stdlog,
2c2fa1
-				  "Detaching vfork parent process "
2c2fa1
-				  "%d after child exit.\n",
2c2fa1
-				  inf->vfork_parent->pid);
2c2fa1
+				  "[Detaching vfork parent %s "
2c2fa1
+				  "after child exit]\n", pidstr);
2c2fa1
 	    }
2c2fa1
 
2c2fa1
 	  target_detach (NULL, 0);
2c2fa1
@@ -3260,7 +3261,7 @@ handle_inferior_event (struct execution_
2c2fa1
       ecs->event_thread = find_thread_ptid (ecs->ptid);
2c2fa1
       /* If it's a new thread, add it to the thread database.  */
2c2fa1
       if (ecs->event_thread == NULL)
2c2fa1
-	ecs->event_thread = add_thread (ecs->ptid);
2c2fa1
+	ecs->event_thread = add_thread (ecs->ptid); /* !!keiths: _silent? */
2c2fa1
     }
2c2fa1
 
2c2fa1
   /* Dependent on valid ECS->EVENT_THREAD.  */
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/linux-nat.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/linux-nat.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/linux-nat.c
2c2fa1
@@ -688,13 +688,13 @@ holding the child stopped.  Try \"set de
2c2fa1
 	      remove_breakpoints_pid (GET_PID (inferior_ptid));
2c2fa1
 	    }
2c2fa1
 
2c2fa1
-	  if (info_verbose || debug_linux_nat)
2c2fa1
+	  if (print_inferior_events)
2c2fa1
 	    {
2c2fa1
 	      target_terminal_ours ();
2c2fa1
 	      fprintf_filtered (gdb_stdlog,
2c2fa1
-				"Detaching after fork from "
2c2fa1
-				"child process %d.\n",
2c2fa1
-				child_pid);
2c2fa1
+				"[Detaching after %s from child %s]\n",
2c2fa1
+				has_vforked ? "vfork" : "fork",
2c2fa1
+				target_pid_to_str (pid_to_ptid (child_pid)));
2c2fa1
 	    }
2c2fa1
 
2c2fa1
 	  old_chain = save_inferior_ptid ();
2c2fa1
@@ -729,7 +729,7 @@ holding the child stopped.  Try \"set de
2c2fa1
 	  save_current_program_space ();
2c2fa1
 
2c2fa1
 	  inferior_ptid = ptid_build (child_pid, child_pid, 0);
2c2fa1
-	  add_thread (inferior_ptid);
2c2fa1
+	  add_thread_silent (inferior_ptid);
2c2fa1
 	  child_lp = add_lwp (inferior_ptid);
2c2fa1
 	  child_lp->stopped = 1;
2c2fa1
 	  child_lp->last_resume_kind = resume_stop;
2c2fa1
@@ -865,19 +865,19 @@ holding the child stopped.  Try \"set de
2c2fa1
       struct lwp_info *child_lp;
2c2fa1
       struct program_space *parent_pspace;
2c2fa1
 
2c2fa1
-      if (info_verbose || debug_linux_nat)
2c2fa1
+      if (print_inferior_events)
2c2fa1
 	{
2c2fa1
+	  const char *parent_pidstr
2c2fa1
+	    = target_pid_to_str (pid_to_ptid (parent_pid));
2c2fa1
+	  const char *child_pidstr
2c2fa1
+	    = target_pid_to_str (pid_to_ptid (child_pid));
2c2fa1
+
2c2fa1
 	  target_terminal_ours ();
2c2fa1
-	  if (has_vforked)
2c2fa1
-	    fprintf_filtered (gdb_stdlog,
2c2fa1
-			      _("Attaching after process %d "
2c2fa1
-				"vfork to child process %d.\n"),
2c2fa1
-			      parent_pid, child_pid);
2c2fa1
-	  else
2c2fa1
-	    fprintf_filtered (gdb_stdlog,
2c2fa1
-			      _("Attaching after process %d "
2c2fa1
-				"fork to child process %d.\n"),
2c2fa1
-			      parent_pid, child_pid);
2c2fa1
+	  fprintf_filtered (gdb_stdlog,
2c2fa1
+			    _("[Attaching after %s %s to child %s]\n"),
2c2fa1
+			    parent_pidstr,
2c2fa1
+			    has_vforked ? "vfork" : "fork",
2c2fa1
+			    child_pidstr);
2c2fa1
 	}
2c2fa1
 
2c2fa1
       /* Add the new inferior first, so that the target_detach below
2c2fa1
@@ -914,7 +914,21 @@ holding the child stopped.  Try \"set de
2c2fa1
 	  parent_inf->waiting_for_vfork_done = 0;
2c2fa1
 	}
2c2fa1
       else if (detach_fork)
2c2fa1
-	target_detach (NULL, 0);
2c2fa1
+	{
2c2fa1
+	  if (print_inferior_events)
2c2fa1
+            {
2c2fa1
+              /* Ensure that we have a process ptid.  */
2c2fa1
+              ptid_t process_ptid = pid_to_ptid (parent_pid);
2c2fa1
+
2c2fa1
+              target_terminal_ours ();
2c2fa1
+              fprintf_filtered (gdb_stdlog,
2c2fa1
+                                _("[Detaching after fork from "
2c2fa1
+                                  "parent %s]\n"),
2c2fa1
+                                target_pid_to_str (process_ptid));
2c2fa1
+            }
2c2fa1
+
2c2fa1
+	  target_detach (NULL, 0);
2c2fa1
+	}
2c2fa1
 
2c2fa1
       /* Note that the detach above makes PARENT_INF dangling.  */
2c2fa1
 
2c2fa1
@@ -923,7 +937,7 @@ holding the child stopped.  Try \"set de
2c2fa1
 	 informing the solib layer about this new process.  */
2c2fa1
 
2c2fa1
       inferior_ptid = ptid_build (child_pid, child_pid, 0);
2c2fa1
-      add_thread (inferior_ptid);
2c2fa1
+      add_thread_silent (inferior_ptid);
2c2fa1
       child_lp = add_lwp (inferior_ptid);
2c2fa1
       child_lp->stopped = 1;
2c2fa1
       child_lp->last_resume_kind = resume_stop;
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/remote.c
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/remote.c
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/remote.c
2c2fa1
@@ -4437,7 +4437,17 @@ remote_detach_1 (char *args, int from_tt
2c2fa1
   if (from_tty && !extended)
2c2fa1
     puts_filtered (_("Ending remote debugging.\n"));
2c2fa1
 
2c2fa1
-  target_mourn_inferior ();
2c2fa1
+  {
2c2fa1
+    /* Save the pid as a string before mourning, since that will
2c2fa1
+       unpush the remote target, and we need the string after.  */
2c2fa1
+    const char *infpid = target_pid_to_str (pid_to_ptid (pid));
2c2fa1
+    struct inferior *inf = find_inferior_pid (pid);
2c2fa1
+
2c2fa1
+    target_mourn_inferior ();
2c2fa1
+    if (print_inferior_events)
2c2fa1
+      printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
2c2fa1
+			 inf->num, infpid);
2c2fa1
+  }
2c2fa1
 }
2c2fa1
 
2c2fa1
 static void
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/attach.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/attach.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/attach.exp
2c2fa1
@@ -70,6 +70,7 @@ proc do_attach_tests {} {
2c2fa1
     global objdir
2c2fa1
     global subdir
2c2fa1
     global timeout
2c2fa1
+    global decimal
2c2fa1
     
2c2fa1
     # Start the program running and then wait for a bit, to be sure
2c2fa1
     # that it can be attached to.
2c2fa1
@@ -203,7 +204,7 @@ proc do_attach_tests {} {
2c2fa1
     # Detach the process.
2c2fa1
    
2c2fa1
     gdb_test "detach" \
2c2fa1
-	"Detaching from program: .*$escapedbinfile, process $testpid" \
2c2fa1
+	"Detaching from program: .*$escapedbinfile, process $testpid\r\n\\\[Inferior $decimal \\(.*\\) detached\\\]" \
2c2fa1
 	"attach1 detach"
2c2fa1
 
2c2fa1
     # Wait a bit for gdb to finish detaching
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/catch-syscall.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/catch-syscall.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/catch-syscall.exp
2c2fa1
@@ -164,7 +164,7 @@ proc check_for_program_end {} {
2c2fa1
     # Deleting the catchpoints
2c2fa1
     delete_breakpoints
2c2fa1
 
2c2fa1
-    gdb_continue_to_end
2c2fa1
+    gdb_continue_to_end "" continue 1
2c2fa1
 
2c2fa1
 }
2c2fa1
 
2c2fa1
@@ -228,7 +228,7 @@ proc test_catch_syscall_with_wrong_args
2c2fa1
     # If it doesn't, everything is right (since we don't have
2c2fa1
     # a syscall named "mlock" in it).  Otherwise, this is a failure.
2c2fa1
     set thistest "catch syscall with unused syscall ($syscall_name)"
2c2fa1
-    gdb_continue_to_end $thistest
2c2fa1
+    gdb_continue_to_end $thistest continue 1
2c2fa1
 }
2c2fa1
 
2c2fa1
 proc test_catch_syscall_restarting_inferior {} {
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/foll-fork.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/foll-fork.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/foll-fork.exp
2c2fa1
@@ -64,7 +64,7 @@ proc default_fork_parent_follow {} {
2c2fa1
 	"default show parent follow, no catchpoints"
2c2fa1
 
2c2fa1
     gdb_test "next 2" \
2c2fa1
-	"Detaching after fork from.*" \
2c2fa1
+	"\\\[Detaching after fork from.*" \
2c2fa1
 	"default parent follow, no catchpoints"
2c2fa1
 
2c2fa1
     # The child has been detached; allow time for any output it might
2c2fa1
@@ -83,7 +83,7 @@ proc explicit_fork_parent_follow {} {
2c2fa1
 	"Debugger response to a program call of fork or vfork is \"parent\"." \
2c2fa1
 	"explicit show parent follow, no catchpoints"
2c2fa1
 
2c2fa1
-    gdb_test "next 2" "Detaching after fork from.*" \
2c2fa1
+    gdb_test "next 2" "\\\[Detaching after fork from.*" \
2c2fa1
 	"explicit parent follow, no catchpoints"
2c2fa1
 
2c2fa1
     # The child has been detached; allow time for any output it might
2c2fa1
@@ -102,7 +102,7 @@ proc explicit_fork_child_follow {} {
2c2fa1
 	"Debugger response to a program call of fork or vfork is \"child\"." \
2c2fa1
 	"explicit show child follow, no catchpoints"
2c2fa1
 
2c2fa1
-    gdb_test "next 2" "Attaching after.* fork to.*" \
2c2fa1
+    gdb_test "next 2" "\\\[Attaching after.* fork to.*" \
2c2fa1
 	"explicit child follow, no catchpoints"
2c2fa1
 
2c2fa1
     # The child has been detached; allow time for any output it might
2c2fa1
@@ -152,7 +152,7 @@ proc catch_fork_child_follow {} {
2c2fa1
 	"set follow-fork child, tbreak"
2c2fa1
 
2c2fa1
     gdb_test "continue" \
2c2fa1
-	"Attaching after.* fork to.* at .*$bp_after_fork.*" \
2c2fa1
+	"\\\[Attaching after.* fork to.* at .*$bp_after_fork.*" \
2c2fa1
 	"set follow-fork child, hit tbreak"
2c2fa1
 
2c2fa1
     # The parent has been detached; allow time for any output it might
2c2fa1
@@ -239,7 +239,7 @@ proc tcatch_fork_parent_follow {} {
2c2fa1
 	"set follow-fork parent, tbreak"
2c2fa1
 
2c2fa1
     gdb_test "continue" \
2c2fa1
-	"Detaching after fork from.* at .*$bp_after_fork.*" \
2c2fa1
+	"\\\[Detaching after fork from.* at .*$bp_after_fork.*" \
2c2fa1
 	"set follow-fork parent, hit tbreak"
2c2fa1
 
2c2fa1
     # The child has been detached; allow time for any output it might
2c2fa1
@@ -338,10 +338,6 @@ gdb_start
2c2fa1
 gdb_reinitialize_dir $srcdir/$subdir
2c2fa1
 gdb_load ${binfile}
2c2fa1
 
2c2fa1
-# The "Detaching..." and "Attaching..." messages may be hidden by
2c2fa1
-# default.
2c2fa1
-gdb_test_no_output "set verbose"
2c2fa1
-
2c2fa1
 # This is a test of gdb's ability to follow the parent, child or both
2c2fa1
 # parent and child of a Unix fork() system call.
2c2fa1
 #
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/foll-vfork.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/foll-vfork.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/foll-vfork.exp
2c2fa1
@@ -73,10 +73,6 @@ proc setup_gdb {} {
2c2fa1
 
2c2fa1
     clean_restart $testfile
2c2fa1
 
2c2fa1
-    # The "Detaching..." and "Attaching..." messages may be hidden by
2c2fa1
-    # default.
2c2fa1
-    gdb_test_no_output "set verbose"
2c2fa1
-
2c2fa1
     if ![runto_main] {
2c2fa1
 	return -code return
2c2fa1
     }
2c2fa1
@@ -117,7 +113,7 @@ proc vfork_parent_follow_through_step {}
2c2fa1
 
2c2fa1
    set test "step"
2c2fa1
    gdb_test_multiple "next" $test {
2c2fa1
-       -re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
+       -re "\\\[Detaching after vfork from.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
 	   pass $test
2c2fa1
        }
2c2fa1
    }
2c2fa1
@@ -142,7 +138,7 @@ proc vfork_parent_follow_to_bp {} {
2c2fa1
 
2c2fa1
    set test "continue to bp"
2c2fa1
    gdb_test_multiple "continue" $test {
2c2fa1
-       -re ".*Detaching after fork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
2c2fa1
+       -re ".*\\\[Detaching after vfork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
2c2fa1
 	   pass $test
2c2fa1
        }
2c2fa1
    }
2c2fa1
@@ -167,7 +163,7 @@ proc vfork_child_follow_to_exit {} {
2c2fa1
 	  # PR gdb/14766
2c2fa1
 	  fail "$test"
2c2fa1
       }
2c2fa1
-      -re "Attaching after.* vfork to.*Detaching vfork parent .* after child exit.*$gdb_prompt " {
2c2fa1
+       -re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent .* after child exit.*$gdb_prompt " {
2c2fa1
 	  pass $test
2c2fa1
       }
2c2fa1
    }
2c2fa1
@@ -191,7 +187,8 @@ proc vfork_and_exec_child_follow_to_main
2c2fa1
 
2c2fa1
    set test "continue to bp"
2c2fa1
    gdb_test_multiple "continue" $test {
2c2fa1
-      -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
2c2fa1
+       -re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
2c2fa1
+
2c2fa1
 	  pass $test
2c2fa1
       }
2c2fa1
    }
2c2fa1
@@ -235,7 +232,7 @@ proc vfork_and_exec_child_follow_through
2c2fa1
        #
2c2fa1
        set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
2c2fa1
        gdb_test_multiple "next" $test {
2c2fa1
-	   -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
2c2fa1
+	   -re "\\\[Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
2c2fa1
 	       pass "$test"
2c2fa1
 	   }
2c2fa1
        }
2c2fa1
@@ -244,7 +241,7 @@ proc vfork_and_exec_child_follow_through
2c2fa1
        # before it execs.  Thus, "next" lands on the next line after
2c2fa1
        # the vfork.
2c2fa1
        gdb_test_multiple "next" $test {
2c2fa1
-	   -re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
+	   -re "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
 	       pass "$test"
2c2fa1
 	   }
2c2fa1
        }
2c2fa1
@@ -398,7 +395,7 @@ proc vfork_relations_in_info_inferiors {
2c2fa1
 
2c2fa1
    set test "step over vfork"
2c2fa1
    gdb_test_multiple "next" $test {
2c2fa1
-       -re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
+       -re "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
2c2fa1
 	   pass "$test"
2c2fa1
        }
2c2fa1
    }
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/fork-print-inferior-events.c
2c2fa1
===================================================================
2c2fa1
--- /dev/null
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/fork-print-inferior-events.c
2c2fa1
@@ -0,0 +1,37 @@
2c2fa1
+/* This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+   Copyright 2007-2018 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This program is free software; you can redistribute it and/or modify
2c2fa1
+   it under the terms of the GNU General Public License as published by
2c2fa1
+   the Free Software Foundation; either version 3 of the License, or
2c2fa1
+   (at your option) any later version.
2c2fa1
+
2c2fa1
+   This program is distributed in the hope that it will be useful,
2c2fa1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+   GNU General Public License for more details.
2c2fa1
+
2c2fa1
+   You should have received a copy of the GNU General Public License
2c2fa1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2c2fa1
+
2c2fa1
+#include <stdlib.h>
2c2fa1
+#include <unistd.h>
2c2fa1
+
2c2fa1
+int
2c2fa1
+main (int argc, char *argv[])
2c2fa1
+{
2c2fa1
+  pid_t child;
2c2fa1
+
2c2fa1
+  child = fork ();
2c2fa1
+  switch (child)
2c2fa1
+    {
2c2fa1
+      case -1:
2c2fa1
+       abort ();
2c2fa1
+      case 0:
2c2fa1
+      default:
2c2fa1
+       break;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
2c2fa1
===================================================================
2c2fa1
--- /dev/null
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
2c2fa1
@@ -0,0 +1,96 @@
2c2fa1
+# This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+# Copyright 2007-2018 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+# Test that the event messages printed when using 'set print
2c2fa1
+# inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and
2c2fa1
+# 'set detach-on-fork [on,off]' are the correct ones.
2c2fa1
+
2c2fa1
+# This test relies on "run", so it cannot run on target remote stubs.
2c2fa1
+if { [use_gdb_stub] } {
2c2fa1
+    untested "not supported on target remote stubs"
2c2fa1
+    return
2c2fa1
+}
2c2fa1
+
2c2fa1
+standard_testfile
2c2fa1
+
2c2fa1
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+# RHEL7 GDB lacks the unified remote/native fork handling code,
2c2fa1
+# so we don't get event notifications for remote targets.
2c2fa1
+# Skip the "on" case of print inferior-events.
2c2fa1
+set using_remote 0
2c2fa1
+if {[target_info gdb_protocol] == "extended-remote"} {
2c2fa1
+    set using_remote 1
2c2fa1
+}
2c2fa1
+
2c2fa1
+# This is the expected output for each of the test combinations
2c2fa1
+# below.  The order here is important:
2c2fa1
+#
2c2fa1
+#    inferior-events: on;  follow-fork: child;  detach-on-fork: on
2c2fa1
+#    inferior-events: on;  follow-fork: child;  detach-on-fork: off
2c2fa1
+#    inferior-events: on;  follow-fork: parent; detach-on-fork: on
2c2fa1
+#    inferior-events: on;  follow-fork: parent; detach-on-fork: off
2c2fa1
+#    inferior-events: off; follow-fork: child;  detach-on-fork: on
2c2fa1
+#    inferior-events: off; follow-fork: child;  detach-on-fork: off
2c2fa1
+#    inferior-events: off; follow-fork: parent; detach-on-fork: on
2c2fa1
+#    inferior-events: off; follow-fork: parent; detach-on-fork: off
2c2fa1
+
2c2fa1
+set reading_re "(Reading.*from remote target\\.\\.\\.\r\n)*"
2c2fa1
+set exited_normally_re "${reading_re}\\\[Inferior $decimal \\(.*\\) exited normally\\\]"
2c2fa1
+# gdbserver produces a slightly different message when attaching after
2c2fa1
+# a fork, so we have to tweak the regexp to accomodate that.
2c2fa1
+set attach_child_re "${reading_re}\\\[Attaching after .* fork to child .*\\\]\r\n"
2c2fa1
+set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n"
2c2fa1
+set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n"
2c2fa1
+set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n"
2c2fa1
+set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n"
2c2fa1
+
2c2fa1
+set expected_output [list \
2c2fa1
+                        "${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \
2c2fa1
+                        "${attach_child_re}${new_inf_re}" \
2c2fa1
+                        "${detach_child_re}" \
2c2fa1
+                        "${new_inf_re}" \
2c2fa1
+                        "" \
2c2fa1
+                        "" \
2c2fa1
+                        "" \
2c2fa1
+                        "" \
2c2fa1
+                       ]
2c2fa1
+
2c2fa1
+set i 0
2c2fa1
+
2c2fa1
+foreach_with_prefix print_inferior_events { "on" "off" } {
2c2fa1
+    foreach_with_prefix follow_fork_mode { "child" "parent" } {
2c2fa1
+       foreach_with_prefix detach_on_fork { "on" "off" } {
2c2fa1
+           clean_restart $binfile
2c2fa1
+           gdb_test_no_output "set print inferior-events $print_inferior_events"
2c2fa1
+           gdb_test_no_output "set follow-fork-mode $follow_fork_mode"
2c2fa1
+           gdb_test_no_output "set detach-on-fork $detach_on_fork"
2c2fa1
+
2c2fa1
+           set output [lindex $expected_output $i]
2c2fa1
+           # Always add the "Starting program..." string so that we
2c2fa1
+           # match exactly the lines we want.
2c2fa1
+           set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}"
2c2fa1
+           set i [expr $i + 1]
2c2fa1
+	   if {$using_remote && $print_inferior_events == "on"} {
2c2fa1
+	       continue
2c2fa1
+	   }
2c2fa1
+	   gdb_test "run" $output
2c2fa1
+       }
2c2fa1
+    }
2c2fa1
+}
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/kill-after-signal.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/kill-after-signal.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/kill-after-signal.exp
2c2fa1
@@ -37,4 +37,8 @@ if ![runto_main] {
2c2fa1
 
2c2fa1
 gdb_test "continue" "Program received signal SIGUSR1, .*"
2c2fa1
 gdb_test "stepi" "\r\nhandler .*"
2c2fa1
-gdb_test "kill" "^y" "kill" "Kill the program being debugged\\? \\(y or n\\) $" "y"
2c2fa1
+gdb_test_multiple "kill" "kill" {
2c2fa1
+    -re "Kill the program being debugged\\? \\(y or n\\) $" {
2c2fa1
+       gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
2c2fa1
+    }
2c2fa1
+}
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/solib-overlap.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/gdb.base/solib-overlap.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/gdb.base/solib-overlap.exp
2c2fa1
@@ -127,7 +127,7 @@ foreach prelink_lib1 {0x40000000 0x50000
2c2fa1
 
2c2fa1
     # Detach the process.
2c2fa1
 
2c2fa1
-    gdb_test "detach" "Detaching from program: .*$escapedbinfile, process $testpid"
2c2fa1
+    gdb_test "detach" "Detaching from program: .*$escapedbinfile, process $testpid\r\n\\\[Inferior $decimal \\(.*\\) detached\\\]"
2c2fa1
 
2c2fa1
     # Wait a bit for gdb to finish detaching
2c2fa1
 
2c2fa1
Index: rhel-7.8/gdb-7.6.1/gdb/testsuite/lib/gdb.exp
2c2fa1
===================================================================
2c2fa1
--- rhel-7.8.orig/gdb-7.6.1/gdb/testsuite/lib/gdb.exp
2c2fa1
+++ rhel-7.8/gdb-7.6.1/gdb/testsuite/lib/gdb.exp
2c2fa1
@@ -1738,6 +1738,27 @@ proc with_test_prefix { prefix body } {
2c2fa1
   }
2c2fa1
 }
2c2fa1
 
2c2fa1
+# Wrapper for foreach that calls with_test_prefix on each iteration,
2c2fa1
+# including the iterator's name and current value in the prefix.
2c2fa1
+
2c2fa1
+proc foreach_with_prefix {var list body} {
2c2fa1
+    upvar 1 $var myvar
2c2fa1
+    foreach myvar $list {
2c2fa1
+        with_test_prefix "$var=$myvar" {
2c2fa1
+            set code [catch {uplevel 1 $body} result]
2c2fa1
+        }
2c2fa1
+
2c2fa1
+        if {$code == 1} {
2c2fa1
+            global errorInfo errorCode
2c2fa1
+            return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
2c2fa1
+        } elseif {$code == 3} {
2c2fa1
+            break
2c2fa1
+        } elseif {$code == 2} {
2c2fa1
+            return -code $code $result
2c2fa1
+        }
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
 # Return 1 if _Complex types are supported, otherwise, return 0.
2c2fa1
 
2c2fa1
 proc support_complex_tests {} {
2c2fa1
@@ -2354,6 +2375,26 @@ proc skip_unwinder_tests {} {
2c2fa1
     return $ok
2c2fa1
 }
2c2fa1
 
2c2fa1
+# Return the effective value of use_gdb_stub.
2c2fa1
+#
2c2fa1
+# If the use_gdb_stub global has been set (it is set when the gdb process is
2c2fa1
+# spawned), return that.  Otherwise, return the value of the use_gdb_stub
2c2fa1
+# property from the board file.
2c2fa1
+#
2c2fa1
+# This is the preferred way of checking use_gdb_stub, since it allows to check
2c2fa1
+# the value before the gdb has been spawned and it will return the correct value
2c2fa1
+# even when it was overriden by the test.
2c2fa1
+
2c2fa1
+proc use_gdb_stub {} {
2c2fa1
+  global use_gdb_stub
2c2fa1
+
2c2fa1
+  if [info exists use_gdb_stub] {
2c2fa1
+     return $use_gdb_stub
2c2fa1
+  }
2c2fa1
+
2c2fa1
+  return [target_info exists use_gdb_stub]
2c2fa1
+}
2c2fa1
+
2c2fa1
 set compiler_info		"unknown"
2c2fa1
 set gcc_compiled		0
2c2fa1
 set hp_cc_compiler		0