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

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