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