]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2007-2023 Free Software Foundation, Inc. |
ed0616c6 VP |
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 | # Test that breakpoints on C++ constructors work, despite the | |
17 | # fact that gcc generates several versions of constructor function. | |
18 | ||
cdd42066 | 19 | if { [skip_cplus_tests] } { return } |
c3ea9a14 | 20 | |
ed0616c6 | 21 | |
f5f3a911 | 22 | standard_testfile .cc |
ed0616c6 | 23 | |
5b362f04 | 24 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
f5f3a911 | 25 | return -1 |
ed0616c6 VP |
26 | } |
27 | ||
3180839c BL |
28 | if {[test_compiler_info {clang-*-*} c++]} { |
29 | set using_clang true | |
30 | } else { | |
31 | set using_clang false | |
32 | } | |
33 | ||
95701cae | 34 | if {![runto_main]} { |
cdd42066 | 35 | return |
9ab4e744 DE |
36 | } |
37 | ||
ed0616c6 VP |
38 | # Set a breakpoint with multiple locations |
39 | # and a condition. | |
40 | ||
41 | gdb_test "break 'Derived::Derived(int)'" \ | |
f8eba3c6 | 42 | "Breakpoint.*at.*: Derived::Derived.int.. \\(2 locations\\).*" \ |
ed0616c6 VP |
43 | "set-breakpoint at ctor" |
44 | ||
9ab4e744 DE |
45 | gdb_breakpoint [gdb_get_line_number "set breakpoint here"] |
46 | ||
ed0616c6 | 47 | gdb_test "break 'Derived::~Derived()'" \ |
f8eba3c6 | 48 | "Breakpoint.*at.*: Derived::~Derived... \\(2 locations\\).*" \ |
5a98ad69 | 49 | "set-breakpoint at dtor" |
ed0616c6 | 50 | |
9ab4e744 DE |
51 | gdb_test "continue" \ |
52 | ".*Breakpoint.*Derived.*i=7.*" \ | |
53 | "run to breakpoint 1 v1" | |
54 | ||
3c2dcf90 | 55 | gdb_continue_to_breakpoint "set breakpoint here, first time" ".* breakpoint here" |
ed0616c6 VP |
56 | |
57 | gdb_test "continue" \ | |
58 | ".*Breakpoint.*Derived.*i=15.*" \ | |
9ab4e744 DE |
59 | "run to breakpoint 1 v2" |
60 | ||
3c2dcf90 | 61 | gdb_continue_to_breakpoint "set breakpoint here, second time" ".* breakpoint here" |
ed0616c6 | 62 | |
0b1505c8 BL |
63 | gdb_test "continue" \ |
64 | ".*Breakpoint.*Derived.*i=24.*" \ | |
65 | "run to breakpoint 1 dynamic v1" | |
66 | ||
67 | gdb_continue_to_breakpoint "set breakpoint here, first dynamic time"\ | |
68 | ".* breakpoint here" | |
69 | ||
70 | gdb_test "continue" \ | |
71 | ".*Breakpoint.*Derived.*i=42.*" \ | |
72 | "run to breakpoint 1 dynamic v2" | |
73 | ||
74 | gdb_continue_to_breakpoint "set breakpoint here, second dynamic time"\ | |
75 | ".* breakpoint here" | |
76 | ||
77 | gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v1" | |
78 | ||
3180839c BL |
79 | # Clang makes Derived::~Derived(this) call Derived::~Derives(this, vtt) |
80 | # whereas gcc puts all the logic necessary on both functions. | |
81 | if {$using_clang} { | |
82 | gdb_test "continue" ".*Breakpoint.*~Derived.*"\ | |
83 | "clang's nested dynamic destructor call" | |
84 | } | |
85 | ||
0b1505c8 BL |
86 | gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v2" |
87 | ||
ed0616c6 VP |
88 | gdb_test "continue" \ |
89 | ".*Breakpoint.*~Derived.*" \ | |
9ab4e744 | 90 | "run to breakpoint 3 v1" |
ed0616c6 VP |
91 | |
92 | gdb_test "continue" \ | |
93 | ".*Breakpoint.*~Derived.*" \ | |
9ab4e744 | 94 | "run to breakpoint 3 v2" |
ed0616c6 | 95 | |
3180839c BL |
96 | if {$using_clang} { |
97 | gdb_test "continue" ".*Breakpoint.*~Derived.*"\ | |
98 | "clang's nested destructor call" | |
99 | } | |
100 | ||
ed0616c6 VP |
101 | gdb_test "continue" \ |
102 | ".*exited normally.*" \ | |
103 | "run to exit" | |
104 | ||
105 | ||
106 |