* gdb.base/attach.exp: When trying to attach to a nonexistent
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / attach.exp
index b86838b2afd72e3e74fd4e2c51a634fe6f93f914..6adb6e3aa4b20c27b469012459badea53d81b306 100644 (file)
@@ -1,4 +1,4 @@
-#   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
        }
@@ -34,9 +24,19 @@ if $tracelevel then {
 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
 }
 
@@ -63,31 +63,12 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      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
 }
@@ -113,6 +94,11 @@ proc do_attach_tests {} {
    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"}
@@ -120,19 +106,41 @@ proc do_attach_tests {} {
    }
 
    # 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 10.30 & 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
@@ -162,7 +170,7 @@ proc do_attach_tests {} {
 
    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"}
@@ -386,8 +394,8 @@ proc do_call_attach_tests {} {
 
    # Get rid of the process
    #
-   gdb_test "p should_exit = 1" ".*" ""
-   gdb_test "c" ".*Program exited normally.*" ""
+   gdb_test "p should_exit = 1" ".*"
+   gdb_test "c" ".*Program exited normally.*"
    
    # Be paranoid
    #
@@ -412,26 +420,7 @@ do_attach_tests
 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
This page took 0.02608 seconds and 4 git commands to generate.