Commit | Line | Data |
---|---|---|
0fb0cc75 JB |
1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009 |
2 | # Free Software Foundation, Inc. | |
2fcf52f0 AC |
3 | |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
2fcf52f0 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
2fcf52f0 AC |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
2fcf52f0 | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2fcf52f0 | 16 | |
2fcf52f0 AC |
17 | # This file tests that GDB's console can be accessed via the MI. |
18 | # Specifically, we are testing the "interpreter-exec" command and that | |
19 | # the commands that are executed via this command are properly executed. | |
20 | # Console commands executed via MI should use MI output wrappers, MI event | |
21 | # handlers, etc. | |
22 | ||
23 | load_lib mi-support.exp | |
24 | set MIFLAGS "-i=mi2" | |
25 | ||
26 | gdb_exit | |
27 | if [mi_gdb_start] { | |
28 | continue | |
29 | } | |
30 | ||
31 | set testfile "basics" | |
32 | set srcfile ${testfile}.c | |
3788363d | 33 | set binfile ${objdir}/${subdir}/mi2-cli |
2fcf52f0 | 34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
35 | untested mi2-cli.exp |
36 | return -1 | |
2fcf52f0 AC |
37 | } |
38 | ||
2fcf52f0 AC |
39 | mi_gdb_test "-interpreter-exec" \ |
40 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
41 | "-interpreter-exec with no arguments" | |
42 | ||
43 | mi_gdb_test "-interpreter-exec console" \ | |
44 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
45 | "-interpreter-exec with one argument" | |
46 | ||
47 | mi_gdb_test "-interpreter-exec bogus command" \ | |
48 | {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \ | |
49 | "-interpreter-exec with bogus interpreter" | |
50 | ||
51 | set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.} | |
52 | mi_gdb_test "-interpreter-exec console bogus" \ | |
53 | "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \ | |
54 | "-interpreter-exec console bogus" | |
55 | ||
56 | # NOTE: cagney/2003-02-03: Not yet. | |
57 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
58 | # {(=.*)+\^done} \ | |
59 | # "-interpreter-exec console \"file \$binfile\"" | |
60 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
3788363d | 61 | {~"Reading symbols from .*mi2-cli...".*\^done} \ |
2fcf52f0 AC |
62 | "-interpreter-exec console \"file \$binfile\"" |
63 | ||
64 | mi_run_to_main | |
65 | ||
45f07fef MC |
66 | set line_main_head [gdb_get_line_number "main ("] |
67 | set line_main_body [expr $line_main_head + 2] | |
68 | set line_main_hello [gdb_get_line_number "Hello, World!"] | |
69 | set line_main_return [expr $line_main_hello + 2] | |
70 | ||
2fcf52f0 AC |
71 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
72 | {\^done} \ | |
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\"" \ | |
92 | {\^done} \ | |
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 | ||
6ae37fef | 100 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \ |
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\"" \ | |
109 | {100\^done} \ | |
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 |