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

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