# Copyright (C) 1992, 1994 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. */ # Please email any bugs, comments, and/or additions to this file to: # bug-gdb@prep.ai.mit.edu # This file was written by Michael Snyder (msnyder@cygnus.com) if $tracelevel then { strace $tracelevel } set prms_id 0 set bug_id 0 set testfile "setshow" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} if { [compile "${srcdir}/${subdir}/${srcfile} -g -o ${binfile}"] != "" } { perror "Couldn't compile ${srcfile}" return -1 } # Start with a fresh gdb gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # # Test gdb set and show commands. # Add tests here for show and set that don't fit neatly elsewhere. # FIXME: many rudimentary tests for set and show commands have been # added below, but most do nothing more than check that a # variable has been set successfully, ie. they do not test # whether setting the variable has had the desired effect. # #load_lib gdb.exp #test default annotation_level is 0 send "show annotate\n" expect { -re "Annotation_level is 0..*$prompt $" \ { pass "default annotation_level is zero" } -re ".*$prompt $" { fail "default annotation_level is zero" } timeout { fail "(timeout) default annotation_level is zero" } } #test set annotate 2 send "set annotate 2\n" expect { -re ".*\032\032pre-prompt.*$prompt .*\032\032prompt.*$" \ { pass "set annotate 2" } -re ".*$prompt $" { fail "set annotate 2" } timeout { fail "(timeout) set annotate 2" } } send "show annotate\n" expect { -re ".*\032\032post-prompt.*Annotation_level is 2..*\032\032pre-prompt.*$prompt .*\032\032prompt.*$" \ { pass "show annotate (2)" } -re ".*$prompt $" { fail "show annotate (2)" } timeout { fail "(timeout) show annotate (2)" } } #test annotation_level 2 send "info line 1\n" expect { -re ".*\032\032post-prompt.*Line 1 of .* is at address .* but contains no code.*:1:0:beg:0x.*\032\032pre-prompt.*$prompt .*\032\032prompt.*$" \ { pass "annotation_level 2" } -re ".*$prompt $" { fail "annotation_level 2" } timeout { fail "(timeout) annotation_level 2" } } #test set annotate 1 send "set annotate 1\n" expect { -re ".*post-prompt.*$prompt $" \ { pass "set annotate 1" } -re ".*$prompt $" { fail "set annotate 1" } timeout { fail "(timeout) set annotate 1" } } send "show annotate\n" expect { -re "Annotation_level is 1..*$prompt $" \ { pass "show annotate (1)" } -re ".*$prompt $" { fail "show annotate (1)" } timeout { fail "(timeout) show annotate (1)" } } #test annotation_level 1 send "info line 1\n" expect { -re "Line 1 of .* is at address .* but contains no code.*:1:0:beg:0x.*$prompt $" \ { pass "annotation_level 1" } -re ".*$prompt $" { fail "annotation_level 1" } timeout { fail "(timeout) annotation_level 1" } } #test set annotate 0 send "set annotate 0\n" expect { -re "$prompt $" { pass "set annotate 0" } -re ".*$prompt $" { fail "set annotate 0" } timeout { fail "(timeout) set annotate 0" } } send "show annotate\n" expect { -re "Annotation_level is 0..*$prompt $" \ { pass "show annotate (0)" } -re ".*$prompt $" { fail "show annotate (0)" } timeout { fail "(timeout) show annotate (1)" } } #test annotation_level 0 send "info line 1\n" expect { -re "Line 1 of .* is at address .* but contains no code.*$prompt $" \ { pass "annotation_level 0" } -re ".*$prompt $" { fail "annotation_level 0" } timeout { fail "(timeout) annotation_level 0" } } #test set args send "set args foo bar blup baz bubble\n" expect { -re "$prompt $" { pass "set args" } -re ".*$prompt $" { fail "set args" } timeout { fail "(timeout) set args" } } #test show args send "show args\n" expect { -re "Arguments to give program being debugged when it is started is \"foo bar blup baz bubble\"..*$prompt $"\ { pass "show args" } -re ".*$prompt $" { fail "show args" } timeout { fail "(timeout) show args" } } #test passing args send "run\n" expect { -re "Starting program:.*foo bar blup baz bubble.*$prompt $" { pass "passing args" } -re ".*$prompt $" { fail "passing args" } timeout { fail "(timeout) passing args" } } #test set check range on send "set check range on\n" expect { -re "$prompt $" { pass "set check range on" } -re ".*$prompt $" { fail "set check range on" } timeout { fail "(timeout) set check range on" } } #test show check range on send "show check range\n" expect { -re "Range checking is \"on\"\..*$prompt $"\ { pass "show check range (on)" } -re ".*$prompt $" { fail "show check range (on)" } timeout { fail "(timeout) show check range (on)" } } #test set check range auto send "set check range auto\n" expect { -re "$prompt $" { pass "set check range auto" } -re ".*$prompt $" { fail "set check range auto" } timeout { fail "(timeout) set check range auto" } } #test show check range auto send "show check range\n" expect { -re "Range checking is \"auto; currently .*$prompt $"\ { pass "show check range (auto)" } -re ".*$prompt $" { fail "show check range (auto)" } timeout { fail "(timeout) show check range (auto)" } } #test set check type on send "set check type on\n" expect { -re "$prompt $" { pass "set check type on" } -re ".*$prompt $" { fail "set check type on" } timeout { fail "(timeout) set check type on" } } #test show check type on send "show check type\n" expect { -re "Type checking is \"on\"..*$prompt $"\ { pass "show check type (on)" } -re ".*$prompt $" { fail "show check type (on)" } timeout { fail "(timeout) show check type (on)" } } #test set check type auto send "set check type auto\n" expect { -re "$prompt $" { pass "set check type auto" } -re ".*$prompt $" { fail "set check type auto" } timeout { fail "(timeout) set check type auto" } } #test show check type send "show check type\n" expect { -re "Type checking is \"auto; currently .*$prompt $"\ { pass "show check type (auto)" } -re ".*$prompt $" { fail "show check type (auto)" } timeout { fail "(timeout) show check type (auto)" } } #test set complaints 100 send "set complaints 100\n" expect { -re "$prompt $" { pass "set complaints 100" } -re ".*$prompt $" { fail "set complaints 100" } timeout { fail "(timeout) set complaints 100" } } #test show complaints 100 send "show complaints\n" expect { -re "Max number of complaints about incorrect symbols is 100..*$prompt $"\ { pass "show complaints (100)" } -re ".*$prompt $" { fail "show complaints (100)" } timeout { fail "(timeout) show complaints (100)" } } #test set complaints 0 send "set complaints 0\n" expect { -re "$prompt $" { pass "set complaints 0" } -re ".*$prompt $" { fail "set complaints 0" } timeout { fail "(timeout) set complaints 0" } } #test show complaints 0 send "show complaints\n" expect { -re "Max number of complaints about incorrect symbols is 0..*$prompt $"\ { pass "show complaints (0)" } -re ".*$prompt $" { fail "show complaints (0)" } timeout { fail "(timeout) show complaints (0)" } } #test set confirm off send "set confirm off\n" expect { -re "$prompt $" { pass "set confirm off" } -re ".*$prompt $" { fail "set confirm off" } timeout { fail "(timeout) set confirm off" } } #test show confirm off send "show confirm\n" expect { -re "Whether to confirm potentially dangerous operations is off..*$prompt $"\ { pass "show confirm (off)" } -re ".*$prompt $" { fail "show confirm (off)" } timeout { fail "(timeout) show confirm (off)" } } #test set confirm on send "set confirm on\n" expect { -re "$prompt $" { pass "set confirm on" } -re ".*$prompt $" { fail "set confirm on" } timeout { fail "(timeout) set confirm on" } } #test show confirm on send "show confirm\n" expect { -re "Whether to confirm potentially dangerous operations is on..*$prompt $"\ { pass "show confirm (on)" } -re ".*$prompt $" { fail "show confirm (on)" } timeout { fail "(timeout) show confirm (on)" } } #test set editing off send "set editing off\n" expect { -re "$prompt $" { pass "set editing off" } -re ".*$prompt $" { fail "set editing off" } timeout { fail "(timeout) set editing off" } } #test show editing off send "show editing\n" expect { -re "Editing of command lines as they are typed is off..*$prompt $"\ { pass "show editing (off)" } -re ".*$prompt $" { fail "show editing (off)" } timeout { fail "(timeout) show editing (off)" } } #test set editing on send "set editing on\n" expect { -re "$prompt $" { pass "set editing on" } -re ".*$prompt $" { fail "set editing on" } timeout { fail "(timeout) set editing on" } } #test show editing on send "show editing\n" expect { -re "Editing of command lines as they are typed is on..*$prompt $"\ { pass "show editing (on)" } -re ".*$prompt $" { fail "show editing (on)" } timeout { fail "(timeout) show editing (on)" } } #test set environment FOOBARBAZ send "set environment FOOBARBAZ = grbxgrbxgrbx\n" expect { -re "$prompt $" { pass "set environment FOOBARBAZ" } -re ".*$prompt $" { fail "set environment FOOBARBAZ" } timeout { fail "(timeout) set environment FOOBARBAZ" } } #test show environment FOOBARBAZ send "show environment FOOBARBAZ\n" expect { -re "FOOBARBAZ = grbxgrbxgrbx.*$prompt $" { pass "show environment FOOBARBAZ" } -re ".*$prompt $" { fail "show environment FOOBARBAZ" } timeout { fail "(timeout) show environment FOOBARBAZ" } } #test set height 100 send "set height 100\n" expect { -re "$prompt $" { pass "set height 100" } -re ".*$prompt $" { pass "set height 100" } timeout { fail "(timeout) set height 100" } } #test show height 100 send "show height\n" expect { -re "Number of lines gdb thinks are in a page is 100..*$prompt $"\ { pass "show height" } -re ".*$prompt $" { fail "show height" } timeout { fail "(timeout) show height" } } #test set history expansion on send "set history expansion on\n" expect { -re "$prompt $" { pass "set history expansion on" } -re ".*$prompt $" { fail "set hitsory expansion on" } timeout { fail "(timeout) set history expansion" } } #test show history expansion on send "show history expansion on\n" expect { -re "History expansion on command input is on.*$prompt $"\ { pass "show history expansion" } -re ".*$prompt $" { fail "show history expansion" } timeout { fail "(timeout) show history expansion" } } #test set history filename foobar.baz send "set history filename foobar.baz\n" expect { -re "$prompt $" { pass "set history filename foobar.baz" } -re ".*$prompt $" { fail "set history filename foobar.baz" } timeout { fail "(timeout) set history filename foobar.baz" } } #test show history filename foobar.baz send "show history filename\n" expect { -re "The filename in which to record the command history is \"foobar.baz\"..*$prompt $" \ { pass "show history filename (foobar.baz)" } -re ".*$prompt $" { fail "show history filename (foobar.baz)" } timeout { fail "(timeout) show history filename (foobar.baz)" } } #test set history save on send "set history save on\n" expect { -re "$prompt $" { pass "set history save on" } -re ".*$prompt $" { fail "set history save on" } timeout { fail "(timeout) set history save on" } } #test show history save on send "show history save\n" expect { -re "Saving of the history record on exit is on..*$prompt $" { pass "show history save (on)" } -re ".*$prompt $" { fail "show history save (on)" } timeout { fail "(timeout) show history save" } } #test set history size 100 send "set history size 100\n" expect { -re "$prompt $" { pass "set history size 100" } -re ".*$prompt $" { fail "set history size 100" } timeout { fail "(timeout) set history size 100" } } #test show history size 100 send "show history size\n" expect { -re "The size of the command history is 100..*$prompt $"\ { pass "show history size (100)" } -re ".*$prompt $" { fail "show history size (100)" } timeout { fail "(timeout) show history size (100)" } } #test set language asm send "set language asm\n" expect { -re "$prompt $" { pass "set language asm" } -re ".*$prompt $" { fail "set language asm" } timeout { fail "(timeout) set language asm" } } #test show language asm send "show language\n" expect { -re "The current source language is \"asm\"..*$prompt $"\ { pass "show language (asm)" } -re ".*$prompt $" { fail "show language (asm)" } timeout { fail "(timeout) show language (asm)" } } #test set language auto send "set language auto\n" expect { -re "$prompt $" { pass "set language auto" } -re ".*$prompt $" { fail "set language auto" } timeout { fail "(timeout) set language auto" } } #test show language send "show language\n" expect { -re "The current source language is \"auto\"..*$prompt $"\ { pass "show language (auto)" } -re ".*$prompt $" { fail "show language (auto)" } timeout { fail "(timeout) show language (auto)" } } #test set listsize 100 send "set listsize 100\n" expect { -re "$prompt $" { pass "set listsize 100" } -re ".*$prompt $" { fail "set listsize 100" } timeout { fail "(timeout) set listsize 100" } } #test show listsize 100 send "show listsize\n" expect { -re "Number of source lines gdb will list by default is 100..*$prompt $"\ { pass "show listsize (100)" } -re ".*$prompt $" { fail "show listsize (100)" } timeout { fail "(timeout) show listsize (100)" } } #test set prompt (FooBarBaz) set newprompt "\\(FooBarBaz\\)" send "set prompt (FooBarBaz) \n" expect { -re "$newprompt $" { pass "set prompt (FooBarBaz) " } timeout { fail "(timeout) set prompt (FooBarBaz) " } } #test show prompt (FooBarBaz) send "show prompt\n" expect { -re "Gdb's prompt is \"$newprompt \"..* $" \ { pass "show prompt (FooBarBaz) " } timeout { fail "(timeout) show prompt (FooBarBaz) " } } #test set prompt (gdb) send "set prompt (gdb) \n" expect { -re "$prompt $" { pass "set prompt (gdb) " } timeout { fail "(timeout) set prompt (gdb) " } } #test set radix 11 send "set radix 11\n" expect { -re "Unsupported output radix ``decimal 11''; output radix unchanged..*$prompt $" \ { pass "set radix 11" } timeout { fail "(timeout) set radix 11" } } #test set radix 16 send "set radix 16\n" expect { -re "Input and output radices now set to decimal 16, hex 10, octal 20..*$prompt $" \ { pass "set radix 16" } timeout { fail "(timeout) set radix 16" } } #test show radix 16 send "show radix\n" expect { -re "Input and output radices set to decimal 16, hex 10, octal 20..*$prompt $" \ { pass "show radix (16)" } timeout { fail "(timeout) show radix (16)" } } #test set radix 10 send "set radix\n" expect { -re "Input and output radices now set to decimal 10, hex a, octal 12..*$prompt $" \ { pass "set radix 10" } timeout { fail "(timeout) set radix 10" } } #test show radix 10 send "show radix\n" expect { -re "Input and output radices set to decimal 10, hex a, octal 12..*$prompt $"\ { pass "show radix (10)" } -re "Default input and output number radix is 10..*$prompt $"\ { fail "show radix (obsolete radix support)" } -re ".*$prompt $" { fail "show radix (10)" } timeout { fail "(timeout) show radix (10)" } } #test set width 90 send "set width 90\n" expect { -re "$prompt $" { pass "set width 90" } -re ".*$prompt $" { fail "set width 90" } timeout { fail "(timeout) set width 90" } } #test show width 90 send "show width\n" expect { -re "Number of characters gdb thinks are in a line is 90..*$prompt $"\ { pass "show width (90)" } -re ".*$prompt $" { fail "show width (90)" } timeout { fail "(timeout) show width (90)" } } #test set write on # This is only supported on targets which use exec.o. if ![istarget "rs6000-*-*"] then { send "set write on\n" expect { -re "$prompt $" { pass "set write on" } -re ".*$prompt $" { fail "set write on" } timeout { fail "(timeout) set write on" } } } #test show write on # This is only supported on targets which use exec.o. if ![istarget "rs6000-*-*"] then { send "show write\n" expect { -re "Writing into executable and core files is on..*$prompt $"\ { pass "show write (on)" } -re ".*$prompt $" { fail "show write (on)" } timeout { fail "(timeout) show write (on)" } } } gdb_test "set write off" "" #test set symbol-reloading on send "set symbol-reloading on\n" expect { -re "$prompt $" { pass "set symbol-reloading on" } -re ".*$prompt $" { fail "set symbol-reloading on" } timeout { fail "(timeout) set symbol-reloading on" } } #test show symbol-reloading on send "show symbol-reloading\n" expect { -re "Dynamic symbol table reloading multiple times in one run is on..*$prompt $"\ { pass "show symbol-reloading (on)" } -re ".*$prompt $" { fail "show symbol-reloading (on)" } timeout { fail "(timeout) show symbol-reloading (on)" } } #test show user send "show user\n" expect { -re "$prompt $" { pass "show user" } -re ".*$prompt $" { fail "show user" } timeout { fail "(timeout) show user" } } #test set verbose on send "set verbose on\n" expect { -re "$prompt $" { pass "set verbose on" } -re ".*$prompt $" { fail "set verbose on" } timeout { fail "(timeout) set verbose on" } } #test show verbose on send "show verbose\n" expect { -re "Verbose printing of informational messages is on..*$prompt $"\ { pass "show verbose (on)" } -re ".*$prompt $" { fail "show verbose (on)" } timeout { fail "(timeout) show verbose (on)" } } #test set verbose off send "set verbose off\n" expect { -re "$prompt $" { pass "set verbose off" } -re ".*$prompt $" { fail "set verbose off" } timeout { fail "(timeout) set verbose off" } } #test show verbose off send "show verbose\n" expect { -re "Verbosity is off..*$prompt $"\ { pass "show verbose (off)" } -re ".*$prompt $" { fail "show verbose (off)" } timeout { fail "(timeout) show verbose (off)" } }