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

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