1 |
330 |
jeremybenn |
# Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
|
2 |
|
|
# Free Software Foundation, Inc.
|
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
|
6 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
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.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program. If not, see .
|
16 |
|
|
|
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
|
33 |
|
|
set binfile ${objdir}/${subdir}/mi2-cli
|
34 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
|
35 |
|
|
untested mi2-cli.exp
|
36 |
|
|
return -1
|
37 |
|
|
}
|
38 |
|
|
|
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\"" \
|
61 |
|
|
{~"Reading symbols from .*mi2-cli...".*\^done} \
|
62 |
|
|
"-interpreter-exec console \"file \$binfile\""
|
63 |
|
|
|
64 |
|
|
mi_run_to_main
|
65 |
|
|
|
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 |
|
|
set line_callee4_head [gdb_get_line_number "callee4 ("]
|
71 |
|
|
set line_callee4_body [expr $line_callee4_head + 2]
|
72 |
|
|
|
73 |
|
|
mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
|
74 |
|
|
{\^done} \
|
75 |
|
|
"-interpreter-exec console \"set args foobar\""
|
76 |
|
|
|
77 |
|
|
mi_gdb_test "-interpreter-exec console \"show args\"" \
|
78 |
|
|
{\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
|
79 |
|
|
"-interpreter-exec console \"show args\""
|
80 |
|
|
|
81 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
82 |
|
|
# mi_gdb_test "-interpreter-exec console \"break callee4\"" \
|
83 |
|
|
# {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
|
84 |
|
|
# "-interpreter-exec console \"break callee4\""
|
85 |
|
|
mi_gdb_test "-interpreter-exec console \"break callee4\"" \
|
86 |
|
|
{(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
|
87 |
|
|
"-interpreter-exec console \"break callee4\""
|
88 |
|
|
|
89 |
|
|
mi_gdb_test "-interpreter-exec console \"info break\"" \
|
90 |
|
|
{\~"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} \
|
91 |
|
|
"-interpreter-exec console \"info break\""
|
92 |
|
|
|
93 |
|
|
mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
|
94 |
|
|
{\^done} \
|
95 |
|
|
"-interpreter-exec console \"set listsize 1\""
|
96 |
|
|
|
97 |
|
|
# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
|
98 |
|
|
mi_gdb_test "-interpreter-exec console \"list\"" \
|
99 |
|
|
".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
|
100 |
|
|
"-interpreter-exec console \"list\""
|
101 |
|
|
|
102 |
|
|
mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \
|
103 |
|
|
{ "" "disp=\"keep\"" } \
|
104 |
|
|
"continue to callee4"
|
105 |
|
|
|
106 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
107 |
|
|
# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
|
108 |
|
|
# {.*=breakpoint-delete,number=\"2\".*\^done} \
|
109 |
|
|
# "-interpreter-exec console \"delete 2\""
|
110 |
|
|
mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
|
111 |
|
|
{100\^done} \
|
112 |
|
|
"-interpreter-exec console \"delete 2\""
|
113 |
|
|
|
114 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
115 |
|
|
# mi_gdb_test "200-interpreter-exec console \"up\"" \
|
116 |
|
|
# {.*=selected-frame-level-changed,level="1".*\^done} \
|
117 |
|
|
# "-interpreter-exec console \"up\""
|
118 |
|
|
mi_gdb_test "200-interpreter-exec console \"up\"" \
|
119 |
|
|
{~"#.*".*200\^done} \
|
120 |
|
|
"-interpreter-exec console \"up\""
|
121 |
|
|
|
122 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
123 |
|
|
# mi_gdb_test "300-interpreter-exec console \"down\"" \
|
124 |
|
|
# {.*=selected-frame-level-changed,level="0".*\^done} \
|
125 |
|
|
# "-interpreter-exec console \"down\""
|
126 |
|
|
mi_gdb_test "300-interpreter-exec console \"down\"" \
|
127 |
|
|
{~"#.*".*300\^done} \
|
128 |
|
|
"-interpreter-exec console \"down\""
|
129 |
|
|
|
130 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
131 |
|
|
# mi_gdb_test "-interpreter-exec console \"frame 2\"" \
|
132 |
|
|
# {.*=selected-frame-level-changed,level="2".*\^done} \
|
133 |
|
|
# "-interpreter-exec console \"frame 2\""
|
134 |
|
|
mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
|
135 |
|
|
{~"#.*".*400\^done} \
|
136 |
|
|
"-interpreter-exec console \"frame 2\""
|
137 |
|
|
|
138 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
139 |
|
|
# mi_gdb_test "-stack-select-frame 0" \
|
140 |
|
|
# {.*=selected-frame-level-changed,level="0".*\^done} \
|
141 |
|
|
# "-stack-select-frame 0"
|
142 |
|
|
mi_gdb_test "500-stack-select-frame 0" \
|
143 |
|
|
{500\^done} \
|
144 |
|
|
"-stack-select-frame 0"
|
145 |
|
|
|
146 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
147 |
|
|
# mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
|
148 |
|
|
# {.*=breakpoint-create,number="3".*\^done} \
|
149 |
|
|
# "-break-insert -t basics.c:\$line_main_hello"
|
150 |
|
|
mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
|
151 |
|
|
{600\^done,bkpt=.number="3",type="breakpoint".*\}} \
|
152 |
|
|
"-break-insert -t basics.c:\$line_main_hello"
|
153 |
|
|
|
154 |
|
|
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
|
155 |
|
|
$line_main_hello { "" "disp=\"del\"" } \
|
156 |
|
|
"-exec-continue to line $line_main_hello"
|
157 |
|
|
|
158 |
|
|
mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \
|
159 |
|
|
"-exec-next to line $line_main_return"
|
160 |
|
|
|
161 |
|
|
mi_gdb_test "-interpreter-exec console \"list\"" \
|
162 |
|
|
"\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
|
163 |
|
|
"-interpreter-exec console \"list\" at basics.c:\$line_main_return"
|
164 |
|
|
|
165 |
|
|
mi_gdb_test "-interpreter-exec console \"help set args\"" \
|
166 |
|
|
{\~"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} \
|
167 |
|
|
"-interpreter-exec console \"help set args\""
|
168 |
|
|
|
169 |
|
|
# NOTE: cagney/2003-02-03: Not yet.
|
170 |
|
|
# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
|
171 |
|
|
# {.*=target-changed.*\^done} \
|
172 |
|
|
# "-interpreter-exec console \"set \$pc=0x0\""
|
173 |
|
|
mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
|
174 |
|
|
{888\^done} \
|
175 |
|
|
"-interpreter-exec console \"set \$pc=0x0\""
|
176 |
|
|
|
177 |
|
|
#mi_gdb_test "-interpreter-exec console \"\"" \
|
178 |
|
|
{} \
|
179 |
|
|
"-interpreter-exec console \"\""
|
180 |
|
|
|
181 |
|
|
mi_gdb_exit
|
182 |
|
|
return 0
|