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

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