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

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