| OLD | NEW |
| 1 # Copyright 1988, 1990-1992, 1994-2000, 2002-2004, 2007-2012 Free | 1 # Copyright 1988, 1990-1992, 1994-2000, 2002-2004, 2007-2012 Free |
| 2 # Software Foundation, Inc. | 2 # 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 # Based on break.exp, written by Rob Savoye. (rob@cygnus.com) | 17 # Based on break.exp, written by Rob Savoye. (rob@cygnus.com) |
| 18 # Modified to test gdb's handling of separate debug info files. | 18 # Modified to test gdb's handling of separate debug info files. |
| 19 # Modified to test gdb's handling of a debug-id retrieval. | 19 # Modified to test gdb's handling of a debug-id retrieval. |
| 20 | 20 |
| 21 # This file has two parts. The first is testing that gdb behaves | 21 # This file has two parts. The first is testing that gdb behaves |
| 22 # normally after reading in an executable and its corresponding | 22 # normally after reading in an executable and its corresponding |
| 23 # separate debug file. The second moves the .debug file to a different | 23 # separate debug file. The second moves the .debug file to a different |
| 24 # location and tests the "set debug-file-directory" command. | 24 # location and tests the "set debug-file-directory" command. |
| 25 # The third is for testing build-id retrievel by finding the separate | 25 # The third is for testing build-id retrievel by finding the separate |
| 26 # ".debug-id/ab/cdef.debug" file. | 26 # ".debug-id/ab/cdef.debug" file. |
| 27 | 27 |
| 28 | 28 |
| 29 if $tracelevel then { | |
| 30 strace $tracelevel | |
| 31 } | |
| 32 | |
| 33 # | 29 # |
| 34 # test running programs | 30 # test running programs |
| 35 # | 31 # |
| 36 | 32 |
| 37 set testfile "sepdebug" | 33 set testfile "sepdebug" |
| 38 set srcfile ${testfile}.c | 34 set srcfile ${testfile}.c |
| 39 set binfile ${objdir}/${subdir}/${testfile}${EXEEXT} | 35 set binfile ${objdir}/${subdir}/${testfile}${EXEEXT} |
| 40 | 36 |
| 41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug nowarnings}] != "" } { | 37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug nowarnings}] != "" } { |
| 42 untested sepdebug.exp | 38 untested sepdebug.exp |
| 43 return -1 | 39 return -1 |
| 44 } | 40 } |
| 45 | 41 |
| 46 # Note: the procedure gdb_gnu_strip_debug will produce an executable called | 42 # Note: the procedure gdb_gnu_strip_debug will produce an executable called |
| 47 # ${binfile}, which is just like the executable ($binfile) but without | 43 # ${binfile}, which is just like the executable ($binfile) but without |
| 48 # the debuginfo. Instead $binfile has a .gnudebuglink section which contains | 44 # the debuginfo. Instead $binfile has a .gnu_debuglink section which contains |
| 49 # the name of a debuginfo only file. This file will be stored in the | 45 # the name of a debuginfo only file. This file will be stored in the |
| 50 # gdb.base/ subdirectory. | 46 # gdb.base/ subdirectory. |
| 51 | 47 |
| 52 if [gdb_gnu_strip_debug $binfile] { | 48 if [gdb_gnu_strip_debug $binfile] { |
| 53 # check that you have a recent version of strip and objcopy installed | 49 # check that you have a recent version of strip and objcopy installed |
| 54 unsupported "cannot produce separate debug info files" | 50 unsupported "cannot produce separate debug info files" |
| 55 return -1 | 51 return -1 |
| 56 } | 52 } |
| 57 | 53 |
| 58 gdb_exit | 54 # |
| 59 gdb_start | 55 # PR gdb/9538. Verify that symlinked executable still finds the separate |
| 60 gdb_reinitialize_dir $srcdir/$subdir | 56 # debuginfo. |
| 61 gdb_load ${binfile} | 57 # |
| 58 set old_subdir ${subdir} |
| 59 set subdir ${subdir}/pr9538 |
| 60 |
| 61 # Cleanup any stale state. |
| 62 remote_exec build "rm -rf ${subdir}" |
| 63 |
| 64 remote_exec build "mkdir ${subdir}" |
| 65 remote_exec build "ln -s ${binfile} ${subdir}" |
| 66 clean_restart ${testfile}${EXEEXT} |
| 62 if { $gdb_file_cmd_debug_info != "debug" } then { | 67 if { $gdb_file_cmd_debug_info != "debug" } then { |
| 63 fail "No debug information found." | 68 fail "No debug information found." |
| 64 } | 69 } |
| 65 | 70 |
| 66 if [target_info exists gdb_stub] { | 71 # Restore subdir |
| 67 gdb_step_for_stub; | 72 set subdir ${old_subdir} |
| 73 |
| 74 clean_restart ${testfile}${EXEEXT} |
| 75 if { $gdb_file_cmd_debug_info != "debug" } then { |
| 76 fail "No debug information found." |
| 68 } | 77 } |
| 78 |
| 69 # | 79 # |
| 70 # test simple breakpoint setting commands | 80 # test simple breakpoint setting commands |
| 71 # | 81 # |
| 72 | 82 |
| 73 # | 83 # |
| 74 # test break at function | 84 # test break at function |
| 75 # | 85 # |
| 76 gdb_test "break main" \ | 86 gdb_test "break main" \ |
| 77 "Breakpoint.*at.* file .*$srcfile, line.*" \ | 87 "Breakpoint.*at.* file .*$srcfile, line.*" \ |
| 78 "breakpoint function" | 88 "breakpoint function" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 # Verify the breakpoint was put at the start of the conditional. | 143 # Verify the breakpoint was put at the start of the conditional. |
| 134 # | 144 # |
| 135 gdb_test "break multi_line_if_conditional" \ | 145 gdb_test "break multi_line_if_conditional" \ |
| 136 "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ | 146 "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ |
| 137 "breakpoint at start of multi line if conditional" | 147 "breakpoint at start of multi line if conditional" |
| 138 | 148 |
| 139 gdb_test "break multi_line_while_conditional" \ | 149 gdb_test "break multi_line_while_conditional" \ |
| 140 "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ | 150 "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ |
| 141 "breakpoint at start of multi line while conditional" | 151 "breakpoint at start of multi line while conditional" |
| 142 | 152 |
| 143 set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] | |
| 144 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] | 153 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] |
| 145 | 154 |
| 146 # | 155 set main_line $bp_location6 |
| 147 # check to see what breakpoints are set | |
| 148 # | |
| 149 if [target_info exists gdb_stub] { | |
| 150 set main_line $bp_location5 | |
| 151 } else { | |
| 152 set main_line $bp_location6 | |
| 153 } | |
| 154 | 156 |
| 155 set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] | 157 set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] |
| 156 set bp_location8 [gdb_get_line_number "set breakpoint 8 here"] | 158 set bp_location8 [gdb_get_line_number "set breakpoint 8 here"] |
| 157 set bp_location9 [gdb_get_line_number "set breakpoint 9 here"] | 159 set bp_location9 [gdb_get_line_number "set breakpoint 9 here"] |
| 158 | 160 |
| 159 gdb_test "info break" \ | 161 gdb_test "info break" \ |
| 160 "Num Type\[ \]+Disp Enb Address\[ \]+What.* | 162 "Num Type\[ \]+Disp Enb Address\[ \]+What.* |
| 161 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* | 163 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* |
| 162 \[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile:($bp_location8|
$bp_location9).* | 164 \[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile:($bp_location8|
$bp_location9).* |
| 163 \[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:$bp_location7
.* | 165 \[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:$bp_location7
.* |
| 164 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* | 166 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* |
| 165 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* | 167 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* |
| 166 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* | 168 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* |
| 167 \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfi
le:$bp_location3.* | 169 \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfi
le:$bp_location3.* |
| 168 \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$sr
cfile:$bp_location4" \ | 170 \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$sr
cfile:$bp_location4" \ |
| 169 "breakpoint info" | 171 "breakpoint info" |
| 170 | 172 |
| 171 # FIXME: The rest of this test doesn't work with anything that can't | 173 # FIXME: The rest of this test doesn't work with anything that can't |
| 172 # handle arguments. | 174 # handle arguments. |
| 173 # Huh? There doesn't *appear* to be anything that passes arguments | 175 # Huh? There doesn't *appear* to be anything that passes arguments |
| 174 # below. | 176 # below. |
| 175 if [istarget "mips-idt-*"] then { | |
| 176 return | |
| 177 } | |
| 178 | 177 |
| 179 # | 178 # |
| 180 # run until the breakpoint at main is hit. For non-stubs-using targets. | 179 # run until the breakpoint at main is hit. For non-stubs-using targets. |
| 181 # | 180 # |
| 182 gdb_run_cmd | 181 gdb_run_cmd |
| 183 gdb_expect { | 182 gdb_expect { |
| 184 -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*
$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { | 183 -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*
$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { |
| 185 pass "run until function breakpoint" | 184 pass "run until function breakpoint" |
| 186 } | 185 } |
| 187 -re "$gdb_prompt $" { | 186 -re "$gdb_prompt $" { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 # | 371 # |
| 373 if ![runto_main] then { fail "sepdebug tests suppressed" } | 372 if ![runto_main] then { fail "sepdebug tests suppressed" } |
| 374 | 373 |
| 375 gdb_test_multiple "break $bp_location1" \ | 374 gdb_test_multiple "break $bp_location1" \ |
| 376 "set to-be-silent break bp_location1" { | 375 "set to-be-silent break bp_location1" { |
| 377 -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $" { | 376 -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $" { |
| 378 pass "set to-be-silent break bp_location1" | 377 pass "set to-be-silent break bp_location1" |
| 379 } | 378 } |
| 380 } | 379 } |
| 381 | 380 |
| 382 send_gdb "commands $expect_out(1,string)\n" | 381 gdb_test "commands $expect_out(1,string)\nsilent\nend" ">end" "set silent break
bp_location1" |
| 383 send_gdb "silent\n" | |
| 384 send_gdb "end\n" | |
| 385 gdb_expect { | |
| 386 -re ".*$gdb_prompt $"\ | |
| 387 {pass "set silent break bp_location1"} | |
| 388 timeout {fail "(timeout) set silent break bp_location1"} | |
| 389 } | |
| 390 | 382 |
| 391 gdb_test "info break $expect_out(1,string)" \ | 383 gdb_test "info break $expect_out(1,string)" \ |
| 392 "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \ | 384 "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \ |
| 393 "info silent break bp_location1" | 385 "info silent break bp_location1" |
| 394 | 386 |
| 395 gdb_test "continue" "Continuing.*" "hit silent break bp_location1" | 387 gdb_test "continue" "Continuing.*" "hit silent break bp_location1" |
| 396 | 388 |
| 397 gdb_test "bt" "#0 main .* at .*:$bp_location1.*" \ | 389 gdb_test "bt" "#0 main .* at .*:$bp_location1.*" \ |
| 398 "stopped for silent break bp_location1" | 390 "stopped for silent break bp_location1" |
| 399 | 391 |
| 400 # Verify that GDB can at least parse a breakpoint with the | 392 # Verify that GDB can at least parse a breakpoint with the |
| 401 # "thread" keyword. (We won't attempt to test here that a | 393 # "thread" keyword. (We won't attempt to test here that a |
| 402 # thread-specific breakpoint really triggers appropriately. | 394 # thread-specific breakpoint really triggers appropriately. |
| 403 # The gdb.threads subdirectory contains tests for that.) | 395 # The gdb.threads subdirectory contains tests for that.) |
| 404 # | 396 # |
| 405 set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] | 397 set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] |
| 406 | 398 |
| 407 gdb_test "break $bp_location12 thread 999" "Unknown thread 999.*" \ | 399 gdb_test "break $bp_location12 thread 999" "Unknown thread 999.*" \ |
| 408 "thread-specific breakpoint on non-existent thread disallowed" | 400 "thread-specific breakpoint on non-existent thread disallowed" |
| 409 | 401 |
| 410 gdb_test "break $bp_location12 thread foo" \ | 402 gdb_test "break $bp_location12 thread foo" \ |
| 411 "Junk after thread keyword.*" \ | 403 "Junk after thread keyword.*" \ |
| 412 "thread-specific breakpoint on bogus thread ID disallowed" | 404 "thread-specific breakpoint on bogus thread ID disallowed" |
| 413 | 405 |
| 414 # Verify that GDB responds gracefully to a breakpoint command with | 406 # Verify that GDB responds gracefully to a breakpoint command with |
| 415 # trailing garbage. | 407 # trailing garbage. |
| 416 # | 408 # |
| 417 | 409 |
| 418 gdb_test "break $bp_location12 foo" \ | 410 gdb_test "break $bp_location12 foo" \ |
| 419 "Junk at end of arguments.*" \ | 411 "malformed linespec error: unexpected string, \"foo\".*" \ |
| 420 "breakpoint with trailing garbage disallowed" | 412 "breakpoint with trailing garbage disallowed" |
| 421 | 413 |
| 422 # Verify that GDB responds gracefully to a "clear" command that has | 414 # Verify that GDB responds gracefully to a "clear" command that has |
| 423 # no matching breakpoint. (First, get us off the current source line, | 415 # no matching breakpoint. (First, get us off the current source line, |
| 424 # which we know has a breakpoint.) | 416 # which we know has a breakpoint.) |
| 425 # | 417 # |
| 426 | 418 |
| 427 gdb_test "next" "marker1.*" "step over breakpoint" | 419 gdb_test "next" "marker1.*" "step over breakpoint" |
| 428 | 420 |
| 429 gdb_test "clear 81" "No breakpoint at 81.*" \ | 421 gdb_test "clear 81" "No breakpoint at 81.*" \ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 if [target_info exists gdb,noresults] { gdb_suppress_tests } | 642 if [target_info exists gdb,noresults] { gdb_suppress_tests } |
| 651 gdb_continue_to_end "recursive next test" | 643 gdb_continue_to_end "recursive next test" |
| 652 gdb_stop_suppressing_tests; | 644 gdb_stop_suppressing_tests; |
| 653 } | 645 } |
| 654 | 646 |
| 655 test_next_with_recursion | 647 test_next_with_recursion |
| 656 | 648 |
| 657 | 649 |
| 658 #******** | 650 #******** |
| 659 | 651 |
| 660 proc test_different_dir {type test_different_dir xfail} { | 652 proc test_different_dir {type test_different_dir xfail} { with_test_prefix "$typ
e" { |
| 661 global srcdir subdir objdir binfile srcfile timeout gdb_prompt | 653 global srcdir subdir objdir binfile srcfile timeout gdb_prompt |
| 662 global pf_prefix | |
| 663 global bp_location6 decimal hex | 654 global bp_location6 decimal hex |
| 664 | 655 |
| 665 set old_pf_prefix $pf_prefix | |
| 666 append pf_prefix " $type:" | |
| 667 | |
| 668 gdb_exit | 656 gdb_exit |
| 669 gdb_start | 657 gdb_start |
| 670 gdb_reinitialize_dir $srcdir/$subdir | 658 gdb_reinitialize_dir $srcdir/$subdir |
| 671 gdb_test_no_output "set debug-file-directory ${test_different_dir}" \ | 659 gdb_test_no_output "set debug-file-directory ${test_different_dir}" \ |
| 672 "set separate debug location" | 660 "set separate debug location" |
| 673 gdb_load ${binfile} | 661 gdb_load ${binfile} |
| 674 | 662 |
| 675 if [target_info exists gdb_stub] { | |
| 676 gdb_step_for_stub; | |
| 677 } | |
| 678 | |
| 679 # | 663 # |
| 680 # test break at function | 664 # test break at function |
| 681 # | 665 # |
| 682 if {$xfail} { | 666 if {$xfail} { |
| 683 setup_xfail "*-*-*" | 667 setup_xfail "*-*-*" |
| 684 } | 668 } |
| 685 gdb_test "break main" \ | 669 gdb_test "break main" \ |
| 686 "Breakpoint.*at.* file .*$srcfile, line.*" \ | 670 "Breakpoint.*at.* file .*$srcfile, line.*" \ |
| 687 "breakpoint function, optimized file" | 671 "breakpoint function, optimized file" |
| 688 | 672 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 735 } |
| 752 | 736 |
| 753 | 737 |
| 754 # Reset the default arguments for VxWorks | 738 # Reset the default arguments for VxWorks |
| 755 if [istarget "*-*-vxworks*"] { | 739 if [istarget "*-*-vxworks*"] { |
| 756 set timeout 10 | 740 set timeout 10 |
| 757 verbose "Timeout is now $timeout seconds" 2 | 741 verbose "Timeout is now $timeout seconds" 2 |
| 758 gdb_test_no_output "set args main" | 742 gdb_test_no_output "set args main" |
| 759 } | 743 } |
| 760 | 744 |
| 761 set pf_prefix $old_pf_prefix | |
| 762 # proc test_different_dir | 745 # proc test_different_dir |
| 763 } | 746 }} |
| 764 | 747 |
| 765 | 748 |
| 766 # now move the .debug file to a different location so that we can test | 749 # now move the .debug file to a different location so that we can test |
| 767 # the "set debug-file-directory" command. | 750 # the "set debug-file-directory" command. |
| 768 | 751 |
| 769 set different_dir "${objdir}/${subdir}/${testfile}.dir" | 752 set different_dir "${objdir}/${subdir}/${testfile}.dir" |
| 770 set debugfile "${different_dir}/${objdir}/${subdir}/${testfile}.debug" | 753 set debugfile "${different_dir}/${objdir}/${subdir}/${testfile}.debug" |
| 771 remote_exec build "rm -rf $different_dir" | 754 remote_exec build "rm -rf $different_dir" |
| 772 remote_exec build "mkdir -p [file dirname $debugfile]" | 755 remote_exec build "mkdir -p [file dirname $debugfile]" |
| 773 remote_exec build "mv -f ${objdir}/${subdir}/${testfile}.debug $debugfile" | 756 remote_exec build "mv -f ${objdir}/${subdir}/${testfile}.debug $debugfile" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 803 |
| 821 # Test also multiple directories can be specified. Without the build-id | 804 # Test also multiple directories can be specified. Without the build-id |
| 822 # reference GDB would find the separate debug info just at the same | 805 # reference GDB would find the separate debug info just at the same |
| 823 # location as the executable file. | 806 # location as the executable file. |
| 824 | 807 |
| 825 test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail | 808 test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail |
| 826 | 809 |
| 827 # Spare debug files may confuse testsuite runs in the future. | 810 # Spare debug files may confuse testsuite runs in the future. |
| 828 remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}" | 811 remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}" |
| 829 } | 812 } |
| OLD | NEW |