-# Copyright (C) 1997 Free Software Foundation, Inc.
+# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
-# On HP-UX 11.0, this test is causing a process running
-# the program "attach" to be left around spinning.
-# Until we figure out why, I am commenting out the test
-# to avoid polluting tiamat (our 11.0 nightly test machine)
-# with these processes. RT
-#
-# Setting the magic bit in the target app should work.
-# I added a "kill", and also a test for the R3 register
-# warning. JB
-#
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
+# On HP-UX 11.0, this test is causing a process running the program
+# "attach" to be left around spinning. Until we figure out why, I am
+# commenting out the test to avoid polluting tiamat (our 11.0 nightly
+# test machine) with these processes. RT
+#
+# Setting the magic bit in the target app should work. I added a
+# "kill", and also a test for the R3 register warning. JB
+if { [istarget "hppa*-*-hpux*"] } {
+ return 0
+}
-if { ![istarget "hppa*-*-hpux*"] } {
- #setup_xfail "*-*-*"
+# are we on a target board
+if [is_remote target] then {
return 0
}
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
-# Because we can't attach over nfs, copy binfile to /tmp/${binfile}.${pid}
-# and replace binfile with a symbolic link
-
- set pid [pid]
- exec /bin/cp -f ${binfile} /tmp/attach1.${pid}
- exec rm -f ${binfile}
- set binfile /tmp/attach1.${pid}
-# exec ln -s /tmp/attach1.${pid} ${binfile}
-
# Build the in-system-call test
if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
-# Because we can't attach over nfs, copy binfile2 to /tmp/${binfile2}.${pid}
-# and replace binfile2 with a symbolic link
-
- set pid [pid]
- exec cp -f ${binfile2} /tmp/attach2.${pid}
- exec rm -f ${binfile2}
- set binfile2 /tmp/attach2.${pid}
-# exec ln -s /tmp/attach2.${pid} ${binfile2}
-
-
if [get_compiler_info ${binfile}] {
return -1
}
gdb_expect {
-re ".*Illegal process-id: abc.*$gdb_prompt $"\
{pass "attach to nonsense is prohibited"}
+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
+ {
+ # Response expected from /proc-based systems.
+ pass "attach to nonsense is prohibited"
+ }
-re "Attaching to.*$gdb_prompt $"\
{fail "attach to nonsense is prohibited (bogus pid allowed)"}
-re "$gdb_prompt $" {fail "attach to nonsense is prohibited"}
}
# Verify that we cannot attach to what appears to be a valid
- # process ID, but is a process that doesn't exist. (I don't
- # believe any process is ever assigned #0, at least on HPUX.)
+ # process ID, but is a process that doesn't exist. Traditionally,
+ # most systems didn't have a process with ID 0, so we take that as
+ # the default. However, there are a few exceptions.
#
- send_gdb "attach 0\n"
+ set boguspid 0
+ if { [istarget "*-*-freebsd*"] } {
+ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead
+ # (which should have the desired effect on any version of FreeBSD).
+ set boguspid -1
+ }
+ send_gdb "attach $boguspid\n"
gdb_expect {
- # This reponse is expected on HP-UX 10.20 (i.e., ptrace-based).
- -re "Attaching to.*, process 0.*No such process.*$gdb_prompt $"\
- {pass "attach to nonexistent process is prohibited"}
- # This response is expected on HP-UX 11.0 (i.e., ttrace-based).
- -re "Attaching to.*, process 0 failed.*Hint.*$gdb_prompt $"\
- {pass "attach to nonexistent process is prohibited"}
- -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
- timeout {fail "(timeout) attach to nonexistent process is prohibited"}
+ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\
+ {
+ # Response expected on ptrace-based systems (i.e. HP-UX 10.20).
+ pass "attach to nonexistent process is prohibited"
+ }
+ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\
+ {
+ # Response expected on ttrace-based systems (i.e. HP-UX 11.0).
+ pass "attach to nonexistent process is prohibited"
+ }
+ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\
+ {pass "attach to nonexistent process is prohibited"}
+ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\
+ {pass "attach to nonexistent process is prohibited"}
+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
+ {
+ # Response expected from /proc-based systems.
+ pass "attach to nonexistent process is prohibited"
+ }
+ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
+ timeout {
+ fail "(timeout) attach to nonexistent process is prohibited"
+ }
}
# Verify that we can attach to the process by first giving its
send_gdb "attach $testpid\n"
gdb_expect {
- -re "Attaching to program.*$binfile, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
+ -re "Attaching to program.*`?$binfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
{pass "attach1, after setting file"}
-re "$gdb_prompt $" {fail "attach1, after setting file"}
timeout {fail "(timeout) attach1, after setting file"}
gdb_exit
gdb_start
-# this seems not necessary. - guo
-#
-# # Since we have moved the executable to /tmp, it will be hard for gdb
-# # to find the object file/executable to read the symbols. This is
-# # a known limitation. We try and get the name of the executable the
-# # process is running from a variety of methods, but none is foolproof.
-# # Using "dir" will get us the symbols.
-#
-# gdb_test "dir ./gdb.base" ".*" "set up directory before attach"
gdb_reinitialize_dir $srcdir/$subdir
do_call_attach_tests
-# Until "set follow-fork-mode" and "catch fork" are implemented on
-# other targets...
-#
-if ![istarget "hppa*-hp-hpux*"] then {
- setup_xfail "*-*-*"
-}
-
-# Cleanup the files placed in /tmp and the symlinks
- remote_exec build "rm -f ${binfile} ${binfile2} /tmp/attach1.${pid} /tmp/attach2.${pid}"
-
return 0