Remove Cell Broadband Engine debugging support
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / exception.exp
index aaf5376d04694e827095404ab2d1066869f6a963..13631df1290ba988821f005da602b84e6d1b0e8a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1997, 1998, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 1997-2019 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
 # Static-linked executables use a different mechanism to get the
 # address of the notification hook in the C++ support library.
 
-# TODO: this file is not ready for production yet.  If you are working
-# on C++ exception support for gdb, you can take out the "continue"
-# statement and try your luck.  -- chastain 2004-01-09
-
 # TODO: this file has many absolute line numbers.
 # Replace them with gdb_get_line_number.
 
 set ws "\[\r\n\t \]+"
 set nl "\[\r\n\]+"
 
-if $tracelevel then {
-    strace $tracelevel
-}
-
-if { [skip_cplus_tests] } { continue }
-
-# On SPU this test fails because the executable exceeds local storage size.
-if { [istarget "spu*-*-*"] } {
-        return 0
-}
+if { [skip_stl_tests] } { continue }
 
-set testfile "exception"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
  
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested exception.exp
-     return -1
-}
-
-# Start with a fresh gdb
-
-set prms_id 0
-set bug_id 0
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-if ![runto_main] then {
-    perror "couldn't run to breakpoint"
-    continue
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
-# As I said before, this test script is not ready yet!
-
-continue
-
 # Set a catch catchpoint
 
-gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
+gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \
+    "catch catch (before inferior run)"
 
 # Set a throw catchpoint
 
 gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
-    "catch throw (static executable)"
+    "catch throw (before inferior run)"
+
+# Set a rethrow catchpoint
+
+gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \
+    "catch rethrow (before inferior run)"
 
-# The catchpoints should be listed in the list of breakpoints.
 
 set re_head    "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
-set re_1_main   "1${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}in main.*breakpoint already hit.*"
-set re_2_catch "2${ws}catch catch${ws}keep${ws}y${ws}$hex${ws}exception catch"
-set re_3_catch "3${ws}catch throw${ws}keep${ws}y${ws}$hex${ws}exception throw"
-set re_2_bp    "2${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception catch"
-set re_3_bp    "3${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception throw"
+set re_2_bp    "1${ws}catchpoint${ws}keep${ws}y${ws}exception catch"
+set re_3_bp    "2${ws}catchpoint${ws}keep${ws}y${ws}exception throw"
+set re_4_bp    "3${ws}catchpoint${ws}keep${ws}y${ws}exception rethrow"
 
-set name "info breakpoints"
+set name "info breakpoints (before inferior run)"
 gdb_test_multiple "info breakpoints" $name {
-    -re "$re_head${ws}$re_1_main${ws}$re_2_catch${ws}$re_3_catch\r\n$gdb_prompt $" {
+    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp${ws}$re_4_bp\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "$re_head${ws}$re_1_main${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
-    }
+    -re ".*$gdb_prompt $"
+      {
+       fail $name
+      }
 }
 
-# Some targets support "info catch".
-# Some do not.
+gdb_test "tbreak main" "Temporary breakpoint 4.*" \
+    "Set temporary breakpoint at main"
 
-set name "info catch"
-gdb_test_multiple "info catch" $name {
-    -re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
-       unsupported $name
+set ok 0
+gdb_run_cmd
+gdb_test_multiple "" "run to main" {
+    -re "Temporary breakpoint 4,.*$gdb_prompt $" {
+       pass "run to main"
+       set ok 1
     }
-    -re "No catches.\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
+}
+
+if { !$ok } {
+    continue
+}
+
+set name "info breakpoints (after inferior run)"
+gdb_test_multiple "info breakpoints" $name {
+    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp${ws}$re_4_bp\r\n$gdb_prompt $" {
+       pass $name
     }
+    -re ".*$gdb_prompt $"
+      {
+       send_user "\n---\n$expect_out(buffer)\n---\n"
+       fail $name
+      }
 }
 
+gdb_test "break catcher" "Breakpoint \[0-9\]+ at.*"
+
 # Get the first exception thrown
        
 set name "continue to first throw"
@@ -126,9 +110,8 @@ gdb_test_multiple "continue" $name {
     -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
+    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
+       pass $name
     }
 }
 
@@ -137,7 +120,9 @@ gdb_test_multiple "continue" $name {
 
 set name "backtrace after first throw"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:48\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+       # Either __cxxabiv1::__cxa_throw or __cxa_throw can be printed
+       # depending on debug info presence.
        pass $name
     }
 }
@@ -149,9 +134,8 @@ gdb_test_multiple "continue" $name {
     -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
+    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
+       pass $name
     }
 }
 
@@ -160,21 +144,23 @@ gdb_test_multiple "continue" $name {
 
 set name "backtrace after first catch"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:50\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
 
+# Continue to breakpoint on catcher.
+gdb_test "continue" ".*catcher \\(x=13\\).*" "continue to catcher for the first time"
+
 # Continue to second throw.
 
 set name "continue to second throw"
 gdb_test_multiple "continue" $name {
-    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
+    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
+    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
+       pass $name
     }
 }
 
@@ -183,7 +169,7 @@ gdb_test_multiple "continue" $name {
 
 set name "backtrace after second throw"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:56\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
@@ -195,9 +181,8 @@ gdb_test_multiple "continue" $name {
     -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
        pass $name
     }
-    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
-       # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
-       unresolved $name
+    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
+       pass $name
     }
 }
 
@@ -206,21 +191,16 @@ gdb_test_multiple "continue" $name {
 
 set name "backtrace after second catch"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:58\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
 
-# That is all for now.
-# 
-# The original code had:
-#
-#    continue to re-throw ; backtrace
-#    continue to catch    ; backtrace
-#    continue to throw out of main
-#
-# The problem is that "re-throw" does not show a throw; only a catch.
-# I do not know if this is because of a bug, or because the generated
-# code is optimized for a throw into the same function.
-#
-# -- chastain 2004-01-09
+# Continue to breakpoint on catcher.
+gdb_test "continue" ".*catcher \\(x=13\\).*" "continue to catcher for the second time"
+
+
+# Continue to the re-throw.
+
+gdb_test "continue" "Catchpoint \[0-9\]+.*exception rethrown.*" \
+    "continue to rethrow"
This page took 0.027253 seconds and 4 git commands to generate.