Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 2002-2005, 2007-2012 Free Software Foundation, Inc. |
2fcf52f0 AC |
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 |
2fcf52f0 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
2fcf52f0 AC |
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 | # |
2fcf52f0 | 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/>. |
2fcf52f0 | 15 | |
2fcf52f0 AC |
16 | # This file tests that GDB's console can be accessed via the MI. |
17 | # Specifically, we are testing the "interpreter-exec" command and that | |
18 | # the commands that are executed via this command are properly executed. | |
19 | # Console commands executed via MI should use MI output wrappers, MI event | |
20 | # handlers, etc. | |
21 | ||
22 | load_lib mi-support.exp | |
23 | set MIFLAGS "-i=mi2" | |
24 | ||
25 | gdb_exit | |
26 | if [mi_gdb_start] { | |
27 | continue | |
28 | } | |
29 | ||
298a9cf0 TT |
30 | standard_testfile basics.c |
31 | ||
9357e021 | 32 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
b60f0898 JB |
33 | untested mi2-cli.exp |
34 | return -1 | |
2fcf52f0 AC |
35 | } |
36 | ||
2fcf52f0 | 37 | mi_gdb_test "-interpreter-exec" \ |
1b05df00 | 38 | {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \ |
2fcf52f0 AC |
39 | "-interpreter-exec with no arguments" |
40 | ||
41 | mi_gdb_test "-interpreter-exec console" \ | |
1b05df00 | 42 | {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \ |
2fcf52f0 AC |
43 | "-interpreter-exec with one argument" |
44 | ||
45 | mi_gdb_test "-interpreter-exec bogus command" \ | |
1b05df00 | 46 | {\^error,msg="-interpreter-exec: could not find interpreter \\\"bogus\\\""} \ |
2fcf52f0 AC |
47 | "-interpreter-exec with bogus interpreter" |
48 | ||
49 | set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.} | |
50 | mi_gdb_test "-interpreter-exec console bogus" \ | |
51 | "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \ | |
52 | "-interpreter-exec console bogus" | |
53 | ||
54 | # NOTE: cagney/2003-02-03: Not yet. | |
55 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
56 | # {(=.*)+\^done} \ | |
57 | # "-interpreter-exec console \"file \$binfile\"" | |
58 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
3788363d | 59 | {~"Reading symbols from .*mi2-cli...".*\^done} \ |
2fcf52f0 AC |
60 | "-interpreter-exec console \"file \$binfile\"" |
61 | ||
62 | mi_run_to_main | |
63 | ||
dd322c54 JK |
64 | set line_main_head [gdb_get_line_number "main ("] |
65 | set line_main_body [expr $line_main_head + 2] | |
66 | set line_main_hello [gdb_get_line_number "Hello, World!"] | |
67 | set line_main_return [expr $line_main_hello + 2] | |
68 | set line_callee4_head [gdb_get_line_number "callee4 ("] | |
69 | set line_callee4_body [expr $line_callee4_head + 2] | |
45f07fef | 70 | |
2fcf52f0 | 71 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
5b9afe8a | 72 | ".*=cmd-param-changed,param=\"args\",value=\"foobar\".*\\^done" \ |
2fcf52f0 AC |
73 | "-interpreter-exec console \"set args foobar\"" |
74 | ||
75 | mi_gdb_test "-interpreter-exec console \"show args\"" \ | |
76 | {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \ | |
77 | "-interpreter-exec console \"show args\"" | |
78 | ||
79 | # NOTE: cagney/2003-02-03: Not yet. | |
80 | # mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
81 | # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \ | |
82 | # "-interpreter-exec console \"break callee4\"" | |
83 | mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
84 | {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \ | |
85 | "-interpreter-exec console \"break callee4\"" | |
86 | ||
87 | mi_gdb_test "-interpreter-exec console \"info break\"" \ | |
88 | {\~"Num[ \t]*Type[ \t]*Disp[ \t]*Enb[ \t]*Address[ \t]*What\\n".*~"2[ \t]*breakpoint[ \t]*keep[ \t]*y[ \t]*0x[0-9A-Fa-f]+[ \t]*in callee4 at .*basics.c:[0-9]+\\n".*\^done} \ | |
89 | "-interpreter-exec console \"info break\"" | |
90 | ||
91 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
5b9afe8a | 92 | ".*=cmd-param-changed,param=\"listsize\",value=\"1\".*\\^done" \ |
2fcf52f0 AC |
93 | "-interpreter-exec console \"set listsize 1\"" |
94 | ||
45f07fef | 95 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
2fcf52f0 | 96 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 97 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
2fcf52f0 AC |
98 | "-interpreter-exec console \"list\"" |
99 | ||
dd322c54 | 100 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ |
18ac113b | 101 | { "" "disp=\"keep\"" } \ |
bb378428 | 102 | "continue to callee4" |
2fcf52f0 AC |
103 | |
104 | # NOTE: cagney/2003-02-03: Not yet. | |
105 | # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
106 | # {.*=breakpoint-delete,number=\"2\".*\^done} \ | |
107 | # "-interpreter-exec console \"delete 2\"" | |
108 | mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
8d3788bd | 109 | {=breakpoint-deleted,id=\"2\"\r\n100\^done} \ |
2fcf52f0 AC |
110 | "-interpreter-exec console \"delete 2\"" |
111 | ||
112 | # NOTE: cagney/2003-02-03: Not yet. | |
113 | # mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
114 | # {.*=selected-frame-level-changed,level="1".*\^done} \ | |
115 | # "-interpreter-exec console \"up\"" | |
116 | mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
39fb8e9e | 117 | {~"#.*".*200\^done} \ |
2fcf52f0 AC |
118 | "-interpreter-exec console \"up\"" |
119 | ||
120 | # NOTE: cagney/2003-02-03: Not yet. | |
121 | # mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
122 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
123 | # "-interpreter-exec console \"down\"" | |
124 | mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
39fb8e9e | 125 | {~"#.*".*300\^done} \ |
2fcf52f0 AC |
126 | "-interpreter-exec console \"down\"" |
127 | ||
128 | # NOTE: cagney/2003-02-03: Not yet. | |
129 | # mi_gdb_test "-interpreter-exec console \"frame 2\"" \ | |
130 | # {.*=selected-frame-level-changed,level="2".*\^done} \ | |
131 | # "-interpreter-exec console \"frame 2\"" | |
132 | mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ | |
39fb8e9e | 133 | {~"#.*".*400\^done} \ |
2fcf52f0 AC |
134 | "-interpreter-exec console \"frame 2\"" |
135 | ||
136 | # NOTE: cagney/2003-02-03: Not yet. | |
137 | # mi_gdb_test "-stack-select-frame 0" \ | |
138 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
139 | # "-stack-select-frame 0" | |
140 | mi_gdb_test "500-stack-select-frame 0" \ | |
141 | {500\^done} \ | |
142 | "-stack-select-frame 0" | |
143 | ||
144 | # NOTE: cagney/2003-02-03: Not yet. | |
45f07fef | 145 | # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \ |
2fcf52f0 | 146 | # {.*=breakpoint-create,number="3".*\^done} \ |
45f07fef MC |
147 | # "-break-insert -t basics.c:\$line_main_hello" |
148 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ | |
2fcf52f0 | 149 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
45f07fef | 150 | "-break-insert -t basics.c:\$line_main_hello" |
2fcf52f0 | 151 | |
18ac113b AR |
152 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \ |
153 | $line_main_hello { "" "disp=\"del\"" } \ | |
bb378428 | 154 | "-exec-continue to line $line_main_hello" |
2fcf52f0 | 155 | |
bb378428 VP |
156 | mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \ |
157 | "-exec-next to line $line_main_return" | |
2fcf52f0 AC |
158 | |
159 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
60c46647 | 160 | "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ |
45f07fef | 161 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" |
2fcf52f0 AC |
162 | |
163 | mi_gdb_test "-interpreter-exec console \"help set args\"" \ | |
164 | {\~"Set argument list to give program being debugged when it is started\.\\nFollow this command with any number of args, to be passed to the program\.".*\^done} \ | |
165 | "-interpreter-exec console \"help set args\"" | |
166 | ||
167 | # NOTE: cagney/2003-02-03: Not yet. | |
168 | # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ | |
169 | # {.*=target-changed.*\^done} \ | |
170 | # "-interpreter-exec console \"set \$pc=0x0\"" | |
171 | mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ | |
172 | {888\^done} \ | |
173 | "-interpreter-exec console \"set \$pc=0x0\"" | |
174 | ||
175 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
176 | {} \ | |
177 | "-interpreter-exec console \"\"" | |
178 | ||
179 | mi_gdb_exit | |
180 | return 0 |