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