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

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