1 # Copyright 2007-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test that breakpoints on C++ constructors work, despite the
17 # fact that gcc generates several versions of constructor function.
19 require allow_cplus_tests
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
28 if {[test_compiler_info {clang-*-*} c++]} {
38 # Set a breakpoint with multiple locations
41 gdb_test "break 'Derived::Derived(int)'" \
42 "Breakpoint.*at.*: Derived::Derived.int.. \\(2 locations\\).*" \
43 "set-breakpoint at ctor"
45 gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
47 gdb_test "break 'Derived::~Derived()'" \
48 "Breakpoint.*at.*: Derived::~Derived... \\(2 locations\\).*" \
49 "set-breakpoint at dtor"
52 ".*Breakpoint.*Derived.*i=7.*" \
53 "run to breakpoint 1 v1"
55 gdb_continue_to_breakpoint "set breakpoint here, first time" ".* breakpoint here"
58 ".*Breakpoint.*Derived.*i=15.*" \
59 "run to breakpoint 1 v2"
61 gdb_continue_to_breakpoint "set breakpoint here, second time" ".* breakpoint here"
64 ".*Breakpoint.*Derived.*i=24.*" \
65 "run to breakpoint 1 dynamic v1"
67 gdb_continue_to_breakpoint "set breakpoint here, first dynamic time"\
71 ".*Breakpoint.*Derived.*i=42.*" \
72 "run to breakpoint 1 dynamic v2"
74 gdb_continue_to_breakpoint "set breakpoint here, second dynamic time"\
77 gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v1"
79 # Clang makes Derived::~Derived(this) call Derived::~Derives(this, vtt)
80 # whereas gcc puts all the logic necessary on both functions.
82 gdb_test "continue" ".*Breakpoint.*~Derived.*"\
83 "clang's nested dynamic destructor call"
86 gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v2"
89 ".*Breakpoint.*~Derived.*" \
90 "run to breakpoint 3 v1"
93 ".*Breakpoint.*~Derived.*" \
94 "run to breakpoint 3 v2"
97 gdb_test "continue" ".*Breakpoint.*~Derived.*"\
98 "clang's nested destructor call"
101 gdb_test "continue" \
102 ".*exited normally.*" \