Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008 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 | ||
30 | set testfile "basics" | |
31 | set srcfile ${testfile}.c | |
32 | set binfile ${objdir}/${subdir}/${testfile} | |
33 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
34 | untested mi2-cli.exp |
35 | return -1 | |
2fcf52f0 AC |
36 | } |
37 | ||
2fcf52f0 AC |
38 | mi_gdb_test "-interpreter-exec" \ |
39 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
40 | "-interpreter-exec with no arguments" | |
41 | ||
42 | mi_gdb_test "-interpreter-exec console" \ | |
43 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
44 | "-interpreter-exec with one argument" | |
45 | ||
46 | mi_gdb_test "-interpreter-exec bogus command" \ | |
47 | {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \ | |
48 | "-interpreter-exec with bogus interpreter" | |
49 | ||
50 | set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.} | |
51 | mi_gdb_test "-interpreter-exec console bogus" \ | |
52 | "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \ | |
53 | "-interpreter-exec console bogus" | |
54 | ||
55 | # NOTE: cagney/2003-02-03: Not yet. | |
56 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
57 | # {(=.*)+\^done} \ | |
58 | # "-interpreter-exec console \"file \$binfile\"" | |
59 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
39fb8e9e | 60 | {~"Reading symbols from .*basics...".*\^done} \ |
2fcf52f0 AC |
61 | "-interpreter-exec console \"file \$binfile\"" |
62 | ||
63 | mi_run_to_main | |
64 | ||
45f07fef MC |
65 | set line_main_head [gdb_get_line_number "main ("] |
66 | set line_main_body [expr $line_main_head + 2] | |
67 | set line_main_hello [gdb_get_line_number "Hello, World!"] | |
68 | set line_main_return [expr $line_main_hello + 2] | |
69 | ||
2fcf52f0 AC |
70 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
71 | {\^done} \ | |
72 | "-interpreter-exec console \"set args foobar\"" | |
73 | ||
74 | mi_gdb_test "-interpreter-exec console \"show args\"" \ | |
75 | {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \ | |
76 | "-interpreter-exec console \"show args\"" | |
77 | ||
78 | # NOTE: cagney/2003-02-03: Not yet. | |
79 | # mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
80 | # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \ | |
81 | # "-interpreter-exec console \"break callee4\"" | |
82 | mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
83 | {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \ | |
84 | "-interpreter-exec console \"break callee4\"" | |
85 | ||
86 | mi_gdb_test "-interpreter-exec console \"info break\"" \ | |
87 | {\~"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} \ | |
88 | "-interpreter-exec console \"info break\"" | |
89 | ||
90 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
91 | {\^done} \ | |
92 | "-interpreter-exec console \"set listsize 1\"" | |
93 | ||
45f07fef | 94 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
2fcf52f0 | 95 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 96 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
2fcf52f0 AC |
97 | "-interpreter-exec console \"list\"" |
98 | ||
6ae37fef | 99 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \ |
18ac113b | 100 | { "" "disp=\"keep\"" } \ |
bb378428 | 101 | "continue to callee4" |
2fcf52f0 AC |
102 | |
103 | # NOTE: cagney/2003-02-03: Not yet. | |
104 | # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
105 | # {.*=breakpoint-delete,number=\"2\".*\^done} \ | |
106 | # "-interpreter-exec console \"delete 2\"" | |
107 | mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
108 | {100\^done} \ | |
109 | "-interpreter-exec console \"delete 2\"" | |
110 | ||
111 | # NOTE: cagney/2003-02-03: Not yet. | |
112 | # mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
113 | # {.*=selected-frame-level-changed,level="1".*\^done} \ | |
114 | # "-interpreter-exec console \"up\"" | |
115 | mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
39fb8e9e | 116 | {~"#.*".*200\^done} \ |
2fcf52f0 AC |
117 | "-interpreter-exec console \"up\"" |
118 | ||
119 | # NOTE: cagney/2003-02-03: Not yet. | |
120 | # mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
121 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
122 | # "-interpreter-exec console \"down\"" | |
123 | mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
39fb8e9e | 124 | {~"#.*".*300\^done} \ |
2fcf52f0 AC |
125 | "-interpreter-exec console \"down\"" |
126 | ||
127 | # NOTE: cagney/2003-02-03: Not yet. | |
128 | # mi_gdb_test "-interpreter-exec console \"frame 2\"" \ | |
129 | # {.*=selected-frame-level-changed,level="2".*\^done} \ | |
130 | # "-interpreter-exec console \"frame 2\"" | |
131 | mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ | |
39fb8e9e | 132 | {~"#.*".*400\^done} \ |
2fcf52f0 AC |
133 | "-interpreter-exec console \"frame 2\"" |
134 | ||
135 | # NOTE: cagney/2003-02-03: Not yet. | |
136 | # mi_gdb_test "-stack-select-frame 0" \ | |
137 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
138 | # "-stack-select-frame 0" | |
139 | mi_gdb_test "500-stack-select-frame 0" \ | |
140 | {500\^done} \ | |
141 | "-stack-select-frame 0" | |
142 | ||
143 | # NOTE: cagney/2003-02-03: Not yet. | |
45f07fef | 144 | # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \ |
2fcf52f0 | 145 | # {.*=breakpoint-create,number="3".*\^done} \ |
45f07fef MC |
146 | # "-break-insert -t basics.c:\$line_main_hello" |
147 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ | |
2fcf52f0 | 148 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
45f07fef | 149 | "-break-insert -t basics.c:\$line_main_hello" |
2fcf52f0 | 150 | |
18ac113b AR |
151 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \ |
152 | $line_main_hello { "" "disp=\"del\"" } \ | |
bb378428 | 153 | "-exec-continue to line $line_main_hello" |
2fcf52f0 | 154 | |
bb378428 VP |
155 | mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \ |
156 | "-exec-next to line $line_main_return" | |
2fcf52f0 AC |
157 | |
158 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
60c46647 | 159 | "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ |
45f07fef | 160 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" |
2fcf52f0 AC |
161 | |
162 | mi_gdb_test "-interpreter-exec console \"help set args\"" \ | |
163 | {\~"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} \ | |
164 | "-interpreter-exec console \"help set args\"" | |
165 | ||
166 | # NOTE: cagney/2003-02-03: Not yet. | |
167 | # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ | |
168 | # {.*=target-changed.*\^done} \ | |
169 | # "-interpreter-exec console \"set \$pc=0x0\"" | |
170 | mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ | |
171 | {888\^done} \ | |
172 | "-interpreter-exec console \"set \$pc=0x0\"" | |
173 | ||
174 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
175 | {} \ | |
176 | "-interpreter-exec console \"\"" | |
177 | ||
178 | mi_gdb_exit | |
179 | return 0 |