1#   Copyright 1988-2024 Free Software Foundation, Inc.
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
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
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.
12#
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/>.
15
16# Start with a fresh gdb
17
18gdb_exit
19gdb_start
20
21set prev_timeout $timeout
22set timeout 60
23
24#
25# test default actions of gdb commands
26#
27
28gdb_test "add-symbol-file" "add-symbol-file takes a file name and an address"
29
30# test append
31gdb_test "append" "List of append subcommands:.*"
32gdb_test "append binary" "List of append binary subcommands:.*"
33gdb_test "append memory" "Missing filename\."
34gdb_test "append value"  "Missing filename\."
35gdb_test "append binary memory" "Missing filename\."
36gdb_test "append binary value"  "Missing filename\."
37
38if !$use_gdb_stub {
39    gdb_test_multiple "attach" "attach" {
40          -re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\
41              { pass "attach" }
42          -re "You can't do that when your target is `None'.*$gdb_prompt $"\
43              { pass "attach" }
44          -re "You can't do that without a process to debug.*$gdb_prompt $"\
45              { pass "attach" }
46          -re "Don't know how to attach.  Try \"help target\"..*$gdb_prompt $"\
47              { pass "attach" }
48          -re "Kill it. .y or n." {
49              send_gdb "y\n"
50              exp_continue
51          }
52    }
53
54    gdb_test "break" "No default breakpoint address now."
55    foreach i "b br bre brea" {
56          gdb_test $i "No default breakpoint address now." "break \"$i\" abbreviation"
57    }
58
59
60    gdb_test "backtrace" "No stack."
61
62    # ba and bac are no longer unique command prefixes. So these tests
63    # elict an error from GDB.
64    # GDB needs to be fixed to map unique alias here for ba bac.
65    #
66    foreach i "bt ba bac" {
67          gdb_test $i "No stack." "backtrace \"$i\" abbreviation"
68    }
69}
70
71gdb_test "continue" "The program is not being run."
72gdb_test "c" "The program is not being run." "continue \"c\" abbreviation"
73
74#test call
75gdb_test "call" "The history is empty..*"
76
77
78#test catch
79gdb_test "catch" "List of catch subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help catch\" followed by catch subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
80
81#test cd
82gdb_test "cd" "Working directory \[^\r\n\]*\(\r\n \\(canonically \[^\r\n\]*\\)\)?\\."
83
84#test clear
85gdb_test "clear" "No source file specified..*"
86
87#test commands
88gdb_test "commands" "Argument required .one or more breakpoint numbers...*"
89
90#test condition
91gdb_test "condition" "Argument required .breakpoint number.*"
92
93#test core-file
94gdb_test "core-file" "No core file now."
95#test delete "d" abbreviation
96gdb_test_no_output "d" "delete \"d\" abbreviation"
97#test delete
98gdb_test_no_output "delete" "delete"
99#test define
100gdb_test "define" "Argument required \[(\]name of command to define\[)\]."
101#test delete breakpoints
102gdb_test_no_output "delete breakpoints" "delete breakpoints"
103#test delete display
104# FIXME -- need to dump full output to detailed log
105
106gdb_test "delete display" \
107    "" \
108    "delete display prompt" \
109    "Delete all auto-display expressions.*y or n. $" \
110    "y"
111
112
113#test detach
114gdb_test "detach" ".*"
115
116#test directory
117# FIXME -- need to dump full output to detailed log
118
119gdb_test "directory" \
120    "Source directories searched: .cdir\[:;\].cwd.*" \
121    "directory prompt" \
122    "Reinitialize source path to empty.*y or n. $" \
123    "y"
124
125#test disable "dis" abbreviation
126gdb_test_no_output "dis" "disable \"dis\" abbreviation"
127#test disable "disa" abbreviation
128gdb_test_no_output "disa" "disable \"disa\" abbreviation"
129#test disable
130gdb_test_no_output "disable" "disable"
131#test disable breakpoints
132gdb_test_no_output "disable breakpoints" "disable breakpoints"
133#test disable display
134gdb_test_no_output "disable display" "disable display"
135#test disassemble
136gdb_test "disassemble" "No frame selected."
137#test display
138gdb_test_no_output "display" "display"
139#test do
140gdb_test "do" "No stack."
141#test document
142gdb_test "document" "Argument required .name of command to define.*"
143#test down
144gdb_test "down" "No stack.*"
145#test down-silently
146gdb_test "down-silently" "No stack."
147# test dump
148gdb_test "dump" "List of dump subcommands:.*"
149gdb_test "dump binary" "List of dump binary subcommands:.*"
150gdb_test "dump ihex" "List of dump ihex subcommands:.*"
151gdb_test "dump memory" "Missing filename\."
152gdb_test "dump srec" "List of dump srec subcommands:.*"
153gdb_test "dump tekhex" "List of dump tekhex subcommands:.*"
154gdb_test "dump value" "Missing filename\."
155gdb_test "dump binary memory" "Missing filename\."
156gdb_test "dump binary value"  "Missing filename\."
157gdb_test "dump ihex memory" "Missing filename\."
158gdb_test "dump ihex value"  "Missing filename\."
159gdb_test "dump srec memory" "Missing filename\."
160gdb_test "dump srec value"  "Missing filename\."
161gdb_test "dump tekhex memory" "Missing filename\."
162gdb_test "dump tekhex value"  "Missing filename\."
163#test echo
164gdb_test_no_output "echo" "echo"
165#test enable breakpoints delete
166gdb_test "enable breakpoints delete" "Argument required .one or more breakpoint numbers.*"
167#test enable breakpoints once
168gdb_test "enable breakpoints once" "Argument required .one or more breakpoint numbers.*"
169#test enable breakpoints
170gdb_test_no_output "enable breakpoints" "enable breakpoints"
171#test enable delete
172gdb_test "enable delete" "Argument required .one or more breakpoint numbers.*"
173#test enable display
174gdb_test_no_output "enable display" "enable display"
175#test enable once
176gdb_test "enable once" "Argument required .one or more breakpoint numbers.*"
177#test enable
178gdb_test_no_output "enable" "enable"
179#test exec-file
180send_gdb "exec-file\n"
181gdb_expect {
182    -re "No executable file now..*$gdb_prompt $" {
183          pass "exec-file"
184    }
185    -re "exec-file.*A program is being debugged already.  Kill it. .y or n.*$" {
186          send_gdb "n\n"
187          if {$verbose > 1} {
188              send_user "\tDidn't kill program being debugged\n"
189          }
190          gdb_expect -re "$gdb_prompt $" { }
191          pass "exec-file"
192    }
193    -re "$gdb_prompt $"       { fail "exec-file" }
194    timeout                   { fail "(timeout) exec-file" }
195}
196
197#test frame "f" abbreviation
198gdb_test "f" "No stack." "frame \"f\" abbreviation"
199#test frame
200gdb_test "frame" "No stack."
201#test fg
202gdb_test "fg" "The program is not being run."
203
204#test file
205send_gdb "file\n"
206gdb_expect {
207    -re "No executable file now..*$gdb_prompt $"\
208              { pass "file" }
209    -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
210          send_gdb "n\n"
211          if {$verbose > 1} {
212              send_user "\t\tDidn't kill program being debugged\n"
213          }
214          gdb_expect -re "$gdb_prompt $" { }
215          pass "file"
216    }
217    -re ".*$gdb_prompt $"     { fail "file" }
218    timeout                   { fail "(timeout) file" }
219}
220
221#test finish
222gdb_test "finish" "The program is not being run."
223#test forward-search
224# The message here comes from the regexp library, not gdb, and so can
225# vary on different systems.
226gdb_test "forward-search" "No previous regular expression.*|There is no previous regular expression.*"
227#test gcore
228
229gdb_test_multiple "gcore" "gcore" {
230    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
231          pass "gcore"
232    }
233    -re "Undefined command: .*$gdb_prompt $" {
234          pass "gcore"
235    }
236}
237
238gdb_test_multiple "generate-core-file" "generate-core-file" {
239    -re "You can\'t do that without a process to debug.*$gdb_prompt $" {
240          pass "generate-core-file"
241    }
242    -re "Undefined command: .*$gdb_prompt $" {
243          pass "generate-core-file"
244    }
245}
246
247#test help "h" abbreviation
248gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined 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"
249#test help
250gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined 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."
251#test handle
252gdb_test "handle" "Argument required .signal to handle.*"
253#test info "i" abbreviation
254gdb_test "i" "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"
255#test info
256gdb_test "info" "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."
257#test ignore
258gdb_test "ignore" "Argument required .a breakpoint number.*"
259#test info address
260gdb_test "info address" "Argument required."
261#test info all-registers
262gdb_test "info all-registers" "The program has no registers now."
263#test info args
264gdb_test "info args" "No frame selected."
265#test info bogus-gdb-command
266gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\".  Try \"help info\".*"
267#test info breakpoints
268gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints."
269#test info copying
270# The license text is very big, so it may overwhelm Expect's output buffer
271# and cause the test to fail occasionally.  To avoid this problem, verify
272# the command's output in small chunks.
273set saw_header 0
274set saw_terms 0
275set saw_section5 0
276set saw_section7 0
277set saw_section10 0
278set saw_section14 0
279set saw_last_para 0
280# These excerpts were chosen for no particular reason, except that they
281# occur at the beginning, middle and end of the license text.
282set re_header [multi_line \
283                       "\\s+GNU GENERAL PUBLIC LICENSE" \
284                       "\\s+Version 3, 29 June 2007" \
285                       "" \
286                       " Copyright \\(C\\) 2007 Free Software Foundation, Inc. <http://fsf.org/>" \
287                       " Everyone is permitted to copy and distribute verbatim copies" \
288                       " of this license document, but changing it is not allowed." \
289                       "" \
290                       "\\s+Preamble" \
291                       "" \
292                       "  The GNU General Public License is a free, copyleft license for" \
293                       "software and other kinds of works.\r\n"]
294set re_terms [multi_line \
295                      "\\s+TERMS AND CONDITIONS" \
296                      "" \
297                      "  0. Definitions." \
298                      "" \
299                      "  \"This License\" refers to version 3 of the GNU General Public License.\r\n"]
300set re_section5 [multi_line \
301                         "  5. Conveying Modified Source Versions." \
302                         "" \
303                         "  You may convey a work based on the Program, or the modifications to\r\n"]
304set re_section7 [multi_line \
305                         "  7. Additional Terms." \
306                         "" \
307                         "  \"Additional permissions\" are terms that supplement the terms of this\r\n"]
308set re_section10 [multi_line \
309                          "  10. Automatic Licensing of Downstream Recipients." \
310                          "" \
311                          "  Each time you convey a covered work, the recipient automatically\r\n"]
312set re_section14 [multi_line \
313                          "  14. Revised Versions of this License." \
314                          "" \
315                          "  The Free Software Foundation may publish revised and/or new versions of\r\n"]
316set re_last_para [multi_line \
317                          "  Later license versions may give you additional or different" \
318                          "permissions.  However, no additional obligations are imposed on any" \
319                          "author or copyright holder as a result of your choosing to follow a" \
320                          "later version.\r\n"]
321set test "info copying"
322gdb_test_multiple $test $test {
323    -re $re_header {
324          set saw_header 1
325          exp_continue
326    }
327    -re $re_terms {
328          set saw_terms 1
329          exp_continue
330    }
331    -re $re_section5 {
332          set saw_section5 1
333          exp_continue
334    }
335    -re $re_section7 {
336          set saw_section7 1
337          exp_continue
338    }
339    -re $re_section10 {
340          set saw_section10 1
341          exp_continue
342    }
343    -re $re_section14 {
344          set saw_section14 1
345          exp_continue
346    }
347    -re $re_last_para {
348          set saw_last_para 1
349          exp_continue
350    }
351    -re "$gdb_prompt \$" {
352          gdb_assert { $saw_header && $saw_terms && $saw_section5 \
353                               && $saw_section7 && $saw_section10 \
354                               && $saw_section14 && $saw_last_para } $test
355    }
356}
357#test info display
358gdb_test "info display" "There are no auto-display expressions now."
359#test info frame "f" abbreviation
360gdb_test "info f" "No stack.*|No selected frame.*" "info frame \"f\" abbreviation"
361#test info frame
362gdb_test "info frame" "No stack.|No selected frame."
363#test info files
364gdb_test_no_output "info files" "info files"
365#test info float
366gdb_test "info float" "The program has no registers now."
367#test info functions
368gdb_test "info functions" "All defined functions:"
369#test info locals
370gdb_test "info locals" "No frame selected."
371#test info program
372gdb_test "info program" "The program being debugged is not being run."
373#test info registers
374gdb_test "info registers" "The program has no registers now."
375#test info stack "s" abbreviation
376gdb_test "info s" "No stack." "info stack \"s\" abbreviation"
377#test info stack
378gdb_test "info stack" "No stack."
379#test info set
380# Test improved to check three parts:
381# 1) confirm
382# 2) prompt
383# 3) write
384# And only succeed if all three are matched.
385# This should fix an old problem on native solaris 2.8,
386# where this test fails due to this line:
387#  prompt:  Gdb's prompt is "(gdb) ".^M
388set set_confirm_seen 0
389set set_prompt_seen 0
390gdb_test_multiple "info set" "info set" {
391    -re "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" {
392          verbose "Confirm dislayed"
393          set set_confirm_seen 1
394          exp_continue
395    }
396    -re "Gdb's prompt is \"$gdb_prompt \"" {
397          verbose "GDB prompt displayed"
398          set set_prompt_seen 1
399          exp_continue
400    }
401    -re "Writing into executable.*$gdb_prompt $" {
402          verbose "write displayed"
403          if { $set_prompt_seen && $set_confirm_seen } {
404              pass "info set"
405          } else {
406              verbose "prompt $set_prompt_seen confirm $set_confirm_seen"
407              fail "info set (incomplete output)"
408          }
409    }
410}
411gdb_test "info symbol" "Argument required .address.."
412#test info source
413gdb_test  "info source" "No current source file..*"
414#test info sources
415gdb_test "info sources" "No symbol table is loaded.  Use the \"file\" command.*"
416#test info target
417gdb_test_no_output "info target" "info target"
418#test info terminal
419gdb_test "info terminal" "No saved terminal information."
420# test info threads
421gdb_test "info threads" "No threads."
422#test info types
423gdb_test "info types" "All defined types:"
424#test info variables
425gdb_test "info variables" "All defined variables:"
426#test info vector
427gdb_test "info vector" "The program has no registers now."
428#test info warranty
429gdb_test "info warranty" "15. *Disclaimer of Warranty.*"
430#test info watchpoints
431gdb_test "info watchpoints" "No watchpoints."
432#test inspect
433gdb_test "inspect" "The history is empty."
434#test jump
435gdb_test "jump" "The program is not being run."
436#test kill
437gdb_test "kill" "The program is not being run."
438#test list "l" abbreviation
439gdb_test "l" "No symbol table is loaded.  Use the \"file\" command.*" "list \"l\" abbreviation"
440#test list
441gdb_test "list" "No symbol table is loaded.  Use the \"file\" command.*"
442#test load
443# The ``takes a file name'' case is for vxgdb.
444# The ``Use the "file" command'' case is for newer GDB versions which try
445# to deduce the filename from the exec file.
446gdb_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.*"
447#test next "n" abbreviation
448gdb_test "n" "The program is not being run." "next \"n\" abbreviation"
449#test next
450gdb_test "next" "The program is not being run."
451#test nexti "ni" abbreviation
452gdb_test "ni" "The program is not being run." "nexti \"ni\" abbreviation"
453#test nexti
454gdb_test "nexti" "The program is not being run."
455#test output
456gdb_test "output" "Argument required .expression to compute.*"
457
458#test overlay
459gdb_test "overlay" "List of overlay subcommands:.*"
460#test a non-existant overlay subcommand
461gdb_test "overlay on"     "Undefined overlay command.* Try \"help overlay\"."
462gdb_test_no_output "overlay manual" "overlay manual #1"
463gdb_test_no_output "overlay auto"
464gdb_test_no_output "overlay off"
465gdb_test "overlay list"   "No sections are mapped."
466gdb_test "overlay map"    "Overlay debugging not enabled.*" "overlay map #1"
467gdb_test "overlay unmap"  "Overlay debugging not enabled.*" "overlay unmap #1"
468gdb_test_no_output "overlay manual" "overlay manual #2"
469gdb_test "overlay map"    "Argument required: name of an overlay section" "overlay map #2"
470gdb_test "overlay unmap"  "Argument required: name of an overlay section" "overlay unmap #2"
471
472#test print "p" abbreviation
473gdb_test "p" "The history is empty." "print \"p\" abbreviation"
474#test print
475gdb_test "print" "The history is empty."
476#test printf
477gdb_test "printf" "Argument required .format-control string and values to print.*"
478#test ptype
479gdb_test "ptype" "The history is empty."
480#test pwd
481gdb_test "pwd" "Working directory .*"
482
483#test run "r" abbreviation
484if $use_gdb_stub {
485    # Only extended-remote supports "run".
486} else {
487    gdb_test_multiple "r" "run \"r\" abbreviation" {
488          -re "Starting program:  .*You can't do that when your target is `None'.*$gdb_prompt $"\
489              { pass "run \"r\" abbreviation" }
490          -re "Starting program:  .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
491              { pass "run \"r\" abbreviation" }
492          -re "Starting program:  .*No executable specified, use .target exec.\\..*$gdb_prompt $"\
493              { pass "run \"r\" abbreviation" }
494          -re "Starting program:  .*No image loaded into target.*$gdb_prompt $"\
495              { pass "run \"r\" abbreviation" }
496          -re "Starting program:  .*No program loaded.*$gdb_prompt $"\
497              { pass "run \"r\" abbreviation" }
498          -re "Don't know how to run.  Try \"help target\"..*$gdb_prompt $"\
499              { pass "run \"r\" abbreviation" }
500          -re "Starting program:  .*Running the default executable on the remote target failed; try \"set remote exec-file\"?.*$gdb_prompt $"\
501              { pass "run \"r\" abbreviation" }
502    }
503}
504
505#test run
506if $use_gdb_stub {
507    # Only extended-remote supports "run".
508} else {
509    gdb_test_multiple "run" "run" {
510          -re "Starting program:.*You can't do that when your target is `None'.*$gdb_prompt $"\
511              { pass "run" }
512          -re "Starting program:  .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
513              { pass "run" }
514          -re "Starting program:  .*No executable specified, use .target exec.\\..*$gdb_prompt $"\
515              { pass "run" }
516          -re "Starting program:  .*No image loaded into target.*$gdb_prompt $"\
517              { pass "run" }
518          -re "Starting program:  .*No program loaded.*$gdb_prompt $"\
519              { pass "run" }
520          -re "Don't know how to run.  Try \"help target\"..*$gdb_prompt $"\
521              { pass "run" }
522          -re "Starting program:  .*Running the default executable on the remote target failed; try \"set remote exec-file\"?.*$gdb_prompt $"\
523              { pass "run" }
524    }
525}
526
527#test rbreak
528gdb_test "rbreak" "rbreak"
529
530# test restore
531gdb_test "restore" "You can't do that without a process to debug\."
532
533#test return
534# The middle case accommodated the obsolete a29k, where doing the "ni"
535# above causes an initial stack to be created.
536gdb_test "return" "No selected frame..*"
537
538
539#test reverse-search
540gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*"
541#test step "s" abbreviation
542gdb_test "s" "The program is not being run." "step \"s\" abbreviation #1"
543#test step
544gdb_test "step" "The program is not being run." "step #1"
545#test search
546gdb_test "search" "No previous regular expression.*|There is no previous regular expression.*"
547#test section
548gdb_test "section" "Must specify section name and its virtual address.*"
549#test set annotate
550gdb_test "set annotate" "Argument required .integer to set it to.*"
551#test set args
552gdb_test_no_output "set args" "set args"
553
554# Test set check abbreviations
555foreach x {"c" "ch" "check"} {
556    gdb_test "set $x" "List of set check subcommands:(\[^\r\n\]*\[\r\n\])+set check range -- Set range checking(\[^\r\n\]*\[\r\n\])+set check type -- Set strict 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." \
557          "set check \"$x\" abbreviation"
558}
559
560#test set check range
561gdb_test "set check range" ".*"
562#test set check type
563gdb_test "set check type" ".*"
564#test set complaints
565gdb_test "set complaints" "Argument required .integer to set it to.*"
566#test set confirm
567gdb_test_no_output "set confirm" "set confirm"
568# Don't test set editing. What if we're talking to a gdb that
569# won't do editing correctly while we're talking to it?
570# gdb_test "set editing" "" "set editing"
571
572#test set environment
573gdb_test "set environment" "Argument required .environment variable and value.*"
574#test set height
575gdb_test "set height" "Argument required .integer to set it to.*"
576#test set history expansion
577gdb_test_no_output "set history expansion" "set history expansion"
578# Make sure the history ends up in the right place.
579gdb_test_no_output "set history filename [standard_output_file .gdb_history]" \
580    "set the history filename"
581#test set history save
582gdb_test_no_output "set history save" "set history save"
583#test set history size
584gdb_test "set history size" "Argument required .integer to set it to.*"
585#test set history
586gdb_test "set history" "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."
587#test set language
588gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, asm, c, c.., d, fortran, go, minimal, modula-2, objective-c, opencl, pascal, rust."
589#test set listsize
590gdb_test "set listsize" "Argument required .integer to set it to.*"
591#test set print "p" abbreviation
592gdb_test "set p" "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"
593#test set print "pr" abbreviation
594gdb_test "set pr" "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"
595#test set print
596gdb_test "set print" "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."
597#test set print address
598gdb_test_no_output "set print address" "set print address"
599#test set print array
600gdb_test_no_output "set print array" "set print array"
601#test set print asm-demangle
602gdb_test_no_output "set print asm-demangle" "set print asm-demangle"
603#test set print characters
604gdb_test "set print characters" \
605           "Argument required \\(integer to set it to, or one of:\
606            \"elements\", \"unlimited\"\\)\\."
607#test set print demangle
608gdb_test_no_output "set print demangle" "set print demangle"
609#test set print elements
610gdb_test "set print elements" \
611           "Argument required \\(integer to set it to, or \"unlimited\"\\)\\."
612#test set print object
613gdb_test_no_output "set print object" "set print object"
614#test set print pretty
615gdb_test_no_output "set print pretty" "set print pretty"
616#test set print sevenbit-strings
617gdb_test_no_output "set print sevenbit-strings" "set print sevenbit-strings"
618#test set print union
619gdb_test_no_output "set print union" "set print union"
620#test set print vtbl
621gdb_test_no_output "set print vtbl" "set print vtbl"
622# FIXME -- need a test for "set prompt"
623#test set radix
624gdb_test "set radix" "Input and output radices now set to decimal 10, hex a, octal 12.*"
625#test set variable
626gdb_test "set variable" "Argument required .expression to compute.*"
627#test set verbose
628gdb_test_no_output "set verbose" "set verbose"
629#test set width
630gdb_test "set width" "Argument required .integer to set it to.*"
631#test set write
632# This is only supported on targets which use exec.o.
633gdb_test_no_output "set write" "set write"
634#test set
635gdb_test "set" "Argument required .expression to compute.*"
636#test shell echo Hi dad!
637gdb_test "shell echo Hi dad!" "Hi dad!"
638#test show annotate
639gdb_test "show annotate" "Annotation_level is 0."
640#test show args
641gdb_test "show args" "Argument list to give program being debugged when it is started is \"\"."
642
643# test show check abbreviations
644foreach x {"c" "ch" "check"} {
645    gdb_test "show $x" "check range:  *Range checking is \"auto; currently off\".(\[^\r\n\]*\[\r\n\])+check type:  *Strict type checking is on\..*" \
646          "show check \"$x\" abbreviation"
647}
648
649#test show check range
650gdb_test "show check range" "Range checking is \"auto; currently off\"."
651#test show check type
652gdb_test "show check type" "Strict type checking is on\."
653#test show commands
654gdb_test "show commands" ".*"
655#test show complaints
656gdb_test "show complaints" "Max number of complaints about incorrect symbols is 0."
657#test show confirm
658gdb_test "show confirm" "Whether to confirm potentially dangerous operations is o\[a-z\]*."
659
660#test show convenience
661# This is trickier as there are multiple internal convenience vars and
662# functions and we can't assume any particular order.
663# And we have to handle the extra convenience funs provided by Python.
664set show_conv_list \
665    { \
666          {$_sdata = void} \
667          {$_siginfo = void} \
668          {$_thread = 0} \
669          {$_gthread = 0} \
670          {$_inferior = 1} \
671          {$_inferior_thread_count = 0} \
672          {$_exception = <error: No frame selected>} \
673          {$_probe_argc = <error: No frame selected>} \
674          {$_probe_arg0 = <error: No frame selected>} \
675          {$_probe_arg1 = <error: No frame selected>} \
676          {$_probe_arg2 = <error: No frame selected>} \
677          {$_probe_arg3 = <error: No frame selected>} \
678          {$_probe_arg4 = <error: No frame selected>} \
679          {$_probe_arg5 = <error: No frame selected>} \
680          {$_probe_arg6 = <error: No frame selected>} \
681          {$_probe_arg7 = <error: No frame selected>} \
682          {$_probe_arg8 = <error: No frame selected>} \
683          {$_probe_arg9 = <error: No frame selected>} \
684          {$_probe_arg10 = <error: No frame selected>} \
685          {$_probe_arg11 = <error: No frame selected>} \
686          {$_cimag = <internal function _cimag>} \
687          {$_creal = <internal function _creal>} \
688          {$_isvoid = <internal function _isvoid>} \
689          {$_shell = <internal function _shell>} \
690          {$_gdb_maint_setting_str = <internal function _gdb_maint_setting_str>} \
691          {$_gdb_maint_setting = <internal function _gdb_maint_setting>} \
692          {$_gdb_setting_str = <internal function _gdb_setting_str>} \
693          {$_gdb_setting = <internal function _gdb_setting>} \
694          {$_gdb_major = 15} \
695          {$_gdb_minor = 1} \
696          {$_shell_exitsignal = void} \
697          {$_shell_exitcode = 0} \
698    }
699if [allow_python_tests] {
700    append show_conv_list \
701          {
702              {$_memeq = <internal function _memeq>} \
703              {$_regex = <internal function _regex>} \
704              {$_streq = <internal function _streq>} \
705              {$_strlen = <internal function _strlen>} \
706              {$_as_string = <internal function _as_string>} \
707              {$_caller_is = <internal function _caller_is>} \
708              {$_caller_matches = <internal function _caller_matches>} \
709              {$_any_caller_is = <internal function _any_caller_is>} \
710              {$_any_caller_matches = <internal function _any_caller_matches>} \
711          }
712}
713gdb_test_list_exact "show convenience" "show convenience" \
714    "\[^\r\n\]+\[\r\n\]+" \
715    "\[^\r\n\]+" \
716    $show_conv_list
717
718#test show directories
719gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd"
720#test show editing
721gdb_test "show editing" "Editing of command lines as they are typed is o\[a-z\]*."
722#test show height
723gdb_test "show height" "Number of lines gdb thinks are in a page is.*"
724#test show history expansion
725gdb_test "show history expansion" "History expansion on command input is o\[a-z\]*.*"
726#test show history filename
727gdb_test "show history filename" "The filename in which to record the command history is.*.gdb_history.*"
728#test show history save
729gdb_test "show history save" "Saving of the history record on exit is on."
730#test show history size
731gdb_test "show history size" "The size of the command history is.*"
732#test show history
733gdb_test "show history" "history expansion:  *History expansion on command input is o(\[^\r\n\]*\[\r\n\])+history filename:  *The filename in which to record the command history is.*.gdb_history(\[^\r\n\]*\[\r\n\])+history save: *Saving of the history record on exit is o(\[^\r\n\]*\[\r\n\])+history size: * The size of the command history is.*"
734#test show language
735gdb_test "show language" "The current source language is \"auto; currently c\"."
736#test show listsize
737gdb_test "show listsize" "Number of source lines gdb will list by default is 10."
738#test show print "p" abbreviation
739gdb_test "show p" ".*"
740#test show print "pr" abbreviation
741gdb_test "show pr" ".*"
742#test show print
743gdb_test "show print" ".*"
744#test show paths
745gdb_test "show paths" "Executable and object file path:.*"
746#test show print address
747gdb_test "show print address" "Printing of addresses is on."
748#test show print array
749gdb_test "show print array" "Pretty formatting of arrays is on."
750#test show print asm-demangle
751gdb_test "show print asm-demangle" "Demangling of C\[+\]+/ObjC names in disassembly listings is on."
752#test show print characters
753gdb_test "show print characters" \
754           "Limit on string characters to print is elements\\."
755#test show print demangle
756gdb_test "show print demangle" "Demangling of encoded C\[+\]+/ObjC names when displaying symbols is on."
757#test show print elements
758gdb_test "show print elements" "Limit on string chars or array elements to print is 200."
759#test show print object
760gdb_test "show print object" "Printing of object's derived type based on vtable info is on."
761#test show print pretty
762gdb_test "show print pretty" "Pretty formatting of structures is on."
763#test show print sevenbit-strings
764gdb_test "show print sevenbit-strings" "Printing of 8-bit characters in strings as .nnn is on."
765#test show print union
766gdb_test "show print union" "Printing of unions interior to structures is on."
767#test show print vtbl
768gdb_test "show print vtbl" "Printing of C\[+\]+ virtual function tables is on."
769#test show prompt
770# In the FAIL case, can't just look for $gdb_prompt because that will match
771# the output, rather than the prompt. So look for $gdb_prompt at the start
772# of a line.
773gdb_test "show prompt" "Gdb's prompt is \"$gdb_prompt \".*"
774#test show radix
775gdb_test "show radix" "Input and output radices set to decimal 10, hex a, octal 12."
776#test show user
777gdb_test_no_output "show user" "show user"
778#test show values
779gdb_test_no_output "show values" "show values"
780#test show verbose
781gdb_test "show verbose" "Verbose printing of informational messages is o.*|Verbosity is off.*"
782#test show version
783gdb_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.(\[^\r\n\]*\[\r\n\])+Type \"show copying\" and \"show warranty\" for details..*"
784#test show width
785gdb_test "show width" "Number of characters gdb thinks are in a line is.*"
786#test show write
787# This is only supported on targets which use exec.o.
788gdb_test "show write" "Writing into executable and core files is o.*"
789#test show
790set show_confirm_seen 0
791set show_prompt_seen 0
792gdb_test_multiple "show" "show" {
793    -re "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." {
794          verbose "Confirm displayed"
795          set show_confirm_seen 1
796          exp_continue
797    }
798    -re "Gdb's prompt is \"$gdb_prompt \"" {
799          verbose "GDB prompt displayed"
800          set show_prompt_seen 1
801          exp_continue
802    }
803    -re "Writing into executable.*$gdb_prompt $" {
804          verbose "write displayed"
805          if { $show_prompt_seen && $show_confirm_seen } {
806              pass "show"
807          } else {
808              verbose "prompt $show_prompt_seen confirm $show_confirm_seen"
809              fail "show (incomplete output)"
810          }
811    }
812}
813#history saving should stay disabled
814gdb_test_no_output "set history save off" "set history save off"
815#test stepi "si" abbreviation
816gdb_test  "si" "The program is not being run." "stepi \"si\" abbreviation"
817#test stepi
818gdb_test "stepi" "The program is not being run."
819#test signal
820gdb_test "signal" "The program is not being run."
821#test source
822gdb_test "source" "source command requires file name of file to source..*|No such file or directory.*"
823#test step "s" abbreviation
824gdb_test "s" "The program is not being run." "step \"s\" abbreviation #2"
825#test step
826gdb_test "step" "The program is not being run." "step #2"
827#test symbol-file
828gdb_test "symbol-file" ".*"
829
830#test target native
831gdb_test "target native" "Use the \"run\" command to start a process.*|Undefined target command: \"native\".  *Try \"help target\".*"
832
833#test target core
834send_gdb "target core\n"
835gdb_expect {
836    -re "No core file specified..*$gdb_prompt $" { pass "target core" }
837    -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
838          send_gdb "n\n"
839          if {$verbose > 1} {
840              send_user "\t\tDidn't kill program being debugged\n"
841          }
842          gdb_expect -re "$gdb_prompt $" { }
843          pass "target core"
844    }
845    -re "Undefined target command: \"core\".  Try \"help target\"..*$gdb_prompt $" { pass "target core" }
846    -re ".*$gdb_prompt $"     { fail "target core" }
847    timeout                   { fail "(timeout) target core" }
848}
849
850#test target exec
851send_gdb "target exec\n"
852gdb_expect {
853          -re "No executable file now..*$gdb_prompt $"\
854                              { pass "target exec" }
855          -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
856              send_gdb "n\n"
857              if {$verbose > 1} {
858                    send_user "\t\tDidn't kill program being debugged\n"
859              }
860              gdb_expect -re "$gdb_prompt $" { }
861              pass "target exec"
862          }
863          -re ".*$gdb_prompt $"         { fail "target exec" }
864          timeout             { fail "(timeout) target exec" }
865          }
866
867#test target remote
868send_gdb "target remote\n"
869gdb_expect {
870    -re "To open a remote debug connection, you need to specify what.*serial.*device is attached to the remote system.*.e.g. .*$gdb_prompt $"\
871          { pass "target remote" }
872    -re ".*A program is being debugged already.  Kill it. .y or n.*$" {
873          send_gdb "n\n"
874          if {$verbose > 1} {
875              send_user "\t\tDidn't kill program being debugged\n"
876          }
877          gdb_expect -re "$gdb_prompt $" { }
878          pass "target remote"
879    }
880    -re ".*$gdb_prompt $"     { fail "target remote" }
881    timeout                   { fail "(timeout) target remote" }
882}
883
884#test target
885gdb_test "target" "List of target subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help target\" followed by target subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
886#test tbreak
887gdb_test "tbreak" "No default breakpoint address now."
888#test thread
889gdb_test "thread" "No thread selected"
890#test thread apply
891gdb_test "thread apply" "Please specify a thread ID list"
892#test thread find
893gdb_test "thread find" "Command requires an argument."
894#test thread name
895gdb_test "thread name" "No thread selected"
896#test until "u" abbreviation
897gdb_test "u" "The program is not being run." "until \"u\" abbreviation"
898#test until
899gdb_test "until" "The program is not being run."
900#test undisplay
901# FIXME -- need to dump full output to detailed log
902
903gdb_test "undisplay" \
904    "" \
905    "undisplay prompt" \
906    "Delete all auto-display expressions.*y or n. $" \
907    "y"
908
909#test unset environment
910
911gdb_test "unset environment" \
912    "" \
913    "unset environment prompt" \
914    "Delete all environment variables?.*y or n. $" \
915    "y"
916
917#test unset
918gdb_test "unset" "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."
919#test up
920#test up-silently
921gdb_test "up-silently" "No stack."
922#test watch
923gdb_test "watch" "Argument required .expression to compute.*"
924#test whatis
925gdb_test "whatis" "The history is empty."
926#test where
927gdb_test "where" "No stack."
928#test x
929gdb_test "x" "Argument required .starting display address.*"
930
931gdb_exit
932
933set timeout $prev_timeout
934