aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi/mi-cli.exp
blob: b9d906de0415094e8e22194c2f68761f79de8347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Copyright 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# This file tests that GDB's console can be accessed via the MI.
# Specifically, we are testing the "interpreter-exec" command and that
# the commands that are executed via this command are properly executed.
# Console commands executed via MI should use MI output wrappers, MI event
# handlers, etc.

load_lib mi-support.exp
set MIFLAGS "-i=mi"

gdb_exit
if [mi_gdb_start] {
    continue
}

set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
     untested mi-cli.exp
     return -1
}

mi_gdb_test "-interpreter-exec" \
  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
  "-interpreter-exec with no arguments"

mi_gdb_test "-interpreter-exec console" \
  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
  "-interpreter-exec with one argument"

mi_gdb_test "-interpreter-exec bogus command" \
  {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
  "-interpreter-exec with bogus interpreter"

set msg {Undefined command: \\\"bogus\\\"\.  Try \\\"help\\\"\.}
mi_gdb_test "-interpreter-exec console bogus" \
    "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
  "-interpreter-exec console bogus"

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
#   {(=.*)+\^done} \
#   "-interpreter-exec console \"file \$binfile\""
mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
  {~"Reading symbols from .*basics...".*done} \
  "-interpreter-exec console \"file \$binfile\""

mi_run_to_main

set line_main_head   [gdb_get_line_number "main ("]
set line_main_body   [expr $line_main_head + 2]
set line_main_hello  [gdb_get_line_number "Hello, World!"]
set line_main_return [expr $line_main_hello + 2]

mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
  {\^done} \
  "-interpreter-exec console \"set args foobar\""

mi_gdb_test "-interpreter-exec console \"show args\"" \
  {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
  "-interpreter-exec console \"show args\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"break callee4\"" \
#   {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
#   "-interpreter-exec console \"break callee4\""
mi_gdb_test "-interpreter-exec console \"break callee4\"" \
  {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
  "-interpreter-exec console \"break callee4\""

mi_gdb_test "-interpreter-exec console \"info break\"" \
  {\~"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} \
  "-interpreter-exec console \"info break\""

mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
  {\^done} \
  "-interpreter-exec console \"set listsize 1\""

# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
mi_gdb_test "-interpreter-exec console \"list\"" \
  ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
  "-interpreter-exec console \"list\""

# # NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-exec-continue" \
#    {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="8"\}} \
#    "-interpreter-exec console \"continue to callee4\""
send_gdb "999-exec-continue\n"
gdb_expect {
    -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
	pass "continue to callee4"
    }
    timeout {
	fail "continue to callee4 (timeout)"
    }
}

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
#   {.*=breakpoint-delete,number=\"2\".*\^done} \
#   "-interpreter-exec console \"delete 2\""
mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
  {100\^done} \
  "-interpreter-exec console \"delete 2\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "200-interpreter-exec console \"up\"" \
#   {.*=selected-frame-level-changed,level="1".*\^done} \
#   "-interpreter-exec console \"up\""
mi_gdb_test "200-interpreter-exec console \"up\"" \
  {~"#.*".*200\^done} \
  "-interpreter-exec console \"up\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "300-interpreter-exec console \"down\"" \
#   {.*=selected-frame-level-changed,level="0".*\^done} \
#   "-interpreter-exec console \"down\""
mi_gdb_test "300-interpreter-exec console \"down\"" \
  {~"#.*".*300\^done} \
  "-interpreter-exec console \"down\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"frame 2\"" \
#   {.*=selected-frame-level-changed,level="2".*\^done} \
#   "-interpreter-exec console \"frame 2\""
mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
  {~"#.*".*400\^done} \
  "-interpreter-exec console \"frame 2\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-stack-select-frame 0" \
#   {.*=selected-frame-level-changed,level="0".*\^done} \
#   "-stack-select-frame 0"
mi_gdb_test "500-stack-select-frame 0" \
  {500\^done} \
  "-stack-select-frame 0"

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
#   {.*=breakpoint-create,number="3".*\^done} \
#   "-break-insert -t basics.c:\$line_main_hello"
mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
	{600\^done,bkpt=.number="3",type="breakpoint".*\}} \
	"-break-insert -t basics.c:\$line_main_hello"

# mi_gdb_test "-exec-continue" \
#   {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \
#   "-exec-continue to line \$line_main_hello"
send_gdb "700-exec-continue\n"
gdb_expect {
    -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" {
	pass "-exec-continue to line \$line_main_hello"
    }
    timeout {
	fail "-exec-continue to line \$line_main_hello"
    }
}

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-exec-next" \
#   {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \
#   "-exec-next to line \$line_main_return"
send_gdb "800-exec-next\n"
gdb_expect {
    -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" {
	pass "-exec-next to line \$line_main_return"
    }
    timeout {
	fail "-exec-next to line \$line_main_return"
    }
}

mi_gdb_test "-interpreter-exec console \"list\"" \
  "\~\"$line_main_return\[\\\\t ]*return 0;\\\\n\".*\\^done" \
  "-interpreter-exec console \"list\" at basics.c:\$line_main_return"

mi_gdb_test "-interpreter-exec console \"help set args\"" \
  {\~"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} \
  "-interpreter-exec console \"help set args\""

# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
#   {.*=target-changed.*\^done} \
#   "-interpreter-exec console \"set \$pc=0x0\""
mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
  {888\^done} \
  "-interpreter-exec console \"set \$pc=0x0\""

#mi_gdb_test "-interpreter-exec console \"\"" \
  {} \
  "-interpreter-exec console \"\""

mi_gdb_exit
return 0