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

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