Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
index 0ecdf675342c569ca10864335c19666131bb6e50..4822b7ef8bce79a1b8e96d91b2cb5efa72d3ee41 100644 (file)
@@ -1,26 +1,19 @@
-#   Copyright 2003, 2004
-#   Free Software Foundation, Inc.
+#   Copyright 2003, 2004, 2005, 2007 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
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
-# The shared library compilation portion was copied from shlib-call.exp which was
-# written by Elena Zannoni (ezannoni@redhat.com).
 
 if $tracelevel then {
     strace $tracelevel
@@ -32,76 +25,37 @@ if $tracelevel then {
 set prms_id 0
 set bug_id 0
 
-# are we on a target board?
-if ![isnative] then {
+if {[skip_shlib_tests]} {
     return 0
 }
 
 set testfile "pending"
 set libfile "pendshr"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set srcfile $testfile.c
+set libsrc  $srcdir/$subdir/$libfile.c
+set binfile $objdir/$subdir/$testfile
+set lib_sl  $objdir/$subdir/$libfile.sl
+
+set lib_opts  debug
+set exec_opts [list debug shlib=$lib_sl]
 
 if [get_compiler_info ${binfile}] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-}
-
-# Build the shared libraries this test case needs.
-#
-
-if {$gcc_compiled == 0} {
-    if [istarget "hppa*-hp-hpux*"] then {
-       set additional_flags "additional_flags=+z"
-    } elseif { [istarget "mips-sgi-irix*"] } {
-       # Disable SGI compiler's implicit -Dsgi
-       set additional_flags "additional_flags=-Usgi"
-    } else {
-       # don't know what the compiler is...
-       set additional_flags ""
-    }
-} else {
-    if { ([istarget "powerpc*-*-aix*"]
-       || [istarget "rs6000*-*-aix*"]) } {
-       set additional_flags ""
-    } else {
-       set additional_flags "additional_flags=-fpic"
-    }
-}
-
-if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-}
-
-if [istarget "hppa*-*-hpux*"] {
-    remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
-} else {
-    set additional_flags "additional_flags=-shared"
-    if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} {
-       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-    }
+if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
+     || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
+    untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
+    return -1
 }
 
-if { ($gcc_compiled 
-      &&  ([istarget "powerpc*-*-aix*"]
-       || [istarget "rs6000*-*-aix*"] )) } {
-    set additional_flags "additional_flags=-L${objdir}/${subdir}"
-} elseif { [istarget "mips-sgi-irix*"] } {
-    set additional_flags "additional_flags=-rpath ${objdir}/${subdir}"
-} else {
-    set additional_flags ""
-}
-if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-}
+# Start with a fresh gdb.
 
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
+gdb_load_shlibs $lib_sl
 
 if [target_info exists gdb_stub] {
     gdb_step_for_stub;
@@ -111,7 +65,7 @@ if [target_info exists gdb_stub] {
 #
 
 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or n. $" {
+     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
            gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
      }
 }
@@ -142,7 +96,7 @@ gdb_test "info break" \
 # Test not setting a pending breakpoint 
 #
 gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or n. $" {
+     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
            gdb_test "n" "" "Don't set pending breakpoint"
      }
 }
@@ -151,7 +105,7 @@ gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
 # Add condition to pending breakpoint 
 #
 
-gdb_test "condition 1 k == 1\n" ""
+gdb_test "condition 1 k == 1" ""
 
 gdb_test "info break" \
     "Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -164,7 +118,7 @@ gdb_test "info break" \
 # Disable pending breakpoint
 #
 
-gdb_test "disable 1\n" ""
+gdb_test "disable 1" ""
 
 gdb_test "info break" \
     "Num Type\[ \]+Disp Enb Address\[ \]+What.*
@@ -191,9 +145,10 @@ gdb_test "info break" \
 # Try a pending break for a line in a source file with a condition
 #
 
-gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
-     -re ".*Make breakpoint pending.*y or n. $" {
-           gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
+set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
+gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" {
+     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
+           gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
                "Set pending breakpoint 2"
      }
 }
@@ -204,16 +159,43 @@ gdb_test "info break" \
 \[\t \]+stop only if k == 1.*
 \[\t \]+print k.*
 \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
-\[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:26 if x > 3.*" \
+\[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
 "multiple pending breakpoints"
 
+
+#
+# Try a pending break for a line in a source file with ignore count:
+#
+
+set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
+gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" {
+     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
+           gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
+               "Set pending breakpoint 3"
+     }
+}
+
+gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
+    "set ignore count on pending breakpoint 3"
+
+gdb_test "info break" \
+    "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+breakpoint     keep n.*PENDING.*pendfunc1.*
+\[\t \]+stop only if k == 1.*
+\[\t \]+print k.*
+\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
+\[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
+\[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \
+"multiple pending breakpoints 2"
+
 #
 # Run to main which should resolve a pending breakpoint
 #
 
-gdb_test "run" \
+gdb_run_cmd
+gdb_test "" \
 "Breakpoint.*at.*
-Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
+Pending breakpoint \"pendshr.c:$bp2_loc if x > 3\" resolved.*
 Breakpoint.*, main.*$mainline.*" \
 "running to main"
 
@@ -231,14 +213,27 @@ Pending breakpoint \"pendfunc1.* resolved.*" \
 #
 
 gdb_test "continue" \
-".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
+".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
 "continue to resolved breakpoint 2"
 
 gdb_test "continue" \
-".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
+".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
 \[$\]1 = 1." \
 "continue to resolved breakpoint 1"
 
+#
+# Disable the other two breakpoints, and continue to the one with
+# the ignore count.  Make sure you hit it the third time, x should
+# be 3 then.
+#
+
+gdb_test "disable 7" "" "Disable other breakpoints"
+gdb_test "disable 5" "" "Disable other breakpoints"
+
+gdb_test "continue" \
+        ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
+"continue to resolved breakpoint 3"
+
 delete_breakpoints
 
 gdb_breakpoint "main"
@@ -247,7 +242,7 @@ gdb_breakpoint "main"
 # Set non-existent pending breakpoint
 #
 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
-     -re ".*Make breakpoint pending.*y or n. $" {
+     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
            gdb_test "y" "Breakpoint.*imaginary.*pending." \
                "set imaginary pending breakpoint"
      }
@@ -259,6 +254,7 @@ gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
 #
 
 rerun_to_main
+
 gdb_test "info break" \
     "Num Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
This page took 0.046266 seconds and 4 git commands to generate.