From: Michael Snyder Date: Mon, 24 May 2010 22:06:59 +0000 (+0000) Subject: 2010-05-24 Michael Snyder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a76e022adf3f91ab44ae8b95e7a5bdc2e06b7136;p=binutils-gdb.git 2010-05-24 Michael Snyder * gdb.base/default.exp: Replace send_gdb with gdb_test. * gdb.base/define.exp: Replace send_gdb with gdb_test. * gdb.base/display.exp: Replace send_gdb with gdb_test. * gdb.base/dump.exp: Replace send_gdb with gdb_test. * gdb.base/ending-run.exp: Replace send_gdb with gdb_test. * gdb.base/eval-skip.exp: Replace send_gdb with gdb_test. * gdb.base/exprs.exp: Replace send_gdb with gdb_test. * gdb.base/fileio.exp: Replace send_gdb with gdb_test. * gdb.base/finish.exp: Replace send_gdb with gdb_test. * gdb.base/foll-fork.exp: Replace send_gdb with gdb_test. * gdb.base/funcargs.exp: Replace send_gdb with gdb_test. * gdb.base/gcore-buffer-overflow.exp: Replace send_gdb with gdb_test. * gdb.base/gcore.exp: Replace send_gdb with gdb_test. * gdb.base/gdb1090.exp: Replace send_gdb with gdb_test. * gdb.base/gdbvars.exp: Replace send_gdb with gdb_test. * gdb.base/help.exp: Replace send_gdb with gdb_test. * gdb.base/info-proc.exp: Replace send_gdb with gdb_test. * gdb.base/jump.exp: Replace send_gdb with gdb_test. * gdb.base/long_long.exp: Replace send_gdb with gdb_test. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4e7326d7cbd..3da5ebd4362 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -14,6 +14,25 @@ * gdb.base/consecutive.exp: Replace send_gdb with gdb_test. * gdb.base/constvars.exp: Replace send_gdb with gdb_test. * gdb.base/corefile.exp: Replace send_gdb with gdb_test. + * gdb.base/default.exp: Replace send_gdb with gdb_test. + * gdb.base/define.exp: Replace send_gdb with gdb_test. + * gdb.base/display.exp: Replace send_gdb with gdb_test. + * gdb.base/dump.exp: Replace send_gdb with gdb_test. + * gdb.base/ending-run.exp: Replace send_gdb with gdb_test. + * gdb.base/eval-skip.exp: Replace send_gdb with gdb_test. + * gdb.base/exprs.exp: Replace send_gdb with gdb_test. + * gdb.base/fileio.exp: Replace send_gdb with gdb_test. + * gdb.base/finish.exp: Replace send_gdb with gdb_test. + * gdb.base/foll-fork.exp: Replace send_gdb with gdb_test. + * gdb.base/funcargs.exp: Replace send_gdb with gdb_test. + * gdb.base/gcore-buffer-overflow.exp: Replace send_gdb with gdb_test. + * gdb.base/gcore.exp: Replace send_gdb with gdb_test. + * gdb.base/gdb1090.exp: Replace send_gdb with gdb_test. + * gdb.base/gdbvars.exp: Replace send_gdb with gdb_test. + * gdb.base/help.exp: Replace send_gdb with gdb_test. + * gdb.base/info-proc.exp: Replace send_gdb with gdb_test. + * gdb.base/jump.exp: Replace send_gdb with gdb_test. + * gdb.base/long_long.exp: Replace send_gdb with gdb_test. 2010-05-21 Tom Tromey diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 2a130071c50..e54f4b6ec97 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -40,22 +40,19 @@ gdb_test "append binary memory" "Missing filename\." gdb_test "append binary value" "Missing filename\." setup_xfail "mips-idt-*" -send_gdb "attach\n" -gdb_expect { +gdb_test_multiple "attach" "attach" { -re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\ - { pass "attach" } + { pass "attach" } -re "You can't do that when your target is `None'.*$gdb_prompt $"\ - { pass "attach" } + { pass "attach" } -re "You can't do that without a process to debug.*$gdb_prompt $"\ - { pass "attach" } + { pass "attach" } -re "Don't know how to attach. Try \"help target\"..*$gdb_prompt $"\ - { pass "attach" } + { pass "attach" } -re "Kill it. .y or n." { send_gdb "y\n" exp_continue } - -re "$gdb_prompt $" { fail "attach" } - timeout { fail "(timeout) attach" } } if ![target_info exists use_gdb_stub] { @@ -117,18 +114,13 @@ gdb_test "define" "Argument required \[(\]name of command to define\[)\]." "defi gdb_test "delete breakpoints" "" "delete breakpoints" #test delete display # FIXME -- need to dump full output to detailed log -send_gdb "delete display\n" -gdb_expect { - -re "Delete all auto-display expressions.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "$gdb_prompt $" { pass "delete display prompt" } - timeout { fail "(timeout) delete display prompt" } - } - } - timeout { fail "(timeout) delete display prompt" } -} +gdb_test "delete display" \ + "" \ + "delete display prompt" \ + "Delete all auto-display expressions.*y or n. $" \ + "y" + #test detach gdb_test "detach" "" "detach" @@ -141,17 +133,11 @@ if [istarget "h8300-*-hms"] then { #test directory # FIXME -- need to dump full output to detailed log -send_gdb "directory\n" -gdb_expect { - -re "Reinitialize source path to empty.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "Source directories searched: .cdir\[:;\].cwd.*$gdb_prompt $"\ - { pass "directory prompt" } - timeout { fail "(timeout) directory prompt" } - } - } -} +gdb_test "directory" \ + "Source directories searched: .cdir\[:;\].cwd.*" \ + "directory prompt" \ + "Reinitialize source path to empty.*y or n. $" \ + "y" #test disable "dis" abbreviation gdb_test "dis" "" "disable \"dis\" abbreviation" @@ -256,26 +242,25 @@ gdb_test "finish" "The program is not being run." "finish" # vary on different systems. gdb_test "forward-search" "No previous regular expression.*|There is no previous regular expression.*" "forward-search" #test gcore -send_gdb "gcore\n" -gdb_expect { + +gdb_test_multiple "gcore" "gcore" { -re "You can\'t do that without a process to debug.*$gdb_prompt $" { pass "gcore" } -re "Undefined command: .*$gdb_prompt $" { pass "gcore" } - default { fail "gcore" } } -send_gdb "generate-core-file\n" -gdb_expect { + +gdb_test_multiple "generate-core-file" "generate-core-file" { -re "You can\'t do that without a process to debug.*$gdb_prompt $" { pass "generate-core-file" } -re "Undefined command: .*$gdb_prompt $" { pass "generate-core-file" } - default { fail "generate-core-file" } } + #test help "h" abbreviation gdb_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" #test help @@ -415,29 +400,20 @@ You must specify a function name to run, and arguments if any"\ gdb_test "set args main" "" "" } else { - send_gdb "r\n" - gdb_expect { - -re "Starting program: .* -You can't do that when your target is `None'.*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Starting program: .* -No executable file specified.* -Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Starting program: .* -No executable specified, use .target exec.\\..*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Starting program: .* -No image loaded into target.*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Starting program: .* -No program loaded.*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re ".*$gdb_prompt $" { fail "run \"r\" abbreviation" } - timeout { fail "(timeout) run \"r\" abbreviation" } - } + gdb_test_multiple "r" "run \"r\" abbreviation" { + -re "Starting program: .*You can't do that when your target is `None'.*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + -re "Starting program: .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + -re "Starting program: .*No executable specified, use .target exec.\\..*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + -re "Starting program: .*No image loaded into target.*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + -re "Starting program: .*No program loaded.*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + -re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\ + { pass "run \"r\" abbreviation" } + } } #test run @@ -449,27 +425,20 @@ You must specify a function name to run, and arguments if any" gdb_test "set args main" "" "" } else { - send_gdb "run\n" - gdb_expect { - -re "Starting program:.*You can't do that when your target is `None'.*$gdb_prompt $" { pass "run" } - -re "Starting program: .* -No executable file specified.* -Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\ - { pass "run" } - -re "Starting program: .* -No executable specified, use .target exec.\\..*$gdb_prompt $"\ - { pass "run" } - -re "Starting program: .* -No image loaded into target.*$gdb_prompt $"\ - { pass "run" } - -re "Starting program: .* -No program loaded.*$gdb_prompt $"\ - { pass "run \"r\" abbreviation" } - -re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\ - { pass "run" } - -re ".*$gdb_prompt $" { fail "run" } - timeout { fail "(timeout) run" } - } + gdb_test_multiple "run" "run" { + -re "Starting program:.*You can't do that when your target is `None'.*$gdb_prompt $"\ + { pass "run" } + -re "Starting program: .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\ + { pass "run" } + -re "Starting program: .*No executable specified, use .target exec.\\..*$gdb_prompt $"\ + { pass "run" } + -re "Starting program: .*No image loaded into target.*$gdb_prompt $"\ + { pass "run" } + -re "Starting program: .*No program loaded.*$gdb_prompt $"\ + { pass "run" } + -re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\ + { pass "run" } + } } #test rbreak @@ -758,34 +727,20 @@ gdb_test "u" "The program is not being run." "until \"u\" abbreviation" gdb_test "until" "The program is not being run." "until" #test undisplay # FIXME -- need to dump full output to detailed log -send_gdb "undisplay\n" -gdb_expect { - -re "Delete all auto-display expressions.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "$gdb_prompt $" { pass "undisplay prompt" } - timeout { fail "(timeout) (timeout) undisplay prompt" } - } - } - timeout { fail "(timeout) (timeout) undisplay prompt" } -} + +gdb_test "undisplay" \ + "" \ + "undisplay prompt" \ + "Delete all auto-display expressions.*y or n. $" \ + "y" #test unset environment -send_gdb "unset environment\n" -gdb_expect { - -re "Delete all environment variables?.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "$gdb_prompt $" { pass "unset environmentprompt" } - timeout { - fail "(timeout) (timeout) unset environment prompt" - } - } - } - timeout { - fail "(timeout) (timeout) unset environment prompt" - } -} + +gdb_test "unset environment" \ + "" \ + "unset environment prompt" \ + "Delete all environment variables?.*y or n. $" \ + "y" #test unset gdb_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" diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 92209b498c7..e4dbd5f18ec 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -59,69 +59,37 @@ if ![runto_main] then { fail "define tests suppressed" } # Verify that GDB allows a user to define their very own commands. # -send_gdb "define nextwhere\n" -gdb_expect { - -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "next\nbt\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "define user command: nextwhere"} - timeout {fail "(timeout) define user command: nextwhere"} - } - } - -re "$gdb_prompt $"\ - {fail "define user command: nextwhere"} - timeout {fail "(timeout) define user command: nextwhere"} +gdb_test_multiple "define nextwhere" "define user command: nextwhere" { + -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "next\nbt\nend" "" \ + "define user command: nextwhere" + } } # Verify that those commands work as gdb_expected. # -send_gdb "nextwhere\n" -gdb_expect { - -re ".*$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*$gdb_prompt $"\ - {pass "use user command: nextwhere"} - -re "$gdb_prompt $"\ - {fail "use user command: nextwhere"} - timeout {fail "(timeout) use user command: nextwhere"} -} +gdb_test "nextwhere" \ + "$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*" \ + "use user command: nextwhere" # Verify that a user can define a command whose spelling is a # proper substring of another user-defined command. # -send_gdb "define nextwh\n" -gdb_expect { - -re "Type commands for definition of \"nextwh\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "next 2\nbt\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "define user command: nextwh"} - timeout {fail "(timeout) define user command: nextwh"} - } - } - -re "$gdb_prompt $"\ - {fail "define user command: nextwh"} - timeout {fail "(timeout) define user command: nextwh"} +gdb_test_multiple "define nextwh" "define user command: nextwh" { + -re "Type commands for definition of \"nextwh\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "next 2\nbt\nend" "" \ + "define user command: nextwh" + } } # Verify that a user can redefine their commands. (Test both the # confirmed and unconfirmed cases.) # -send_gdb "define nextwhere\n" -gdb_expect { - -re "Redefine command \"nextwhere\".*y or n. $"\ - {send_gdb "n\n" - gdb_expect { - -re "Command \"nextwhere\" not redefined.*$gdb_prompt $"\ - {pass "redefine user command aborted: nextwhere"} - -re "$gdb_prompt $"\ - {fail "redefine user command aborted: nextwhere"} - timeout {fail "(timeout) redefine user command aborted: nextwhere"} - } - } - -re "$gdb_prompt $"\ - {fail "redefine user command aborted: nextwhere"} - timeout {fail "(timeout) redefine user command aborted: nextwhere"} -} +gdb_test "define nextwhere" \ + "Command \"nextwhere\" not redefined.*" \ + "redefine user command aborted: nextwhere" \ + "Redefine command \"nextwhere\".*y or n. $" \ + "n" send_gdb "define nextwhere\n" gdb_expect { @@ -147,81 +115,45 @@ gdb_expect { # Verify that GDB gracefully handles an attempt to redefine the # help text for a builtin command. # -send_gdb "document step\n" -gdb_expect { - -re "Command \"step\" is built-in..*$gdb_prompt $"\ - {pass "redocumenting builtin command disallowed"} - -re "$gdb_prompt $"\ - {fail "redocumenting builtin command disallowed"} - timeout {fail "(timeout) redocumenting builtin command disallowed"} -} +gdb_test "document step" "Command \"step\" is built-in.*" \ + "redocumenting builtin command disallowed" # Verify that a user can document their own commands. (And redocument # them.) # -send_gdb "document nextwhere\n" -gdb_expect { - -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "A next command that frist shows you where you're stepping from.\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "document user command: nextwhere"} - timeout {fail "(timeout) document user command: nextwhere"} - } - } - -re "$gdb_prompt $"\ - {fail "document user command: nextwhere"} - timeout {fail "(timeout) document user command: nextwhere"} +gdb_test_multiple "document nextwhere" "document user command: nextwhere" { + -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "A next command that first shows you where you're stepping from.\nend" \ + "" \ + "document user command: nextwhere" + } } -send_gdb "document nextwhere\n" -gdb_expect { - -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "A next command that first shows you where you're stepping from.\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "re-document user command: nextwhere"} - timeout {fail "(timeout) re-document user command: nextwhere"} - } - } - -re "$gdb_prompt $"\ - {fail "re-document user command: nextwhere"} - timeout {fail "(timeout) re-document user command: nextwhere"} +gdb_test_multiple "document nextwhere" "re-document user command: nextwhere" { + -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "A next command that first shows you where you're stepping from.\nend" \ + "" \ + "re-document user command: nextwhere" + } } -send_gdb "help nextwhere\n" -gdb_expect { - -re "A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\ - {pass "help user command: nextwhere"} - -re "$gdb_prompt $"\ - {fail "help user command: nextwhere"} - timeout {fail "(timeout) help user command: nextwhere"} -} +gdb_test "help nextwhere" \ + "A next command that first shows you where you're stepping from.*" \ + "help user command: nextwhere" # Verify that the document command preserves whitespace in the beginning of the line. # -send_gdb "document nextwhere\n" -gdb_expect { - -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb " A next command that first shows you where you're stepping from.\nend\n" - gdb_expect { - -re "$gdb_prompt $" {} - timeout {fail "(timeout) preserve whitespace in help string"} - } - } - -re "$gdb_prompt $"\ - {fail "preserve whitespace in help string"} - timeout {fail "(timeout) preserve whitespace in help string"} +gdb_test_multiple "document nextwhere" "set up whitespace in help string" { + -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test " A next command that first shows you where you're stepping from.\nend" \ + "" \ + "set up whitespace in help string" + } } -send_gdb "help nextwhere\n" -gdb_expect { - -re " A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\ - {pass "preserve whitespace in help string"} - -re "$gdb_prompt $"\ - {fail "preserve whitespace in help string"} - timeout {fail "(timeout) preserve whitespace in help string"} -} +gdb_test "help nextwhere" \ + " A next command that first shows you where you're stepping from.*" \ + "preserve whitespace in help string" # Verify that the command parser doesn't require a space after an 'if' # command in a user defined function. @@ -261,65 +193,34 @@ gdb_test "whilenospace" ".*hi there.*" "test whilenospace is parsed correctly" # hook the "stop" pseudo command, and we'll define it to use a user- # define command. # -send_gdb "define user-bt\n" -gdb_expect { - -re "Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "bt\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "define user command: user-bt"} - timeout {fail "(timeout) define user command: user-bt"} - } - } - -re "$gdb_prompt $"\ - {fail "define user command: user-bt"} - timeout {fail "(timeout) define user command: user-bt"} +gdb_test_multiple "define user-bt" "define user command: user-bt" { + -re "Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "bt\nend" \ + "" \ + "define user command: user-bt" + } } -send_gdb "define hook-stop\n" -gdb_expect { - -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$"\ - {send_gdb "user-b\nend\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "define hook-stop command"} - timeout {fail "(timeout) define hook-stop command"} - } - } - -re "$gdb_prompt $"\ - {fail "define hook-stop command"} - timeout {fail "(timeout) define hook-stop command"} +gdb_test_multiple "define hook-stop" "define hook-stop command" { + -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test "user-b\nend" \ + "" \ + "define hook-stop command" + } } -send_gdb "next\n" -gdb_expect { - -re "#0\[ \t\]*main.*:$bp_location11.*$gdb_prompt $"\ - {pass "use hook-stop command"} - -re "$gdb_prompt $"\ - {fail "use hook-stop command"} - timeout {fail "(timeout) use hook-stop command"} -} +gdb_test "next" "#0\[ \t\]*main.*:$bp_location11.*" \ + "use hook-stop command" # Verify that GDB responds gracefully to an attempt to define a "hook # command" which doesn't exist. (Test both the confirmed and unconfirmed # cases.) # -send_gdb "define hook-bar\n" -gdb_expect { - -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\ - {send_gdb "n\n" - gdb_expect { - -re "Not confirmed.*$gdb_prompt $"\ - {pass "define hook undefined command aborted: bar"} - -re "$gdb_prompt $"\ - {fail "define hook undefined command aborted: bar"} - timeout {fail "(timeout) define hook undefined command aborted: bar"} - } - } - -re "$gdb_prompt $"\ - {fail "define hook undefined command aborted: bar"} - timeout {fail "(timeout) define hook undefined command aborted: bar"} -} +gdb_test "define hook-bar" \ + "Not confirmed.*" \ + "define hook undefined command aborted: bar" \ + "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $" \ + "n" send_gdb "define hook-bar\n" gdb_expect { @@ -378,20 +279,16 @@ gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks" # This is a quasi-define command: Verify that the user can redefine # GDB's gdb_prompt. # -send_gdb "set prompt \\(blah\\) \n" -gdb_expect { - -re "\\(blah\\) $"\ - {pass "set gdb_prompt"} - -re "$gdb_prompt $"\ - {fail "set gdb_prompt"} - timeout {fail "(timeout) set gdb_prompt"} +gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" { + -re "\\(blah\\) $" { + pass "set gdb_prompt" + } } -send_gdb "set prompt \\(gdb\\) \n" -gdb_expect { - -re "$gdb_prompt $"\ - {pass "reset gdb_prompt"} - timeout {fail "(timeout) reset gdb_prompt"} +gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" { + -re "$gdb_prompt $" { + pass "reset gdb_prompt" + } } gdb_exit diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index c1102b44560..434df3c876b 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -112,28 +112,12 @@ gdb_test "info disp" ".*Auto-display expressions now in effect.*y /f f.*y / gdb_test "cont" ".*\[Ww\]atch.*5.1415.*.*i = 0.*" "next hit" -send_gdb "undisp\n" -gdb_expect { - -re ".*Delete all auto-display expressions.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "y\r\n$gdb_prompt $" { - pass "undisp all" - } - -re ".*$gdb_prompt $" { - fail "some un-helpful response" - } - -re ".*Delete all.*$" { - fail "re-ask question" - } - timeout { fail "timeout" } - } - } - -re ".*$gdb_prompt $" { - fail "undisp all" - } - timeout { fail "timeout" } -} +gdb_test "undisp" \ + "" \ + "undisp all" \ + ".*Delete all auto-display expressions.*y or n. $" \ + "y" + gdb_test "disab 3" ".*.*" "disab 3" gdb_test "cont" ".*Breakpoint 4.*" "watch off" @@ -144,8 +128,7 @@ gdb_test "cont" ".*Breakpoint 4.*" "watch off" # targets, including but not limited to the m68k, i386 & PA. So we # have to arrange to step until we hit the line with the call to # "do_vars". -send_gdb "finish\n" -gdb_expect { +gdb_test_multiple "finish" "finish" { -re ".*do_loops\\(\\);.*$gdb_prompt $" { send_gdb "step\n" exp_continue @@ -153,14 +136,6 @@ gdb_expect { -re ".*do_vars.*$gdb_prompt $" { pass "finish" } - -re ".*$gdb_prompt $" { - fail "finish" - gdb_suppress_tests - } - timeout { - fail "(timeout) finish" - gdb_suppress_tests - } } gdb_test "step" ".*do_vars.*.*i = 9.*" diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 624c7e3bacf..384db3fe17b 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -77,15 +77,11 @@ if { ! [ runto checkpoint1 ] } then { # Get the endianness for the later use with endianless formats. -send_gdb "show endian\n" -gdb_expect { +gdb_test_multiple "show endian" "show endian" { -re ".* (big|little) endian.*$gdb_prompt $" { set endian $expect_out(1,string) pass "endianness: $endian" } - default { - fail "(timeout) getting target endianness" - } } # Now generate some dump files. @@ -93,13 +89,11 @@ gdb_expect { proc make_dump_file { command msg } { global gdb_prompt - send_gdb "${command}\n" - gdb_expect { + gdb_test_multiple "${command}" "$msg" { -re ".*\[Ee\]rror.*$gdb_prompt $" { fail $msg } -re ".*\[Ww\]arning.*$gdb_prompt $" { fail $msg } -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg } - -re ".*$gdb_prompt $" { pass $msg } - timeout { fail "$msg (timeout)" } + -re ".*$gdb_prompt $" { pass $msg } } } @@ -210,14 +204,10 @@ gdb_file_cmd ${binfile} # Now fix the endianness at the correct state. -send_gdb "set endian $endian\n" -gdb_expect { +gdb_test_multiple "set endian $endian" "set endianness" { -re ".* (big|little) endian.*$gdb_prompt $" { pass "setting $endian endianness" } - default { - fail "(timeout) setting $endian endianness" - } } # Reload saved values one by one, and compare. diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp index a60e704bdd6..bdc3f3f5f9f 100644 --- a/gdb/testsuite/gdb.base/ending-run.exp +++ b/gdb/testsuite/gdb.base/ending-run.exp @@ -51,17 +51,13 @@ gdb_run_cmd gdb_test "" ".*Breakpoint.*1.*callee.*14.*" "run" gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked" -send_gdb "i b\n" -gdb_expect { +gdb_test_multiple "i b" "cleared bp at line before routine" { -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { fail "cleared bp at line before routine" } -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" } - -re ".*$gdb_prompt $" { - fail "cleared bp at line before routine (info b)" - } } # Test some other "clear" combinations @@ -71,8 +67,7 @@ gdb_test "b ending-run.c:14" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:14, gdb_test "cle ending-run.c:14" \ ".*Deleted breakpoint 5.*" "Cleared 2 by line" -send_gdb "info line ending-run.c:14\n" -gdb_expect { +gdb_test_multiple "info line ending-run.c:14" "" { -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { set line_nine $expect_out(1,string) gdb_test "b ending-run.c:14" ".*Breakpoint 6.*ending-run.c, line 14.*" @@ -84,8 +79,7 @@ gdb_expect { } } -send_gdb "i b\n" -gdb_expect { +gdb_test_multiple "i b" "all set to continue" { -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { fail "all set to continue (didn't clear bps)" } @@ -117,9 +111,9 @@ if ![gdb_skip_stdio_test "Step to return"] { set old_timeout $timeout set timeout 50 set program_exited 0 -send_gdb "next\n" set nexted 0 -gdb_expect { + +gdb_test_multiple "next" "step out of main" { -re "33\[ \t\]+\}.*$gdb_prompt $" { # sometimes we stop at the closing brace, if so, do another next if { $nexted } { @@ -201,8 +195,6 @@ gdb_expect { -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { pass "step out of main" } - -re ".*$gdb_prompt $" { fail "step out of main" } - timeout { fail "step out of main" } } # When we're talking to a program running on a real stand-alone board, @@ -216,8 +208,7 @@ if {! [target_info exists use_gdb_stub] && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { global program_exited; if {[eval expr $program_exited == 0]} { - send_gdb "n\n" - gdb_expect { + gdb_test_multiple "n" "step to end of run" { -re "Program exited normally.*$gdb_prompt $" { # If we actually have debug info for the start function, # then we won't get the "Single-stepping until function @@ -246,14 +237,6 @@ if {! [target_info exists use_gdb_stub] set program_exited_normally 1 } } - -re ".*$gdb_prompt $" { - fail "step to end of run" - set program_not_exited 1 - } - timeout { - fail "(timeout) step to end of run" - set program_not_exited 1 - } } } diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp index d1e6d2efd2e..ade7c3290d3 100644 --- a/gdb/testsuite/gdb.base/eval-skip.exp +++ b/gdb/testsuite/gdb.base/eval-skip.exp @@ -65,278 +65,87 @@ gdb_test "set variable y=2" "" "set variable y=2" gdb_test "set variable z=2" "" "set variable z=2" gdb_test "set variable w=3" "" "set variable w=3" -send_gdb "print (0 && (x+y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x+y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x+y))" } - timeout { fail "(timeout) print value of (0 && (x+y))" } - } - - -send_gdb "print (0 && (x-y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x-y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x-y))" } - timeout { fail "(timeout) print value of (0 && (x-y))" } - } - - -send_gdb "print (0 && (x*y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x*y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x*y))" } - timeout { fail "(timeout) print value of (0 && (x*y))" } - } - - - -send_gdb "print (0 && (x/y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x/y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x/y))" } - timeout { fail "(timeout) print value of (0 && (x/y))" } - } - - -send_gdb "print (0 && (x%y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x%y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x%y))" } - timeout { fail "(timeout) print value of (0 && (x%y))" } - } - - -send_gdb "print (0 && (x&&y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x&&y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x&&y))" } - timeout { fail "(timeout) print value of (0 && (x&&y))" } - } - - - -send_gdb "print (0 && (x||y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x||y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x||y))" } - timeout { fail "(timeout) print value of (0 && (x||y))" } - } - - - -send_gdb "print (0 && (x&y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x&y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x&y))" } - timeout { fail "(timeout) print value of (0 && (x&y))" } - } - - -send_gdb "print (0 && (x|y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x|y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x|y))" } - timeout { fail "(timeout) print value of (0 && (x|y))" } - } - - -send_gdb "print (0 && (x^y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x^y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x^y))" } - timeout { fail "(timeout) print value of (0 && (x^y))" } - } - - - -send_gdb "print (0 && (x < y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x < y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x < y))" } - timeout { fail "(timeout) print value of (0 && (x < y))" } - } - - -send_gdb "print (0 && (x <= y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x <= y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x <= y))" } - timeout { fail "(timeout) print value of (0 && (x <= y))" } - } - - - -send_gdb "print (0 && (x>y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x>y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x>y))" } - timeout { fail "(timeout) print value of (0 && (x>y))" } - } - - -send_gdb "print (0 && (x>=y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x>=y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x>=y))" } - timeout { fail "(timeout) print value of (0 && (x>=y))" } - } - - - -send_gdb "print (0 && (x==y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x==y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x==y))" } - timeout { fail "(timeout) print value of (0 && (x==y))" } - } - - -send_gdb "print (0 && (x!=y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x!=y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x!=y))" } - timeout { fail "(timeout) print value of (0 && (x!=y))" } - } - - -send_gdb "print (0 && (x<<31))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x<<31))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x<<31))" } - timeout { fail "(timeout) print value of (0 && (x<<31))" } - } - - -send_gdb "print (0 && (x>>31))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x>>31))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x>>31))" } - timeout { fail "(timeout) print value of (0 && (x>>31))" } - } - - - -send_gdb "print (0 && (!x))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (!x))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (!x))" } - timeout { fail "(timeout) print value of (0 && (!x))" } - } - - -send_gdb "print (0 && (~x))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (~x))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (~x))" } - timeout { fail "(timeout) print value of (0 && (~x))" } - } - -send_gdb "print (0 && (-x))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (-x))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (-x))" } - timeout { fail "(timeout) print value of (0 && (-x))" } - } - - -send_gdb "print (0 && (x++))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x++))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x++))" } - timeout { fail "(timeout) print value of (0 && (x++))" } - } - - -send_gdb "print (0 && (++x))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (++x))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (++x))" } - timeout { fail "(timeout) print value of (0 && (++x))" } - } - - -send_gdb "print (0 && (x--))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x--))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x--))" } - timeout { fail "(timeout) print value of (0 && (x--))" } - } - - -send_gdb "print (0 && (--x))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (--x))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (--x))" } - timeout { fail "(timeout) print value of (0 && (--x))" } - } - -send_gdb "print (0 && (x+=7))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x+=7))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x+=7))" } - timeout { fail "(timeout) print value of (0 && (x+=7))" } - } - -send_gdb "print (0 && (x=y))\n" -gdb_expect { - -re ".$decimal = $false\r\n$gdb_prompt $" { - pass "print value of (0 && (x=y))" - } - -re ".*$gdb_prompt $" { fail "print value of (0 && (x=y))" } - timeout { fail "(timeout) print value of (0 && (x=y))" } - } +gdb_test "print (0 && (x+y))" ".$decimal = $false" \ + "print value of (0 && (x+y))" + +gdb_test "print (0 && (x-y))" ".$decimal = $false" \ + "print value of (0 && (x-y))" + +gdb_test "print (0 && (x*y))" ".$decimal = $false" \ + "print value of (0 && (x*y))" + +gdb_test "print (0 && (x/y))" ".$decimal = $false" \ + "print value of (0 && (x/y))" + +gdb_test "print (0 && (x%y))" ".$decimal = $false" \ + "print value of (0 && (x%y))" + +gdb_test "print (0 && (x&&y))" ".$decimal = $false" \ + "print value of (0 && (x&&y))" + +gdb_test "print (0 && (x||y))" ".$decimal = $false" \ + "print value of (0 && (x||y))" + +gdb_test "print (0 && (x&y))" ".$decimal = $false" \ + "print value of (0 && (x&y))" + +gdb_test "print (0 && (x|y))" ".$decimal = $false" \ + "print value of (0 && (x|y))" + +gdb_test "print (0 && (x^y))" ".$decimal = $false" \ + "print value of (0 && (x^y))" + +gdb_test "print (0 && (x < y))" ".$decimal = $false" \ + "print value of (0 && (x < y))" + +gdb_test "print (0 && (x <= y))" ".$decimal = $false" \ + "print value of (0 && (x <= y))" + +gdb_test "print (0 && (x>y))" ".$decimal = $false" \ + "print value of (0 && (x>y))" + +gdb_test "print (0 && (x>=y))" ".$decimal = $false" \ + "print value of (0 && (x>=y))" + +gdb_test "print (0 && (x==y))" ".$decimal = $false" \ + "print value of (0 && (x==y))" + +gdb_test "print (0 && (x!=y))" ".$decimal = $false" \ + "print value of (0 && (x!=y))" + +gdb_test "print (0 && (x<<31))" ".$decimal = $false" \ + "print value of (0 && (x<<31))" + +gdb_test "print (0 && (x>>31))" ".$decimal = $false" \ + "print value of (0 && (x>>31))" + +gdb_test "print (0 && (!x))" ".$decimal = $false" \ + "print value of (0 && (!x))" + +gdb_test "print (0 && (~x))" ".$decimal = $false" \ + "print value of (0 && (~x))" + +gdb_test "print (0 && (-x))" ".$decimal = $false" \ + "print value of (0 && (-x))" + +gdb_test "print (0 && (x++))" ".$decimal = $false" \ + "print value of (0 && (x++))" + +gdb_test "print (0 && (++x))" ".$decimal = $false" \ + "print value of (0 && (++x))" + +gdb_test "print (0 && (x--))" ".$decimal = $false" \ + "print value of (0 && (x--))" + +gdb_test "print (0 && (--x))" ".$decimal = $false" \ + "print value of (0 && (--x))" + +gdb_test "print (0 && (x+=7))" ".$decimal = $false" \ + "print value of (0 && (x+=7))" + +gdb_test "print (0 && (x=y))" ".$decimal = $false" \ + "print value of (0 && (x=y))" + gdb_exit return 0 diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index 4841ecceadd..a872d1355ca 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -225,8 +225,8 @@ test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$ # sizeof(long long) and sizeof(void*) are # the same size so this test can not work. # -send_gdb "print sizeof (long long) > sizeof (long)\n" -gdb_expect { +gdb_test_multiple "print sizeof (long long) > sizeof (long)" \ + "sizeof long long > sizeof long" { -re "\\$\[0-9\]* = $true.*$gdb_prompt" { set ok 1 pass "sizeof (long long) > sizeof (long) (true)" @@ -235,10 +235,6 @@ gdb_expect { set ok 0 pass "sizeof (long long) > sizeof (long) (false)" } - timeout { - set ok 0 - fail "sizeof (long long) > sizeof (long) (timeout)" - } } if [expr ! $ok] { setup_xfail "*-*-*" } gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \ diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index 2a2e0ae1b0b..bd1876cfc88 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -54,17 +54,17 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" -send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" -send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" - +gdb_test_no_output "set print sevenbit-strings" +gdb_test_no_output "set print address off" +gdb_test_no_output "set width 0" if ![runto_main] then { perror "couldn't run to breakpoint" continue } -send_gdb "break stop\n" ; gdb_expect -re "Breakpoint .*$srcfile.*$gdb_prompt $" +gdb_test "break stop" "Breakpoint .*$srcfile.*" + set stop_msg ".*Breakpoint .* stop \\(\\) at.*$srcfile:.*static void stop \\(\\) {}.*" gdb_test continue \ @@ -83,7 +83,8 @@ gdb_test continue \ "Continuing\\..*open 4:.*ENOENT$stop_msg" \ "Opening nonexistant file returns ENOENT" -send_gdb "continue\n" ; gdb_expect -re "$gdb_prompt $" +gdb_test "continue" "" "" + catch "system \"chmod -f -w nowrt.fileio.test\"" gdb_test continue \ @@ -179,7 +180,8 @@ gdb_test continue \ "Continuing\\..*system 1:.*OK$stop_msg" \ "System says shell is available" -send_gdb "set remote system-call-allowed 1\n"; gdb_expect -re ".*$gdb_prompt $" +gdb_test_no_output "set remote system-call-allowed 1" + gdb_test continue \ "Continuing\\..*system 2:.*OK$stop_msg" \ "System(3) call" diff --git a/gdb/testsuite/gdb.base/finish.exp b/gdb/testsuite/gdb.base/finish.exp index 9b6b5f90a89..83893b8c828 100644 --- a/gdb/testsuite/gdb.base/finish.exp +++ b/gdb/testsuite/gdb.base/finish.exp @@ -32,8 +32,7 @@ proc finish_1 { type } { "set break on ${type}_func" gdb_test "continue" "Breakpoint.* ${type}_func.*" \ "continue to ${type}_func" - send_gdb "finish\n" - gdb_expect { + gdb_test_multiple "finish" "finish from ${type}_func" { -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" { if { $type == "char" } { pass "finish from char_func" @@ -51,12 +50,6 @@ proc finish_1 { type } { -re ".*Value returned is .* = 1\r\n$gdb_prompt $" { pass "finish from ${type}_func" } - -re ".*$gdb_prompt $" { - fail "finish from ${type}_func" - } - timeout { - fail "finish from ${type}_func (timeout)" - } } } @@ -67,24 +60,17 @@ proc finish_void { } { "set break on void_func" gdb_test "continue" "Breakpoint.* void_func.*" \ "continue to void_func" - send_gdb "finish\n" # Some architectures will have one or more instructions after the # call instruction which still is part of the call sequence, so we # must be prepared for a "finish" to show us the void_func call # again as well as the statement after. - gdb_expect { + gdb_test_multiple "finish" "finish from void_func" { -re ".*void_checkpoint.*$gdb_prompt $" { pass "finish from void_func" } -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" { pass "finish from void_func" } - -re ".*$gdb_prompt $" { - fail "finish from void_func" - } - timeout { - fail "finish from void_func (timeout)" - } } } diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp index e3de7f32ea0..90f001920f5 100644 --- a/gdb/testsuite/gdb.base/foll-fork.exp +++ b/gdb/testsuite/gdb.base/foll-fork.exp @@ -61,369 +61,276 @@ proc check_fork_catchpoints {} { } proc default_fork_parent_follow {} { - global gdb_prompt - - send_gdb "show follow-fork\n" - gdb_expect { - -re "Debugger response to a program call of fork or vfork is \"parent\"..*$gdb_prompt $"\ - {pass "default show parent follow, no catchpoints"} - -re "$gdb_prompt $" {fail "default show parent follow, no catchpoints"} - timeout {fail "(timeout) default show parent follow, no catchpoints"} - } - send_gdb "next 2\n" - gdb_expect { - -re "Detaching after fork from.*$gdb_prompt $"\ - {pass "default parent follow, no catchpoints"} - -re "$gdb_prompt $" {fail "default parent follow, no catchpoints"} - timeout {fail "(timeout) default parent follow, no catchpoints" } - } - # The child has been detached; allow time for any output it might - # generate to arrive, so that output doesn't get confused with - # any expected debugger output from a subsequent testpoint. - # - exec sleep 1 + global gdb_prompt + + gdb_test "show follow-fork" \ + "Debugger response to a program call of fork or vfork is \"parent\".*" \ + "default show parent follow, no catchpoints" + + gdb_test "next 2" \ + "Detaching after fork from.*" \ + "default parent follow, no catchpoints" + + # The child has been detached; allow time for any output it might + # generate to arrive, so that output doesn't get confused with + # any expected debugger output from a subsequent testpoint. + # + exec sleep 1 } proc explicit_fork_parent_follow {} { - global gdb_prompt - - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork parent"} - timeout {fail "(timeout) set follow-fork parent"} - } - send_gdb "show follow-fork\n" - gdb_expect { - -re "Debugger response to a program call of fork or vfork is \"parent\"..*$gdb_prompt $"\ - {pass "explicit show parent follow, no catchpoints"} - -re "$gdb_prompt $" {fail "explicit show parent follow, no catchpoints"} - timeout {fail "(timeout) explicit show parent follow, no catchpoints"} - } - send_gdb "next 2\n" - gdb_expect { - -re "Detaching after fork from.*$gdb_prompt $"\ - {pass "explicit parent follow, no catchpoints"} - -re "$gdb_prompt $" {fail "explicit parent follow, no catchpoints"} - timeout {fail "(timeout) explicit parent follow, no catchpoints"} - } - # The child has been detached; allow time for any output it might - # generate to arrive, so that output doesn't get confused with - # any expected debugger output from a subsequent testpoint. - # - exec sleep 1 + global gdb_prompt + + gdb_test_no_output "set follow-fork parent" + + gdb_test "show follow-fork" \ + "Debugger response to a program call of fork or vfork is \"parent\"." \ + "explicit show parent follow, no catchpoints" + + gdb_test "next 2" "Detaching after fork from.*" \ + "explicit parent follow, no catchpoints" + + # The child has been detached; allow time for any output it might + # generate to arrive, so that output doesn't get confused with + # any expected debugger output from a subsequent testpoint. + # + exec sleep 1 } proc explicit_fork_child_follow {} { - global gdb_prompt - - send_gdb "set follow-fork child\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork child"} - timeout {fail "(timeout) set follow-fork child"} - } - send_gdb "show follow-fork\n" - gdb_expect { - -re "Debugger response to a program call of fork or vfork is \"child\"..*$gdb_prompt $"\ - {pass "explicit show child follow, no catchpoints"} - -re "$gdb_prompt $" {fail "explicit show child follow, no catchpoints"} - timeout {fail "(timeout) explicit show child follow, no catchpoints"} - } - send_gdb "next 2\n" - gdb_expect { - -re "Attaching after.* fork to.*$gdb_prompt $"\ - {pass "explicit child follow, no catchpoints"} - -re "$gdb_prompt $" {fail "explicit child follow, no catchpoints"} - timeout {fail "(timeout) explicit child follow, no catchpoints"} - } - # The child has been detached; allow time for any output it might - # generate to arrive, so that output doesn't get confused with - # any gdb_expected debugger output from a subsequent testpoint. - # - exec sleep 1 + global gdb_prompt + + gdb_test_no_output "set follow-fork child" + + gdb_test "show follow-fork" \ + "Debugger response to a program call of fork or vfork is \"child\"." \ + "explicit show child follow, no catchpoints" + + gdb_test "next 2" "Attaching after.* fork to.*" \ + "explicit child follow, no catchpoints" + + # The child has been detached; allow time for any output it might + # generate to arrive, so that output doesn't get confused with + # any gdb_expected debugger output from a subsequent testpoint. + # + exec sleep 1 } proc catch_fork_child_follow {} { - global gdb_prompt - global srcfile - - set bp_after_fork [gdb_get_line_number "set breakpoint here"] - - send_gdb "catch fork\n" - gdb_expect { - -re "Catchpoint .*(fork).*$gdb_prompt $"\ - {pass "explicit child follow, set catch fork"} - -re "$gdb_prompt $" {fail "explicit child follow, set catch fork"} - timeout {fail "(timeout) explicit child follow, set catch fork"} - } - - # Verify that the catchpoint is mentioned in an "info breakpoints", - # and further that the catchpoint mentions no process id. - # - set test_name "info shows catchpoint without pid" - gdb_test_multiple "info breakpoints" "$test_name" { - -re ".*catchpoint.*keep y.*fork\[\r\n\]+$gdb_prompt $" { - pass "$test_name" - } - } - - send_gdb "continue\n" - gdb_expect { - -re "Catchpoint.*(forked process.*),.*in .*(fork|__kernel_v?syscall).*$gdb_prompt $"\ - {pass "explicit child follow, catch fork"} - -re "$gdb_prompt $" {fail "explicit child follow, catch fork"} - timeout {fail "(timeout) explicit child follow, catch fork"} - } - - # Verify that the catchpoint is mentioned in an "info breakpoints", - # and further that the catchpoint managed to capture a process id. - # - set test_name "info shows catchpoint without pid" - gdb_test_multiple "info breakpoints" "$test_name" { - -re ".*catchpoint.*keep y.*fork, process.*$gdb_prompt $" { - pass "$test_name" - } - } - - send_gdb "set follow-fork child\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork child"} - timeout {fail "(timeout) set follow-fork child"} - } - send_gdb "tbreak ${srcfile}:$bp_after_fork\n" - gdb_expect { - -re "Temporary breakpoint.*, line $bp_after_fork.*$gdb_prompt $"\ - {pass "set follow-fork child, tbreak"} - -re "$gdb_prompt $" {fail "set follow-fork child, tbreak"} - timeout {fail "(timeout) set follow-fork child, tbreak"} - } - send_gdb "continue\n" - gdb_expect { - -re "Attaching after.* fork to.* at .*$bp_after_fork.*$gdb_prompt $"\ - {pass "set follow-fork child, hit tbreak"} - -re "$gdb_prompt $" {fail "set follow-fork child, hit tbreak"} - timeout {fail "(timeout) set follow-fork child, hit tbreak"} - } - # The parent has been detached; allow time for any output it might - # generate to arrive, so that output doesn't get confused with - # any expected debugger output from a subsequent testpoint. - # - exec sleep 1 - send_gdb "delete breakpoints\n" - gdb_expect { - -re "Delete all breakpoints.*$" { - send_gdb "y\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "set follow-fork child, cleanup"} - timeout {fail "(timeout) set follow-fork child, cleanup"} - } - } - -re "$gdb_prompt $" {fail "set follow-fork child, cleanup"} - timeout {fail "(timeout) set follow-fork child, cleanup"} - } + global gdb_prompt + global srcfile + + set bp_after_fork [gdb_get_line_number "set breakpoint here"] + + gdb_test "catch fork" "Catchpoint .*(fork).*" \ + "explicit child follow, set catch fork" + + # Verify that the catchpoint is mentioned in an "info breakpoints", + # and further that the catchpoint mentions no process id. + # + set test_name "info shows catchpoint without pid" + gdb_test_multiple "info breakpoints" "$test_name" { + -re ".*catchpoint.*keep y.*fork\[\r\n\]+$gdb_prompt $" { + pass "$test_name" + } + } + + gdb_test "continue" \ + "Catchpoint.*(forked process.*),.*in .*(fork|__kernel_v?syscall).*" \ + "explicit child follow, catch fork" + + # Verify that the catchpoint is mentioned in an "info breakpoints", + # and further that the catchpoint managed to capture a process id. + # + set test_name "info shows catchpoint without pid" + gdb_test_multiple "info breakpoints" "$test_name" { + -re ".*catchpoint.*keep y.*fork, process.*$gdb_prompt $" { + pass "$test_name" + } + } + + gdb_test_no_output "set follow-fork child" + + gdb_test "tbreak ${srcfile}:$bp_after_fork" \ + "Temporary breakpoint.*, line $bp_after_fork.*" \ + "set follow-fork child, tbreak" + + gdb_test "continue" \ + "Attaching after.* fork to.* at .*$bp_after_fork.*" \ + "set follow-fork child, hit tbreak" + + # The parent has been detached; allow time for any output it might + # generate to arrive, so that output doesn't get confused with + # any expected debugger output from a subsequent testpoint. + # + exec sleep 1 + + gdb_test "delete breakpoints" \ + "" \ + "set follow-fork child, cleanup" \ + "Delete all breakpoints.*$" \ + "y" } proc catch_fork_unpatch_child {} { - global gdb_prompt - global srcfile - - set bp_exit [gdb_get_line_number "at exit"] - - gdb_test "break callee" "file .*$srcfile, line .*" "unpatch child, break at callee" - gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "unpatch child, set catch fork" - - gdb_test "continue" \ - "Catchpoint.*\\(forked process.*\\).*,.*in .*(fork|__kernel_v?syscall).*" \ - "unpatch child, catch fork" - - # Delete all breakpoints and catchpoints. - delete_breakpoints - - # Force $srcfile as the current GDB source can be in glibc sourcetree. - gdb_test "break $srcfile:$bp_exit" \ - "Breakpoint .*file .*$srcfile, line .*" \ - "unpatch child, breakpoint at exit call" - - gdb_test "set follow-fork child" "" "unpatch child, set follow-fork child" - - set test "unpatch child, unpatched parent breakpoints from child" - gdb_test_multiple "continue" $test { - -re "at exit.*$gdb_prompt $" { - pass "$test" - } - -re "SIGTRAP.*$gdb_prompt $" { - fail "$test" - - # Explicitly kill this child, so we can continue gracefully - # with further testing... - send_gdb "kill\n" - gdb_expect { - -re ".*Kill the program being debugged.*y or n. $" { - send_gdb "y\n" - gdb_expect -re "$gdb_prompt $" {} - } - } - } - -re ".*$gdb_prompt $" { - fail "$test (unknown output)" - } - timeout { - fail "$test (timeout)" - } - } + global gdb_prompt + global srcfile + + set bp_exit [gdb_get_line_number "at exit"] + + gdb_test "break callee" "file .*$srcfile, line .*" \ + "unpatch child, break at callee" + gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" \ + "unpatch child, set catch fork" + + gdb_test "continue" \ + "Catchpoint.*\\(forked process.*\\).*,.*in .*(fork|__kernel_v?syscall).*" \ + "unpatch child, catch fork" + + # Delete all breakpoints and catchpoints. + delete_breakpoints + + # Force $srcfile as the current GDB source can be in glibc sourcetree. + gdb_test "break $srcfile:$bp_exit" \ + "Breakpoint .*file .*$srcfile, line .*" \ + "unpatch child, breakpoint at exit call" + + gdb_test "set follow-fork child" "" "unpatch child, set follow-fork child" + + set test "unpatch child, unpatched parent breakpoints from child" + gdb_test_multiple "continue" $test { + -re "at exit.*$gdb_prompt $" { + pass "$test" + } + -re "SIGTRAP.*$gdb_prompt $" { + fail "$test" + + # Explicitly kill this child, so we can continue gracefully + # with further testing... + send_gdb "kill\n" + gdb_expect { + -re ".*Kill the program being debugged.*y or n. $" { + send_gdb "y\n" + gdb_expect -re "$gdb_prompt $" {} + } + } + } + } } proc tcatch_fork_parent_follow {} { - global gdb_prompt - global srcfile - - set bp_after_fork [gdb_get_line_number "set breakpoint here"] - - send_gdb "catch fork\n" - gdb_expect { - -re "Catchpoint .*(fork).*$gdb_prompt $"\ - {pass "explicit parent follow, set tcatch fork"} - -re "$gdb_prompt $" {fail "explicit parent follow, set tcatch fork"} - timeout {fail "(timeout) explicit parent follow, set tcatch fork"} - } + global gdb_prompt + global srcfile + + set bp_after_fork [gdb_get_line_number "set breakpoint here"] + + gdb_test "catch fork" "Catchpoint .*(fork).*" \ + "explicit parent follow, set tcatch fork" + # ??rehrauer: I don't yet know how to get the id of the tcatch # via this script, so that I can add a -do list to it. For now, # do the follow stuff after the catch happens. - send_gdb "continue\n" - gdb_expect { - -re ".*in .*(fork|__kernel_v?syscall).*$gdb_prompt $"\ - {pass "explicit parent follow, tcatch fork"} - -re "$gdb_prompt $" {fail "explicit parent follow, tcatch fork"} - timeout {fail "(timeout) explicit parent follow, tcatch fork"} - } - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork parent"} - timeout {fail "(timeout) set follow-fork parent"} - } - send_gdb "tbreak ${srcfile}:$bp_after_fork\n" - gdb_expect { - -re "Temporary breakpoint.*, line $bp_after_fork.*$gdb_prompt $"\ - {pass "set follow-fork parent, tbreak"} - -re "$gdb_prompt $" {fail "set follow-fork parent, tbreak"} - timeout {fail "(timeout) set follow-fork child, tbreak"} - } - send_gdb "continue\n" - gdb_expect { - -re ".*Detaching after fork from.* at .*$bp_after_fork.*$gdb_prompt $"\ - {pass "set follow-fork parent, hit tbreak"} - -re "$gdb_prompt $" {fail "set follow-fork parent, hit tbreak"} - timeout {fail "(timeout) set follow-fork parent, hit tbreak"} - } - # The child has been detached; allow time for any output it might - # generate to arrive, so that output doesn't get confused with - # any expected debugger output from a subsequent testpoint. - # - exec sleep 1 - send_gdb "delete breakpoints\n" - gdb_expect { - -re "Delete all breakpoints.*$" { - send_gdb "y\n" - gdb_expect { - -re "$gdb_prompt $"\ - {pass "set follow-fork parent, cleanup"} - timeout {fail "(timeout) set follow-fork parent, cleanup"} - } - } - -re "$gdb_prompt $" {fail "set follow-fork parent, cleanup"} - timeout {fail "(timeout) set follow-fork parent, cleanup"} - } + gdb_test "continue" "in .*(fork|__kernel_v?syscall).*" \ + "explicit parent follow, tcatch fork" + + gdb_test_no_output "set follow-fork parent" + + gdb_test "tbreak ${srcfile}:$bp_after_fork" \ + "Temporary breakpoint.*, line $bp_after_fork.*" \ + "set follow-fork parent, tbreak" + + gdb_test "continue" \ + "Detaching after fork from.* at .*$bp_after_fork.*" \ + "set follow-fork parent, hit tbreak" + + # The child has been detached; allow time for any output it might + # generate to arrive, so that output doesn't get confused with + # any expected debugger output from a subsequent testpoint. + # + exec sleep 1 + + gdb_test "delete breakpoints" \ + "" \ + "set follow-fork parent, cleanup" \ + "Delete all breakpoints.*$" \ + "y" } proc do_fork_tests {} { - global gdb_prompt + global gdb_prompt - # Verify that help is available for "set follow-fork-mode". - # - send_gdb "help set follow-fork-mode\n" - gdb_expect { - -re "Set debugger response to a program call of fork or vfork..* + # Verify that help is available for "set follow-fork-mode". + # + gdb_test "help set follow-fork-mode" \ + "Set debugger response to a program call of fork or vfork..* A fork or vfork creates a new process. follow-fork-mode can be:.* .*parent - the original process is debugged after a fork.* .*child - the new process is debugged after a fork.* The unfollowed process will continue to run..* -By default, the debugger will follow the parent process..*$gdb_prompt $"\ - { pass "help set follow-fork" } - -re "$gdb_prompt $" { fail "help set follow" } - timeout { fail "(timeout) help set follow-fork" } - } - - # Verify that we can set follow-fork-mode, using an abbreviation - # for both the flag and its value. - # - send_gdb "set follow-fork ch\n" - send_gdb "show follow-fork\n" - gdb_expect { - -re "Debugger response to a program call of fork or vfork is \"child\".*$gdb_prompt $"\ - {pass "set follow-fork, using abbreviations"} - timeout {fail "(timeout) set follow-fork, using abbreviations"} - } - - # Verify that we cannot set follow-fork-mode to nonsense. - # - send_gdb "set follow-fork chork\n" - gdb_expect { - -re "Undefined item: \"chork\".*$gdb_prompt $"\ - {pass "set follow-fork to nonsense is prohibited"} - -re "$gdb_prompt $" {fail "set follow-fork to nonsense is prohibited"} - timeout {fail "(timeout) set follow-fork to nonsense is prohibited"} - } - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork to nonsense is prohibited (reset parent)"} - timeout {fail "set follow-fork to nonsense is prohibited (reset parent)"} - } - - # Check that fork catchpoints are supported, as an indicator for whether - # fork-following is supported. - if [runto_main] then { check_fork_catchpoints } - - # Test the default behaviour, which is to follow the parent of a - # fork, and detach from the child. Do this without catchpoints. - # - if [runto_main] then { default_fork_parent_follow } - - # Test the ability to explicitly follow the parent of a fork, and - # detach from the child. Do this without catchpoints. - # - if [runto_main] then { explicit_fork_parent_follow } - - # Test the ability to follow the child of a fork, and detach from - # the parent. Do this without catchpoints. - # - if [runto_main] then { explicit_fork_child_follow } - - # Test the ability to follow both child and parent of a fork. Do - # this without catchpoints. - # ??rehrauer: NYI. Will add testpoints here when implemented. - # - - # Test the ability to have the debugger ask the user at fork-time - # whether to follow the parent, child or both. Do this without - # catchpoints. - # ??rehrauer: NYI. Will add testpoints here when implemented. - # - - # Test the ability to catch a fork, specify that the child be - # followed, and continue. Make the catchpoint permanent. - # - if [runto_main] then { catch_fork_child_follow } - - # Test that parent breakpoints are successfully detached from the - # child at fork time, even if the user removes them from the - # breakpoints list after stopping at a fork catchpoint. - if [runto_main] then { catch_fork_unpatch_child } - - # Test the ability to catch a fork, specify via a -do clause that - # the parent be followed, and continue. Make the catchpoint temporary. - # - if [runto_main] then { tcatch_fork_parent_follow } +By default, the debugger will follow the parent process..*" \ + "help set follow-fork" + + # Verify that we can set follow-fork-mode, using an abbreviation + # for both the flag and its value. + # + gdb_test_no_output "set follow-fork ch" + + gdb_test "show follow-fork" \ + "Debugger response to a program call of fork or vfork is \"child\".*" \ + "set follow-fork, using abbreviations" + + # Verify that we cannot set follow-fork-mode to nonsense. + # + gdb_test "set follow-fork chork" "Undefined item: \"chork\".*" \ + "set follow-fork to nonsense is prohibited" + + gdb_test_no_output "set follow-fork parent" "reset parent" + + # Check that fork catchpoints are supported, as an indicator for whether + # fork-following is supported. + if [runto_main] then { check_fork_catchpoints } + + # Test the default behaviour, which is to follow the parent of a + # fork, and detach from the child. Do this without catchpoints. + # + if [runto_main] then { default_fork_parent_follow } + + # Test the ability to explicitly follow the parent of a fork, and + # detach from the child. Do this without catchpoints. + # + if [runto_main] then { explicit_fork_parent_follow } + + # Test the ability to follow the child of a fork, and detach from + # the parent. Do this without catchpoints. + # + if [runto_main] then { explicit_fork_child_follow } + + # Test the ability to follow both child and parent of a fork. Do + # this without catchpoints. + # ??rehrauer: NYI. Will add testpoints here when implemented. + # + + # Test the ability to have the debugger ask the user at fork-time + # whether to follow the parent, child or both. Do this without + # catchpoints. + # ??rehrauer: NYI. Will add testpoints here when implemented. + # + + # Test the ability to catch a fork, specify that the child be + # followed, and continue. Make the catchpoint permanent. + # + if [runto_main] then { catch_fork_child_follow } + + # Test that parent breakpoints are successfully detached from the + # child at fork time, even if the user removes them from the + # breakpoints list after stopping at a fork catchpoint. + if [runto_main] then { catch_fork_unpatch_child } + + # Test the ability to catch a fork, specify via a -do clause that + # the parent be followed, and continue. Make the catchpoint temporary. + # + if [runto_main] then { tcatch_fork_parent_follow } } # Start with a fresh gdb diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index 6e7dea3c975..78c387c63f2 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -455,28 +455,13 @@ proc discard_and_shuffle {} { setup_xfail "mips-sgi-irix5*" } - send_gdb "backtrace 100\n" - gdb_expect { - -re "backtrace 100\[\r\n\]+ -.* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r -.* main \\(.*\\) .*\r -$gdb_prompt $" { + gdb_test_multiple "backtrace 100" "backtrace from call6a" { + -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" { pass "backtrace from call6a" } - -re "backtrace 100\[\r\n\]+ -.* call6a \\(c=97 'a', s=1, i=2, l=3, f=.*, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r -.* main \\(.*\\) .*\r -$gdb_prompt $" { + -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=.*, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" { xfail "backtrace from call6a" } - -re "$gdb_prompt $" { - fail "backtrace from call6a" - gdb_suppress_tests - } - timeout { - fail "(timeout) backtrace from call6a" - gdb_suppress_tests - } } # Continue; should stop at call6b and print actual arguments. @@ -707,22 +692,13 @@ proc shuffle_round_robin {} { } if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } - send_gdb "backtrace 100\n" - gdb_expect { - -re "backtrace 100\[\r\n\]+ -.* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r -.* main \\(.*\\) .*\r -$gdb_prompt $" { + gdb_test_multiple "backtrace 100" "backtrace from call7a" { + -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" { pass "backtrace from call7a" } - -re "backtrace 100\[\r\n\]+ -.* call7a \\(c=97 'a', i=2, s=1, l=3, f=.*, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r -.* main \\(.*\\) .*\r -$gdb_prompt $" { + -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=.*, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" { xfail "backtrace from call7a" } - -re "$gdb_prompt $" { fail "backtrace from call7a" ; return } - timeout { fail "(timeout) backtrace from call7a" ; return } } # Continue; should stop at call7b and print actual arguments. @@ -1057,22 +1033,25 @@ proc localvars_in_indirect_call { } { # second indirect call. # - send_gdb "finish\n" - gdb_expect { - -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" { -#On hppa2.0w-hp-hpux11.00, gdb finishes at one line earlier than -#hppa1.1-hp-hpux11.00. Therefore, an extra "step" is necessary to continue the test. + gdb_test_multiple "finish" "finish from indirectly called function" { + -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" { + #On hppa2.0w-hp-hpux11.00, gdb finishes at one line earlier than + #hppa1.1-hp-hpux11.00. Therefore, an extra "step" is necessary + #to continue the test. send_gdb "step\n" exp_continue } - -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" { + -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" { pass "finish from indirectly called function" } - -re ".*$gdb_prompt $" { + -re ".*$gdb_prompt $" { fail "finish from indirectly called function" gdb_suppress_tests; } - default { fail "finish from indirectly called function" ; gdb_suppress_tests; } + default { + fail "finish from indirectly called function" + gdb_suppress_tests; + } } if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } @@ -1095,19 +1074,21 @@ proc test_stepping_over_trampolines { } { if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; } # Cater for gdb stopping in midline, see comment for finish above. - send_gdb "finish\n" - gdb_expect { - -re "marker_call_with_trampolines ..;.*$gdb_prompt $" { + gdb_test_multiple "finish" "finish from marker_call_with_trampolines" { + -re "marker_call_with_trampolines ..;.*$gdb_prompt $" { send_gdb "step\n" exp_continue } - -re "pointer_to_call_with_trampolines.*$gdb_prompt $" { + -re "pointer_to_call_with_trampolines.*$gdb_prompt $" { pass "finish from marker_call_with_trampolines" } - -re ".*$gdb_prompt $" { + -re ".*$gdb_prompt $" { fail "finish from marker_call_with_trampolines" } - default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; } + default { + fail "finish from marker_call_with_trampolines" + gdb_suppress_tests + } } # Try to step into the target function. @@ -1122,20 +1103,22 @@ proc test_stepping_over_trampolines { } { # Stepping back to main might stop again after the gdb_suppress_tests; statement # or immediately transfer control back to main if optimizations # are performed. - send_gdb "step\n" - gdb_expect { - -re "main .* at.*$gdb_prompt $" { - pass "stepping back to main from function called with trampolines" ; - gdb_suppress_tests + gdb_test_multiple "step" "stepping back to main from function called with trampolines" { + -re "main .* at.*$gdb_prompt $" { + pass "stepping back to main from function called with trampolines" + gdb_suppress_tests } - -re "\}.*End of call_with_trampolines.*$gdb_prompt $" { + -re "\}.*End of call_with_trampolines.*$gdb_prompt $" { send_gdb "step\n" exp_continue } - -re ".*$gdb_prompt $" { + -re ".*$gdb_prompt $" { + fail "stepping back to main from function called with trampolines" + } + default { fail "stepping back to main from function called with trampolines" + gdb_suppress_tests } - default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; } } gdb_stop_suppressing_tests; } @@ -1157,38 +1140,41 @@ if [istarget "mips*tx39-*"] { # Determine expected output for unsigned long variables, # the output varies with sizeof (unsigned long). -set target_sizeof_long 4 -send_gdb "print sizeof (long)\n" -gdb_expect { - -re ".\[0-9\]* = 4.*$gdb_prompt $" { } - -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_long 8 } - -re ".*$gdb_prompt $" { - fail "getting sizeof long" +gdb_test_multiple "print sizeof (long)" "getting sizeof long" { + -re ".\[0-9\]* = 4.*$gdb_prompt $" { + set target_sizeof_long 4 + # pass silently + } + -re ".\[0-9\]* = 8.*$gdb_prompt $" { + set target_sizeof_long 8 + # pass silently } - default { fail "(timeout) getting sizeof long" } } -set target_sizeof_int 4 -send_gdb "print sizeof (int)\n" -gdb_expect { - -re ".\[0-9\]* = 2.*$gdb_prompt $" { set target_sizeof_int 2 } - -re ".\[0-9\]* = 4.*$gdb_prompt $" { } - -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_int 8 } - -re ".*$gdb_prompt $" { - fail "getting sizeof unsigned long" +gdb_test_multiple "print sizeof (int)" "getting sizeof int" { + -re ".\[0-9\]* = 2.*$gdb_prompt $" { + set target_sizeof_int 2 + # pass silently + } + -re ".\[0-9\]* = 4.*$gdb_prompt $" { + set target_sizeof_int 4 + # pass silently + } + -re ".\[0-9\]* = 8.*$gdb_prompt $" { + set target_sizeof_int 8 + # pass silently } - default { fail "(timeout) getting sizeof int" } } -set target_bigendian_p 1 -send_gdb "show endian\n" -gdb_expect { - -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 } - -re ".*big endian.*$gdb_prompt $" { } - -re ".*$gdb_prompt $" { - fail "getting target endian" +gdb_test_multiple "show endian" "getting target endian" { + -re ".*little endian.*$gdb_prompt $" { + set target_bigendian_p 0 + # pass silently + } + -re ".*big endian.*$gdb_prompt $" { + set target_bigendian_p 1 + # pass silently } - default { fail "(timeout) getting target endian" } } # Perform tests diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp index e412a20edb5..f048c05cd7d 100644 --- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp +++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp @@ -40,8 +40,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Does this gdb support gcore? -send_gdb "help gcore\n" -gdb_expect { +gdb_test_multiple "help gcore" "help gcore" { -re "Undefined command: .gcore.*$gdb_prompt $" { # gcore command not supported -- nothing to test here. unsupported "gdb does not support gcore on this target" @@ -50,12 +49,6 @@ gdb_expect { -re "Save a core file .*$gdb_prompt $" { pass "help gcore" } - -re ".*$gdb_prompt $" { - fail "help gcore" - } - timeout { - fail "help gcore (timeout)" - } } gdb_test "set args ${pattern}" \ diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp index fd69db7a721..0da0c75fa4a 100644 --- a/gdb/testsuite/gdb.base/gcore.exp +++ b/gdb/testsuite/gdb.base/gcore.exp @@ -39,8 +39,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Does this gdb support gcore? -send_gdb "help gcore\n" -gdb_expect { +gdb_test_multiple "help gcore" "help gcore" { -re "Undefined command: .gcore.*$gdb_prompt $" { # gcore command not supported -- nothing to test here. unsupported "gdb does not support gcore on this target" @@ -49,12 +48,6 @@ gdb_expect { -re "Save a core file .*$gdb_prompt $" { pass "help gcore" } - -re ".*$gdb_prompt $" { - fail "help gcore" - } - timeout { - fail "help gcore (timeout)" - } } if { ! [ runto_main ] } then { @@ -125,8 +118,8 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -send_gdb "core ${objdir}/${subdir}/gcore.test\n" -gdb_expect { +gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \ + "re-load generated corefile" { -re ".* is not a core dump:.*$gdb_prompt $" { fail "re-load generated corefile (bad file format)" # No use proceeding from here. @@ -143,12 +136,6 @@ gdb_expect { -re "Core was generated by .*$gdb_prompt $" { pass "re-load generated corefile" } - -re ".*$gdb_prompt $" { - fail "re-load generated corefile" - } - timeout { - fail "re-load generated corefile (timeout)" - } } send_gdb "where\n" diff --git a/gdb/testsuite/gdb.base/gdb1090.exp b/gdb/testsuite/gdb.base/gdb1090.exp index d8a7ca198e8..91e34b2149a 100644 --- a/gdb/testsuite/gdb.base/gdb1090.exp +++ b/gdb/testsuite/gdb.base/gdb1090.exp @@ -46,8 +46,7 @@ if ![runto marker] then { } gdb_test "up" ".*foo.*" "up from marker" -send_gdb "print s24\n" -gdb_expect { +gdb_test_multiple "print s24" "print s24" { -re "\\\$\[0-9\]* = \\{field_0 = 1170, field_1 = 64701\\}\r\n$gdb_prompt $" { pass "print s24" } @@ -56,10 +55,4 @@ gdb_expect { # gdb cannot find the second register and prints garbage. kfail "gdb/1090" "print s24" } - -re ".*$gdb_prompt $" { - fail "print s24" - } - timeout { - fail "print s24 (timeout)" - } } diff --git a/gdb/testsuite/gdb.base/gdbvars.exp b/gdb/testsuite/gdb.base/gdbvars.exp index 9fbae4b286c..10c7c21082e 100644 --- a/gdb/testsuite/gdb.base/gdbvars.exp +++ b/gdb/testsuite/gdb.base/gdbvars.exp @@ -124,7 +124,7 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -send_gdb "set print sevenbit-strings\n" ; gdb_expect -re ".*$gdb_prompt $" +gdb_test_no_output "set print sevenbit-strings" test_value_history test_convenience_variables diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp index ab6b6116a23..b193292f63d 100644 --- a/gdb/testsuite/gdb.base/help.exp +++ b/gdb/testsuite/gdb.base/help.exp @@ -199,25 +199,21 @@ gdb_test "help finish" "Execute until selected stack frame returns\.\[\r\n\]+Upo # test help forward-search gdb_test "help forward-search" "Search for regular expression \\(see regex\\(3\\)\\) from last line listed.*" "help forward-search" # test help gcore -send_gdb "help gcore\n" -gdb_expect { +gdb_test_multiple "help gcore" "help gcore" { -re "Undefined command: \"gcore\"\. Try \"help\".*$gdb_prompt $" { pass "help gcore" } -re "Save a core file with the current state of the debugged process\.\[\r\n\]+Argument is optional filename\. Default filename is 'core\.'.*$gdb_prompt $" { pass "help gcore" } - default { fail "help gcore" } } -send_gdb "help generate-core-file\n" -gdb_expect { +gdb_test_multiple "help generate-core-file" "help generate-core-file" { -re "Undefined command: \"generate-core-file\"\. Try \"help\".*$gdb_prompt $" { pass "help gcore" } -re "Save a core file with the current state of the debugged process\.\[\r\n\]+Argument is optional filename\. Default filename is 'core\.'.*$gdb_prompt $" { pass "help gcore" } - default { fail "help gcore" } } # test help help "h" abbreviation gdb_test "help h" "Print list of commands\." "help help \"h\" abbreviation" diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp index 1591fa2ecf7..265e46ea380 100644 --- a/gdb/testsuite/gdb.base/info-proc.exp +++ b/gdb/testsuite/gdb.base/info-proc.exp @@ -56,8 +56,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Does this gdb support info proc? -send_gdb "help info proc\n" -gdb_expect { +gdb_test_multiple "help info proc" "help info proc" { -re "Undefined info command: .proc.. Try .help info.*$gdb_prompt $" { # info proc command not supported -- nothing to test here. unsupported "gdb does not support info proc on this target" @@ -66,12 +65,6 @@ gdb_expect { -re "Show /proc process information about .*$gdb_prompt $" { pass "help info proc" } - -re ".*$gdb_prompt $" { - fail "help info proc" - } - timeout { - fail "help info proc (timeout)" - } } gdb_test "info proc" "No current process.*" "info proc without a process" diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp index 8c80a0137ac..9e4ed375192 100644 --- a/gdb/testsuite/gdb.base/jump.exp +++ b/gdb/testsuite/gdb.base/jump.exp @@ -47,96 +47,59 @@ if ![runto_main] then { # Set a breakpoint on the statement that we're about to jump to. # The statement doesn't contain a function call. # -send_gdb "break 22\n" set bp_on_non_call 0 -gdb_expect { - -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $"\ - {set bp_on_non_call $expect_out(1,string) - pass "break before jump to non-call"} - -re "$gdb_prompt $"\ - {fail "break before jump to non-call"} - timeout {fail "(timeout) break before jump to non-call"} +gdb_test_multiple "break 22" "break before jump to non-call" { + -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 22.*$gdb_prompt $" { + set bp_on_non_call $expect_out(1,string) + pass "break before jump to non-call" + } } # Can we jump to the statement? Do we stop there? # -send_gdb "jump 22\n" -gdb_expect { - -re "Breakpoint \[0-9\]*, .*${srcfile}:22.*$gdb_prompt $"\ - {pass "jump to non-call"} - -re "$gdb_prompt $"\ - {fail "jump to non-call"} - timeout {fail "(timeout) jump to non-call"} -} +gdb_test "jump 22" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \ + "jump to non-call" # Set a breakpoint on the statement that we're about to jump to. # The statement does contain a function call. # -send_gdb "break 21\n" set bp_on_call 0 -gdb_expect { - -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $"\ - {set bp_on_call $expect_out(1,string) - pass "break before jump to call"} - -re "$gdb_prompt $"\ - {fail "break before jump to call"} - timeout {fail "(timeout) break before jump to call"} +gdb_test_multiple "break 21" "break before jump to call" { + -re "\[Bb\]reakpoint (\[0-9\]*) at 0x\[0-9a-fA-F\]*: file .*${srcfile}, line 21.*$gdb_prompt $" { + set bp_on_call $expect_out(1,string) + pass "break before jump to call" + } } # Can we jump to the statement? Do we stop there? # -send_gdb "jump 21\n" -gdb_expect { - -re "Breakpoint \[0-9\]*, .*${srcfile}:21.*$gdb_prompt $"\ - {pass "jump to call"} - -re "$gdb_prompt $"\ - {fail "jump to call"} - timeout {fail "(timeout) jump to call"} -} +gdb_test "jump 21" \ + "Breakpoint \[0-9\]*, .*${srcfile}:21.*" \ + "jump to call" # If we disable the breakpoint at the function call, and then # if we jump to that statement, do we not stop there, but at # the following breakpoint? # -send_gdb "disable $bp_on_call\n" -gdb_expect { - -re "$gdb_prompt $"\ - {pass "disable breakpoint on call"} - timeout {fail "(timeout) disable breakpoint on call"} -} +gdb_test_no_output "disable $bp_on_call" "disable breakpoint on call" -send_gdb "jump 21\n" -gdb_expect { - -re "Breakpoint \[0-9\]*, .*${srcfile}:22.*$gdb_prompt $"\ - {pass "jump to call with disabled breakpoint"} - -re "$gdb_prompt $"\ - {fail "jump to call with disabled breakpoint"} - timeout {fail "(timeout) jump to call with disabled breakpoint"} -} +gdb_test "jump 21" "Breakpoint \[0-9\]*, .*${srcfile}:22.*" \ + "jump to call with disabled breakpoint" # Verify that GDB responds gracefully to the "jump" command without # an argument. # -send_gdb "jump\n" -gdb_expect { - -re "Argument required .starting address..*$gdb_prompt $"\ - {pass "jump without argument disallowed"} - -re "$gdb_prompt $"\ - {fail "jump without argument disallowed"} - timeout {fail "(timeout) jump without argument disallowed"} -} +gdb_test "jump" "Argument required .starting address.*" \ + "jump without argument disallowed" + # Verify that GDB responds gracefully to the "jump" command with # trailing junk. # -send_gdb "jump 21 100\n" -gdb_expect { - -re "Junk at end of line specification: 100.*$gdb_prompt $"\ - {pass "jump with trailing argument junk"} - -re "$gdb_prompt $"\ - {fail "jump with trailing argument junk"} - timeout {fail "(timeout) jump with trailing argument junk"} -} +gdb_test "jump 21 100" \ + "Junk at end of line specification: 100.*" \ + "jump with trailing argument junk" + # Verify that GDB responds gracefully to a request to jump out of # the current function. (Note that this will very likely cause the @@ -145,39 +108,18 @@ gdb_expect { # # Try it both ways: confirming and not confirming the jump. # -send_gdb "jump 12\n" -gdb_expect { - -re "Line 12 is not in `main'. Jump anyway.*y or n. $"\ - {send_gdb "n\n" - gdb_expect { - -re "Not confirmed.*$gdb_prompt $"\ - {pass "aborted jump out of current function"} - -re "$gdb_prompt $"\ - {fail "aborted jump out of current function"} - timeout {fail "(timeout) aborted jump out of current function"} - } - } - -re "$gdb_prompt $"\ - {fail "aborted jump out of current function"} - timeout {fail "(timeout) aborted jump out of current function"} -} -send_gdb "jump 12\n" -gdb_expect { - -re "Line 12 is not in `main'. Jump anyway.*y or n. $"\ - {send_gdb "y\n" - gdb_expect { - -re "Continuing at.*$gdb_prompt $"\ - {pass "jump out of current function"} - -re "$gdb_prompt $"\ - {fail "jump out of current function"} - timeout {fail "(timeout) jump out of current function"} - } - } - -re "$gdb_prompt $"\ - {fail "jump out of current function"} - timeout {fail "(timeout) jump out of current function"} -} +gdb_test "jump 12" \ + "Not confirmed.*" \ + "aborted jump out of current function" \ + "Line 12 is not in `main'. Jump anyway.*y or n. $" \ + "n" + +gdb_test "jump 12" \ + "Continuing at.*" \ + "jump out of current function" \ + "Line 12 is not in `main'. Jump anyway.*y or n. $" \ + "y" gdb_exit return 0 diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp index 436ecf99e83..bc84b1885aa 100644 --- a/gdb/testsuite/gdb.base/long_long.exp +++ b/gdb/testsuite/gdb.base/long_long.exp @@ -61,17 +61,6 @@ if { ![runto known_types] } then { return } -set target_bigendian_p 1 -send_gdb "show endian\n" -gdb_expect { - -re "little endian.*$gdb_prompt $" { set target_bigendian_p 0 } - -re "big endian.*$gdb_prompt $" { } - -re "$gdb_prompt $" { - fail "getting target endian" - } - default { fail "(timeout) getting target endian" } -} - # Detect the size of the target's basic types. set sizeof_char [get_sizeof "char" 1] @@ -103,16 +92,6 @@ proc gdb_test_xxx { test pat name } { } } -proc gdb_test_bi { test be le } { - global target_bigendian_p - - if { $target_bigendian_p } { - gdb_test_xxx $test $be $test - } else { - gdb_test_xxx $test $le $test - } -} - proc gdb_test_ptr { test args } { global sizeof_data_ptr