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