This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! A long long time ago, I submitted a TUI testsuite for the validation of the gdb TUI: http://sourceware.org/ml/gdb-patches/2003-08/msg00166.html Andrew approved the integration of such testsuite: http://sourceware.org/ml/gdb-patches/2003-08/msg00300.html But... it was never integrated (:- (this is my fault; I guess it was because the testsuite had few problems; a thread in Jan 2004 mention this; unless I was disturbed by the birth of my son; ...). This new TUI testsuite is seriously improved: - it contains new tests for tui specific commands like the 'layout' commands and few others (tui-commands.exp) - I've defined specific tests for tui register window and the 'tui reg' command (tui-regs.exp). This testsuite may be tuned for a specific target by specifying a list of register names, for example: "i[3456]86-*-*" { set registers "eax,ebx,ecx,edx" } This is optional. When defined, the testsuite verifies that the named register appears in the 'tui reg general' curses window. - the testsuite is more reliable than it was (few patterns had problems and failures could occur sometimes) I've validated this testsuite on the following targets: i686-pc-linux-gnu m6811-elf Here are the results for Linux: runtest gdb.tui/*.exp Test Run By ciceron on Sat Nov 12 17:23:14 2005 Native configuration is i686-pc-linux-gnu === gdb tests === Schedule of variations: unix Running target unix Using /usr/local/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/local/share/dejagnu/config/unix.exp as generic interface file for target. Using ../.././gdb/testsuite/config/unix.exp as tool-and-target-specific interface file. Running ../.././gdb/testsuite/gdb.tui/tui-commands.exp ... Running ../.././gdb/testsuite/gdb.tui/tui-single-key.exp ... Running ../.././gdb/testsuite/gdb.tui/tui-regs.exp ... Running ../.././gdb/testsuite/gdb.tui/tui-mode.exp ... Running ../.././gdb/testsuite/gdb.tui/tui-break.exp ... === gdb Summary === # of expected passes 120 /archives/build/gdb-6_4-i386/gdb/testsuite/../../gdb/gdb version 6.3.90-20051111-cvs -nx Can you approve this patch for the mainline? Stephane 2005-11-12 Stephane Carrez <stcarrez@nerim.fr> * lib/tui-support.exp: New file for TUI testsuite. * gdb.tui/break.c: New file (from gdb.base/break.c) * gdb.tui/Makefile.in: New file for TUI testsuite. * gdb.tui/tui-commands.exp: New test for TUI specific commands. * gdb.tui/tui-break.exp: New test for TUI debugging. * gdb.tui/tui-regs.exp: New test for TUI register window and commands * gdb.tui/tui-mode.exp: New test for entering/leaving TUI mode. * gdb.tui/tui-single-key.exp: New test for TUI SingleKey mode.
Index: lib/tui-support.exp =================================================================== RCS file: lib/tui-support.exp diff -N lib/tui-support.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/tui-support.exp 12 Nov 2005 16:06:18 -0000 @@ -0,0 +1,155 @@ +# Copyright 1999, 2000, 2002, 2003, 2005 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; +} + +# Synchronize with TUI output. This is necessary in some cases because +# of the curses output. +proc tui-sync { } { + send_gdb "show prompt\n" + gdb_expect 5 { + -re ".*Gdb.s.prompt.is.*" { + pass "synchronize gdb-tui and testsuite" + } + timeout { + fail "synchronize gdb-tui and testsuite" + } + } +} + +# Send a command and verify the output. +# Unlike gdb_test, we must not change the expect pattern and wait for +# the gdb prompt. It TUI mode, it may not be printed (due to curses). +proc tui-check { input expect title } { + send_gdb "$input" + gdb_expect 10 { + -re $expect { + pass "$title" + } + timeout { + fail "$title (timeout)" + } + } +} + diff -Nup null/break.c gdb.tui/break.c --- null/break.c 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/break.c 2005-11-12 13:37:59.000000000 +0100 @@ -0,0 +1,131 @@ +#ifdef vxworks + +# include <stdio.h> + +/* 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 <stdio.h> +# include <stdlib.h> +#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 <number>\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 -Nup null/Makefile.in gdb.tui/Makefile.in --- null/Makefile.in 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/Makefile.in 2005-11-12 13:37:59.000000000 +0100 @@ -0,0 +1,20 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +EXECUTABLES = break + +MISCELLANEOUS = + +all info install-info dvi install uninstall installcheck check: + @echo "Nothing to be done for $@..." + +clean mostlyclean: + -rm -f *~ *.o a.out *.x *.ci *.tmp + -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES) + -rm -f $(MISCELLANEOUS) + +distclean maintainer-clean realclean: clean + -rm -f *~ core + -rm -f Makefile config.status config.log + -rm -f *-init.exp + -rm -fr *.log summary detail *.plog *.sum *.psum site.* diff -Nup null/tui-break.exp gdb.tui/tui-break.exp --- null/tui-break.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-break.exp 2005-11-12 17:48:53.000000000 +0100 @@ -0,0 +1,230 @@ +# Copyright 2003, 2005 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.*$gdb_prompt" { + pass "TUI, continue to factorial" + } + -re ".*96.*if..value...1.*B\\+.*$gdb_prompt" { + pass "TUI, continue to factorial" + } + timeout { + fail "TUI, continue to factorial (timeout)" + } +} + +tui-sync + +# 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 "2" +gdb_expect 5 { + -re ".*B\\+.*0x\[0-9a-f\]+\[ \t\].factorial.*" { + pass "TUI, display of asm window" + } + -re ".*0x\[0-9a-f\]+\[ \t\].factorial.*B\\+\\>.*" { + pass "TUI, display of asm window" + } + timeout { + fail "TUI, display of asm window (timeout)" + } +} + +tui-sync + +# 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 10 { + -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 -Nup null/tui-commands.exp gdb.tui/tui-commands.exp --- null/tui-commands.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-commands.exp 2005-11-12 17:48:02.000000000 +0100 @@ -0,0 +1,195 @@ +# Copyright 2005 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 commands. +# + +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 + +# Expect one TUI layout after a layout next or layout prev command +proc tui-expect-one-layout { mode title } { + switch $mode { + "src" { + gdb_expect 5 { + -re ".*No Source Available.*" { + pass "$title (source)" + } + timeout { + fail "$title" + } + } + set pattern ".*SRC.*has focus.*CMD.*Gdb.s.prompt.is.*" + } + + "asm" { + gdb_expect 5 { + -re ".*No Assembly Available.*" { + pass "$title (asm)" + } + timeout { + fail "$title" + } + } + set pattern ".*ASM.*has focus.*CMD.*Gdb.s.prompt.is.*" + } + + "src+asm" { + gdb_expect 5 { + -re ".*No Source Available.*No Assembly Available.*" { + pass "$title (src+asm)" + } + -re ".*No Assembly Available.*No Source Available.*" { + pass "$title (src+asm)" + } + timeout { + fail "$title" + } + } + set pattern ".*SRC.*ASM.*CMD.*Gdb.s.prompt.is.*" + } + + "src+regs" { + gdb_expect 5 { + -re ".*Register Values Unavailable.*No Source Available.*" { + pass "$title (reg+src)" + } + -re ".*No Source Available.*Register Values Unavailable.*" { + pass "$title (reg+src)" + } + timeout { + fail "$title" + } + } + set pattern ".*SRC.*REGS.*CMD.*Gdb.s.prompt.is.*" + } + + "asm+regs" { + gdb_expect 5 { + -re ".*Register Values Unavailable.*No Assemblty Available.*" { + pass "$title (reg+src)" + } + -re ".*No Assembly Available.*Register Values Unavailable.*" { + pass "$title (reg+src)" + } + timeout { + fail "$title" + } + } + set pattern ".*ASM.*REGS.*CMD.*Gdb.s.prompt.is.*" + } + } + + send_gdb "info win\nshow prompt\n" + gdb_expect 5 { + -re $pattern { + pass "info win $title" + } + timeout { + fail "info win $title" + } + } +} + +# Get in sync with gdb and TUI. +send_gdb "layout asm\nshow prompt\n" +gdb_expect 5 { + -re ".*Gdb.s.prompt.is.*" { + pass "synchronize gdb-tui and testsuite" + } + timeout { + fail "synchronize gdb-tui and testsuite" + } +} + +# We expect the current layout to be different than 'src'. +send_gdb "layout src\n" +tui-expect-one-layout "src" "layout src" + +send_gdb "layout asm\n" +tui-expect-one-layout "asm" "layout asm" + +send_gdb "layout split\n" +tui-expect-one-layout "src+asm" "layout split" + +send_gdb "layout regs\n" +tui-expect-one-layout "asm+regs" "layout regs" + +# Check layout next command. +send_gdb "layout next\n" +tui-expect-one-layout "src" "layout next (src)" + +send_gdb "layout next\n" +tui-expect-one-layout "asm" "layout next (asm)" + +send_gdb "layout next\n" +tui-expect-one-layout "src+asm" "layout next (src+asm)" + +send_gdb "layout next\n" +tui-expect-one-layout "src+regs" "layout next (src+regs)" + +send_gdb "layout next\n" +tui-expect-one-layout "asm+regs" "layout next (asm+regs)" + +# Check layout prev command. +send_gdb "layout prev\n" +tui-expect-one-layout "src+regs" "layout prev (src+regs)" + +send_gdb "layout prev\n" +tui-expect-one-layout "src+asm" "layout prev (src+asm)" + +send_gdb "layout prev\n" +tui-expect-one-layout "asm" "layout prev (asm)" + +send_gdb "layout prev\n" +tui-expect-one-layout "src" "layout prev (src)" + +tui-check "show tui border-kind\n" \ + ".*The kind of border for TUI windows is.*" \ + "show tui border-kind (1)" + +tui-check "show tui active-border-mode\n" \ + ".*The attribute mode to use for the active TUI window border is.*" \ + "show tui active-border-mode (1)" + +tui-check "show tui border-mode\n" \ + ".*The attribute mode to use for the TUI window borders is.*" \ + "show tui border-mode (1)" + + + + + + + diff -Nup null/tui-mode.exp gdb.tui/tui-mode.exp --- null/tui-mode.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-mode.exp 2005-11-12 17:44:57.000000000 +0100 @@ -0,0 +1,183 @@ +# Copyright 2003, 2005 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 "2show prompt\n" +gdb_expect 5 { + -re ".*No.Source.Available.*No.Assembly.Available.*Gdb.s.prompt.is.*" { + pass "Keybinding CTRL-X 2 (src+asm)" + } + -re ".*No.Assembly.Available.*No.Source.Available.*Gdb.s.prompt.is.*" { + pass "Keybinding CTRL-X 2 (src+asm)" + } + timeout { + fail "Keybinding CTRL-X 2 (src+asm) timeout" + } +} + +# Switch the layout to see register+assembly +send_gdb "2show prompt\n" +gdb_expect 5 { + -re ".*Register.Values.Unavailable.*No.Assembly.Available.*Gdb.s.prompt.is.*" { + pass "Keybinding CTRL-X 2 (asm+reg)" + } + -re ".*No.Assembly.Available.*Register.Values.Unavailable.*Gdb.s.prompt.is.*" { + 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 -Nup null/tui-regs.exp gdb.tui/tui-regs.exp --- null/tui-regs.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-regs.exp 2005-11-12 17:39:23.000000000 +0100 @@ -0,0 +1,230 @@ +# Copyright 2005 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, displaying registers 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; +} + +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)" + } +} + +# 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.*Breakpoint.\[0-9\]+, factorial.*"\ + { 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\]+, factorial \\(value=.*\\) at .*$srcfile:96.*96\[\t \]+if .value.*\{.*" "stub continue" + } +} + +# Enter in TUI mode and display the registers + source layout. +send_gdb "layout regs\n" +gdb_expect 5 { + -re ".*Register group:.*\[0-9a-z\].*0x\[0-9a-f\]+.*int.factorial.*" { + pass "TUI, display of regs+src window" + } + -re ".*int.factorial.*Register group:.*\[0-9a-z\].*0x\[0-9a-f\]+.*" { + pass "TUI, display of regs+src window" + } + timeout { + fail "TUI, display of regs+src window (timeout)" + } +} + +tui-sync + +# Display several register groups (this only verifies that the tui reg next +# command does not crash). +for { set i 0 } { $i < 10 } { incr i } { + send_gdb "tui reg next\n" + gdb_expect 10 { + -re ".*\[a-z0-9\]+\[ =\t\]+\[0-9a-fx\]+.*" { + pass "TUI, tui reg next, pass $i" + } + -re ".*No.Data.Values.Displayed.*" { + pass "TUI, tui reg next, pass $i" + } + timeout { + fail "TUI, tui reg next, pass $i, (timeout)" + } + } +} + +proc get_valueofx { fmt exp default } { + global gdb_prompt + send_gdb "print${fmt} ${exp}\n" + gdb_expect { + -re "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*$gdb_prompt $" { + set val $expect_out(1,string) + pass "get value of ${exp} ($val)" + } + timeout { + set val ${default} + fail "get value of ${exp} (timeout)" + } + } + return ${val} +} + +# For a specific target, give the name of some general purpose registers +# that we can use for the 'tui reg general' test. Register names are separated +# by ','. They must at least be 16-bit wide. They will be modified. +# (the test stops after that test). +set registers "" +switch -glob -- [istarget] { + "m6811-*-*" { + set registers "d,x,y" + send_gdb "set \$d = 0x1234\n" + } + "m6812-*-*" { + set registers "d,x,y" + send_gdb "set \$d = 0x1234\n" + } + "i[3456]86-*-*" { + set registers "eax,ebx,ecx,edx" + } +} + +# Switch to float registers for the next test (this is to force +# curses to print out the registers we want). +send_gdb "tui reg float\n" +gdb_expect 10 { + -re ".*\[a-z0-9\]+\[ =\t\]+\[0-9a-fx\]+.*" { + pass "TUI, tui reg float" + } + -re ".*No.Data.Values.Displayed.*" { + pass "TUI, tui reg float" + } + timeout { + fail "TUI, tui reg float (timeout)" + } +} + +# If we know a register name, make some specific test on that register. +foreach reg_name [split "$registers" ","] { + set valueof_reg [get_valueofx "/x" "\$$reg_name" "0"] + + send_gdb "tui reg general\n" + gdb_expect 10 { + -re ".*$reg_name.*$valueof_reg.*" { + pass "TUI, tui reg general, register $reg_name" + } + timeout { + fail "TUI, tui reg general, register $reg_name, (timeout)" + } + } + + # Set the register to a well known value + send_gdb "set \$$reg_name = 0\n" + tui-sync + + # Set the register to some value and verify we get that value in the + # display (the 'set $x = v' command does not print anything). + # Set to a 16-bit value so that it's ok on the embedded targets. + send_gdb "set \$$reg_name = 0xabcd\n" + gdb_expect 10 { + -re ".*0xabcd.*" { + pass "TUI, set $reg_name 0xabcd" + } + timeout { + fail "TUI, set $reg_name 0xabcd (timeout)" + } + } + + send_gdb "set \$$reg_name = 0xdcba\n" + gdb_expect 10 { + -re ".*0xdcba.*" { + pass "TUI, set $reg_name 0xdbca" + } + timeout { + fail "TUI, set $reg_name 0xdcba (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 -Nup null/tui-single-key.exp gdb.tui/tui-single-key.exp --- null/tui-single-key.exp 1970-01-01 01:00:00.000000000 +0100 +++ gdb.tui/tui-single-key.exp 2005-11-12 17:33:57.000000000 +0100 @@ -0,0 +1,338 @@ +# 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) +send_gdb "u" +gdb_expect 10 { + -re "No\[ \t\]stack\." { + pass "TUI, SingleKey 'u' (no prog)" + } + -re "Initial frame selected.*cannot go up" { + pass "TUI, SingleKey 'u' (no prog)" + } + timeout { + fail "TUI, SingleKey 'u' (no prog) (timeout)" + } +} + +send_gdb "d" +gdb_expect 10 { + -re "No\[ \t\]stack\." { + pass "TUI, SingleKey 'd' (no prog)" + } + -re "Bottom.*frame selected.*cannot go down" { + pass "TUI, SingleKey 'd' (no prog)" + } + timeout { + fail "TUI, SingleKey 'd' (no prog) (timeout)" + } +} + +send_gdb "w" +gdb_expect 10 { + -re "No\[ \t\]stack\." { + pass "TUI, SingleKey 'w' (no prog)" + } + -re "\#0.*" { + pass "TUI, SingleKey 'w' (no prog)" + } + timeout { + fail "TUI, SingleKey 'w' (no prog) (timeout)" + } +} + +send_gdb "v" +gdb_expect 10 { + -re "No\[ \t\]frame\[ \t\]selected\." { + pass "TUI, SingleKey 'v' (no prog)" + } + -re "No\[ \t\]locals\." { + pass "TUI, SingleKey 'v' (no prog)" + } + -re "No\[ \t\]symbol.table.info.available" { + pass "TUI, SingleKey 'v' (no prog)" + } + timeout { + fail "TUI, SingleKey 'v' (no prog) (timeout)" + } +} + +send_gdb "f" +gdb_expect 10 { + -re "The.program.is.not.running\." { + pass "TUI, SingleKey 'f' (no prog)" + } + -re ".*finish.*not.meaningful.in.the.outermost.frame\." { + pass "TUI, SingleKey 'f' (no prog)" + } + timeout { + fail "TUI, SingleKey 'f' (no prog) (timeout)" + } +} + +tui-check "c" "The.program.is.not.being.run\." "TUI, SingleKey 'c' (no prog)" +tui-check "s" "The.program.is.not.being.run\." "TUI, SingleKey 's' (no prog)" +tui-check "n" "The.program.is.not.being.run\." "TUI, SingleKey 'n' (no prog)" + +# 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 ".*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.*$srcfile.*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 $" {} +}
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |