Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2003-2015 Free Software Foundation, Inc. |
1b3bb3d0 JB |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
1b3bb3d0 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
1b3bb3d0 JB |
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. | |
e22f8b7c | 12 | # |
1b3bb3d0 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1b3bb3d0 JB |
15 | |
16 | ||
17 | # This is a regression test for the following bug, as of 2003-12-12: | |
18 | # | |
19 | # Set a breakpoint which will be hit many times. Attach a complex set | |
20 | # of commands to it, including a "continue" command. Run the program, | |
21 | # so that the breakpoint is hit, its commands get executed, and the | |
22 | # program continues and hits the breakpoint again. You will see | |
23 | # messages like "warning: Invalid control type in command structure.", | |
24 | # or maybe GDB will crash. | |
25 | # | |
26 | # When the breakpoint is hit, bpstat_stop_status copies the | |
27 | # breakpoint's command tree to the bpstat. bpstat_do_actions then | |
28 | # calls execute_control_command to run the commands. The 'continue' | |
29 | # command invokes the following chain of calls: | |
30 | # | |
31 | # continue_command | |
32 | # -> clear_proceed_status | |
33 | # -> bpstat_clear | |
34 | # -> free_command_lines | |
35 | # -> frees the commands we are currently running. | |
36 | # | |
37 | # When control does eventually return to execute_control_command, GDB | |
38 | # continues to walk the tree of freed command nodes, resulting in the | |
39 | # error messages and / or crashes. | |
40 | # | |
41 | # Since this bug depends on storage being reused between the time that | |
42 | # we continue and the time that we fall back to bpstat_do_actions, the | |
43 | # reproduction recipe is more delicate than I would like. I welcome | |
44 | # suggestions for improving this. | |
45 | ||
1b3bb3d0 | 46 | |
289f9037 TT |
47 | standard_testfile |
48 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { | |
49 | untested $testfile.exp | |
50 | return -1 | |
1b3bb3d0 JB |
51 | } |
52 | ||
f6978de9 MS |
53 | gdb_test "break ${srcfile}:[gdb_get_line_number "euphonium"]" ".*" \ |
54 | "set breakpoint" | |
1b3bb3d0 JB |
55 | |
56 | # The goal of all this is to make sure that there's plenty of memory | |
57 | # churn, and different amounts of it each time the inferior stops; | |
58 | # this seems to make GDB crash more reliably. | |
91cc9324 JK |
59 | set lines {{if i<0 || i > 100} |
60 | {echo Invalid i value\n} | |
61 | {else} | |
62 | {if (i%2) == 0} | |
1b3bb3d0 JB |
63 | {echo "even "} |
64 | {print i} | |
65 | {else} | |
66 | {echo "odd "} | |
67 | {print i} | |
68 | {end} | |
69 | {set variable $foo = 0} | |
70 | {set variable $j = 0} | |
71 | {while $j < i} | |
72 | {set variable $foo += $j} | |
73 | {set variable $j++} | |
74 | {end} | |
75 | {print $foo} | |
76 | {if i != 40} | |
77 | {c} | |
78 | {end} | |
91cc9324 | 79 | {end} |
1b3bb3d0 JB |
80 | {end}} |
81 | ||
82 | send_gdb "commands\n" | |
83 | for {set i 0} {$i < [llength $lines]} {incr i} { | |
84 | gdb_expect { | |
85 | -re ".*>" { | |
86 | send_gdb "[lindex $lines $i]\n" | |
87 | } | |
88 | -re "$gdb_prompt $" { | |
89 | set reason "got top-level prompt early" | |
90 | break | |
91 | } | |
92 | timeout { | |
93 | set reason "timeout" | |
94 | break | |
95 | } | |
96 | } | |
97 | } | |
98 | if {$i >= [llength $lines]} { | |
99 | pass "send breakpoint commands" | |
100 | } else { | |
101 | fail "send breakpoint commands ($reason)" | |
102 | } | |
103 | ||
104 | gdb_run_cmd | |
c65016bd | 105 | |
97f2ed50 | 106 | set prev_timeout $timeout |
c65016bd MK |
107 | set timeout 120 |
108 | ||
1b3bb3d0 JB |
109 | gdb_test_multiple "" "run program with breakpoint commands" { |
110 | -re "warning: Invalid control type in command structure" { | |
80e4b428 | 111 | kfail "gdb/1489" "run program with breakpoint commands" |
1b3bb3d0 | 112 | } |
91cc9324 JK |
113 | -re "Invalid i value\r\n$gdb_prompt $" { |
114 | xfail "run program with breakpoint commands (i value not readable)" | |
115 | } | |
1b3bb3d0 JB |
116 | -re "$gdb_prompt $" { |
117 | pass "run program with breakpoint commands" | |
118 | } | |
119 | eof { | |
80e4b428 | 120 | kfail "gdb/1489" "run program with breakpoint commands (GDB died)" |
1b3bb3d0 JB |
121 | } |
122 | } | |
97f2ed50 DJ |
123 | |
124 | set timeout $prev_timeout |