diff -Nrup empty/break.c gdb.tui/break.c --- empty/break.c 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/break.c 2003-07-25 18:44:14.000000000 +0200 @@ -0,0 +1,131 @@ +#ifdef vxworks + +# include + +/* VxWorks does not supply atoi. */ +static int +atoi (z) + char *z; +{ + int i = 0; + + while (*z >= '0' && *z <= '9') + i = i * 10 + (*z++ - '0'); + return i; +} + +/* I don't know of any way to pass an array to VxWorks. This function + can be called directly from gdb. */ + +vxmain (arg) +char *arg; +{ + char *argv[2]; + + argv[0] = ""; + argv[1] = arg; + main (2, argv, (char **) 0); +} + +#else /* ! vxworks */ +# include +# include +#endif /* ! vxworks */ + +/* + * The following functions do nothing useful. They are included simply + * as places to try setting breakpoints at. They are explicitly + * "one-line functions" to verify that this case works (some versions + * of gcc have or have had problems with this). + */ + +#ifdef PROTOTYPES +int marker1 (void) { return (0); } +int marker2 (int a) { return (1); } +void marker3 (char *a, char *b) {} +void marker4 (long d) {} +#else +int marker1 () { return (0); } +int marker2 (a) int a; { return (1); } +void marker3 (a, b) char *a, *b; {} +void marker4 (d) long d; {} +#endif + +/* + * This simple classical example of recursion is useful for + * testing stack backtraces and such. + */ + +#ifdef PROTOTYPES +int factorial(int); + +int +main (int argc, char **argv, char **envp) +#else +int +main (argc, argv, envp) +int argc; +char *argv[], **envp; +#endif +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ + fprintf (stderr, "usage: factorial \n"); + return 1; + } + printf ("%d\n", factorial (atoi ("6"))); + + marker1 (); + marker2 (43); + marker3 ("stack", "trace"); + marker4 (177601976L); + argc = (argc == 12345); /* This is silly, but we can step off of it */ + return argc; +} + +#ifdef PROTOTYPES +int factorial (int value) +#else +int factorial (value) +int value; +#endif +{ + if (value > 1) { + value *= factorial (value - 1); + } + return (value); +} + +#ifdef PROTOTYPES +int multi_line_if_conditional (int a, int b, int c) +#else +int multi_line_if_conditional (a, b, c) + int a, b, c; +#endif +{ + if (a + && b + && c) + return 0; + else + return 1; +} + +#ifdef PROTOTYPES +int multi_line_while_conditional (int a, int b, int c) +#else +int multi_line_while_conditional (a, b, c) + int a, b, c; +#endif +{ + while (a + && b + && c) + { + a--, b--, c--; + } + return 0; +} diff -Nrup empty/tui-break.exp gdb.tui/tui-break.exp --- empty/tui-break.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-break.exp 2003-08-10 15:37:06.000000000 +0200 @@ -0,0 +1,226 @@ +# Copyright 2003 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 Stephane Carrez (stcarrez@nerim.fr) + +# Test the gdb TUI mode, setting breakpoints and update of TUI +# while doing this. + +load_lib tui-support.exp + +set prms_id 0 +set bug_id 0 + +if { ![tui_is_supported ] } { + verbose "Skipping TUI test: TUI is not supported." + continue +} + +# Follow gdb.break test but in TUI mode +set testfile "break" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +gdb_exit + +# Start gdb in normal mode. This is necessary for reinitialize+load. +gdb_start + +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# Switch to TUI mode, we must see curses output +send_gdb "a" +gdb_expect 10 { + -re ".*No\[ \t\]Source\[ \t\]Available.*$" { + pass "Enter TUI with key binding CTRL-X A" + } + -re "$gdb_prompt $" { + fail "Enter TUI with key binding CTRL-X A" + } + timeout { + fail "Enter TUI with key binding CTRL-X A" + } +} + +# List the source +# Check a few lines but we can't check for exact match since the way +# curses prints it is really terminal dependent. We just want to make +# sure line numbers and source lines are globally (?) displayed. +send_gdb "list break.c:75\n" +gdb_expect 10 { + -re "71.*ifdef.usestubs.*75.*argc.*81.*marker1.*82.*marker2.*83" { + pass "TUI, list break.c:75" + } + timeout { + fail "TUI, list break.c:75 (timeout)" + } +} + +# Test break at function +# The b+ is the TUI marker +send_gdb "break main\n" +gdb_expect 10 { + -re ".*b\+.*Breakpoint.*at.*file.*$srcfile,.line.*$gdb_prompt $" { + pass "TUI, break main" + } + timeout { + fail "TUI, break main (timeout)" + } +} + +send_gdb "break 79\n" +gdb_expect 10 { + -re ".*b\+.*Breakpoint.*at.*file.*$srcfile,.line.*$gdb_prompt" { + pass "TUI, break at 79" + } + timeout { + fail "TUI, break at 79 (timeout)" + } +} + +send_gdb "list 1\n" +gdb_expect 10 { + -re ".*1.*ifdef.vxworks.*2.*include.*stdio.*" { + pass "TUI, list 1" + } + timeout { + fail "TUI, list 1 (timeout)" + } +} + +# run until the breakpoint at main is hit. For non-stubs-using targets. +# (copied from gdb.base/break.exp and adapted to TUI) +if ![target_info exists use_gdb_stub] { + if [istarget "*-*-vxworks*"] then { + send_gdb "run vxmain \"2\"\n" + set timeout 120 + verbose "Timeout is now $timeout seconds" 2 + } else { + send_gdb "run\n" + } + + # The B+ TUI marker can appear before or after the 'Breakpoint' + gdb_expect { + -re ".*The.program.*has.been.started.already.*y.or.n.*$" { + send_gdb "y\n" + exp_continue + } + -re ".*Starting.program.*B\+.*Breakpoint.\[0-9\]+"\ + { pass "TUI, run until function breakpoint" } + -re ".*Starting.program.*Breakpoint.\[0-9\]+.*B\+"\ + { pass "TUI, run until function breakpoint" } + -re ".*$gdb_prompt $" { fail "run until function breakpoint" } + timeout { fail "run until function breakpoint (timeout)" } + } +} else { + if ![target_info exists gdb_stub] { + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue" + } +} + +# Must hit second breakpoint at line 79 +# Verify that the line is redrawn (due to reverse video setting). +send_gdb "continue\n" +gdb_expect 10 { + -re ".*B\+.*79.*printf.*factorial.*Breakpoint.\[0-9\]" { + pass "TUI, continue" + } + -re ".*79.*printf.*factorial.*Breakpoint.\[0-9\].*B\+" { + pass "TUI, continue" + } + timeout { + fail "TUI, continue (timeout)" + } +} + +send_gdb "break factorial\n" +gdb_expect 10 { + -re ".*Breakpoint.*at.*file.*$srcfile,.line.*$gdb_prompt" { + pass "TUI, break factorial" + } + timeout { + fail "TUI, break factorial (timeout)" + } +} + +send_gdb "continue\n" +gdb_expect 10 { + -re ".*B\+.*96.*if..value...1" { + pass "TUI, continue to factorial" + } + -re ".*96.*if..value...1.*B\+" { + pass "TUI, continue to factorial" + } + timeout { + fail "TUI, continue to factorial (timeout)" + } +} + +# Switch the layout to see source+assembly +# Show prompt to force curses output and have a well known end of screen. +# This is necessary to make sure expect eats everything before next command. +send_gdb "2show prompt\n" +gdb_expect 5 { + -re ".*B\+.*0x\[0-9a-f\]+\[ \t\].factorial.*Gdb.s.prompt.is.*" { + pass "TUI, display of asm window" + } + -re ".*0x\[0-9a-f\]+\[ \t\].factorial.*B\+\>.*Gdb.s.prompt.is.*" { + pass "TUI, display of asm window" + } + timeout { + fail "TUI, display of asm window (timeout)" + } +} + +# Do several stepi and check that the '>' marker and assembly line is +# redisplayed at each step. After each step, the 'show prompt' is +# used to ensure proper synchronization with what stepi produces. +for { set i 0 } { $i < 3 } { incr i } { + send_gdb "stepi\nshow prompt\n" + gdb_expect 5 { + -re ".*\[^a-z0-9]\>.*0x\[0-9a-f\]+\[ \t\].factorial.*Gdb.s.prompt.is.*" { + pass "TUI, stepi of asm window, pass $i" + } + timeout { + fail "TUI, stepi of asm window, pass $i, (timeout)" + } + } +} + +# (do what gdb.base/break.exp does at the end) +# Reset the default arguments for VxWorks +if [istarget "*-*-vxworks*"] { + set timeout 10 + verbose "Timeout is now $timeout seconds" 2 + send_gdb "set args main\n" + gdb_expect -re ".*$gdb_prompt $" {} +} diff -Nrup empty/tui-mode.exp gdb.tui/tui-mode.exp --- empty/tui-mode.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-mode.exp 2003-08-10 15:35:15.000000000 +0200 @@ -0,0 +1,186 @@ +# Copyright 2003 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 Stephane Carrez (stcarrez@nerim.fr) + +# +# Test the gdb TUI mode and the ability to switch between normal mode +# and curses mode. We can't check for the exact curses output as this +# is terminal specific. Instead, we check for plain text messages that +# appear in the TUI windows, ignoring any escape sequences. +# + +load_lib tui-support.exp + +set prms_id 0 +set bug_id 0 + +if { ![tui_is_supported ] } { + verbose "Skipping TUI test: TUI is not supported." + continue +} + +gdb_exit + +# Start gdb in TUI mode (--tui). +tui_gdb_start + +# Leave the TUI mode +send_gdb "a" +gdb_expect { + -re "$gdb_prompt $" { + pass "Keybinding CTRL-X A" + } + timeout { + fail "Keybinding CTRL-X A" + } +} + +# Small test in gdb normal mode +send_gdb "set height 0\n" +gdb_expect 10 { + -re "$gdb_prompt $" { + pass "no TUI, set height" + } + timeout { + fail "no TUI, set height (timeout)" + } +} +send_gdb "show height\n" +gdb_expect 10 { + -re "Number of lines gdb thinks are in a page is unlimited.*$gdb_prompt $" { + pass "no TUI, show height" + } + timeout { + fail "no TUI, show height (timeout)" + } +} + +# Switch back to TUI mode, we must see curses output +send_gdb "a" +gdb_expect 10 { + -re ".*No\[ \t\]Source\[ \t\]Available.*$" { + pass "Enter TUI with key binding CTRL-X A" + } + -re "$gdb_prompt $" { + fail "Enter TUI with key binding CTRL-X A" + } + timeout { + fail "Enter TUI with key binding CTRL-X A" + } +} + +# And the height must have been changed to reflect the new window +# (with a number instead of 'unlimited') +# Take care: it seems that ncurses sends \t instead of ' ' so +# we use . in the regex for simplicity. +send_gdb "show height\n" +gdb_expect 10 { + -re ".*Number.of.lines.gdb.thinks.are.in.a.page.is.\[0-9\]+.*" { + pass "TUI, show height" + } + timeout { + fail "TUI, show height (timeout)" + } +} + +# Switch the layout to see source+assembly +send_gdb "2" +gdb_expect 5 { + -re ".*No.Source.Available.*No.Assembly.Available.*$" { + pass "Keybinding CTRL-X 2 (src+asm)" + } + -re ".*No.Assembly.Available.*No.Source.Available.*$" { + pass "Keybinding CTRL-X 2 (src+asm)" + } + -re "$gdb_prompt $" { + fail "Keybinding CTRL-X 2 (src+asm)" + } + timeout { + fail "Keybinding CTRL-X 2 (src+asm) timeout" + } +} + +# Switch the layout to see register+assembly +send_gdb "2" +gdb_expect 5 { + -re ".*Register.Values.Unavailable.*No.Assembly.Available.*$" { + pass "Keybinding CTRL-X 2 (asm+reg)" + } + -re ".*No.Assembly.Available.*Register.Values.Unavailable.*$" { + pass "Keybinding CTRL-X 2 (asm+reg)" + } + -re "$gdb_prompt $" { + fail "Keybinding CTRL-X 2 (asm+reg)" + } + timeout { + fail "Keybinding CTRL-X 2 (asm+reg) timeout" + } +} + +# Switch the layout to see register+source +send_gdb "2" +gdb_expect 5 { + -re ".*Register.Values.Unavailable.*No.Source.Available.*$" { + pass "Keybinding CTRL-X 2 (reg+src)" + } + -re ".*No.Source.Available.*Register.Values.Unavailable.*$" { + pass "Keybinding CTRL-X 2 (reg+src)" + } + -re "$gdb_prompt $" { + fail "Keybinding CTRL-X 2 (reg+src)" + } + timeout { + fail "Keybinding CTRL-X 2 (reg+src) timeout" + } +} + +# Final one to make sure we roll over all configuration +send_gdb "2" +gdb_expect 5 { + -re ".*No.Source.Available.*No.Assembly.Available.*$" { + pass "Keybinding CTRL-X 2 (src+asm) final" + } + -re "$gdb_prompt $" { + fail "Keybinding CTRL-X 2 (src+asm) final" + } + timeout { + fail "Keybinding CTRL-X 2 (src+asm) final timeout" + } +} + +# Switch the layout to one window +send_gdb "1" +gdb_expect 5 { + -re ".*No.Source.Available.*No.Assembly.Available.*$" { + fail "Keybinding CTRL-X 1 (no effect?)" + } + -re ".*No.Assembly.Available.*No.Source.Available.*$" { + fail "Keybinding CTRL-X 1 (no effect?)" + } + -re ".*No.Source.Available.*$" { + pass "Keybinding CTRL-X 1" + } + -re "$gdb_prompt $" { + fail "Keybinding CTRL-X 2 (src+asm) final" + } + timeout { + fail "Keybinding CTRL-X 2 (src+asm) final timeout" + } +} diff -Nrup empty/tui-single-key.exp gdb.tui/tui-single-key.exp --- empty/tui-single-key.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-single-key.exp 2003-08-10 15:42:16.000000000 +0200 @@ -0,0 +1,275 @@ +# Copyright 2003 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 Stephane Carrez (stcarrez@nerim.fr) + +# Test the gdb TUI SingleKey mode. +# + +load_lib tui-support.exp + +set prms_id 0 +set bug_id 0 + +if { ![tui_is_supported ] } { + verbose "Skipping TUI test: TUI is not supported." + continue +} + +# Follow gdb.break test but in TUI mode + SingleKey +set testfile "break" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +gdb_exit + +gdb_start + +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# Switch to TUI mode, we must see curses output +send_gdb "a" +gdb_expect 10 { + -re ".*No\[ \t\]Source\[ \t\]Available.*$" { + pass "Enter TUI with key binding CTRL-X A" + } + -re "$gdb_prompt $" { + fail "Enter TUI with key binding CTRL-X A" + } + timeout { + fail "Enter TUI with key binding CTRL-X A" + } +} + +# List the source +# Check a few lines but we can't check for exact match since the way +# curses prints it is really terminal dependent. We just want to make +# sure line numbers and source lines are globally (?) displayed. +send_gdb "list break.c:75\n" +gdb_expect 10 { + -re "71.*ifdef.usestubs.*75.*argc.*81.*marker1.*82.*marker2.*83" { + pass "TUI, list break.c:75" + } + timeout { + fail "TUI, list break.c:75 (timeout)" + } +} + +# Enter SingleKey. At least the TUI status line is refreshed +# and indicates the SingleKey mode. To test the test, pass "^Xsq" +# to leave SingleKey after setting it (next tests will fail of course). +send_gdb "s" +gdb_expect 10 { + -re ".*SingleKey.*" { + pass "TUI, enter SingleKey" + } + timeout { + fail "TUI, enter SingleKey (timeout)" + } +} + +# Do simple commands (program not running) +tui-check "u" "No\[ \t\]stack\." "TUI, SingleKey 'u'" +tui-check "d" "No\[ \t\]stack\." "TUI, SingleKey 'd'" +tui-check "w" "No\[ \t\]stack\." "TUI, SingleKey 'w'" +tui-check "v" "No\[ \t\]frame\[ \t\]selected\." "TUI, SingleKey 'v'" +tui-check "f" "The.program.is.not.running\." "TUI, SingleKey 'f'" +tui-check "c" "The.program.is.not.being.run\." "TUI, SingleKey 'c'" +tui-check "s" "The.program.is.not.being.run\." "TUI, SingleKey 's'" +tui-check "n" "The.program.is.not.being.run\." "TUI, SingleKey 'n'" + +# Check that sending 'b' leaves the SingleKey temporarily +# and we can give normal gdb commands (with prompt). +tui-check "b" "$gdb_prompt\[ \t\]b$" "TUI, SingleKey 'b'" + +send_gdb " 79\n" +gdb_expect 10 { + -re ".*Breakpoint.*at.*file.*" { + pass "TUI, SingleKey 'b 79' 1" + } + timeout { + fail "TUI, SingleKey 'b 79' (timeout)" + } +} + +# Leave temporarily SingleKey and remove the character. +# This should have the effect of staying in the SingleKey mode. +tui-check "b" "$gdb_prompt\[ \t\]b$" "TUI, SingleKey 'b'" +tui-check "\b" ".*SingleKey.*" "TUI, SingleKey" + +# In case the \b didn't worked, leave SingleKey explicitly +tui-check "q\n" ".*$gdb_prompt" "TUI, leave SingleKey" + +tui-check "s" ".*SingleKey.*" "TUI, SingleKey mode" +tui-check "b" "$gdb_prompt\[ \t\]b$" "TUI, SingleKey 'b'" +send_gdb " main\n" +gdb_expect 10 { + -re ".*b\+.*Breakpoint.*at.*file.*$srcfile,.line." { + pass "TUI, SingleKey 'b main' 1" + } + timeout { + fail "TUI, SingleKey 'b main' (timeout)" + } +} + +send_gdb "info break\n" +gdb_expect 10 { + -re "Num.Type.*Disp.*Enb.*Address.*What.*\[12\].*breakpoint.*keep.*y.*main.*at.*$srcfile.*\[12\].*breakpoint.*keep.*y.*main.*at.*$srcfile.*" { + pass "TUI, SingleKey info break" + } + timeout { + fail "TUI, SingleKey 'info break' (timeout)" + } +} + +# run until the breakpoint at main is hit. For non-stubs-using targets. +# (copied from gdb.base/break.exp and adapted to TUI) +if ![target_info exists use_gdb_stub] { + if [istarget "*-*-vxworks*"] then { + # Since we must pass more arguments, leave temporarily SingleKey + # run the target and re-enter SingleKey. SCz: no VxWorks to check (:- + send_gdb "qrun vxmain \"2\"\ns" + set timeout 120 + verbose "Timeout is now $timeout seconds" 2 + } else { + send_gdb "r" + } + + # The B+ TUI marker can appear before or after the 'Breakpoint' + gdb_expect { + -re ".*The.program.*has.been.started.already.*y.or.n.*$" { + send_gdb "y\n" + exp_continue + } + -re ".*Starting.program.*B\+.*Breakpoint.\[0-9\]+.*at.*"\ + { pass "TUI, run until function breakpoint" } + -re ".*Starting.program.*Breakpoint.\[0-9\]+.*at.*B\+"\ + { pass "TUI, run until function breakpoint" } + -re ".*$gdb_prompt $" { fail "run until function breakpoint" } + timeout { fail "run until function breakpoint (timeout)" } + } +} else { + if ![target_info exists gdb_stub] { + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue" + } +} + +# Synchronize TUI output +tui-check " show prompt\n" \ + ".*Gdb.s.prompt.is.*$gdb_prompt.*SingleKey" \ + "TUI, SingleKey 'show prompt'" + +# Must hit second breakpoint at line 75 +# Verify that the line is redrawn (due to reverse video setting). +tui-check " continue" \ + ".*continue.*" \ + "TUI, SingleKey ' continue'" + +send_gdb "\n" +gdb_expect 5 { + -re ".*Continuing.*" { + pass "TUI, continue" + } + timeout { + fail "TUI, continue (timeout)" + } +} + +send_gdb "break factorial\n" +gdb_expect 10 { + -re ".*Breakpoint.*at.*file.*$srcfile,.line.*SingleKey" { + pass "TUI, SingleKey break factorial" + } + timeout { + fail "TUI, SingleKey break factorial (timeout)" + } +} + +#tui-check " show prompt\n" "TUI, SingleKey 'show prompt'" \ +# ".*Gdb.s.prompt.is.*$gdb_prompt.*SingleKey" + +send_gdb " continue\n" +gdb_expect 10 { + -re ".*Continuing.*" { + pass "TUI, SingleKey continue to factorial" + } + timeout { + fail "TUI, continue to factorial (timeout)" + } +} + +# Single step in factorial +send_gdb "s" +gdb_expect 5 { + -re ".*In.*factorial" { + pass "TUI, SingleKey 's'" + } + timeout { + fail "TUI, SingleKey 's', (timeout)" + } +} + +# Move up in main +# The show prompt is used to have a marker to recognize end of up command +send_gdb "u show prompt\n" +gdb_expect 5 { + -re ".*main.*printf.*factorial.*In.*main.*Gdb.s.prompt.is.*$gdb_prompt" { + pass "TUI, SingleKey 'u'" + } + timeout { + fail "TUI, SingleKey 'u', (timeout)" + } +} + +# Move down in factorial +send_gdb "d show prompt\n" +gdb_expect 5 { + -re ".*factorial.*In.*factorial.*Gdb.s.prompt.is.*$gdb_prompt" { + pass "TUI, SingleKey 'd'" + } + timeout { + fail "TUI, SingleKey 'd', (timeout)" + } +} + +tui-check " show prompt\n" \ + ".*Gdb.s.prompt.is.*$gdb_prompt.*SingleKey" \ + "TUI, SingleKey 'show prompt'" + +# (do what gdb.base/break.exp does at the end) +# Reset the default arguments for VxWorks +if [istarget "*-*-vxworks*"] { + set timeout 10 + verbose "Timeout is now $timeout seconds" 2 + send_gdb "set args main\n" + gdb_expect -re ".*$gdb_prompt $" {} +} --- empty/tui-support.exp 2003-08-10 20:28:40.000000000 +0200 +++ lib/tui-support.exp 2003-08-10 15:49:10.000000000 +0200 @@ -0,0 +1,138 @@ +# Copyright 1999, 2000, 2002, 2003 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 based on a file written by Fred Fish. (fnf@cygnus.com) + +# Test setup routines that work with the TUI interpreter. + +# The variable tui_gdb_prompt is a regexp which matches the gdb mi prompt. +# Set it if it is not already set. +global tui_gdb_prompt +if ![info exists tui_gdb_prompt] then { + set tui_gdb_prompt "\[(\]gdb\[)\] \r\n" +} + +set TUIFLAGS "-i=tui" +set TUITERM "xterm" + +set tui_supported "-1" + +# Return 1 if the TUI is supported by gdb + +proc tui_is_supported { } { + global GDB + global tui_supported + + if { $tui_supported >= 0 } { + return $tui_supported + } + set tui_supported 0 + verbose "Spawning $GDB --help" + + # To check if TUI is supported, look at the gdb usage and check + # for the --tui option + set output [remote_exec host "$GDB --help"] + set res [lindex $output 1] + if [regexp ".*\-\-tui.*terminal user interface" $res] { + set tui_supported 1 + return 1 + } + return 0; +} + +# +# start gdb -- start gdb running, default procedure +# +# When running over NFS, particularly if running many simultaneous +# tests on different hosts all using the same server, things can +# get really slow. Give gdb at least 3 minutes to start up. +# +proc tui_gdb_start { } { + global verbose + global GDB + global GDBFLAGS + global gdb_prompt + global tui_gdb_prompt + global timeout + global gdb_spawn_id; + global TUIFLAGS + global TUITERM + + gdb_stop_suppressing_tests; + + # Start SID. + if { [info procs sid_start] != "" } { + verbose "Spawning SID" + sid_start + } + + verbose "Spawning $GDB -tui $GDBFLAGS $TUIFLAGS" + + if [info exists gdb_spawn_id] { + return 0; + } + + if ![is_remote host] { + if { [which $GDB] == 0 } then { + perror "$GDB does not exist." + exit 1 + } + } + set res [remote_spawn host "$GDB -nw $GDBFLAGS $TUIFLAGS [host_info gdb_opts]"]; + if { $res < 0 || $res == "" } { + perror "Spawning $GDB failed." + return 1; + } + gdb_expect { + -re ".*No process.*GNU.*" { + verbose "GDB initialized." + } + -re ".*unrecognized option.*for a complete list of options." { + untested "Skip TUI tests (not compiled with TUI support)." + remote_close host; + return -1; + } + -re ".*Interpreter `tui' unrecognized." { + untested "Skip TUI tests (not compiled with TUI support)." + remote_close host; + return -1; + } + timeout { + perror "(timeout) GDB never initialized after 10 seconds." + remote_close host; + return -1 + } + } + set gdb_spawn_id -1; + + return 0; +} + +proc tui-check { input expect title } { + send_gdb "$input" + gdb_expect 10 { + -re $expect { + pass "$title" + } + timeout { + fail "$title (timeout)" + } + } +} +