[gdb/symtab] Fix missing breakpoint location for inlined function
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / step-and-next-inline.exp
1 # Copyright 2019-2020 Free Software Foundation, Inc.
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
18 if { ![supports_statement_frontiers] } {
19 return -1
20 }
21
22 # Compile the test source with USE_NEXT_INLINE_H defined (when
23 # use_header is true), or not defined.
24 proc do_test { use_header } {
25 global srcfile testfile
26
27 if { $use_header } {
28 # This test will not pass due to poor debug information
29 # generated by GCC (at least upto 10.x). See
30 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
31 return
32 }
33
34 set options {c++ debug nowarnings optimize=-O2\ -gstatement-frontiers}
35 if { $use_header } {
36 lappend options additional_flags=-DUSE_NEXT_INLINE_H
37 set executable "$testfile-with-header"
38 set hdrfile "step-and-next-inline.h"
39 set prefix "use_header"
40 } else {
41 set executable "$testfile-no-header"
42 set hdrfile "$srcfile"
43 set prefix "no_header"
44 }
45
46 if { [prepare_for_testing "failed to prepare" $executable \
47 $srcfile $options] } {
48 return -1
49 }
50
51 with_test_prefix $prefix {
52
53 if ![runto_main] {
54 fail "can't run to main"
55 return
56 }
57
58 gdb_test "bt" "\\s*\\#0\\s+main.*" "in main"
59 gdb_test "step" ".*" "step into get_alias_set"
60 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
61 "not in inline 1"
62 # It's possible that this first failure (when not using a header
63 # file) is GCC's fault, though the remaining failures would best
64 # be fixed by adding location views support (though it could be
65 # that some easier heuristic could be figured out). Still, it is
66 # not certain that the first failure wouldn't also be fixed by
67 # having location view support, so for now it is tagged as such.
68 if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
69 gdb_test "next" ".*TREE_TYPE.*" "next step 1"
70 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
71 "not in inline 2"
72 gdb_test "next" ".*TREE_TYPE.*" "next step 2"
73 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
74 "not in inline 3"
75 if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
76 gdb_test "next" ".*TREE_TYPE.*" "next step 3"
77 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
78 "not in inline 4"
79 if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
80 gdb_test "next" "return 0.*" "next step 4"
81 gdb_test "bt" \
82 "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
83 "not in inline 5"
84
85 if {!$use_header} {
86 # With the debug from GCC 10.x (and earlier) GDB is currently
87 # unable to successfully complete the following tests when we
88 # are not using a header file.
89 kfail symtab/25507 "stepping tests"
90 return
91 }
92
93 clean_restart ${executable}
94
95 if ![runto_main] {
96 fail "can't run to main pass 2"
97 return
98 }
99
100 gdb_test "bt" "\\s*\\#0\\s+main.*" "in main pass 2"
101 gdb_test "step" ".*" "step into get_alias_set pass 2"
102 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
103 "in get_alias_set pass 2"
104 gdb_test "step" ".*TREE_TYPE.*" "step 1"
105 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
106 "not in inline 1 pass 2"
107 gdb_test "step" ".*if \\(t->x != i\\).*" "step 2"
108 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
109 "in inline 1 pass 2"
110 gdb_test "step" ".*TREE_TYPE.*" "step 3"
111 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
112 "not in inline 2 pass 2"
113 gdb_test "step" ".*if \\(t->x != i\\).*" "step 4"
114 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
115 "in inline 2 pass 2"
116 gdb_test "step" ".*TREE_TYPE.*" "step 5"
117 gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
118 "not in inline 3 pass 2"
119 gdb_test "step" ".*if \\(t->x != i\\).*" "step 6"
120 gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
121 "in inline 3 pass 2"
122 gdb_test "step" "return 0.*" "step 7"
123 gdb_test "bt" \
124 "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
125 "not in inline 4 pass 2"
126 }
127 }
128
129 do_test 0
130 do_test 1
This page took 0.046628 seconds and 4 git commands to generate.