Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-ctor.exp
blob1a84b7990f45a82389ac548b45e849b71971262f
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
22 standard_testfile .cc
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
25     return -1
28 if {[test_compiler_info {clang-*-*} c++]} {
29     set using_clang true
30 } else {
31     set using_clang false
34 if {![runto_main]} {
35     return
38 # Set a breakpoint with multiple locations
39 # and a condition.
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"
51 gdb_test "continue" \
52     ".*Breakpoint.*Derived.*i=7.*" \
53     "run to breakpoint 1 v1"
55 gdb_continue_to_breakpoint "set breakpoint here, first time" ".* breakpoint here"
57 gdb_test "continue" \
58     ".*Breakpoint.*Derived.*i=15.*" \
59     "run to breakpoint 1 v2"
61 gdb_continue_to_breakpoint "set breakpoint here, second time" ".* breakpoint here"
63 gdb_test "continue" \
64     ".*Breakpoint.*Derived.*i=24.*" \
65     "run to breakpoint 1 dynamic v1"
67 gdb_continue_to_breakpoint "set breakpoint here, first dynamic time"\
68     ".* breakpoint here"
70 gdb_test "continue" \
71     ".*Breakpoint.*Derived.*i=42.*" \
72     "run to breakpoint 1 dynamic v2"
74 gdb_continue_to_breakpoint "set breakpoint here, second dynamic time"\
75     ".* breakpoint here"
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.
81 if {$using_clang} {
82     gdb_test "continue" ".*Breakpoint.*~Derived.*"\
83         "clang's nested dynamic destructor call"
86 gdb_test "continue" ".*Breakpoint.*~Derived.*" "Run to dynamic destructor v2"
88 gdb_test "continue" \
89     ".*Breakpoint.*~Derived.*" \
90     "run to breakpoint 3 v1"
92 gdb_test "continue" \
93     ".*Breakpoint.*~Derived.*" \
94     "run to breakpoint 3 v2"
96 if {$using_clang} {
97     gdb_test "continue" ".*Breakpoint.*~Derived.*"\
98         "clang's nested destructor call"
101 gdb_test "continue" \
102     ".*exited normally.*" \
103     "run to exit"