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

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