1 # Copyright 2002-2005, 2007-2012 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
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
22 load_lib mi-support.exp
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/mi2-cli
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 mi_gdb_test "-interpreter-exec" \
39 {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
40 "-interpreter-exec with no arguments"
42 mi_gdb_test "-interpreter-exec console" \
43 {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
44 "-interpreter-exec with one argument"
46 mi_gdb_test "-interpreter-exec bogus command" \
47 {\^error,msg="-interpreter-exec: could not find interpreter \\\"bogus\\\""} \
48 "-interpreter-exec with bogus interpreter"
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"
55 # NOTE: cagney/2003-02-03: Not yet.
56 # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
58 # "-interpreter-exec console \"file \$binfile\""
59 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
60 {~"Reading symbols from .*mi2-cli...".*\^done} \
61 "-interpreter-exec console \"file \$binfile\""
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 set line_callee4_head [gdb_get_line_number "callee4 ("]
70 set line_callee4_body [expr $line_callee4_head + 2]
72 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
74 "-interpreter-exec console \"set args foobar\""
76 mi_gdb_test "-interpreter-exec console \"show args\"" \
77 {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
78 "-interpreter-exec console \"show args\""
80 # NOTE: cagney/2003-02-03: Not yet.
81 # mi_gdb_test "-interpreter-exec console \"break callee4\"" \
82 # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
83 # "-interpreter-exec console \"break callee4\""
84 mi_gdb_test "-interpreter-exec console \"break callee4\"" \
85 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
86 "-interpreter-exec console \"break callee4\""
88 mi_gdb_test "-interpreter-exec console \"info break\"" \
89 {\~"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} \
90 "-interpreter-exec console \"info break\""
92 mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
94 "-interpreter-exec console \"set listsize 1\""
96 # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
97 mi_gdb_test "-interpreter-exec console \"list\"" \
98 ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
99 "-interpreter-exec console \"list\""
101 mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \
102 { "" "disp=\"keep\"" } \
103 "continue to callee4"
105 # NOTE: cagney/2003-02-03: Not yet.
106 # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
107 # {.*=breakpoint-delete,number=\"2\".*\^done} \
108 # "-interpreter-exec console \"delete 2\""
109 mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
110 {=breakpoint-deleted,id=\"2\"\r\n100\^done} \
111 "-interpreter-exec console \"delete 2\""
113 # NOTE: cagney/2003-02-03: Not yet.
114 # mi_gdb_test "200-interpreter-exec console \"up\"" \
115 # {.*=selected-frame-level-changed,level="1".*\^done} \
116 # "-interpreter-exec console \"up\""
117 mi_gdb_test "200-interpreter-exec console \"up\"" \
118 {~"#.*".*200\^done} \
119 "-interpreter-exec console \"up\""
121 # NOTE: cagney/2003-02-03: Not yet.
122 # mi_gdb_test "300-interpreter-exec console \"down\"" \
123 # {.*=selected-frame-level-changed,level="0".*\^done} \
124 # "-interpreter-exec console \"down\""
125 mi_gdb_test "300-interpreter-exec console \"down\"" \
126 {~"#.*".*300\^done} \
127 "-interpreter-exec console \"down\""
129 # NOTE: cagney/2003-02-03: Not yet.
130 # mi_gdb_test "-interpreter-exec console \"frame 2\"" \
131 # {.*=selected-frame-level-changed,level="2".*\^done} \
132 # "-interpreter-exec console \"frame 2\""
133 mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
134 {~"#.*".*400\^done} \
135 "-interpreter-exec console \"frame 2\""
137 # NOTE: cagney/2003-02-03: Not yet.
138 # mi_gdb_test "-stack-select-frame 0" \
139 # {.*=selected-frame-level-changed,level="0".*\^done} \
140 # "-stack-select-frame 0"
141 mi_gdb_test "500-stack-select-frame 0" \
143 "-stack-select-frame 0"
145 # NOTE: cagney/2003-02-03: Not yet.
146 # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
147 # {.*=breakpoint-create,number="3".*\^done} \
148 # "-break-insert -t basics.c:\$line_main_hello"
149 mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
150 {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
151 "-break-insert -t basics.c:\$line_main_hello"
153 mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
154 $line_main_hello { "" "disp=\"del\"" } \
155 "-exec-continue to line $line_main_hello"
157 mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \
158 "-exec-next to line $line_main_return"
160 mi_gdb_test "-interpreter-exec console \"list\"" \
161 "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
162 "-interpreter-exec console \"list\" at basics.c:\$line_main_return"
164 mi_gdb_test "-interpreter-exec console \"help set args\"" \
165 {\~"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} \
166 "-interpreter-exec console \"help set args\""
168 # NOTE: cagney/2003-02-03: Not yet.
169 # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
170 # {.*=target-changed.*\^done} \
171 # "-interpreter-exec console \"set \$pc=0x0\""
172 mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
174 "-interpreter-exec console \"set \$pc=0x0\""
176 #mi_gdb_test "-interpreter-exec console \"\"" \
178 "-interpreter-exec console \"\""