]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2013-2024 Free Software Foundation, Inc. |
72f1fe8a TT |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | standard_testfile .cc | |
17 | ||
0b94d2b9 | 18 | require allow_cplus_tests |
72f1fe8a | 19 | |
5b362f04 | 20 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
72f1fe8a TT |
21 | return -1 |
22 | } | |
23 | ||
24 | if {![runto_main]} { | |
25 | return -1 | |
26 | } | |
27 | ||
b694989f | 28 | if {[skip_libstdcxx_probe_tests]} { |
72f1fe8a TT |
29 | untested "could not find libstdc++ stap probe" |
30 | return -1 | |
31 | } | |
32 | ||
33 | proc do_continue_to_catchpoint {name} { | |
34 | global gdb_prompt | |
35 | ||
36 | gdb_test_multiple "continue" $name { | |
37 | -re "Continuing.*Catchpoint \[0-9\].*\r\n$gdb_prompt $" { | |
38 | pass $name | |
39 | } | |
40 | } | |
41 | } | |
42 | ||
43 | proc do_exceptprint_tests {prefix output} { | |
44 | with_test_prefix $prefix { | |
45 | do_continue_to_catchpoint "continue to throw" | |
46 | gdb_test "print \$_exception" " = $output" \ | |
47 | "print exception value at throw" | |
48 | ||
49 | do_continue_to_catchpoint "continue to catch" | |
50 | gdb_test "print \$_exception" " = $output" \ | |
51 | "print exception value at catch" | |
52 | ||
53 | do_continue_to_catchpoint "continue to rethrow" | |
54 | gdb_test "print \$_exception" " = $output" \ | |
55 | "print exception value at rethrow" | |
56 | ||
57 | do_continue_to_catchpoint "continue to final catch" | |
58 | } | |
59 | } | |
60 | ||
e96ec2ba TV |
61 | gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" |
62 | gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" | |
63 | gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" | |
72f1fe8a TT |
64 | |
65 | do_exceptprint_tests string "$hex \"hi bob\"" | |
66 | do_exceptprint_tests int 23 | |
67 | do_exceptprint_tests struct "{mv = 77}" | |
68 | do_exceptprint_tests "reference to struct" "{mv = 77}" | |
cc16e6c9 TT |
69 | |
70 | ||
71 | delete_breakpoints | |
72 | ||
73 | if {![runto_main]} { | |
74 | return -1 | |
75 | } | |
76 | ||
c2b75043 LM |
77 | with_test_prefix "2nd run" { |
78 | gdb_test "catch catch int if \$_exception == 23" \ | |
79 | "Catchpoint \[0-9\]+ \\(catch\\)" \ | |
80 | "catch catch" | |
81 | gdb_test "catch throw int if \$_exception == 23" \ | |
82 | "Catchpoint \[0-9\]+ \\(throw\\)" \ | |
83 | "catch throw" | |
84 | gdb_test "catch rethrow int if \$_exception == 23" \ | |
85 | "Catchpoint \[0-9\]+ \\(rethrow\\)" \ | |
86 | "catch rethrow" | |
87 | } | |
cc16e6c9 TT |
88 | |
89 | # This tests both the case where the regular expression does not | |
90 | # match, and the case where it does. | |
c2b75043 LM |
91 | with_test_prefix "2nd run" { |
92 | do_exceptprint_tests int 23 | |
93 | } |