| OLD | NEW |
| 1 # Test macro scoping. | 1 # Test macro scoping. |
| 2 # Copyright 2002, 2007-2012 Free Software Foundation, Inc. | 2 # Copyright 2002, 2007-2012 Free Software Foundation, Inc. |
| 3 | 3 |
| 4 # This program is free software; you can redistribute it and/or modify | 4 # This program is free software; you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License as published by | 5 # it under the terms of the GNU General Public License as published by |
| 6 # the Free Software Foundation; either version 3 of the License, or | 6 # the Free Software Foundation; either version 3 of the License, or |
| 7 # (at your option) any later version. | 7 # (at your option) any later version. |
| 8 # | 8 # |
| 9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
| 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
| 13 # | 13 # |
| 14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
| 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | 16 |
| 17 if $tracelevel then { | |
| 18 strace $tracelevel | |
| 19 } | |
| 20 | |
| 21 | 17 |
| 22 set srcfile macscp1.c | 18 set srcfile macscp1.c |
| 23 set testfile "macscp" | 19 set testfile "macscp" |
| 24 set objfile ${objdir}/${subdir}/${testfile}.o | 20 set objfile ${objdir}/${subdir}/${testfile}.o |
| 25 set binfile ${objdir}/${subdir}/${testfile} | 21 set binfile ${objdir}/${subdir}/${testfile} |
| 26 | 22 |
| 27 set options { debug additional_flags=-DFROM_COMMANDLINE=ARG} | 23 set options { debug additional_flags=-DFROM_COMMANDLINE=ARG} |
| 28 | 24 |
| 29 get_compiler_info ${binfile} | 25 get_compiler_info |
| 30 if [test_compiler_info gcc*] { | 26 if [test_compiler_info gcc*] { |
| 31 lappend options additional_flags=-g3 | 27 lappend options additional_flags=-g3 |
| 32 } | 28 } |
| 33 | 29 |
| 34 # Generate the intermediate object file. This is required by Darwin to | 30 # Generate the intermediate object file. This is required by Darwin to |
| 35 # have access to the .debug_macinfo section. | 31 # have access to the .debug_macinfo section. |
| 36 if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ | 32 if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ |
| 37 object $options] != "" | 33 object $options] != "" |
| 38 || [gdb_compile "${objfile}" "${binfile}" executable $options] != "" } { | 34 || [gdb_compile "${objfile}" "${binfile}" executable $options] != "" } { |
| 39 untested macscp.exp | 35 untested macscp.exp |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 220 |
| 225 list_and_check_macro main WHERE {macscp1.c {before macscp1_3}} | 221 list_and_check_macro main WHERE {macscp1.c {before macscp1_3}} |
| 226 list_and_check_macro macscp2_2 WHERE {macscp2.h macscp1.c {before macscp2_2}} | 222 list_and_check_macro macscp2_2 WHERE {macscp2.h macscp1.c {before macscp2_2}} |
| 227 list_and_check_macro macscp3_2 WHERE {macscp3.h macscp1.c {before macscp3_2}} | 223 list_and_check_macro macscp3_2 WHERE {macscp3.h macscp1.c {before macscp3_2}} |
| 228 | 224 |
| 229 | 225 |
| 230 # Assuming the current position inside program by `list' from above. | 226 # Assuming the current position inside program by `list' from above. |
| 231 gdb_test "info macro FROM_COMMANDLINE" \ | 227 gdb_test "info macro FROM_COMMANDLINE" \ |
| 232 "Defined at \[^\r\n\]*:0\r\n-DFROM_COMMANDLINE=ARG" | 228 "Defined at \[^\r\n\]*:0\r\n-DFROM_COMMANDLINE=ARG" |
| 233 | 229 |
| 230 gdb_test "info macro __FILE__" "#define __FILE__ \".*macscp3.h\"" \ |
| 231 "info macro __FILE__ before running" |
| 232 gdb_test "info macro __LINE__" "#define __LINE__ 26" \ |
| 233 "info macro __LINE__ before running" |
| 234 | 234 |
| 235 # Although GDB's macro table structures distinguish between multiple | 235 # Although GDB's macro table structures distinguish between multiple |
| 236 # #inclusions of the same file, GDB's other structures don't. So the | 236 # #inclusions of the same file, GDB's other structures don't. So the |
| 237 # `list' command here doesn't reliably select one #inclusion or the | 237 # `list' command here doesn't reliably select one #inclusion or the |
| 238 # other, even though it could. It would be nice to eventually change | 238 # other, even though it could. It would be nice to eventually change |
| 239 # GDB's structures to handle this correctly. | 239 # GDB's structures to handle this correctly. |
| 240 gdb_test "list macscp4_2_from_macscp2" ".*macscp4_2_, MACSCP4_INCLUSION.*" | 240 gdb_test "list macscp4_2_from_macscp2" ".*macscp4_2_, MACSCP4_INCLUSION.*" |
| 241 switch -exact -- [info_macro WHERE] { | 241 switch -exact -- [info_macro WHERE] { |
| 242 {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} { | 242 {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} { |
| 243 pass "info macro WHERE after `list macscp_4_2_from_macscp2'" | 243 pass "info macro WHERE after `list macscp_4_2_from_macscp2'" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 gdb_test "break [gdb_get_line_number "set breakpoint here"]" \ | 439 gdb_test "break [gdb_get_line_number "set breakpoint here"]" \ |
| 440 "Breakpoint.*at.* file .*, line.*" \ | 440 "Breakpoint.*at.* file .*, line.*" \ |
| 441 "breakpoint macscp_expr" | 441 "breakpoint macscp_expr" |
| 442 | 442 |
| 443 gdb_test "cond \$bpnum foo == MACRO_TO_EXPAND" \ |
| 444 "No symbol \"MACRO_TO_EXPAND\" in current context\." \ |
| 445 "macro MACRO_TO_EXPAND not in scope at breakpoint" |
| 446 |
| 447 # Note that we choose the condition so that this breakpoint never |
| 448 # stops. |
| 449 set l2 [gdb_get_line_number "set second breakpoint here"] |
| 450 gdb_test "break $l2 if foo != MACRO_TO_EXPAND" \ |
| 451 "Breakpoint.*at.*" \ |
| 452 "breakpoint macscp_expr using MACRO_TO_EXPAND" |
| 453 |
| 443 gdb_test "continue" "foo = 0;.*" "continue to macsp_expr" | 454 gdb_test "continue" "foo = 0;.*" "continue to macsp_expr" |
| 444 | 455 |
| 445 gdb_test "print address.addr" \ | 456 gdb_test "print address.addr" \ |
| 446 " = 0" \ | 457 " = 0" \ |
| 447 "print address.addr" | 458 "print address.addr" |
| 448 | 459 |
| 449 gdb_test "print MACRO_TO_EXPAND" \ | 460 gdb_test "print MACRO_TO_EXPAND" \ |
| 450 "No symbol \"MACRO_TO_EXPAND\" in current context\." \ | 461 "No symbol \"MACRO_TO_EXPAND\" in current context\." \ |
| 451 "print expression with macro before define." | 462 "print expression with macro before define." |
| 452 | 463 |
| 453 gdb_test "next" "foo = 1;" "next to definition 1" | 464 gdb_test "next" "foo = 1;.*here.*/" "next to definition 1" |
| 454 | 465 |
| 455 gdb_test "print MACRO_TO_EXPAND" \ | 466 gdb_test "print MACRO_TO_EXPAND" \ |
| 456 " = 0" \ | 467 " = 0" \ |
| 457 "print expression with macro in scope." | 468 "print expression with macro in scope." |
| 458 | 469 |
| 459 gdb_test_no_output "macro define MACRO_TO_EXPAND 72" \ | 470 gdb_test_no_output "macro define MACRO_TO_EXPAND 72" \ |
| 460 "user macro override" | 471 "user macro override" |
| 461 | 472 |
| 462 gdb_test "print MACRO_TO_EXPAND" \ | 473 gdb_test "print MACRO_TO_EXPAND" \ |
| 463 " = 72" \ | 474 " = 72" \ |
| 464 "choose user macro" | 475 "choose user macro" |
| 465 | 476 |
| 466 gdb_test_no_output "macro undef MACRO_TO_EXPAND" \ | 477 gdb_test_no_output "macro undef MACRO_TO_EXPAND" \ |
| 467 "remove user override" | 478 "remove user override" |
| 468 | 479 |
| 469 gdb_test "print MACRO_TO_EXPAND" \ | 480 gdb_test "print MACRO_TO_EXPAND" \ |
| 470 " = 0" \ | 481 " = 0" \ |
| 471 "print expression with macro after removing override" | 482 "print expression with macro after removing override" |
| 472 | 483 |
| 473 gdb_test "next" "foo = 2;" "next to definition 2" | 484 gdb_test "next" "foo = 2;.*" "next to definition 2" |
| 474 | 485 |
| 475 gdb_test "print MACRO_TO_EXPAND" \ | 486 gdb_test "print MACRO_TO_EXPAND" \ |
| 476 "No symbol \"MACRO_TO_EXPAND\" in current context\." \ | 487 "No symbol \"MACRO_TO_EXPAND\" in current context\." \ |
| 477 "print expression with macro after undef." | 488 "print expression with macro after undef." |
| 478 | 489 |
| 479 gdb_test_no_output "macro define MACRO_TO_EXPAND 5" \ | 490 gdb_test_no_output "macro define MACRO_TO_EXPAND 5" \ |
| 480 "basic macro define" | 491 "basic macro define" |
| 481 | 492 |
| 482 gdb_test "print MACRO_TO_EXPAND" \ | 493 gdb_test "print MACRO_TO_EXPAND" \ |
| 483 " = 5" \ | 494 " = 5" \ |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 " = \"5\"" \ | 681 " = \"5\"" \ |
| 671 "stringify with substitution" | 682 "stringify with substitution" |
| 672 | 683 |
| 673 # Regression test for pp-number bug. | 684 # Regression test for pp-number bug. |
| 674 gdb_test_no_output "macro define si_addr fields.fault.si_addr" \ | 685 gdb_test_no_output "macro define si_addr fields.fault.si_addr" \ |
| 675 "define si_addr macro" | 686 "define si_addr macro" |
| 676 | 687 |
| 677 gdb_test "macro expand siginfo.si_addr" \ | 688 gdb_test "macro expand siginfo.si_addr" \ |
| 678 "expands to: siginfo.fields.fault.si_addr" \ | 689 "expands to: siginfo.fields.fault.si_addr" \ |
| 679 "macro expand siginfo.si_addr" | 690 "macro expand siginfo.si_addr" |
| 691 |
| 692 gdb_test "print __FILE__" " = \".*macscp1.c\"" |
| 693 gdb_test "print __LINE__" \ |
| 694 " = [gdb_get_line_number {stopping point for line test}]" |
| OLD | NEW |