1# Copyright 1997-2023 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# written by Elena Zannoni (elz@apollo.hp.com) 17# 18# This file is part of the gdb testsuite 19# 20# tests for const variables 21# const pointers to vars 22# pointers to const variables 23# const pointers to const vars 24# with mixed types 25 26# 27# test running programs 28# 29 30standard_testfile .c 31 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } { 33 untested "failed to compile" 34 return -1 35} 36 37clean_restart ${binfile} 38 39 40# 41# set it up at a breakpoint so we can play with the variable values 42# 43if {![runto_main]} { 44 return 45} 46 47get_debug_format 48 49# Many tests xfail with gcc 2 -gstabs+. 50# TODO: check out the hp side of this. 51 52proc local_compiler_xfail_check { } { 53 if {[test_compiler_info gcc-2-*]} { 54 if { ![test_debug_format "HP"] \ 55 && ![test_debug_format "DWARF \[0-9\]"] } then { 56 setup_xfail "*-*-*" 57 } 58 } 59} 60 61# A few tests still xfail with gcc 3 -gstabs+ and gcc 4 -gstabs+. 62 63proc local_compiler_xfail_check_2 { } { 64 if { [test_compiler_info gcc-3-*] || [test_compiler_info gcc-4-*] } { 65 if { [test_debug_format "stabs" ] } { 66 setup_xfail "*-*-*" 67 } 68 } 69} 70 71gdb_test "break marker1" "Breakpoint $decimal at .*" 72 73gdb_test_multiple "cont" "up from marker1" { 74 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { 75 pass "continue to marker1" 76 gdb_test "up" " main .*" "up from marker1" 77 } 78 -re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" { 79 fail "continue to marker1 (demangling)" 80 gdb_test "up" " main .*" "up from marker1" 81 } 82} 83 84# test function parameters 85 86local_compiler_xfail_check 87local_compiler_xfail_check_2 88 89gdb_test "ptype qux1" \ 90 "type = int \\(const char, const char, const char \\*, char \\* const\\).*" 91 92# test vars and pointers 93 94proc do_constvar_tests {} { 95 gdb_test "print lave" " = 66 'B'" 96 gdb_test "ptype lave" "type = char" 97 gdb_test "print lavish" " = 10 '\\\\n'" 98 gdb_test "ptype lavish" "type = unsigned char" 99 gdb_test "print lax" " = 20" 100 gdb_test "ptype lax" "type = short.*" 101 gdb_test "print lecherous" " = 30" 102 gdb_test "ptype lecherous" "type = (unsigned short|short unsigned)( int)?" 103 gdb_test "print lechery" " = 40" 104 gdb_test "ptype lechery" "type = long.*" 105 gdb_test "print lectern" " = 50" 106 gdb_test "ptype lectern" "type = (unsigned long|long unsigned)( int)?" 107 gdb_test "print leeway" " = 60" 108 gdb_test "ptype leeway" "type = float" 109 gdb_test "print legacy" " = 70" 110 gdb_test "ptype legacy" "type = double" 111 gdb_test "print laconic" " = 65 'A'" 112 local_compiler_xfail_check 113 gdb_test "ptype laconic" "type = const char" 114 gdb_test "print laggard" " = 1 '.001'" 115 local_compiler_xfail_check 116 gdb_test "ptype laggard" "type = const unsigned char" 117 gdb_test "print lagoon" " = 2" 118 local_compiler_xfail_check 119 gdb_test "ptype lagoon" "type = const short( int)?" 120 gdb_test "print laity" " = 3" 121 local_compiler_xfail_check 122 gdb_test "ptype laity" "type = const (unsigned short|short unsigned)( int)?" 123 gdb_test "print lambent" " = 4" 124 local_compiler_xfail_check 125 gdb_test "ptype lambent" "type = const long( int)?" 126 gdb_test "print laminated" " = 5" 127 local_compiler_xfail_check 128 gdb_test "ptype laminated" "type = const (unsigned long|long unsigned)( int)?" 129 gdb_test "print lampoon" " = 6" 130 local_compiler_xfail_check 131 gdb_test "ptype lampoon" "type = const float" 132 gdb_test "print languid" " = 7" 133 local_compiler_xfail_check 134 gdb_test "ptype languid" "type = const double" 135 gdb_test "print *legend" " = 66 'B'" 136 local_compiler_xfail_check 137 gdb_test "ptype legend" "type = const char \\*" 138 gdb_test "print *legerdemain" " = 10 '\\\\n'" 139 local_compiler_xfail_check 140 gdb_test "ptype legerdemain" "type = const unsigned char \\*" 141 gdb_test "print *leniency" " = 20" 142 local_compiler_xfail_check 143 gdb_test "ptype leniency" "type = const short( int)? \\*" 144 gdb_test "print *leonine" " = 30" 145 local_compiler_xfail_check 146 gdb_test "ptype leonine" "type = const (unsigned short|short unsigned)( int)? \\*" 147 gdb_test "print *lesion" " = 40" 148 local_compiler_xfail_check 149 gdb_test "ptype lesion" "type = const long( int)? \\*" 150 gdb_test "print *lethal" " = 50" 151 local_compiler_xfail_check 152 gdb_test "ptype lethal" "type = const (unsigned long|long unsigned)( int)? \\*" 153 gdb_test "print *lethargic" " = 60" 154 local_compiler_xfail_check 155 gdb_test "ptype lethargic" "type = const float \\*" 156 gdb_test "print *levity" " = 70" 157 local_compiler_xfail_check 158 gdb_test "ptype levity" "type = const double \\*" 159 gdb_test "print *lewd" " = 65 'A'" 160 local_compiler_xfail_check 161 gdb_test "ptype lewd" "type = const char \\* const" 162 gdb_test "print *lexicographer" " = 1 '.001'" 163 local_compiler_xfail_check 164 gdb_test "ptype lexicographer" "type = const unsigned char \\* const" 165 gdb_test "print *lexicon" " = 2" 166 local_compiler_xfail_check 167 gdb_test "ptype lexicon" "type = const short( int)? \\* const" 168 gdb_test "print *liaison" " = 3" 169 local_compiler_xfail_check 170 gdb_test "ptype liaison" "type = const (unsigned short|short unsigned)( int)? \\* const" 171 gdb_test "print *libation" " = 4" 172 local_compiler_xfail_check 173 gdb_test "ptype libation" "type = const long( int)? \\* const" 174 gdb_test "print *libelous" " = 5" 175 local_compiler_xfail_check 176 gdb_test "ptype libelous" "type = const (unsigned long|long unsigned)( int)? \\* const" 177 gdb_test "print *libertine" " = 6" 178 local_compiler_xfail_check 179 gdb_test "ptype libertine" "type = const float \\* const" 180 gdb_test "print *libidinous" " = 7" 181 local_compiler_xfail_check 182 gdb_test "ptype libidinous" "type = const double \\* const" 183 gdb_test "print *languish" " = 65 'A'" 184 local_compiler_xfail_check 185 gdb_test "ptype languish" "type = const char \\*" 186 gdb_test "print *languor" " = 1 '.001'" 187 local_compiler_xfail_check 188 gdb_test "ptype languor" "type = const unsigned char \\*" 189 gdb_test "print *lank" " = 2" 190 local_compiler_xfail_check 191 gdb_test "ptype lank" "type = const short( int)? \\*" 192 gdb_test "print *lapidary" " = 3" 193 local_compiler_xfail_check 194 gdb_test "ptype lapidary" "type = const (unsigned short|short unsigned)( int)? \\*" 195 gdb_test "print *larceny" " = 4" 196 local_compiler_xfail_check 197 gdb_test "ptype larceny" "type = const long( int)? \\*" 198 gdb_test "print *largess" " = 5" 199 local_compiler_xfail_check 200 gdb_test "ptype largess" "type = const (unsigned long|long unsigned)( int)? \\*" 201 gdb_test "print *lascivious" " = 6" 202 local_compiler_xfail_check 203 204 gdb_test "ptype lascivious" "type = const float \\*" 205 gdb_test "print *lassitude" " = 7" 206 local_compiler_xfail_check 207 gdb_test "ptype lassitude" "type = const double \\*" 208 gdb_test "print *lamprey" " = 66 'B'" 209 local_compiler_xfail_check 210 gdb_test "ptype lamprey" "type = char \\* const" 211 gdb_test "print *lariat" " = 10 '\\\\n'" 212 local_compiler_xfail_check 213 gdb_test "ptype lariat" "type = unsigned char \\* const" 214 gdb_test "print *laudanum" " = 20" 215 local_compiler_xfail_check 216 gdb_test "ptype laudanum" "type = short( int)? \\* const" 217 gdb_test "print *lecithin" " = 30" 218 local_compiler_xfail_check 219 gdb_test "ptype lecithin" "type = (unsigned short|short unsigned)( int)? \\* const" 220 gdb_test "print *leviathan" " = 40" 221 local_compiler_xfail_check 222 gdb_test "ptype leviathan" "type = long( int)? \\* const" 223 gdb_test "print *libretto" " = 50" 224 local_compiler_xfail_check 225 gdb_test "ptype libretto" "type = (unsigned long|long unsigned)( int)? \\* const" 226 gdb_test "print *lissome" " = 60" 227 local_compiler_xfail_check 228 gdb_test "ptype lissome" "type = float \\* const" 229 gdb_test "print *locust" " = 70" 230 local_compiler_xfail_check 231 gdb_test "ptype locust" "type = double \\* const" 232 233 local_compiler_xfail_check 234 gdb_test "ptype logical" "type = const char \\\[2\\\]" 235 local_compiler_xfail_check 236 gdb_test "ptype lugged" "type = const unsigned char \\\[2\\\]" 237 local_compiler_xfail_check 238 gdb_test "ptype luck" "type = const short( int)? \\\[2\\\]" 239 local_compiler_xfail_check 240 gdb_test "ptype lunar" "type = const (unsigned short|short unsigned)( int)? \\\[2\\\]" 241 local_compiler_xfail_check 242 gdb_test "ptype lumen" "type = const long( int)? \\\[2\\\]" 243 local_compiler_xfail_check 244 gdb_test "ptype lurk" "type = const (unsigned long|long unsigned)( int)? \\\[2\\\]" 245 local_compiler_xfail_check 246 gdb_test "ptype lush" "type = const float \\\[2\\\]" 247 local_compiler_xfail_check 248 gdb_test "ptype lynx" "type = const double \\\[2\\\]" 249 250 local_compiler_xfail_check 251 local_compiler_xfail_check_2 252 gdb_test "ptype crass" "type = struct crass \{\[\r\n\]+\[\ \t\]+char \\* const ptr;\[\r\n\]+\}" 253 local_compiler_xfail_check 254 gdb_test "ptype crisp" "type = struct crisp \{\[\r\n\]+\[\ \t\]+char \\* const \\*ptr;\[\r\n\]+\}" 255} 256 257do_constvar_tests 258