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