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

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