[testsuite/Ada] Add testing of access to packed arrays.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / catch_ex.exp
index 603909ce0e1c1778d7d139c55b97bb0c418f7c28..ca933e96e3e983e876f96560f18b95ddcd84bcc5 100644 (file)
@@ -1,8 +1,8 @@
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007-2013 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,
 # 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., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA
-
-if $tracelevel then {
-    strace $tracelevel
-}
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 load_lib "ada.exp"
 
-set testdir "catch_ex"
-set testfile "${testdir}/foo"
-set srcfile ${srcdir}/${subdir}/${testfile}.adb
-set binfile ${objdir}/${subdir}/${testfile}
+standard_ada_testfile foo
 
-file mkdir ${objdir}/${subdir}/${testdir}
 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
   return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${testfile}
 
 # Some global variables used to simplify the maintenance of some of
 # the regular expressions below.
@@ -56,9 +43,19 @@ if ![runto_main] then {
    return 0
 }
 
-gdb_test "catch exception" \
-         "Catchpoint $any_nb: all Ada exceptions" \
-         "insert catchpoint on all Ada exceptions"
+set msg "insert catchpoint on all Ada exceptions"
+gdb_test_multiple "catch exception" $msg {
+    -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
+       pass $msg
+    }
+    -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
+       # If the runtime was not built with enough debug information,
+       # or if it was stripped, we can not test exception
+       # catchpoints.
+       unsupported $msg
+       return -1
+    }
+}
 
 gdb_test "info break" \
          "$info_break_header$eol.*$catch_exception_info" \
@@ -128,16 +125,46 @@ set catchpoint_msg \
   "Catchpoint $any_nb, failed assertion at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
 gdb_test "continue" \
          "Continuing\.$eol$catchpoint_msg$eol.*SPOT3" \
-         "continuing to Program_Error exception"
+         "continuing to failed assertion"
 
 set catchpoint_msg \
   "Catchpoint $any_nb, unhandled CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
 gdb_test "continue" \
          "Continuing\.$eol$catchpoint_msg$eol.*SPOT4" \
-         "continuing to Program_Error exception"
+         "continuing to unhandled exception"
 
 gdb_test "continue" \
-         "Continuing\..*Program exited.*" \
+         "Continuing\..*$inferior_exited_re.*" \
          "continuing to program completion"
 
+#################################
+# 3. Try temporary catchpoints. #
+#################################
+
+# Scenario:
+#   - Insert a temporary catchpoint on all exceptions.
+#   - Run to that catchpoint
+#   - Continue; we should reach the program's exit, not stopping
+#     at any of the other exceptions that are being raised inside
+#     the program.
+
+if ![runto_main] then {
+   fail "Cannot run to main, testcase aborted"
+   return 0
+}
+
+gdb_test "tcatch exception" \
+         "Temporary catchpoint $any_nb: all Ada exceptions"
+
+set temp_catchpoint_msg \
+  "Temporary catchpoint $any_nb, CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
+gdb_test "continue" \
+         "Continuing\.$eol$temp_catchpoint_msg$eol.*SPOT1" \
+         "continuing to temporary catchpoint"
+
+gdb_test "continue" \
+         "Continuing\..*$inferior_exited_re.*" \
+         "continuing to program completion"
+
+
 
This page took 0.025862 seconds and 4 git commands to generate.