info-macros.exp revision 1.6
1# Copyright 2011-2016 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 16standard_testfile .c 17 18# Fission doesn't support macros yet. Bug 15954. 19if [using_fission] { 20 untested ${testfile}.exp 21 return -1 22} 23 24get_compiler_info 25if ![test_compiler_info gcc*] { 26 untested ${testfile}.exp 27 return -1 28} 29 30# Don't use "debug" here. Otherwise "-g" would be appended to the gcc 31# command line, possibly overriding "-g3" (depending on gcc version). 32set options "additional_flags=-g3" 33 34if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $options] } { 35 untested ${testfile}.exp 36 return -1 37} 38 39if ![runto_main] { 40 untested ${testfile}.exp 41 return -1 42} 43 44# Test various error messages. 45gdb_test "info macro -- -all" \ 46 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ 47 "info macro -- -all" 48gdb_test "info macro -- -all" \ 49 "The symbol `-all' has no definition .*\r\nat .*$srcfile:\[0-9\]+" \ 50 "info macro -- -all" 51 52gdb_test "info macro -all --" \ 53 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 54 "info macro -all --" 55 56gdb_test "info macro -all --" \ 57 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 58 "info macro -all --" 59 60gdb_test "info macro -all --" \ 61 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 62 "info macro -all --" 63 64gdb_test "info macro --" \ 65 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 66 "info macro --" 67 68gdb_test "info macro -- " \ 69 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 70 "'info macro -- '" 71gdb_test "info macro -- " \ 72 "You must follow.*with the name.*you want to see.*\[^\r\n\]*\[\r\n\]" \ 73 "'info macro -- '" 74 75gdb_test "info macro -invalid-option" \ 76 "Unrecognized option.*Try \"help info macro\"\." \ 77 "info macro -invalid-option 1" 78 79gdb_test "info macro -invalid-option" \ 80 "Unrecognized option.*Try \"help info macro\"\." \ 81 "info macro -invalid-option" 82 83gdb_test "info macro -invalid-option FOO" \ 84 "Unrecognized option.*Try \"help info macro\"\." \ 85 "info macro -invalid-option FOO" 86gdb_test "info macro -invalid-option FOO" \ 87 "Unrecognized option.*Try \"help info macro\"\." \ 88 "info macro -invalid-option FOO" 89 90# Single macro lookups. 91gdb_test "info macro -- FOO" \ 92 ".*#define FOO \"hello\"" \ 93 "info macro -- FOO" 94 95gdb_test "info macro -- FOO" \ 96 ".*#define FOO \"hello\"" \ 97 "info macro -- FOO" 98 99gdb_test "info macro -- FOO" \ 100 ".*#define FOO \"hello\"" \ 101 "info macro -- FOO" 102 103gdb_test "info macro FOO" \ 104 ".*#define FOO \"hello\"" \ 105 "info macro FOO" 106 107gdb_test "info macro FOO" \ 108 ".*#define FOO \"hello\"" \ 109 "info macro FOO" 110 111# Multiple macro lookups. 112set test "info macro -a FOO" 113set r1 ".*#define FOO \"hello\"" 114set r2 ".*#define FOO \" \"" 115set r3 ".*#define FOO \"world\"" 116set r4 ".*#define FOO\\(a\\) foo = a" 117set testname "$test 1" 118gdb_test "$test" "$r1$r2$r3$r4" "$testname" 119 120set test "info macro -a -- FOO" 121set testname "$test 1" 122gdb_test "$test" "$r1$r2$r3$r4" "$testname" 123 124set test "info macro -all -- FOO" 125set testname "$test 1" 126gdb_test "$test" "$r1$r2$r3$r4" "$testname" 127 128set test "info macro -a -- FOO" 129set testname "$test" 130gdb_test "$test" "$r1$r2$r3$r4" "$testname" 131 132set test "info macro -a -- FOO" 133set testname "$test" 134gdb_test "$test" "$r1$r2$r3$r4" "$testname" 135 136set test "info macros" 137set r1 ".*#define FOO \"hello\"" 138set r2 ".*#define ONE" 139set r3 ".*\r\n$gdb_prompt" 140set testname "$test 2" 141gdb_test_multiple "$test" $testname { 142 -re "$r1$r2$r3" { 143 pass $testname 144 } 145 -re ".*#define TWO.*\r\n$gdb_prompt" { 146 fail $testname 147 } 148 -re ".*#define THREE.*\r\n$gdb_prompt" { 149 fail $testname 150 } 151 -re ".*#define FOUR.*\r\n$gdb_prompt" { 152 fail $testname 153 } 154} 155gdb_test "next" ".*" "" 156 157set r1 ".*#define FOO \" \"" 158set r2 ".*#define ONE" 159set r3 ".*#define TWO" 160set r4 ".*\r\n$gdb_prompt" 161set testname "$test 3" 162gdb_test_multiple "$test" $testname { 163 -re ".*#define THREE.*\r\n$gdb_prompt" { 164 fail $testname 165 } 166 -re ".*#define FOUR.*\r\n$gdb_prompt" { 167 fail $testname 168 } 169 -re "$r1$r2$r3$r4" { 170 pass $testname 171 } 172} 173gdb_test "next" ".*" "" 174 175# in alpabetical order... 176set r1 ".*#define FOO \"world\"" 177set r2 ".*#define ONE" 178set r3 ".*#define THREE" 179set r4 ".*#define TWO" 180set r5 ".*\r\n$gdb_prompt" 181set testname "$test 4" 182gdb_test_multiple "$test" $testname { 183 -re ".*#define FOUR.*\r\n$gdb_prompt" { 184 fail $testname 185 } 186 -re "$r1$r2$r3$r4$r5" { 187 pass $testname 188 } 189} 190# same as above with a linespec. 191set test "info macros *\$pc" 192gdb_test_multiple "$test" $test { 193 -re ".*#define FOUR.*\r\n$gdb_prompt" { 194 fail $test 195 } 196 -re "$r1$r2$r3$r4$r5" { 197 pass $test 198 } 199} 200gdb_test "next" ".*" "" 201 202set r1 ".*#define FOO \" \"" 203set r2 ".*#define ONE" 204set r3 ".*#define TWO." 205set r4 ".*\r\n$gdb_prompt" 206set test "info macros" 207set testname "$test 5" 208gdb_test_multiple "$test" $test { 209 -re ".*#define THREE.*\r\n$gdb_prompt" { 210 fail $testname 211 } 212 -re ".*#define FOUR.*\r\n$gdb_prompt" { 213 fail $testname 214 } 215 -re "$r1$r2$r3$r4" { 216 pass $testname 217 } 218} 219gdb_test "next" ".*" "" 220gdb_test "next" ".*" "" 221 222set r1 ".*#define DEF_MACROS" 223set r2 ".*\r\n$gdb_prompt" 224set testname "$test 6" 225gdb_test_multiple "$test" $testname { 226 -re ".*#define FOO \" \".*\r\n$gdb_prompt" { 227 fail $testname 228 } 229 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { 230 fail $testname 231 } 232 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { 233 fail $testname 234 } 235 -re ".*#define FOO\\(a\\) foo = a.*" { 236 fail $testname 237 } 238 -re ".*#define ONE.*\r\n$gdb_prompt" { 239 fail $testname 240 } 241 -re ".*#define TWO.*\r\n$gdb_prompt" { 242 fail $testname 243 } 244 -re ".*#define THREE.*\r\n$gdb_prompt" { 245 fail $testname 246 } 247 -re ".*#define FOUR.*\r\n$gdb_prompt" { 248 fail $testname 249 } 250 -re "$r1$r2" { 251 pass $testname 252 } 253} 254 255gdb_test "next" ".*" "" 256set r1 ".*#define DEF_MACROS" 257set r2 ".*#define FOO\\(a\\) foo = a" 258set r3 ".*#define FOUR" 259set r4 ".*\r\n$gdb_prompt" 260set testname "$test 7" 261gdb_test_multiple "$test" $testname { 262 -re ".*#define FOO \" \".*\r\n$gdb_prompt" { 263 fail $testname 264 } 265 -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { 266 fail $testname 267 } 268 -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { 269 fail $testname 270 } 271 -re ".*#define ONE.*\r\n$gdb_prompt" { 272 fail $testname 273 } 274 -re ".*#define TWO.*\r\n$gdb_prompt" { 275 fail $testname 276 } 277 -re ".*#define THREE.*\r\n$gdb_prompt" { 278 fail $testname 279 } 280 -re "$r1$r2$r3$r4" { 281 pass $testname 282 } 283} 284 285set test "info macros info-macros.c:42" 286 287set r1 ".*define DEF_MACROS" 288set r2 ".*define ONE" 289# info macros on the line where the #define or #include is 290# fails to find the macro defined (though it works on the next line.) 291setup_kfail "gdb/NNNN" *-*-* 292gdb_test "$test" "$r1$r2" "$test" 293