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

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