Blame SOURCES/gdb-6.3-inferior-notification-20050721.patch

689258
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
689258
From: Jeff Johnston <jjohnstn@redhat.com>
689258
Date: Fri, 27 Oct 2017 21:07:50 +0200
689258
Subject: gdb-6.3-inferior-notification-20050721.patch
689258
689258
;; Notify observers that the inferior has been created
689258
;;=fedoratest
689258
689258
2005-07-21  Jeff Johnston  <jjohnstn@redhat.com>
689258
689258
	* gdb.base/attach-32.exp: New test for attaching in 32-bit
689258
	mode on 64-bit systems.
689258
	* gdb.base/attach-32.c: Ditto.
689258
	* gdb.base/attach-32b.c: Ditto.
689258
689258
2007-12-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
689258
689258
	* gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set.
689258
689258
diff --git a/gdb/testsuite/gdb.base/attach-32.c b/gdb/testsuite/gdb.base/attach-32.c
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.base/attach-32.c
689258
@@ -0,0 +1,20 @@
689258
+/* This program is intended to be started outside of gdb, and then
689258
+   attached to by gdb.  Thus, it simply spins in a loop.  The loop
689258
+   is exited when & if the variable 'should_exit' is non-zero.  (It
689258
+   is initialized to zero in this program, so the loop will never
689258
+   exit unless/until gdb sets the variable to non-zero.)
689258
+   */
689258
+#include <stdio.h>
689258
+
689258
+int  should_exit = 0;
689258
+
689258
+int main ()
689258
+{
689258
+  int  local_i = 0;
689258
+
689258
+  while (! should_exit)
689258
+    {
689258
+      local_i++;
689258
+    }
689258
+  return 0;
689258
+}
689258
diff --git a/gdb/testsuite/gdb.base/attach-32.exp b/gdb/testsuite/gdb.base/attach-32.exp
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.base/attach-32.exp
689258
@@ -0,0 +1,245 @@
689258
+# Copyright 2005 Free Software Foundation, Inc.
689258
+
689258
+# This program is free software; you can redistribute it and/or modify
689258
+# it under the terms of the GNU General Public License as published by
689258
+# the Free Software Foundation; either version 2 of the License, or
689258
+# (at your option) any later version.
689258
+# 
689258
+# This program is distributed in the hope that it will be useful,
689258
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
689258
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
689258
+# GNU General Public License for more details.
689258
+# 
689258
+# You should have received a copy of the GNU General Public License
689258
+# along with this program; if not, write to the Free Software
689258
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
689258
+#
689258
+# This test was based on attach.exp and modified for 32/64 bit Linux systems. */
689258
+
689258
+# On HP-UX 11.0, this test is causing a process running the program
689258
+# "attach" to be left around spinning.  Until we figure out why, I am
689258
+# commenting out the test to avoid polluting tiamat (our 11.0 nightly
689258
+# test machine) with these processes. RT
689258
+#
689258
+# Setting the magic bit in the target app should work.  I added a
689258
+# "kill", and also a test for the R3 register warning.  JB
689258
+if { ![istarget "x86_64*-*linux*"] 
689258
+     && ![istarget "powerpc64*-*linux*"]} {
689258
+    return 0
689258
+}
689258
+
689258
+# are we on a target board
689258
+if [is_remote target] then {
689258
+    return 0
689258
+}
689258
+
689258
+set testfile "attach-32"
689258
+set srcfile  ${testfile}.c
689258
+set srcfile2 ${testfile}b.c
689258
+set binfile  [standard_output_file ${testfile}]
689258
+set binfile2 [standard_output_file ${testfile}b]
689258
+set escapedbinfile  [string_to_regexp [standard_output_file ${testfile}]]
689258
+
689258
+#execute_anywhere "rm -f ${binfile} ${binfile2}"
689258
+remote_exec build "rm -f ${binfile} ${binfile2}"
689258
+# For debugging this test
689258
+#
689258
+#log_user 1
689258
+
689258
+# build the first test case
689258
+#
689258
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } {
689258
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
689258
+}
689258
+
689258
+# Build the in-system-call test
689258
+
689258
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } {
689258
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
689258
+}
689258
+
689258
+if [get_compiler_info ${binfile}] {
689258
+    return -1
689258
+}
689258
+
689258
+proc do_attach_tests {} {
689258
+    global gdb_prompt
689258
+    global binfile
689258
+    global escapedbinfile
689258
+    global srcfile
689258
+    global testfile
689258
+    global objdir
689258
+    global subdir
689258
+    global timeout
689258
+    global testpid
689258
+    
689258
+    # Verify that we can "see" the variable "should_exit" in the
689258
+    # program, and that it is zero.
689258
+   
689258
+    gdb_test "print should_exit" " = 0" "after attach-32, print should_exit"
689258
+
689258
+    # Verify that we can modify the variable "should_exit" in the
689258
+    # program.
689258
+
689258
+    gdb_test "set should_exit=1" "" "after attach-32, set should_exit"
689258
+
689258
+    # Verify that the modification really happened.
689258
+
689258
+    send_gdb "tbreak 19\n"
689258
+    gdb_expect {
689258
+	-re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" {
689258
+	    pass "after attach-32, set tbreak postloop"
689258
+	}
689258
+	-re "$gdb_prompt $" {
689258
+	    fail "after attach-32, set tbreak postloop"
689258
+	}
689258
+	timeout {
689258
+	    fail "(timeout) after attach-32, set tbreak postloop"
689258
+	}
689258
+    }
689258
+    send_gdb "continue\n"
689258
+    gdb_expect {
689258
+	-re "main.*at.*$srcfile:19.*$gdb_prompt $" {
689258
+	    pass "after attach-32, reach tbreak postloop"
689258
+	}
689258
+	-re "$gdb_prompt $" {
689258
+	    fail "after attach-32, reach tbreak postloop"
689258
+	}
689258
+	timeout {
689258
+	    fail "(timeout) after attach-32, reach tbreak postloop"
689258
+	}
689258
+    }
689258
+
689258
+    # Allow the test process to exit, to cleanup after ourselves.
689258
+
689258
+    gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit"
689258
+
689258
+    # Make sure we don't leave a process around to confuse
689258
+    # the next test run (and prevent the compile by keeping
689258
+    # the text file busy), in case the "set should_exit" didn't
689258
+    # work.
689258
+   
689258
+    remote_exec build "kill -9 ${testpid}"
689258
+
689258
+    # Start the program running and then wait for a bit, to be sure
689258
+    # that it can be attached to.
689258
+   
689258
+    set testpid [eval exec $binfile &]
689258
+    exec sleep 2
689258
+    if { [istarget "*-*-cygwin*"] } {
689258
+	# testpid is the Cygwin PID, GDB uses the Windows PID, which might be
689258
+	# different due to the way fork/exec works.
689258
+	set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
689258
+    }
689258
+
689258
+    # Verify that we can attach to the process, and find its a.out
689258
+    # when we're cd'd to some directory that doesn't contain the
689258
+    # a.out.  (We use the source path set by the "dir" command.)
689258
+    
689258
+    gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
689258
+	"set source path"
689258
+
689258
+    gdb_test "cd /tmp" "Working directory /tmp." \
689258
+	"cd away from process working directory"
689258
+
689258
+    # Explicitly flush out any knowledge of the previous attachment.
689258
+
689258
+    set test "before attach-32-3, flush symbols"
689258
+    gdb_test_multiple "symbol" "$test" {
689258
+	-re "Discard symbol table from.*y or n. $" {
689258
+	    gdb_test "y" "No symbol file now." \
689258
+		"$test"
689258
+	}
689258
+	-re "No symbol file now.*$gdb_prompt $" {
689258
+	    pass "$test"
689258
+	}
689258
+    }
689258
+
689258
+    gdb_test "exec" "No executable file now." \
689258
+	"before attach-32-3, flush exec"
689258
+
689258
+    gdb_test "attach $testpid" \
689258
+	"Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \
689258
+	"attach-32 when process' a.out not in cwd"
689258
+
689258
+    set test "after attach-32-3, exit"
689258
+    gdb_test_multiple "kill" "$test" {
689258
+	-re "Kill the program being debugged.*y or n. $" {
689258
+	    gdb_test "y" "" "$test"
689258
+	}
689258
+    }
689258
+    
689258
+    # Another "don't leave a process around"
689258
+    remote_exec build "kill -9 ${testpid}"
689258
+}
689258
+
689258
+proc do_call_attach_tests {} {
689258
+    global gdb_prompt
689258
+    global binfile2
689258
+    global testpid
689258
+    
689258
+    # See if other registers are problems
689258
+    
689258
+    set test "info other register"
689258
+    gdb_test_multiple "i r r3" "$test" {
689258
+	-re "warning: reading register.*$gdb_prompt $" {
689258
+	    fail "$test"
689258
+	}
689258
+	-re "r3.*$gdb_prompt $" {
689258
+	    pass "$test"
689258
+	}
689258
+    }
689258
+
689258
+    # Get rid of the process
689258
+    
689258
+    gdb_test "p should_exit = 1"
689258
+    gdb_test "c" {\[Inferior .* exited normally\]}
689258
+   
689258
+    # Be paranoid
689258
+   
689258
+    remote_exec build "kill -9 ${testpid}"
689258
+}
689258
+
689258
+
689258
+# Start with a fresh gdb
689258
+
689258
+gdb_exit
689258
+set testpid [eval exec $binfile &]
689258
+exec sleep 3
689258
+if { [istarget "*-*-cygwin*"] } {
689258
+    # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
689258
+    # different due to the way fork/exec works.
689258
+    set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
689258
+}
689258
+
689258
+set GDBFLAGS_orig $GDBFLAGS
689258
+set GDBFLAGS "--pid=$testpid"
689258
+gdb_start
689258
+set GDBFLAGS $GDBFLAGS_orig
689258
+
689258
+gdb_reinitialize_dir $srcdir/$subdir
689258
+
689258
+# This is a test of gdb's ability to attach to a running process.
689258
+
689258
+do_attach_tests
689258
+
689258
+# Test attaching when the target is inside a system call
689258
+
689258
+gdb_exit
689258
+set testpid [eval exec $binfile2 &]
689258
+exec sleep 3
689258
+if { [istarget "*-*-cygwin*"] } {
689258
+    # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
689258
+    # different due to the way fork/exec works.
689258
+    set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
689258
+}
689258
+
689258
+set GDBFLAGS_orig $GDBFLAGS
689258
+set GDBFLAGS "--pid=$testpid"
689258
+gdb_start
689258
+set GDBFLAGS $GDBFLAGS_orig
689258
+
689258
+gdb_reinitialize_dir $srcdir/$subdir
689258
+do_call_attach_tests
689258
+
689258
+return 0
689258
diff --git a/gdb/testsuite/gdb.base/attach-32b.c b/gdb/testsuite/gdb.base/attach-32b.c
689258
new file mode 100644
689258
--- /dev/null
689258
+++ b/gdb/testsuite/gdb.base/attach-32b.c
689258
@@ -0,0 +1,24 @@
689258
+/* This program is intended to be started outside of gdb, and then
689258
+   attached to by gdb.  Thus, it simply spins in a loop.  The loop
689258
+   is exited when & if the variable 'should_exit' is non-zero.  (It
689258
+   is initialized to zero in this program, so the loop will never
689258
+   exit unless/until gdb sets the variable to non-zero.)
689258
+   */
689258
+#include <stdio.h>
689258
+#include <stdlib.h>
689258
+#include <unistd.h>
689258
+
689258
+int  should_exit = 0;
689258
+
689258
+int main ()
689258
+{
689258
+  int  local_i = 0;
689258
+
689258
+  sleep( 10 ); /* System call causes register fetch to fail */
689258
+               /* This is a known HPUX "feature"            */
689258
+  while (! should_exit)
689258
+    {
689258
+      local_i++;
689258
+    }
689258
+  return (0);
689258
+}