1#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
2#   2000, 2001, 2002, 2003, 2005, 2006, 2007 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 <http://www.gnu.org/licenses/>.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# Start with a fresh gdb
21
22gdb_exit
23gdb_start
24
25set timeout 60
26
27#
28# test default actions of gdb commands
29#
30
31#load_lib gdb.exp
32
33gdb_test "add-symbol-file" "add-symbol-file takes a file name and an address" "add-symbol-file"
34
35# test append
36gdb_test "append" "\"append\" must be followed by a subcommand\.\[\r\n\]+List of append subcommands:.*"
37gdb_test "append binary" "\"append binary\" must be followed by a subcommand\.\[\r\n\]+List of append binary subcommands:.*"
38gdb_test "append memory" "Missing filename\."
39gdb_test "append value"  "Missing filename\."
40gdb_test "append binary memory" "Missing filename\."
41gdb_test "append binary value"  "Missing filename\."
42
43setup_xfail "mips-idt-*"
44send_gdb "attach\n"
45gdb_expect {
46    -re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\
47			{ pass "attach" }
48    -re "You can't do that when your target is `None'.*$gdb_prompt $"\
49			{ pass "attach" }
50    -re "You can't do that without a process to debug.*$gdb_prompt $"\
51			{ pass "attach" }
52    -re "Don't know how to attach.  Try \"help target\"..*$gdb_prompt $"\
53			{ pass "attach" }
54    -re "Kill it. .y or n." {
55	send_gdb "y\n"
56	exp_continue
57    }
58    -re "$gdb_prompt $" { fail "attach" }
59    timeout { fail "(timeout) attach" }
60}
61
62if ![target_info exists use_gdb_stub] {
63    gdb_test "break" "No default breakpoint address now." "break"
64    foreach i "b br bre brea" {
65	gdb_test $i "No default breakpoint address now." "break \"$i\" abbreviation"
66    }
67
68
69    setup_xfail "mips-idt-*"
70    gdb_test "backtrace" "No stack."
71
72    # ba and bac are no longer unique command prefixes. So these tests
73    # elict an error from GDB.
74    # GDB needs to be fixed to map unique alias here for ba bac.
75    #
76    foreach i "bt ba bac" {
77	setup_xfail "mips-idt-*"
78	gdb_test $i "No stack." "backtrace \"$i\" abbreviation"
79    }
80} else {
81    warning "Skipping backtrace and break tests because of GDB stub."
82}
83
84# This works on the MIPS IDT board, but confuses future tests.
85if ![istarget "mips-idt-*"] then {
86    gdb_test "continue" "The program is not being run." "continue"
87    gdb_test "c" "The program is not being run." "continue \"c\" abbreviation"
88}
89
90#test call
91gdb_test "call" "The history is empty..*" "call"
92
93
94#test catch
95gdb_test "catch" "Catch requires an event name..*" "catch"
96
97#test cd
98gdb_test "cd" "Argument required .new working directory.*" "cd"
99
100#test clear
101gdb_test "clear" "No source file specified..*" "clear"
102
103#test commands
104gdb_test "commands" "No breakpoint number 0..*" "commands"
105
106#test condition
107gdb_test "condition" "Argument required .breakpoint number.*" "condition"
108
109#test core-file
110gdb_test "core-file" "No core file now.|GDB can't read core files on this machine." "core-file"
111#test delete "d" abbreviation
112gdb_test "d" "" "delete \"d\" abbreviation"
113#test delete
114gdb_test "delete" "" "delete"
115#test define
116gdb_test "define" "Argument required \[(\]name of command to define\[)\]." "define"
117#test delete breakpoints
118gdb_test "delete breakpoints" "" "delete breakpoints"
119#test delete display
120# FIXME -- need to dump full output to detailed log
121send_gdb "delete display\n"
122gdb_expect {
123    -re "Delete all auto-display expressions.*y or n. $" {
124	send_gdb "y\n"
125	gdb_expect {
126	    -re "$gdb_prompt $"     { pass "delete display prompt" }
127	    timeout		{ fail "(timeout) delete display prompt" }
128	}
129    }
130    timeout		{ fail "(timeout) delete display prompt" }
131
132}
133
134#test detach
135gdb_test "detach" "" "detach"
136
137if [istarget "h8300-*-hms"] then {
138    gdb_exit
139    gdb_start
140}
141
142#test directory
143# FIXME -- need to dump full output to detailed log
144
145send_gdb "directory\n"
146gdb_expect {
147    -re "Reinitialize source path to empty.*y or n. $"  {
148	send_gdb "y\n"
149	gdb_expect {
150	    -re "Source directories searched: .cdir\[:;\].cwd.*$gdb_prompt $"\
151		    { pass "directory prompt" }
152	    timeout		{ fail "(timeout) directory prompt" }
153	}
154    }
155}
156
157#test disable "dis" abbreviation
158gdb_test "dis" "" "disable \"dis\" abbreviation"
159#test disable "disa" abbreviation
160gdb_test "disa" "" "disable \"disa\" abbreviation"
161#test disable
162gdb_test "disable" "" "disable"
163#test disable breakpoints
164gdb_test "disable breakpoints" "" "disable breakpoints"
165#test disable display
166gdb_test "disable display" "" "disable display"
167#test disassemble
168gdb_test "disassemble" "No frame selected." "disassemble"
169#test display
170gdb_test "display" "" "display"
171#test do
172gdb_test "do" "No stack." "do"
173#test document
174gdb_test "document" "Argument required .name of command to define.*" "document"
175#test down
176gdb_test "down" "No stack.*" "down"
177#test down-silently
178gdb_test "down-silently" "No stack." "down-silently"
179# test dump
180gdb_test "dump" "\"dump\" must be followed by a subcommand\.\[\r\n\]+List of dump subcommands:.*"
181gdb_test "dump binary" "\"dump binary\" must be followed by a subcommand\.\[\r\n\]+List of dump binary subcommands:.*"
182gdb_test "dump ihex" "\"dump ihex\" must be followed by a subcommand\.\[\r\n\]+List of dump ihex subcommands:.*"
183gdb_test "dump memory" "Missing filename\."
184gdb_test "dump srec" "\"dump srec\" must be followed by a subcommand\.\[\r\n\]+List of dump srec subcommands:.*"
185gdb_test "dump tekhex" "\"dump tekhex\" must be followed by a subcommand\.\[\r\n\]+List of dump tekhex subcommands:.*"
186gdb_test "dump value" "Missing filename\."
187gdb_test "dump binary memory" "Missing filename\."
188gdb_test "dump binary value"  "Missing filename\."
189gdb_test "dump ihex memory" "Missing filename\."
190gdb_test "dump ihex value"  "Missing filename\."
191gdb_test "dump srec memory" "Missing filename\."
192gdb_test "dump srec value"  "Missing filename\."
193gdb_test "dump tekhex memory" "Missing filename\."
194gdb_test "dump tekhex value"  "Missing filename\."
195#test echo
196gdb_test "echo" "" "echo"
197#test enable breakpoints delete
198gdb_test "enable breakpoints delete" "Argument required .one or more breakpoint numbers.*" "enable breakpoints delete"
199#test enable breakpoints once
200gdb_test "enable breakpoints once" "Argument required .one or more breakpoint numbers.*" "enable breakpoints once"
201#test enable breakpoints
202gdb_test "enable breakpoints" "" "enable breakpoints"
203#test enable delete
204gdb_test "enable delete" "Argument required .one or more breakpoint numbers.*" "enable delete"
205#test enable display
206gdb_test "enable display" "" "enable display"
207#test enable once
208gdb_test "enable once" "Argument required .one or more breakpoint numbers.*" "enable once"
209#test enable
210gdb_test "enable" "" "enable"
211#test exec-file
212send_gdb "exec-file\n"
213gdb_expect {
214    -re "No executable file now..*$gdb_prompt $" {
215	pass "exec-file"
216    }
217    -re "exec-file.*A program is being debugged already.  Kill it. .y or n.*$" {
218	send_gdb "n\n"
219	if $verbose>1 then {
220	    send_user "\tDidn't kill program being debugged\n"
221	}
222	gdb_expect -re "$gdb_prompt $" { }
223	pass "exec-file"
224    }
225    -re "$gdb_prompt $"	{ fail "exec-file" }
226    timeout		{ fail "(timeout) exec-file" }
227}
228
229#test frame "f" abbreviation
230gdb_test "f" "No stack." "frame \"f\" abbreviation"
231#test frame
232gdb_test "frame" "No stack." "frame"
233#test fg
234gdb_test "fg" "The program is not being run." "fg"
235# FIXME: fg kills the udi connection
236#test file
237send_gdb "file\n"
238gdb_expect {
239    -re "No executable file now..*$gdb_prompt $"\
240	    { pass "file" }
241    -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
242	send_gdb "n\n"
243	if $verbose>1 then {
244	    send_user "\t\tDidn't kill program being debugged\n"
245	}
246	gdb_expect -re "$gdb_prompt $" { }
247	pass "file"
248    }
249    -re ".*$gdb_prompt $"	{ fail "file" }
250    timeout		{ fail "(timeout) file" }
251}
252
253#test finish
254gdb_test "finish" "The program is not running." "finish"
255#test forward-search
256# The message here comes from the regexp library, not gdb, and so can
257# vary on different systems.
258gdb_test "forward-search" "No previous regular expression.*|There is no previous regular expression.*" "forward-search"
259#test gcore
260send_gdb "gcore\n"
261gdb_expect {
262    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
263	pass "gcore"
264    }
265    -re "Undefined command: .*$gdb_prompt $" {
266	pass "gcore"
267    }
268    default { fail "gcore" }
269}
270send_gdb "generate-core-file\n"
271gdb_expect {
272    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
273	pass "generate-core-file"
274    }
275    -re "Undefined command: .*$gdb_prompt $" {
276	pass "generate-core-file"
277    }
278    default { fail "generate-core-file" }
279}
280#test help "h" abbreviation
281gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- Aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help \"h\" abbreviation"
282#test help
283gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- Aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help"
284#test handle
285gdb_test "handle" "Argument required .signal to handle.*" "handle"
286#test info "i" abbreviation
287gdb_test "i" "\"info\" must be followed by the name of an info command.(\[^\r\n\]*\[\r\n\])+List of info subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help info\" followed by info subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "info \"i\" abbreviation"
288#test info
289gdb_test "info" "\"info\" must be followed by the name of an info command.(\[^\r\n\]*\[\r\n\])+List of info subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help info\" followed by info subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "info"
290#test ignore
291gdb_test "ignore" "Argument required .a breakpoint number.*" "ignore"
292#test info address
293gdb_test "info address" "Argument required." "info address"
294#test info all-registers
295gdb_test "info all-registers" "The program has no registers now." "info all-registers"
296#test info args
297gdb_test "info args" "No frame selected." "info args"
298#test info bogus-gdb-command
299gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\".  Try \"help info\".*" "info bogus-gdb-command"
300#test info breakpoints
301gdb_test "info breakpoints" "No breakpoints or watchpoints." "info breakpoints"
302#test info catch
303gdb_test "info catch" "You can't do that without a process to debug." "info catch"
304#test info copying
305# FIXME -- doesn't work worth a shit
306#send_gdb "info copying"
307#	-re "GNU GENERAL PUBLIC LICENSE.*#of preserving the free status of all derivatives of our free software and.*#of promoting the sharing and reuse of software generally."#
308gdb_test "info copying"
309#	}
310#
311#
312#test info display
313gdb_test "info display" "There are no auto-display expressions now." "info display"
314#test info frame "f" abbreviation
315gdb_test "info f" "No stack.*|No selected frame.*" "info frame \"f\" abbreviation"
316#test info frame
317gdb_test "info frame" "No stack.|No selected frame." "info frame"
318#test info files
319gdb_test "info files" "" "info files"
320#test info float
321gdb_test "info float" "The program has no registers now." "info float"
322#test info functions
323gdb_test "info functions" "All defined functions:" "info functions"
324#test info locals
325gdb_test "info locals" "No frame selected." "info locals"
326#test info program
327gdb_test "info program" "The program being debugged is not being run." "info program"
328#test info registers
329gdb_test "info registers" "The program has no registers now." "info registers"
330#test info stack "s" abbreviation
331gdb_test "info s" "No stack." "info stack \"s\" abbreviation"
332#test info stack
333gdb_test "info stack" "No stack." "info stack"
334#test info set
335# FIXME -- needs to match the entire output
336# FIXME -- on native solaris 2.8, this test fails due to this line:
337#  prompt:  Gdb's prompt is "(gdb) ".^M
338gdb_test "info set" "confirm:  Whether to confirm potentially dangerous operations is o\[a-z\]*.(\[^\r\n\]*\[\r\n\])+history filename:  The filename in which to record the command history is (\[^\r\n\]*\[\r\n\])+listsize:  Number of source lines gdb will list by default is 10.*" "info set"
339gdb_test "info symbol" "Argument required .address.."
340#test info source
341gdb_test  "info source" "No current source file..*" "info source"
342#test info sources
343gdb_test "info sources" "No symbol table is loaded.  Use the \"file\" command.*" "info sources"
344#test info target
345gdb_test "info target" "" "info target"
346#test info terminal
347gdb_test "info terminal" "No saved terminal information." "info terminal"
348#test info types
349gdb_test "info types" "All defined types:" "info types"
350#test info variables
351gdb_test "info variables" "All defined variables:" "info variables"
352#test info vector
353gdb_test "info vector" "The program has no registers now." "info vector"
354#test info warranty
355gdb_test "info warranty" "15. *Disclaimer of Warranty.*" "info warranty"
356#test info watchpoints
357gdb_test "info watchpoints" "No breakpoints or watchpoints." "info watchpoints"
358#test inspect
359gdb_test "inspect" "The history is empty." "inspect"
360#test jump
361gdb_test "jump" "The program is not being run." "jump"
362#test kill
363gdb_test "kill" "The program is not being run." "kill"
364#test list "l" abbreviation
365gdb_test "l" "No symbol table is loaded.  Use the \"file\" command.*" "list \"l\" abbreviation"
366#test list
367gdb_test "list" "No symbol table is loaded.  Use the \"file\" command.*" "list"
368#test load
369# The ``takes a file name'' case is for vxgdb.
370# The ``Use the "file" command'' case is for newer GDB versions which try
371# to deduce the filename from the exec file.
372gdb_test "load" "You can't do that when your target is `None'.*|The load command takes a file name.*|Must specify at least a file name with the load command.*|.*Use the .file. or .exec-file. command.*" "load"
373#test next "n" abbreviation
374gdb_test "n" "The program is not being run." "next \"n\" abbreviation"
375#test next
376gdb_test "next" "The program is not being run." "next"
377#test nexti "ni" abbreviation
378gdb_test "ni" "The program is not being run." "nexti \"ni\" abbreviation"
379#test nexti
380gdb_test "nexti" "The program is not being run." "nexti"
381#test output
382gdb_test "output" "Argument required .expression to compute.*" "output"
383
384#test overlay
385gdb_test "overlay" "\"overlay\" must be followed by the name of .*"
386#test a non-existant overlay subcommand
387gdb_test "overlay on"     "Undefined overlay command.* Try \"help overlay\"."
388gdb_test "overlay manual" "" "overlay manual #1"
389gdb_test "overlay auto"   ""
390gdb_test "overlay off"    ""
391gdb_test "overlay list"   "No sections are mapped."
392gdb_test "overlay map"    "Overlay debugging not enabled.*" "overlay map #1"
393gdb_test "overlay unmap"  "Overlay debugging not enabled.*" "overlay unmap #1"
394gdb_test "overlay manual" "" "overlay manual #2"
395gdb_test "overlay map"    "Argument required: name of an overlay section." "overlay map #2"
396gdb_test "overlay unmap"  "Argument required: name of an overlay section." "overlay unmap #2"
397
398#test print "p" abbreviation
399gdb_test "p" "The history is empty." "print \"p\" abbreviation"
400#test print
401gdb_test "print" "The history is empty." "print"
402#test printf
403gdb_test "printf" "Argument required .format-control string and values to print.*" "printf"
404#test ptype
405gdb_test "ptype" "The history is empty." "ptype"
406#test pwd
407gdb_test "pwd" "Working directory .*" "pwd"
408
409#test run "r" abbreviation
410if [istarget "*-*-vxworks*"] then {
411    gdb_test "set args" "" ""
412
413    gdb_test "r" "Starting program: .*
414You must specify a function name to run, and arguments if any"\
415		"run \"r\" abbreviation"
416    gdb_test "set args main" "" ""
417
418} else {
419    send_gdb "r\n"
420    gdb_expect {
421	    -re "Starting program:  .*
422You can't do that when your target is `None'.*$gdb_prompt $"\
423			{ pass "run \"r\" abbreviation" }
424	    -re "Starting program:  .*
425No executable file specified.*
426Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
427			{ pass "run \"r\" abbreviation" }
428	    -re "Starting program:  .*
429No executable specified, use .target exec.\\..*$gdb_prompt $"\
430			{ pass "run \"r\" abbreviation" }
431	    -re "Starting program:  .*
432No image loaded into target.*$gdb_prompt $"\
433			{ pass "run \"r\" abbreviation" }
434	    -re "Starting program:  .*
435No program loaded.*$gdb_prompt $"\
436			{ pass "run \"r\" abbreviation" }
437	    -re "Don't know how to run.  Try \"help target\"..*$gdb_prompt $"\
438			{ pass "run \"r\" abbreviation" }
439	    -re ".*$gdb_prompt $"	{ fail "run \"r\" abbreviation" }
440	    timeout		{ fail "(timeout) run \"r\" abbreviation" }
441	}
442}
443
444#test run
445if [istarget "*-*-vxworks*"] then {
446    gdb_test "set args" "" ""
447
448    gdb_test "run" "Starting program: .*
449You must specify a function name to run, and arguments if any"
450    gdb_test "set args main" "" ""
451
452} else {
453    send_gdb "run\n"
454    gdb_expect {
455	    -re "Starting program:.*You can't do that when your target is `None'.*$gdb_prompt $" { pass "run" }
456	    -re "Starting program:  .*
457No executable file specified.*
458Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
459			{ pass "run" }
460	    -re "Starting program:  .*
461No executable specified, use .target exec.\\..*$gdb_prompt $"\
462			{ pass "run" }
463	    -re "Starting program:  .*
464No image loaded into target.*$gdb_prompt $"\
465			{ pass "run" }
466	    -re "Starting program:  .*
467No program loaded.*$gdb_prompt $"\
468			{ pass "run \"r\" abbreviation" }
469	    -re "Don't know how to run.  Try \"help target\"..*$gdb_prompt $"\
470			{ pass "run" }
471	    -re ".*$gdb_prompt $"	{ fail "run" }
472	    timeout		{ fail "(timeout) run" }
473	}
474}
475
476#test rbreak
477gdb_test "rbreak" "" "rbreak"
478
479# test restore
480gdb_test "restore" "You can't do that without a process to debug\."
481
482#test return
483# The middle case accomodated the obsolete a29k, where doing the "ni"
484# above causes an initial stack to be created.
485gdb_test "return" "No selected frame..*" "return"  "Make .* return now.*y or n. $" "y"
486
487
488#test reverse-search
489gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*" "reverse-search"
490#test step "s" abbreviation
491gdb_test "s" "The program is not being run." "step \"s\" abbreviation #1"
492#test step
493gdb_test "step" "The program is not being run." "step #1"
494#test search
495gdb_test "search" "No previous regular expression.*|There is no previous regular expression.*" "search"
496#test section
497gdb_test "section" "Must specify section name and its virtual address.*" "section"
498#test set annotate
499gdb_test "set annotate" "Argument required .integer to set it to.*" "set annotate"
500#test set args
501gdb_test "set args" "" "set args"
502#test set check "c" abbreviation
503gdb_test "set c" "\"set check\" must be followed by the name of a check subcommand.(\[^\r\n\]*\[\r\n\])+List of set check subcommands:(\[^\r\n\]*\[\r\n\])+set check range -- Set range checking(\[^\r\n\]*\[\r\n\])+set check type -- Set type checking(\[^\r\n\]*\[\r\n\])+Type \"help set check\" followed by set check subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set check \"c\" abbreviation"
504#test set check "ch" abbreviation
505gdb_test "set ch" "\"set check\" must be followed by the name of a check subcommand.(\[^\r\n\]*\[\r\n\])+List of set check subcommands:(\[^\r\n\]*\[\r\n\])+set check range -- Set range checking(\[^\r\n\]*\[\r\n\])+set check type -- Set type checking(\[^\r\n\]*\[\r\n\])+Type \"help set check\" followed by set check subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set check \"ch\" abbreviation"
506#test set check
507gdb_test "set check" "\"set check\" must be followed by the name of a check subcommand.(\[^\r\n\]*\[\r\n\])+List of set check subcommands:(\[^\r\n\]*\[\r\n\])+set check range -- Set range checking(\[^\r\n\]*\[\r\n\])+set check type -- Set type checking(\[^\r\n\]*\[\r\n\])+Type \"help set check\" followed by set check subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set check"
508#test set check range
509gdb_test "set check range" "" "set check range"
510#test set check type
511gdb_test "set check type" "" "set check type"
512#test set complaints
513gdb_test "set complaints" "Argument required .integer to set it to.*" "set complaints"
514#test set confirm
515gdb_test "set confirm" "" "set confirm"
516# Don't test set editing. What if we're talking to a gdb that
517# won't do editing correctly while we're talking to it?
518# gdb_test "set editing" "" "set editing"
519
520#test set environment
521gdb_test "set environment" "Argument required .environment variable and value.*" "set environment"
522#test set height
523gdb_test "set height" "Argument required .integer to set it to.*" "set height"
524#test set history expansion
525gdb_test "set history expansion" "" "set history expansion"
526#test set history filename
527gdb_test "set history filename" "Argument required .filename to set it to.*" "set history filename"
528#test set history save
529gdb_test "set history save" "" "set history save"
530#test set history size
531gdb_test "set history size" "Argument required .integer to set it to.*" "set history size"
532#test set history
533gdb_test "set history" "\"set history\" must be followed by the name of a history subcommand.(\[^\r\n\]*\[\r\n\])+List of set history subcommands:(\[^\r\n\]*\[\r\n\])+set history expansion -- Set history expansion on command input(\[^\r\n\]*\[\r\n\])+set history filename -- Set the filename in which to record the command history(\[^\r\n\]*\[\r\n\])+set history save -- Set saving of the history record on exit(\[^\r\n\]*\[\r\n\])+set history size -- Set the size of the command history(\[^\r\n\]*\[\r\n\])+Type \"help set history\" followed by set history subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set history"
534#test set language
535gdb_test "set language" "The currently understood settings are:(\[^\r\n\]*\[\r\n\])+local or auto  *Automatic setting based on source file(\[^\r\n\]*\[\r\n\])+c  *Use the C language(\[^\r\n\]*\[\r\n\])+c\[+\]+  *Use the C\[+\]+ language(\[^\r\n\]*\[\r\n\])+modula-2  *Use the Modula-2 language.*" "set language"
536#test set listsize
537gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
538#test set print "p" abbreviation
539gdb_test "set p" "\"set print\" must be followed by the name of a print subcommand.(\[^\r\n\]*\[\r\n\])+List of set print subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by set print subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set print \"p\" abbreviation"
540#test set print "pr" abbreviation
541gdb_test "set pr" "\"set print\" must be followed by the name of a print subcommand.(\[^\r\n\]*\[\r\n\])+List of set print subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by set print subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set print \"pr\" abbreviation"
542#test set print
543gdb_test "set print" "\"set print\" must be followed by the name of a print subcommand.(\[^\r\n\]*\[\r\n\])+List of set print subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help set print\" followed by set print subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set print"
544#test set print address
545gdb_test "set print address" "" "set print address"
546#test set print array
547gdb_test "set print array" "" "set print array"
548#test set print asm-demangle
549gdb_test "set print asm-demangle" "" "set print asm-demangle"
550#test set print demangle
551gdb_test "set print demangle" "" "set print demangle"
552#test set print elements
553gdb_test "set print elements" "Argument required .integer to set it to.*" "set print elements"
554#test set print object
555gdb_test "set print object" "" "set print object"
556#test set print pretty
557gdb_test "set print pretty" "" "set print pretty"
558#test set print sevenbit-strings
559gdb_test "set print sevenbit-strings" "" "set print sevenbit-strings"
560#test set print union
561gdb_test "set print union" "" "set print union"
562#test set print vtbl
563gdb_test "set print vtbl" "" "set print vtbl"
564# FIXME -- need a test for "set prompt"
565#test set radix
566gdb_test "set radix" "Input and output radices now set to decimal 10, hex a, octal 12.*" "set radix"
567#test set symbol-reloading
568gdb_test "set symbol-reloading" "" "set symbol-reloading"
569#test set variable
570gdb_test "set variable" "Argument required .expression to compute.*" "set variable"
571#test set verbose
572gdb_test "set verbose" "" "set verbose"
573#test set width
574gdb_test "set width" "Argument required .integer to set it to.*" "set width"
575#test set write
576# This is only supported on targets which use exec.o.
577gdb_test "set write" "" "set write"
578#test set
579gdb_test "set" "Argument required .expression to compute.*" "set"
580#test shell echo Hi dad!
581gdb_test "shell echo Hi dad!" "Hi dad!" "shell echo Hi dad!"
582#test show annotate
583gdb_test "show annotate" "Annotation_level is 0." 	 "show annotate"
584#test show args
585gdb_test "show args" "Argument list to give program being debugged when it is started is \"\"." "show args"
586#test show check "c" abbreviation
587gdb_test "show c" "range:  *Range checking is \"auto; currently off\".(\[^\r\n\]*\[\r\n\])+type:  *Type checking is \"auto; currently off\".*" "show check \"c\" abbreviation"
588#test show check "ch" abbreviation
589gdb_test "show ch" "range: *Range checking is \"auto; currently off\".(\[^\r\n\]*\[\r\n\])+type:  *Type checking is \"auto; currently off\"." "show check \"ch\" abbreviation"
590#test show check
591gdb_test "show check" "range:  *Range checking is \"auto; currently off\".(\[^\r\n\]*\[\r\n\])+type:  *Type checking is \"auto; currently off\"." "show check"
592#test show check range
593gdb_test "show check range" "Range checking is \"auto; currently off\"." "show check range"
594#test show check type
595gdb_test "show check type" "Type checking is \"auto; currently off\"." "show check type"
596#test show commands
597gdb_test "show commands" "" "show commands"
598#test show complaints
599gdb_test "show complaints" "Max number of complaints about incorrect symbols is 0." "show complaints"
600#test show confirm
601gdb_test "show confirm" "Whether to confirm potentially dangerous operations is o\[a-z\]*." "show confirm"
602#test show convenience
603gdb_test "show convenience" "No debugger convenience variables now defined.(\[^\r\n\]*\[\r\n\])+Convenience variables have names starting with \".\";(\[^\r\n\]*\[\r\n\])+use \"set\" as in \"set .foo = 5\" to define them." "show convenience"
604#test show directories
605gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd" "show directories"
606#test show editing
607gdb_test "show editing" "Editing of command lines as they are typed is o\[a-z\]*." "show editing"
608#test show height
609gdb_test "show height" "Number of lines gdb thinks are in a page is.*" "show height"
610#test show history expansion
611gdb_test "show history expansion" "History expansion on command input is o\[a-z\]*.*" "show history expansion"
612#test show history filename
613gdb_test "show history filename" "The filename in which to record the command history is.*.gdb_history.*" "show history filename"
614#test show history save
615gdb_test "show history save" "Saving of the history record on exit is on." "show history save"
616#test show history size
617gdb_test "show history size" "The size of the command history is.*" "show history size"
618#test show history
619gdb_test "show history" "expansion:  *History expansion on command input is o(\[^\r\n\]*\[\r\n\])+filename:  *The filename in which to record the command history is.*.gdb_history(\[^\r\n\]*\[\r\n\])+save: *Saving of the history record on exit is o(\[^\r\n\]*\[\r\n\])+size: * The size of the command history is.*" "show history"
620#test show language
621gdb_test "show language" "The current source language is \"auto; currently c\"." "show language"
622#test show listsize
623gdb_test "show listsize" "Number of source lines gdb will list by default is 10." "show listsize"
624#test show print "p" abbreviation
625gdb_test "show p" ".*" "show p"
626#test show print "pr" abbreviation
627gdb_test "show pr" ".*" "show pr"
628#test show print
629gdb_test "show print" "" "show print"
630#test show paths
631gdb_test "show paths" "Executable and object file path:.*" "show paths"
632#test show print address
633gdb_test "show print address" "Printing of addresses is on." "show print address"
634#test show print array
635gdb_test "show print array" "Prettyprinting of arrays is on." "show print array"
636#test show print asm-demangle
637gdb_test "show print asm-demangle" "Demangling of C\[+\]+/ObjC names in disassembly listings is on." "show print asm-demangle"
638#test show print demangle
639gdb_test "show print demangle" "Demangling of encoded C\[+\]+/ObjC names when displaying symbols is on." "show print demangle"
640#test show print elements
641gdb_test "show print elements" "Limit on string chars or array elements to print is 200." "show print elements"
642#test show print object
643gdb_test "show print object" "Printing of object's derived type based on vtable info is on." "show print object"
644#test show print pretty
645gdb_test "show print pretty" "Prettyprinting of structures is on." "show print pretty"
646#test show print sevenbit-strings
647gdb_test "show print sevenbit-strings" "Printing of 8-bit characters in strings as .nnn is on." "show print sevenbit-strings"
648#test show print union
649gdb_test "show print union" "Printing of unions interior to structures is on." "show print union"
650#test show print vtbl
651gdb_test "show print vtbl" "Printing of C\[+\]+ virtual function tables is on." "show print vtbl"
652#test show prompt
653# In the FAIL case, can't just look for $gdb_prompt because that will match
654# the output, rather than the prompt. So look for $gdb_prompt at the start
655# of a line.
656gdb_test "show prompt" "Gdb's prompt is \"$gdb_prompt \".*" "show prompt"
657#test show radix
658gdb_test "show radix" "Input and output radices set to decimal 10, hex a, octal 12." "show radix"
659#test show symbol-reloading
660gdb_test "show symbol-reloading" "Dynamic symbol table reloading multiple times in one run is on." "show symbol-reloading"
661#test show user
662gdb_test "show user" "" "show user"
663#test show values
664gdb_test "show values" "" "show values"
665#test show verbose
666gdb_test "show verbose" "Verbose printing of informational messages is o.*|Verbosity is off.*" "show verbose"
667#test show version
668gdb_test "show version" "GNU gdb \[0-9\.\]*(\[^\r\n\]*\[\r\n\])+Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc(\[^\r\n\]*\[\r\n\])+License GPLv3\\+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>(\[^\r\n\]*\[\r\n\])+This is free software: you are free to change and redistribute it.(\[^\r\n\]*\[\r\n\])+There is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"(\[^\r\n\]*\[\r\n\])+and \"show warranty\" for details..*" "show version"
669#test show width
670gdb_test "show width" "Number of characters gdb thinks are in a line is.*" "show width"
671#test show write
672# This is only supported on targets which use exec.o.
673gdb_test "show write" "Writing into executable and core files is o.*" "show write"
674#test show
675gdb_test "show" "confirm:  *Whether to confirm potentially dangerous operations is on.(\[^\r\n\]*\[\r\n\])+history filename:  *The filename in which to record the command history is (\[^\r\n\]*\[\r\n\])+history save:  *Saving of the history record on exit is on.(\[^\r\n\]*\[\r\n\])+history size:  *The size of the command history is(\[^\r\n\]*\[\r\n\])+listsize:  *Number of source lines gdb will list by default is 10(\[^\r\n]*\[\r\n\])+print elements:  *Limit on string chars or array elements to print is 200..*" "show"
676#test stepi "si" abbreviation
677gdb_test  "si" "The program is not being run." "stepi \"si\" abbreviation"
678#test stepi
679gdb_test "stepi" "The program is not being run." "stepi"
680#test signal
681gdb_test "signal" "The program is not being run." "signal"
682#test source
683gdb_test "source" "source command requires file name of file to source..*|No such file or directory.*" "source"
684#test step "s" abbreviation
685gdb_test "s" "The program is not being run." "step \"s\" abbreviation #2"
686#test step
687gdb_test "step" "The program is not being run." "step #2"
688#test symbol-file
689gdb_test "symbol-file" "" "symbol-file"
690
691#test target child
692gdb_test "target child" "Use the \"run\" command to start a Unix child process.*|Undefined target command: \"child\".  *Try \"help target\".*" "target child"
693
694#test target procfs
695gdb_test "target procfs" "Use the \"run\" command to start a Unix child process.*|Undefined target command: \"procfs\".  *Try \"help target\".*" "target procfs"
696
697#test target core
698send_gdb "target core\n"
699gdb_expect {
700    -re "No core file specified..*$gdb_prompt $" { pass "target core" }
701    -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
702	send_gdb "n\n"
703	if $verbose>1 then {
704	    send_user "\t\tDidn't kill program being debugged\n"
705	}
706	gdb_expect -re "$gdb_prompt $" { }
707	pass "target core"
708    }
709    -re "Undefined target command: \"core\".  Try \"help target\"..*$gdb_prompt $" { pass "target core" }
710    -re ".*$gdb_prompt $"	{ fail "target core" }
711    timeout		{ fail "(timeout) target core" }
712}
713
714#test target exec
715send_gdb "target exec\n"
716gdb_expect {
717	-re "No executable file now..*$gdb_prompt $"\
718			{ pass "target exec" }
719	-re ".*A program is being debugged already.  Kill it. .y or n.*$" {
720	    send_gdb "n\n"
721	    if $verbose>1 then {
722		send_user "\t\tDidn't kill program being debugged\n"
723	    }
724	    gdb_expect -re "$gdb_prompt $" { }
725	    pass "target exec"
726	}
727	-re ".*$gdb_prompt $"	{ fail "target exec" }
728	timeout		{ fail "(timeout) target exec" }
729	}
730
731#test target remote
732if ![istarget "*-*-udi*"] then {
733    send_gdb "target remote\n"
734    gdb_expect {
735	-re "To open a remote debug connection, you need to specify what.*serial.*device is attached to the remote system.*.e.g. .*$gdb_prompt $"\
736			{ pass "target remote" }
737	-re ".*A program is being debugged already.  Kill it. .y or n.*$" {
738	    send_gdb "n\n"
739	    if $verbose>1 then {
740		send_user "\t\tDidn't kill program being debugged\n"
741	    }
742	    gdb_expect -re "$gdb_prompt $" { }
743	    pass "target remote"
744	}
745	-re ".*$gdb_prompt $"	{ fail "target remote" }
746	timeout		{ fail "(timeout) target remote" }
747    }
748}
749
750#test target
751gdb_test "target" "Argument required .target name.*" "target"
752#test tbreak
753gdb_test "tbreak" "No default breakpoint address now." "tbreak"
754#test tty
755gdb_test "tty" "Argument required .filename to set it to\..*" "tty"
756#test until "u" abbreviation
757gdb_test "u" "The program is not running." "until \"u\" abbreviation"
758#test until
759gdb_test "until" "The program is not running." "until"
760#test undisplay
761# FIXME -- need to dump full output to detailed log
762send_gdb "undisplay\n"
763gdb_expect {
764    -re "Delete all auto-display expressions.*y or n. $" {
765	send_gdb "y\n"
766	gdb_expect {
767	    -re "$gdb_prompt $" { pass "undisplay prompt" }
768	    timeout { fail "(timeout) (timeout) undisplay prompt"    }
769	}
770    }
771    timeout		{ fail "(timeout) (timeout) undisplay prompt" }
772}
773
774#test unset environment
775send_gdb "unset environment\n"
776gdb_expect {
777    -re "Delete all environment variables?.*y or n. $" {
778	send_gdb "y\n"
779	gdb_expect {
780	    -re "$gdb_prompt $" { pass "unset environmentprompt" }
781	    timeout {
782		fail "(timeout) (timeout) unset environment prompt"
783	    }
784	}
785    }
786    timeout {
787	fail "(timeout) (timeout) unset environment prompt"
788    }
789}
790
791#test unset
792gdb_test "unset" "\"unset\" must be followed by the name of an unset subcommand.(\[^\r\n\]*\[\r\n\])+List of unset subcommands:(\[^\r\n\]*\[\r\n\])+unset environment -- Cancel environment variable VAR for the program(\[^\r\n\]*\[\r\n\])+Type \"help unset\" followed by unset subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "unset"
793#test up
794#test up-silently
795gdb_test "up-silently" "No stack." "up-silently"
796#test watch
797gdb_test "watch" "Argument required .expression to compute.*" "watch"
798#test whatis
799gdb_test "whatis" "The history is empty." "whatis"
800#test where
801gdb_test "where" "No stack." "where"
802#test x
803#The case in which it prints a number is for vxgdb.
804send_gdb "x\n"
805gdb_expect {
806    -re "0x0:.*Cannot access memory at address 0x0..*$gdb_prompt $" {
807        pass "x"
808    }
809    -re "0x0:.*Error accessing memory address 0x0:.*$gdb_prompt $" {
810        pass "x"
811    }
812    -re ".*$gdb_prompt $" { fail "x" }
813    timeout { fail "(timeout) x" }
814}
815
816gdb_exit
817