diff options
author | Andrew Cagney <cagney@redhat.com> | 2001-06-18 12:55:07 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2001-06-18 12:55:07 +0000 |
commit | b85045e00b6c4078feb46b9f98d31df5a98d3b54 (patch) | |
tree | 42f7827deba55e366322bb85eb509dbb507598cb /gdb/testsuite/gdb.mi | |
parent | f6eb6cffbabe896b8f69fb82ad19212c9878c825 (diff) | |
download | gdb-b85045e00b6c4078feb46b9f98d31df5a98d3b54.zip gdb-b85045e00b6c4078feb46b9f98d31df5a98d3b54.tar.gz gdb-b85045e00b6c4078feb46b9f98d31df5a98d3b54.tar.bz2 |
Clone the mi-*.exp tests into mi0-*.exp.
Diffstat (limited to 'gdb/testsuite/gdb.mi')
-rw-r--r-- | gdb/testsuite/gdb.mi/ChangeLog-mi | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-basics.exp | 177 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-break.exp | 141 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-console.exp | 112 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-disassemble.exp | 227 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-eval.exp | 105 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-hack-cli.exp | 43 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-read-memory.exp | 103 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-regs.exp | 183 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-return.exp | 94 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-simplerun.exp | 232 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-stack.exp | 222 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-stepi.exp | 110 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-until.exp | 127 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-var-block.exp | 233 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-var-child.exp | 1334 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-var-cmd.exp | 609 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-var-display.exp | 628 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi0-watch.exp | 195 |
19 files changed, 4897 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.mi/ChangeLog-mi b/gdb/testsuite/gdb.mi/ChangeLog-mi index be7c543..4349d09 100644 --- a/gdb/testsuite/gdb.mi/ChangeLog-mi +++ b/gdb/testsuite/gdb.mi/ChangeLog-mi @@ -1,3 +1,25 @@ +2001-06-16 Andrew Cagney <ac131313@redhat.com> + + MI0 was the never enabled MI interface included in GDB 5.0. + * mi0-basics.exp: Copy mi-basics.exp. + * mi0-break.exp: Copy mi-break.exp. + * mi0-console.exp: Copy mi-console.exp. + * mi0-disassemble.exp: Copy mi-disassemble.exp. + * mi0-eval.exp: Copy mi-eval.exp. + * mi0-hack-cli.exp: Copy mi-hack-cli.exp. + * mi0-read-memory.exp: Copy mi-read-memory.exp. + * mi0-regs.exp: Copy mi-regs.exp. + * mi0-return.exp: Copy mi-return.exp. + * mi0-simplerun.exp: Copy mi-simplerun.exp. + * mi0-stack.exp: Copy mi-stack.exp. + * mi0-stepi.exp: Copy mi-stepi.exp. + * mi0-until.exp: Copy mi-until.exp. + * mi0-var-block.exp: Copy mi-var-block.exp. + * mi0-var-child.exp: Copy mi-var-child.exp. + * mi0-var-cmd.exp: Copy mi-var-cmd.exp. + * mi0-var-display.exp: Copy mi-var-display.exp. + * mi0-watch.exp: Copy mi-watch.exp. + 2001-05-11 Fernando Nasser <fnasser@redhat.com> * mi-var-child.exp: Adjust for the fact that now (char *) can be diff --git a/gdb/testsuite/gdb.mi/mi0-basics.exp b/gdb/testsuite/gdb.mi/mi0-basics.exp new file mode 100644 index 0000000..41ce792 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-basics.exp @@ -0,0 +1,177 @@ +# Copyright 1999, 2000 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 + +# +# test basic Machine interface (MI) operations +# +# Verify that, using the MI, we can load a program and do +# other basic things that are used by all test files through mi_gdb_exit, +# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and +# mi_gdb_load, so we can safely use those. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but the command syntax and correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# In this file we want to test if the operations needed by the following +# procedures work, so it makes no sense using them here. + +# mi_delete_breakpoints +# mi_gdb_reinitialize_dir $srcdir/$subdir +# mi_gdb_load ${binfile} + +# Test if the MI interpreter has been configured + +proc test_mi_interpreter_selection {} { + global mi_gdb_prompt + global gdb_prompt + + # All this test expects is to get the prompt back + # with no syntax error message + send_gdb "-gdb-version\n" + gdb_expect { + -re "GNU gdb .*\r\n$mi_gdb_prompt$" \ + { pass "acceptance of MI operations" + return 1} + -re ".*\r\n$mi_gdb_prompt$" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + -re "Undefined command.*$gdb_prompt $" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + -re ".*$gdb_prompt $" \ + { fail "acceptance of MI operations" + note "Skipping all other MI tests." } + timeout { fail "acceptance of MI operations (timeout)" + note "Skipping all other MI tests." } + } + return 0 +} + +proc test_exec_and_symbol_mi_operatons {} { + global mi_gdb_prompt + global binfile + + # Load symbols and specify executable on a single operation + # Tests: + # -file-exec-and-symbols + + # Can't use mi_gdb_test as if this doesn't work, + # we must give up on the whole test file + send_gdb "-file-exec-and-symbols ${binfile}\n" + gdb_expect { + -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \ + { pass "file-exec-and-symbols operation" } + timeout { fail "file-exec-and-symbols operation (timeout)" + note "Skipping all other MI tests." + return 0} + } + + # The following is not used by mi-support.exp, but we test here so + # we get done with loading a program basics. + + # Do it again, but now load symbols and specify executable with + # two separate operations + # Tests: + # -file-clear + # -file-exec-file + # -file-symbol-file + + # FIXME: file-clear is not implemented yet. +# mi_gdb_test "-file-clear" \ +# "\\\^done" \ +# "file-clear operation" + + mi_gdb_test "-file-exec-file ${binfile}" \ + "\\\^done" \ + "file-exec-file operation" + + mi_gdb_test "-file-symbol-file ${binfile}" \ + "\\\^done" \ + "file-symbol-file operation" + + # FIXME: if we cannot load we have to skip all other tests. +} + +proc test_breakpoints_deletion {} { + global mi_gdb_prompt + global srcfile + + # Clear all breakpoints and list to confirm + # Tests: + # -break-delete (all) + # -break-list + + # The all parameter is actually no parameter. + mi_gdb_test "200-break-delete" \ + "\\\^done" \ + "break-delete (all) operation" + + mi_gdb_test "201-break-list" \ + ".*\\\^done,BreakpointTable=\\\{\\\}" \ + "all breakpoints removed" +} + +proc test_dir_specification {} { + global mi_gdb_prompt + global srcdir + global subdir + + # Clear the search directories, then specify one to be searched + # Tests: + # -environment-directory + # -environment-directory arg + +#exp_internal 1 + mi_gdb_test "202-environment-directory" \ + "\\\^done" \ + "environment-directory operation" + + mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \ + "\\\^done" \ + "environment-directory arg operation" +#exp_internal 0 +} + +if [test_mi_interpreter_selection] { + test_exec_and_symbol_mi_operatons + test_breakpoints_deletion + test_dir_specification +} + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-break.exp b/gdb/testsuite/gdb.mi/mi0-break.exp new file mode 100644 index 0000000..8ac38ea --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-break.exp @@ -0,0 +1,141 @@ +# Copyright 1999 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_tbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert -t main + # -break-insert -t basics.c:callee2 + # -break-insert -t basics.c:15 + # -break-insert -t srcfile:6 + # -break-list + + mi_gdb_test "222-break-insert -t main" \ + "222\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert -t operation" + + mi_gdb_test "333-break-insert -t basics.c:callee2" \ + "333\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",line=\"22\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:callee2" + + mi_gdb_test "444-break-insert -t basics.c:15" \ + "444\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"15\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:15 (callee3)" + + # Getting the quoting right is tricky. That is "\"<file>\":6" + mi_gdb_test "555-break-insert -t \"\\\"${srcfile}\\\":6\"" \ + "555\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"6\",times=\"0\"\}" \ + "insert temp breakpoint at \"<fullfilename>\":6 (callee4)" + + mi_gdb_test "666-break-list" \ + "666\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \ + "list of breakpoints" + + mi_gdb_test "777-break-delete" \ + "777\\^done" \ + "delete temp breakpoints" +} + +proc test_rbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert -r main + # -break-insert -r callee2 + # -break-insert -r callee + # -break-insert -r .*llee + # -break-list + + setup_xfail "*-*-*" + mi_gdb_test "122-break-insert -r main" \ + "122\\^done,bkpt=\{number=\"5\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \ + "break-insert -r operation" + + setup_xfail "*-*-*" + mi_gdb_test "133-break-insert -r callee2" \ + "133\\^done,bkpt=\{number=\"6\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\}" \ + "insert breakpoint with regexp callee2" + + setup_xfail "*-*-*" + mi_gdb_test "144-break-insert -r callee" \ + "144\\^done,bkpt=\{number=\"7\",addr=\"$hex\",file=\".*basics.c\",line=\"27\"\},bkpt=\{number=\"8\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\},bkpt=\{number=\"9\",addr=\"$hex\",file=\".*basics.c\",line=\"17\"\},bkpt=\{number=\"10\",addr=\"$hex\",file=\".*basics.c\",line=\"8\"\}" \ + "insert breakpoint with regexp callee" + + setup_xfail "*-*-*" + mi_gdb_test "155-break-insert -r \.\*llee" \ + "155\\^done,bkpt=\{number=\"11\",addr=\"$hex\",file=\".*basics.c\",line=\"27\"\},bkpt=\{number=\"12\",addr=\"$hex\",file=\".*basics.c\",line=\"22\"\},bkpt=\{number=\"13\",addr=\"$hex\",file=\".*basics.c\",line=\"17\"\},bkpt=\{number=\"14\",addr=\"$hex\",file=\".*basics.c\",line=\"8\"\}" \ + "insert breakpoint with regexp .*llee" + + setup_xfail "*-*-*" + mi_gdb_test "166-break-list" \ + "166\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete" \ + "177\\^done" \ + "delete temp breakpoints" +} + +test_tbreak_creation_and_listing +test_rbreak_creation_and_listing + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-console.exp b/gdb/testsuite/gdb.mi/mi0-console.exp new file mode 100644 index 0000000..04ee841 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-console.exp @@ -0,0 +1,112 @@ +# Copyright 1999, 2000, 2001 Cygnus Solutions. + +# 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +# This test only works when talking to a target that routes its output +# through GDB. Check that we're either talking to a simulator or a +# remote target. + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-console" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# Halt in main +mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*mi-console.c\",line=\"13\",times=\"0\"\}" \ + "break-insert operation" +mi_run_cmd +gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*mi-console.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + timeout { + fail "run to main (timeout)" + } +} + +# Next over the hello() call which will produce lots of output +send_gdb "47-exec-next\n" +gdb_expect { + -re "47\\^running\r\n$mi_gdb_prompt" { + pass "Started step over hello" + } + timeout { + fail "Started step over hello (timeout)" + } +} + +gdb_expect { + -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" { + pass "Hello message" + } + -re "Hello" { + + # Probably a native system where GDB doesn't have direct + # control over the inferior console. + # For this to work, GDB would need to run the inferior process + # under a PTY and then use the even-loops ability to wait on + # multiple event sources to channel the output back through the + # MI. + + fail "Hello message (known bug)" + } + timeout { + fail "Hello message (timeout)" + } +} + +gdb_expect { + -re "47\\*stopped.*$mi_gdb_prompt$" { + pass "Finished step over hello" + } + timeout { + fail "Finished step over hello (timeout)" + } +} + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-disassemble.exp b/gdb/testsuite/gdb.mi/mi0-disassemble.exp new file mode 100644 index 0000000..75f097d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-disassemble.exp @@ -0,0 +1,227 @@ +# Copyright 1999, 2000 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 + +# +# Test Machine interface (MI) operations for disassembly. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_breakpoints_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert + # -break-list + # -break-disable + # -break-info + + mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert operation" + + mi_gdb_test "204-break-list" \ + "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}\}" \ + "list of breakpoints" +} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args + # Tests: + # -exec-run + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # FIXME: We are accepting a duplicate file and line info temporarely. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + # The running part has been checked already by mi_run_cmd + gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + -re ".*$mi_gdb_prompt$" {fail "run to main (2)"} + timeout {fail "run to main (timeout 2)"} + } +} + +proc test_disassembly_only {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassemble -s $pc -e "$pc+8" -- 0 + # -data-disassembly -f basics.c -l 32 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "111-data-disassemble -s \$pc -e \"\$pc + 12\" -- 0" \ + "111\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \ + "data-disassemble from pc to pc+12 assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -- 0" \ + "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \ + "data-disassemble file & line, assembly only" +} + +proc test_disassembly_lines_limit {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 32 -n 20 -- 0 + # -data-disassembly -f basics.c -l 32 -n 0 -- 0 + # -data-disassembly -f basics.c -l 32 -n 50 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 0" \ + "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \ + "data-disassemble file, line, number assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 0" \ + "222\\^done,asm_insns=\{\}" \ + "data-disassemble file, line, number (zero lines) assembly only" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 0" \ + "222\\^done,asm_insns=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}" \ + "data-disassemble file, line, number (more than main lines) assembly only" +} + + +proc test_disassembly_mixed {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 21 -- 1 + # -data-disassembly -s $pc -e "$pc+8" -- 1 + + mi_gdb_test "002-data-disassemble -f basics.c -l 21 -- 1" \ + "002\\^done,asm_insns=\{src_and_asm_line=\{line=\"21\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\}\},.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\}\}\}" \ + "data-disassemble file, line assembly mixed" + + # + # In mixed mode, the lowest level of granularity is the source line. + # So we are going to get the disassembly for the source line at + # which we are now, even if we have specified that the range is only 2 insns. + # + mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \ + "003\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\}\}\}" \ + "data-disassemble range assembly mixed" +} + +proc test_disassembly_mixed_lines_limit {} { + global mi_gdb_prompt + global hex + global decimal + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l 32 -n 20 -- 1 + # -data-disassembly -f basics.c -l 32 -n 0 -- 1 + # -data-disassembly -f basics.c -l 32 -n 50 -- 1 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 20 -- 1" \ + "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \ + "data-disassemble file, line, number assembly mixed" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 0 -- 1" \ + "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"31\",file=\".*basics.c\",line_asm_insn=\{\}\}\}" \ + "data-disassemble file, line, number (zero lines) assembly mixed" + + mi_gdb_test "222-data-disassemble -f basics.c -l 32 -n 50 -- 1" \ + "222\\^done,asm_insns=\{src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\{\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\}" \ + "data-disassemble file, line, number (more than main lines) assembly mixed" +} + +proc test_disassembly_bogus_args {} { + global mi_gdb_prompt + global hex + + # Test that bogus input to disassembly command is rejected. + # Tests: + # -data-disassembly -f foo -l abc -n 0 -- 0 + # -data-disassembly -s foo -e bar -- 0 + # -data-disassembly -s $pc -f basics.c -- 0 + # -data-disassembly -f basics.c -l 32 -- 9 + + mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \ + ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \ + "data-disassemble bogus filename" + + mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \ + "321\\^error,msg=\"No symbol \\\\\"foo\\\\\" in current context.\"" \ + "data-disassemble bogus address" + + mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \ + "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \ + "data-disassemble mix different args" + + mi_gdb_test "789-data-disassemble -f basics.c -l 32 -- 9" \ + "789\\^error,msg=\"mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.\"" \ + "data-disassemble wrong mode arg" + +} + +test_breakpoints_creation_and_listing +test_running_the_program +test_disassembly_only +test_disassembly_mixed +test_disassembly_bogus_args +test_disassembly_lines_limit +test_disassembly_mixed_lines_limit + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-eval.exp b/gdb/testsuite/gdb.mi/mi0-eval.exp new file mode 100644 index 0000000..542d31d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-eval.exp @@ -0,0 +1,105 @@ +# Copyright 1999, 2000 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify -data-evaluate-expression. There are really minimal tests. + +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args, then specify srgs and rerun the program + # Tests: + # -exec-run + + mi_gdb_test "300-break-insert callee4" \ + "300\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \ + "insert breakpoint at callee4" + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + # The running part has been checked already by mi_run_cmd + gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" \ + { pass "run to callee4" } + -re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"} + timeout {fail "run to callee4 (timeout 2)"} + } + + send_gdb "101-exec-next\n" + gdb_expect { + -re "101\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "\[\r\n\]*101\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"9\"\}\r\n$mi_gdb_prompt$" \ + { pass "next in callee4" } + -re ".*$mi_gdb_prompt$" {fail "next in callee4 (2)"} + timeout {fail "next in callee4 (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "next in callee4 (1)"} + timeout {fail "next in callee4 (timeout 1)"} + } + +} + +test_running_the_program + +mi_gdb_test "211-data-evaluate-expression A" "211\\^done,value=\"1\"" "eval A" + +mi_gdb_test "311-data-evaluate-expression &A" "311\\^done,value=\"$hex\"" "eval &A" + +mi_gdb_test "411-data-evaluate-expression A+3" "411\\^done,value=\"4\"" "eval A+3" + +mi_gdb_test "511-data-evaluate-expression \"A + 3\"" "511\\^done,value=\"4\"" "eval A + 3" + + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + diff --git a/gdb/testsuite/gdb.mi/mi0-hack-cli.exp b/gdb/testsuite/gdb.mi/mi0-hack-cli.exp new file mode 100644 index 0000000..44b7ff3 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-hack-cli.exp @@ -0,0 +1,43 @@ +# Copyright 1999 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 + + +# Some basic checks for the CLI. + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +mi_gdb_test "show architecture\n" \ + "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n\\^done" \ + "show architecture" + +mi_gdb_test "47show architecture\n" \ + "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n47\\^done" \ + "47show architecture" + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-read-memory.exp b/gdb/testsuite/gdb.mi/mi0-read-memory.exp new file mode 100644 index 0000000..871b129 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-read-memory.exp @@ -0,0 +1,103 @@ +# Copyright 1999, 2000 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 + +# +# test basic Machine interface (MI) operations +# +# Verify that, using the MI, we can load a program and do +# other basic things that are used by all test files through mi_gdb_exit, +# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and +# mi_gdb_load, so we can safely use those. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but the command syntax and correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-read-memory" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + + +mi_run_to_main + +#mi_next "do initialization" +send_gdb "101-exec-next\n" +gdb_expect { + -re "101\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "\[\r\n\]*101\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*mi-read-memory.c\",line=\"20\"\}.*$mi_gdb_prompt$" \ + { pass "do initialization" } + -re ".*$mi_gdb_prompt$" {fail "do initialization (2)"} + timeout {fail "do initialization (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "do initialization (1)"} + timeout {fail "do initialization (timeout 1)"} +} + +mi_gdb_test "1-data-read-memory" \ + "1\\^error,msg=\".*\"" \ + "no arguments" + + +mi_gdb_test "2-data-read-memory bytes x 1 3 2" \ + "2\\^done,addr=\"$hex\",nr-bytes=\"6\",total-bytes=\"6\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"0x00\",\"0x01\"}},{addr=\"$hex\",data={\"0x02\",\"0x03\"}},{addr=\"$hex\",data={\"0x04\",\"0x05\"}}}" \ + "3x2, one byte" + + +mi_gdb_test "9-data-read-memory -o -6 -- -0+bytes+6 x 1 3 2" \ + "9\\^done,addr=\"$hex\",nr-bytes=\"6\",total-bytes=\"6\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"0x00\",\"0x01\"}},{addr=\"$hex\",data={\"0x02\",\"0x03\"}},{addr=\"$hex\",data={\"0x04\",\"0x05\"}}}" \ + "3x2, one byte offset by -6" + + +mi_gdb_test "3-data-read-memory \"(shorts + 128)\" x 2 1 2" \ + "3\\^done,addr=\"$hex\",nr-bytes=\"4\",total-bytes=\"4\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"0x0100\",\"0x0102\"}}}" \ + "expression in quotes" + + +mi_gdb_test "4-data-read-memory bytes+16 x 1 8 4 x" \ + "4\\^done,addr=\"$hex\",nr-bytes=\"32\",total-bytes=\"32\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"0x10\",\"0x11\",\"0x12\",\"0x13\"},ascii=\"xxxx\"},{addr=\"$hex\",data={\"0x14\",\"0x15\",\"0x16\",\"0x17\"},ascii=\"xxxx\"},{addr=\"$hex\",data={\"0x18\",\"0x19\",\"0x1a\",\"0x1b\"},ascii=\"xxxx\"},{addr=\"$hex\",data={\"0x1c\",\"0x1d\",\"0x1e\",\"0x1f\"},ascii=\"xxxx\"},{addr=\"$hex\",data={\"0x20\",\"0x21\",\"0x22\",\"0x23\"},ascii=\" !\\\\\"#\"},{addr=\"$hex\",data={\"0x24\",\"0x25\",\"0x26\",\"0x27\"},ascii=\"\\$%&'\"},{addr=\"$hex\",data={\"0x28\",\"0x29\",\"0x2a\",\"0x2b\"},ascii=\"().+\"},{addr=\"$hex\",data={\"0x2c\",\"0x2d\",\"0x2e\",\"0x2f\"},ascii=\",-\./\"}}" \ + "ascii and data" + + +mi_gdb_test "5-data-read-memory shorts+64 d 2 1 1" \ + "5\\^done,addr=\"$hex\",nr-bytes=\"2\",total-bytes=\"2\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"128\"}}}" \ + "decimal" + +mi_gdb_test "6-data-read-memory shorts+64 o 2 1 1" \ + "6\\^done,addr=\"$hex\",nr-bytes=\"2\",total-bytes=\"2\",next-row=\"$hex\",prev-row=\"$hex\",next-page=\"$hex\",prev-page=\"$hex\",memory={{addr=\"$hex\",data={\"0200\"}}}" \ + "octal" + + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-regs.exp b/gdb/testsuite/gdb.mi/mi0-regs.exp new file mode 100644 index 0000000..089b767 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-regs.exp @@ -0,0 +1,183 @@ +# Copyright 1999, 2000 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 +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and look at registers. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_breakpoints_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert + # -break-list + # -break-disable + # -break-info + + mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert operation" + + mi_gdb_test "204-break-list" \ + "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}\}" \ + "list of breakpoints" +} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args + # Tests: + # -exec-run + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # FIXME: We are accepting a duplicate file and line info temporarely. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + # The running part has been checked already by mi_run_cmd + gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + -re ".*$mi_gdb_prompt$" {fail "run to main (2)"} + timeout {fail "run to main (timeout 2)"} + } +} + +proc sparc_register_tests_no_exec { } { + # Test the generic IDT chip. + mi_gdb_test "111-data-list-register-values" \ + ".*111\\^error,msg=\"mi_cmd_data_list_register_values: Usage: -data-list-register-values <format> \\\[<regnum1>...<regnumN>\\\]\"" \ + "wrong arguments" + + mi_gdb_test "111-data-list-register-values x" \ + ".*111\\^error,msg=\"mi_cmd_data_list_register_values: No registers\.\"" \ + "no executable" +} + +# These tests exercise IDT-specific MIPS registers for several +# different processor models. + +# This should detect the actual processor in use and change +# the expected results appropriately. FIXME + +proc sparc_register_tests { } { + global hex + global decimal + set octal "\[0-7\]+" + set binary "\[0-1\]+" + set float "-?\[0-9\]+(\.\[0-9\]+)?(e\[+\-\]\[0-9\]+)?" + set float2 "\-?\[0-9\]+" + + mi_gdb_test "111-data-list-register-names" \ + "111\\^done,register-names=\{\"g0\",\"g1\",\"g2\",\"g3\",\"g4\",\"g5\",\"g6\",\"g7\",\"o0\",\"o1\",\"o2\",\"o3\",\"o4\",\"o5\",\"sp\",\"o7\",\"l0\",\"l1\",\"l2\",\"l3\",\"l4\",\"l5\",\"l6\",\"l7\",\"i0\",\"i1\",\"i2\",\"i3\",\"i4\",\"i5\",\"fp\",\"i7\",\"f0\",\"f1\",\"f2\",\"f3\",\"f4\",\"f5\",\"f6\",\"f7\",\"f8\",\"f9\",\"f10\",\"f11\",\"f12\",\"f13\",\"f14\",\"f15\",\"f16\",\"f17\",\"f18\",\"f19\",\"f20\",\"f21\",\"f22\",\"f23\",\"f24\",\"f25\",\"f26\",\"f27\",\"f28\",\"f29\",\"f30\",\"f31\",\"y\",\"psr\",\"wim\",\"tbr\",\"pc\",\"npc\",\"fpsr\",\"cpsr\"\}" \ + "list register names" + + mi_gdb_test "222-data-list-register-values x" \ + "222\\^done,register-values=\{\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\}" \ + "register values x" + + mi_gdb_test "333-data-list-register-values f" \ + "333\\^done,register-values=\{\{number=\"0\",value=\"$float\"\},\{number=\"1\",value=\"$float\"\},.*\{number=\"71\",value=\"$float\"\}\}" \ + "register values f" + + mi_gdb_test "444-data-list-register-values d" \ + "444\\^done,register-values=\{\{number=\"0\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\}" \ + "register values d" + + mi_gdb_test "555-data-list-register-values o" \ + "555\\^done,register-values=\{\{number=\"0\",value=\"$octal\"\}.*\{number=\"71\",value=\"$octal\"\}\}" \ + "register values o" + + mi_gdb_test "666-data-list-register-values t" \ + "666\\^done,register-values=\{\{number=\"0\",value=\"$binary\"\}.*\{number=\"71\",value=\"$binary\"\}\}" \ + "register values t" + + # On the sparc, registers 0-31 are int, 32-63 float, 64-71 int + + mi_gdb_test "777-data-list-register-values N" \ + "777\\^done,register-values=\{\{number=\"0\",value=\"$decimal\"\}.*\{number=\"31\",value=\"$decimal\"\},\{number=\"32\",value=\"$float\"\}.*\{number=\"63\",value=\"$float\"\},\{number=\"64\",value=\"$decimal\"\}.*\{number=\"71\",value=\"$decimal\"\}\}" \ + "register values N" + + mi_gdb_test "888-data-list-register-values r" \ + "888\\^done,register-values=\{\{number=\"0\",value=\"$hex\"\}.*\{number=\"71\",value=\"$hex\"\}\}" \ + "register values r" + + mi_gdb_test "999-data-list-register-names 68 69 70 71" \ + "999\\^done,register-names=\{\"pc\",\"npc\",\"fpsr\",\"cpsr\"\}" \ + "list names of some regs" + + mi_gdb_test "001-data-list-register-values x 68 69 70 71" \ + "001\\^done,register-values=\{\{number=\"68\",value=\"$hex\"\},\{number=\"69\",value=\"$hex\"\},\{number=\"70\",value=\"$hex\"\},\{number=\"71\",value=\"$hex\"\}\}" \ + "list values of some regs" + + # Don't know how useful this test is + + mi_gdb_test "002-data-list-changed-registers" \ + "002\\^done,changed-registers=\{\"1\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"30\",\"31\",\"65\",\"68\",\"69\"\}" \ + "list changed registers" +} + +if [istarget "sparc-*-*"] then { + sparc_register_tests_no_exec + test_breakpoints_creation_and_listing + test_running_the_program + sparc_register_tests +} else { + verbose "mi-regs.exp tests ignored for this target" +} + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + + + diff --git a/gdb/testsuite/gdb.mi/mi0-return.exp b/gdb/testsuite/gdb.mi/mi0-return.exp new file mode 100644 index 0000000..57ea05e --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-return.exp @@ -0,0 +1,94 @@ +# Copyright 1999, 2000 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 + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-return. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_running_to_callee4 {} { + global mi_gdb_prompt + global hex + + mi_gdb_test "200-break-insert callee4" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \ + "break-insert operation" + + mi_run_cmd + + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" { + pass "run to callee4" + } + timeout { + fail "run to callee4 (timeout)" + } + } + + mi_gdb_test "205-break-delete" \ + "205\\^done.*" \ + "delete all breakpoints" + +} + +proc test_return_simple {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-return\n" + gdb_expect { + -re "111\\^done,frame=\{level=\"0 \",addr=\"$hex\",func=\"callee3\",args=\{.*\},file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"} + -re ".*\r\n$mi_gdb_prompt$" { fail "return from callee4 now" } + timeout { fail "return from callee4 now (timeout)" + } + } +} + +test_running_to_callee4 +test_return_simple + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-simplerun.exp b/gdb/testsuite/gdb.mi/mi0-simplerun.exp new file mode 100644 index 0000000..636f60d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-simplerun.exp @@ -0,0 +1,232 @@ +# Copyright 1999, 2000 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_breakpoints_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert some breakpoints and list them + # Also, disable some so they do not interfere with other tests + # Tests: + # -break-insert + # -break-list + # -break-disable + # -break-info + + mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert operation" + + mi_gdb_test "201-break-insert basics.c:callee2" \ + "201\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",line=\"22\",times=\"0\"\}" \ + "insert breakpoint at basics.c:callee2" + + mi_gdb_test "202-break-insert basics.c:15" \ + "202\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"15\",times=\"0\"\}" \ + "insert breakpoint at basics.c:15 (callee3)" + + mi_gdb_test "203-break-insert \"\\\"${srcfile}\\\":6\"" \ + "203\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"6\",times=\"0\"\}" \ + "insert breakpoint at \"<fullfilename>\":6 (callee4)" + + mi_gdb_test "204-break-list" \ + "204\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \ + "list of breakpoints" + + mi_gdb_test "205-break-disable 2 3 4" \ + "205\\^done.*" \ + "disabling of breakpoints" + + mi_gdb_test "206-break-info 2" \ + "206\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"2\",.*,enabled=\"n\",.*\}\}" \ + "list of breakpoints, 16 disabled" +} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args, then specify srgs and rerun the program + # Tests: + # -exec-run + # -gdb-set + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + timeout { + fail "run to main (timeout)" + } + } +} + +proc test_controlled_execution {} { + global mi_gdb_prompt + global hex + + # Continue execution until a breakpoint is reached, step into calls, verifying + # if the arguments are correctly shown, continue to the end of a called + # function, step over a call (next). + # Tests: + # -exec-continue + # -exec-next + # -exec-step + # -exec-finish + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + send_gdb "220-exec-next\n" + gdb_expect { + -re "220\\^running\r\n${mi_gdb_prompt}220\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"33\"\}\r\n$mi_gdb_prompt$" { + pass "next at main" + } + timeout { + fail "next at main (timeout)" + } + } + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + # NOTE: The ``\\\\\"'' is for \". + send_gdb "221-exec-step\n" + gdb_expect { + -re "221\\^running\r\n${mi_gdb_prompt}221\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee1\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\},file=\".*basics.c\",line=\"27\"\}\r\n$mi_gdb_prompt$" { + pass "step at main" + } + timeout { + fail "step at main (timeout)" + } + } + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + send_gdb "222-exec-step 3\n" + gdb_expect 30 { + -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" { + pass "step to callee4" + } + timeout { + fail "step to callee4 (timeout)" + } + } + + # FIXME: A string argument is not printed right; should be fixed and + # we should look for the right thing here. + # NOTE: The ``.'' is part of ``gdb-result-var="$1"'' + send_gdb "223-exec-finish\n" + gdb_expect 30 { + -re "223\\^running\r\n${mi_gdb_prompt}223\\*stopped,reason=\"function-finished\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee3\",args=\{.*\},file=\".*basics.c\",line=\"18\"\},gdb-result-var=\".1\",return-value=\"0\"\r\n$mi_gdb_prompt$" { + pass "exec-finish" + } + timeout { + fail "exec-finish (timeout)" + } + } +} + +proc test_controlling_breakpoints {} { + global mi_gdb_prompt + + # Enable, delete, set ignore counts in breakpoints + # (disable was already tested above) + # Tests: + # -break-delete + # -break-enable + # -break-after + # -break-condition + +} + +proc test_program_termination {} { + global mi_gdb_prompt + + # Run to completion: normal and forced + # Tests: + # -exec-abort + # (normal termination of inferior) + + # FIXME: "stopped" doesn't seem appropriate. + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + send_gdb "999-exec-continue\n" + gdb_expect { + -re "999\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "999\\*stopped,reason=\"exited-normally\"\r\n$mi_gdb_prompt$" { + pass "continue to end" + } + -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"} + timeout {fail "continue to end (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "continue to end (1)"} + timeout {fail "continue to end (timeout 1)"} + } +} + +test_breakpoints_creation_and_listing +test_running_the_program +test_controlled_execution +test_controlling_breakpoints +test_program_termination + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + + diff --git a/gdb/testsuite/gdb.mi/mi0-stack.exp b/gdb/testsuite/gdb.mi/mi0-stack.exp new file mode 100644 index 0000000..045e981 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-stack.exp @@ -0,0 +1,222 @@ +# Copyright 2000 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify that stack commands work. + +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + + +mi_gdb_test "200-break-insert callee4" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" { + pass "run to callee4" + } + -re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"} + timeout {fail "run to callee4 (timeout 2)"} +} + + +proc test_stack_frame_listing {} { + global mi_gdb_prompt + global hex + + # Obtain a stack trace + # Tests: + # -stack-list-frames + # -stack-list-frames 1 1 + # -stack-list-frames 1 3 + + mi_gdb_test "231-stack-list-frames" \ + "231\\^done,stack=\{frame=\{level=\"0 \",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\"\},frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4 \",addr=\"$hex\",func=\"main\",.*\}\}" \ + "stack frame listing" + mi_gdb_test "232-stack-list-frames 1 1" \ + "232\\^done,stack=\{frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\}\}" \ + "stack frame listing 1 1" + mi_gdb_test "233-stack-list-frames 1 3" \ + "233\\^done,stack=\{frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\}\}" \ + "stack frame listing 1 3" + + mi_gdb_test "234-stack-list-frames 1" \ + "234\\^error,msg=\"mi_cmd_stack_list_frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \ + "stack frame listing wrong" +} + +proc test_stack_args_listing {} { + global mi_gdb_prompt + global hex + + # Obtain lists for args for the stack frames + # Tests: + # -stack-list-arguments 0 + # -stack-list-arguments 0 1 1 + # -stack-list-arguments 0 1 3 + # -stack-list-arguments 1 + # -stack-list-arguments 1 1 1 + # -stack-list-arguments 1 1 3 + # -stack-list-arguments + + mi_gdb_test "231-stack-list-arguments 0" \ + "231\\^done,stack-args=\{frame=\{level=\"0\",args=\{\}\},frame=\{level=\"1\",args=\{name=\"strarg\"\}\},frame=\{level=\"2\",args=\{name=\"intarg\",name=\"strarg\"\}\},frame=\{level=\"3\",args=\{name=\"intarg\",name=\"strarg\",name=\"fltarg\"\}\},frame=\{level=\"4\",args=\{\}\}\}" \ + "stack args listing 0" + + mi_gdb_test "232-stack-list-arguments 0 1 1" \ + "232\\^done,stack-args=\{frame=\{level=\"1\",args=\{name=\"strarg\"\}\}\}" \ + "stack args listing 0 1 1" + + mi_gdb_test "233-stack-list-arguments 0 1 3" \ + "233\\^done,stack-args=\{frame=\{level=\"1\",args=\{name=\"strarg\"\}\},frame=\{level=\"2\",args=\{name=\"intarg\",name=\"strarg\"\}\},frame=\{level=\"3\",args=\{name=\"intarg\",name=\"strarg\",name=\"fltarg\"\}\}\}" \ + "stack args listing 0 1 3" + + mi_gdb_test "231-stack-list-arguments 1" \ + "231\\^done,stack-args=\{frame=\{level=\"0\",args=\{\}\},frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"2\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"3\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\}\},frame=\{level=\"4\",args=\{\}\}\}" \ + "stack args listing 1" + + mi_gdb_test "232-stack-list-arguments 1 1 1" \ + "232\\^done,stack-args=\{frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\}\}" \ + "stack args listing 1 1 1" + + mi_gdb_test "233-stack-list-arguments 1 1 3" \ + "233\\^done,stack-args=\{frame=\{level=\"1\",args=\{\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"2\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\}\}\},frame=\{level=\"3\",args=\{\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}\}\}\}" \ + "stack args listing 1 1 3" + + mi_gdb_test "234-stack-list-arguments" \ + "234\\^error,msg=\"mi_cmd_stack_list_args: Usage.*PRINT_VALUES.*FRAME_LOW FRAME_HIGH.*\"" \ + "stack args listing wrong" +} + +proc test_stack_info_depth {} { + global mi_gdb_prompt + global hex + + # Obtain depth of stack + # Tests: + # -stack-info-depth + # -stack-info-depth 3 + # -stack-info-depth 99 + + mi_gdb_test "231-stack-info-depth" \ + "231\\^done,depth=\"5\"" \ + "stack info-depth" + + mi_gdb_test "231-stack-info-depth 3" \ + "231\\^done,depth=\"3\"" \ + "stack info-depth 3" + + mi_gdb_test "231-stack-info-depth 99" \ + "231\\^done,depth=\"5\"" \ + "stack info-depth 99" + + mi_gdb_test "231-stack-info-depth 99 99" \ + "231\\^error,msg=\"mi_cmd_stack_info_depth: Usage: .MAX_DEPTH.\"" \ + "stack info-depth wrong usage" +} + +proc test_stack_locals_listing {} { + global mi_gdb_prompt + global hex + + # Obtain lists for locals for the stack frames + # Tests: + # -stack-list-locals 0 + # -stack-list-locals 1 + # -stack-list-arguments + + mi_gdb_test "232-stack-list-locals 0" \ + "232\\^done,locals=\{name=\"A\",name=\"B\",name=\"C\"\}" \ + "stack locals listing 0" + +# step until A, B, C, have some reasonable values. +send_gdb "-exec-next 3\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" { + pass "next's in callee4" + } + timeout { fail "next in callee4 (timeout)" } +} + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\{\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\}\}" \ + "stack locals listing 1" + + mi_gdb_test "234-stack-list-locals" \ + "234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \ + "stack locals listing wrong" + + mi_gdb_test "232-stack-select-frame 1" \ + "232\\^done" \ + "stack select frame 1" + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\{\}" \ + "stack locals listing for new frame" + +# this should be a no-op + + mi_gdb_test "232-stack-select-frame" \ + "232\\^done" \ + "stack select same frame" + + mi_gdb_test "232-stack-list-locals 1" \ + "232\\^done,locals=\{\}" \ + "stack locals for same frame (level 1)" + +} + +test_stack_frame_listing +test_stack_args_listing +test_stack_locals_listing +test_stack_info_depth + + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + diff --git a/gdb/testsuite/gdb.mi/mi0-stepi.exp b/gdb/testsuite/gdb.mi/mi0-stepi.exp new file mode 100644 index 0000000..a67d742 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-stepi.exp @@ -0,0 +1,110 @@ +# Copyright 1999, 2000 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 + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-step-instruction and exec-next-instruction. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_running_to_main {} { + global mi_gdb_prompt + global hex + + mi_gdb_test "200-break-insert main" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert operation" + + mi_run_cmd + + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"32\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + timeout { + fail "run to main (timeout)" + } + } +} + +proc test_stepi_nexti {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-step-instruction\n" + gdb_expect { + -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "step-instruction at main" + } + timeout { + fail "step-instruction at main (timeout)" + } + } + send_gdb "222-exec-next-instruction\n" + gdb_expect { + -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "next-instruction at main" + } + timeout { + fail "next-instruction at main (timeout)" + } + } + send_gdb "333-exec-next-instruction\n" + gdb_expect { + -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*basics.c\",line=\"3.\"\}\r\n$mi_gdb_prompt$" { + pass "next-instruction at main" + } + timeout { + fail "next-instruction at main (timeout)" + } + } +} + +test_running_to_main +test_stepi_nexti + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + diff --git a/gdb/testsuite/gdb.mi/mi0-until.exp b/gdb/testsuite/gdb.mi/mi0-until.exp new file mode 100644 index 0000000..cf3c21d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-until.exp @@ -0,0 +1,127 @@ +# Copyright 1999, 2000 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 + +# Test Machine interface (MI) operations +# Verify that, using the MI, we can run a simple program and perform +# exec-until. + +# The goal is not to +# test gdb functionality, which is done by other tests, but to verify +# the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "until" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_running_to_foo {} { + global mi_gdb_prompt + global hex + + mi_gdb_test "200-break-insert 10" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"foo\",file=\".*until.c\",line=\"10\",times=\"0\"\}" \ + "break-insert operation" + + mi_run_cmd + + gdb_expect { + -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"foo\",args=\{\},file=\".*until.c\",line=\"10\"\}\r\n$mi_gdb_prompt$" { + pass "run to main" + } + timeout { + fail "run to main (timeout)" + } + } + + mi_gdb_test "100-break-delete 1" "100\\^done" "break-delete 1" + +} + +proc test_until {} { + global mi_gdb_prompt + global hex + + send_gdb "111-exec-until\n" + gdb_expect { + -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"foo\",args=\{\},file=\".*until.c\",line=\"12\"\}\r\n$mi_gdb_prompt$" { + pass "until after while loop" + } + timeout { + fail "until after while loop (timeout)" + } + } + + send_gdb "222-exec-until 15\n" + gdb_expect { + -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"location-reached\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"foo\",args=\{\},file=\".*until.c\",line=\"15\"\}\r\n$mi_gdb_prompt$" { + pass "until line number" + } + timeout { + fail "until line number (timeout)" + } + } + + send_gdb "333-exec-until until.c:17\n" + gdb_expect { + -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"location-reached\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"foo\",args=\{\},file=\".*until.c\",line=\"17\"\}\r\n$mi_gdb_prompt$" { + pass "until line number:file" + } + timeout { + fail "until line number:file (timeout)" + } + } + + # This is supposed to NOT stop at line 25. It stops right after foo is over. + + send_gdb "444-exec-until until.c:25\n" + gdb_expect { + -re "444\\^running\r\n${mi_gdb_prompt}444\\*stopped,reason=\"location-reached\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"main\",args=\{\},file=\".*until.c\",line=\"24\"\}\r\n$mi_gdb_prompt$" { + pass "until after current function" + } + timeout { + fail "until after current function (timeout)" + } + } + +} + +test_running_to_foo +test_until + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-var-block.exp b/gdb/testsuite/gdb.mi/mi0-var-block.exp new file mode 100644 index 0000000..539a58d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-var-block.exp @@ -0,0 +1,233 @@ +# Copyright (C) 1999 2000 s Solutions +# +# 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 + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "200-break-insert do_block_tests" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_block_tests\",file=\".*var-cmd.c\",line=\"154\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"154\"\}\r\n$mi_gdb_prompt$" { + pass "run to do_block_tests" + } + -re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"} + timeout {fail "run to do_block_tests (timeout 2)"} +} + +# Test: c_variable-3.2 +# Desc: create cb and foo +mi_gdb_test "-var-create cb * cb" \ + "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \ + "create local variable cb" + +mi_gdb_test "-var-create foo * foo" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create local variable foo" + +# step to "foo = 123;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"158\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { + fail "step at do_block_tests (timeout)" + } +} + + +# Be paranoid and assume 3.2 created foo +mi_gdb_test "-var-delete foo" \ + "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \ + "delete var foo" + + +# Test: c_variable-3.3 +# Desc: create foo +mi_gdb_test "-var-create foo * foo" \ + "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \ + "create local variable foo" + +# step to "foo2 = 123;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"161\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { + fail "step at do_block_tests (timeout)" + } +} + +# Test: c_variable-3.4 +# Desc: check foo, cb changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: cb foo changed" + +# step to "foo = 321;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"164\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { + fail "step at do_block_tests (timeout)" + } +} + +# Test: c_variable-3.5 +# Desc: create inner block foo +mi_gdb_test "-var-create inner_foo * foo" \ + "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \ + "create local variable inner_foo" + +# step to "foo2 = 0;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"166\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { fail "step at do_block_tests (timeout)" } +} + +# Test: c_variable-3.6 +# Desc: create foo2 +mi_gdb_test "-var-create foo2 * foo2" \ + "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \ + "create local variable foo2" + +# Test: c_variable-3.7 +# Desc: check that outer foo in scope and inner foo out of scope +# Note: also a known gdb problem +setup_xfail *-*-* +mi_gdb_test "-var-update inner_foo" \ + "\\^done,changelist=\{FIXME\}" \ + "update inner_foo: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +setup_xfail *-*-* +mi_gdb_test "-var-evaluate-expression inner_foo" \ + "\\^done,value=\{FIXME\}" \ + "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +mi_gdb_test "-var-update foo" \ + "\\^done,changelist=\{\}" \ + "update foo: did not change" + +mi_gdb_test "-var-delete inner_foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var inner_foo" + +# step to "foo = 0;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"168\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { fail "step at do_block_tests (timeout)" } +} + +# Test: c_variable-3.8 +# Desc: check that foo2 out of scope (known gdb problem) +setup_xfail *-*-* +mi_gdb_test "-var-update foo2" \ + "\\^done,changelist=\{FIXME\}" \ + "update foo2: should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* + +# step to "cb = 21;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\{\},file=\".*var-cmd.c\",line=\"171\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_block_tests" + } + timeout { fail "step at do_block_tests (timeout)" } +} + + +# Test: c_variable-3.9 +# Desc: check that only cb is in scope (known gdb problem) +setup_xfail *-*-* +mi_gdb_test "-var-update foo2" \ + "\\^done,changelist=\{FIXME\}" \ + "update foo2 should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* +setup_xfail *-*-* +mi_gdb_test "-var-update foo" \ + "\\^done,changelist=\{FIXME\}" \ + "update foo should be out of scope: KNOWN PROBLEM" +clear_xfail *-*-* +mi_gdb_test "-var-update cb" \ + "\\^done,changelist=\{\}" \ + "update cb" + +# Test: c_variable-3.10 +# Desc: names of editable variables +#gdbtk_test c_variable-3.10 {names of editable variables} { +# editable_variables +#} {{foo cb foo2} {}} + +# Done with block tests +mi_gdb_test "-var-delete foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo" + +mi_gdb_test "-var-delete foo2" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo2" + +mi_gdb_test "-var-delete cb" \ + "\\^done,ndeleted=\"1\"" \ + "delete var cb" + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + + diff --git a/gdb/testsuite/gdb.mi/mi0-var-child.exp b/gdb/testsuite/gdb.mi/mi0-var-child.exp new file mode 100644 index 0000000..6ac6e6b --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-var-child.exp @@ -0,0 +1,1334 @@ +# Copyright (C) 1999 2000 Cygnus Solutions +# +# 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 + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "200-break-insert do_children_tests" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"190\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"190\"\}\r\n$mi_gdb_prompt$" { + pass "run to do_children_tests" + } + -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"} + timeout {fail "run to do_children_tests (timeout 2)"} +} + +##### ##### +# # +# children tests # +# # +##### ##### + + +# Test: c_variable-4.2 +# Desc: create variable "struct_declarations" +mi_gdb_test "-var-create struct_declarations * struct_declarations" \ + "\\^done,name=\"struct_declarations\",numchild=\"11\",type=\"struct _struct_decl\"" \ + "create local variable struct_declarations" + +# Test: c_variable-4.3 +# Desc: children of struct_declarations +mi_gdb_test "-var-list-children struct_declarations" \ + "\\^done,numchild=\"11\",children=\{child=\{name=\"struct_declarations.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"struct_declarations.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"struct_declarations.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"struct_declarations.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\(\\)\"\},child=\{name=\"struct_declarations.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\(\\)\"\},child=\{name=\"struct_declarations.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\(\\)\"\},child=\{name=\"struct_declarations.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\}" \ + "get children of struct_declarations" + +#gdbtk_test c_variable-4.3 {children of struct_declarations} { +# get_children struct_declarations +#} {integer character char_ptr long_int int_ptr_ptr long_array func_ptr func_ptr_struct func_ptr_ptr u1 s2} + +# Test: c_variable-4.4 +# Desc: number of children of struct_declarations +mi_gdb_test "-var-info-num-children struct_declarations" \ + "\\^done,numchild=\"11\"" \ + "get number of children of struct_declarations" + +# Test: c_variable-4.5 +# Desc: children of struct_declarations.integer +mi_gdb_test "-var-list-children struct_declarations.integer" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.integer" + +# Test: c_variable-4.6 +# Desc: number of children of struct_declarations.integer +mi_gdb_test "-var-info-num-children struct_declarations.integer" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.integer" + +# Test: c_variable-4.7 +# Desc: children of struct_declarations.character +mi_gdb_test "-var-list-children struct_declarations.character" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.character" + +# Test: c_variable-4.8 +# Desc: number of children of struct_declarations.character +mi_gdb_test "-var-info-num-children struct_declarations.character" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.character" + +# Test: c_variable-4.9 +# Desc: children of struct_declarations.char_ptr +mi_gdb_test "-var-list-children struct_declarations.char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"struct_declarations.char_ptr.\\*char_ptr\",exp=\"\\*char_ptr\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of struct_declarations.char_ptr" + +# Test: c_variable-4.10 +# Desc: number of children of struct_declarations.char_ptr +mi_gdb_test "-var-info-num-children struct_declarations.char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.char_ptr" + +# Test: c_variable-4.11 +# Desc: children of struct_declarations.long_int +mi_gdb_test "-var-list-children struct_declarations.long_int" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_int" + +# Test: c_variable-4.12 +# Desc: number of children of struct_declarations.long_int +mi_gdb_test "-var-info-num-children struct_declarations.long_int" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_int" + +# Test: c_variable-4.13 +# Desc: children of int_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr\",exp=\"\\*int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\}" \ + "get children of struct_declarations.int_ptr_ptr" + +#gdbtk_test c_variable-4.13 {children of int_ptr_ptr} { +# get_children struct_declarations.int_ptr_ptr +#} {*int_ptr_ptr} + +# Test: c_variable-4.14 +# Desc: number of children of int_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.int_ptr_ptr" + + +# Test: c_variable-4.15 +# Desc: children of struct_declarations.long_array +mi_gdb_test "-var-list-children struct_declarations.long_array" \ + "\\^done,numchild=\"10\",children=\{child=\{name=\"struct_declarations.long_array.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of struct_declarations.long_array" + +# Test: c_variable-4.16 +# Desc: number of children of struct_declarations.long_array +mi_gdb_test "-var-info-num-children struct_declarations.long_array" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.long_array" + +# Test: c_variable-4.17 +# Desc: children of struct_declarations.func_ptr +mi_gdb_test "-var-list-children struct_declarations.func_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr" + + +# Test: c_variable-4.18 +# Desc: number of children of struct_declarations.func_ptr +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr" + + +# Test: c_variable-4.19 +# Desc: children of struct_declarations.func_ptr_struct +mi_gdb_test "-var-list-children struct_declarations.func_ptr_struct" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr_struct" + +# Test: c_variable-4.20 +# Desc: number of children of struct_declarations.func_ptr_struct +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_struct" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr_struct" + + +# Test: c_variable-4.21 +# Desc: children of struct_declarations.func_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.func_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.func_ptr_ptr" + +# Test: c_variable-4.22 +# Desc: number of children of struct_declarations.func_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.func_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.func_ptr_ptr" + + +# Test: c_variable-4.23 +# Desc: children of struct_declarations.u1 +mi_gdb_test "-var-list-children struct_declarations.u1" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"struct_declarations.u1.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.u1.b\",exp=\"b\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"struct_declarations.u1.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.u1.d\",exp=\"d\",numchild=\"0\",type=\"enum foo\"\}\}" \ + "get children of struct_declarations.u1" + +# Test: c_variable-4.24 +# Desc: number of children of struct_declarations.u1 +mi_gdb_test "-var-info-num-children struct_declarations.u1" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.u1" + +# Test: c_variable-4.25 +# Desc: children of struct_declarations.s2 +mi_gdb_test "-var-list-children struct_declarations.s2" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"struct_declarations.s2.u2\",exp=\"u2\",numchild=\"3\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2.g\",exp=\"g\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.s2.h\",exp=\"h\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.i\",exp=\"i\",numchild=\"10\",type=\"long int \\\[10\\\]\"\}\}" \ + "get children of struct_declarations.s2" +#gdbtk_test c_variable-4.25 {children of struct_declarations.s2} { +# get_children struct_declarations.s2 +#} {u2 g h i} + +# Test: c_variable-4.26 +# Desc: number of children of struct_declarations.s2 +mi_gdb_test "-var-info-num-children struct_declarations.s2" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.s2" + + +# Test: c_variable-4.27 +# Desc: children of struct_declarations.long_array.1 +mi_gdb_test "-var-list-children struct_declarations.long_array.1" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.1" + +# Test: c_variable-4.28 +# Desc: number of children of struct_declarations.long_array.1 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.1" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.1" + +# Test: c_variable-4.29 +# Desc: children of struct_declarations.long_array.2 +mi_gdb_test "-var-list-children struct_declarations.long_array.2" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.2" + +# Test: c_variable-4.30 +# Desc: number of children of struct_declarations.long_array.2 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.2" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.2" + +# Test: c_variable-4.31 +# Desc: children of struct_declarations.long_array.3 +mi_gdb_test "-var-list-children struct_declarations.long_array.3" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.3" + +# Test: c_variable-4.32 +# Desc: number of children of struct_declarations.long_array.3 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.3" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.3" + +# Test: c_variable-4.33 +# Desc: children of struct_declarations.long_array.4 +mi_gdb_test "-var-list-children struct_declarations.long_array.4" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.4" + +# Test: c_variable-4.34 +# Desc: number of children of struct_declarations.long_array.4 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.4" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.4" + +# Test: c_variable-4.35 +# Desc: children of struct_declarations.long_array.5 +mi_gdb_test "-var-list-children struct_declarations.long_array.5" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.5" + +# Test: c_variable-4.36 +# Desc: number of children of struct_declarations.long_array.5 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.5" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.5" + +# Test: c_variable-4.37 +# Desc: children of struct_declarations.long_array.6 +mi_gdb_test "-var-list-children struct_declarations.long_array.6" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.6" + +# Test: c_variable-4.38 +# Desc: number of children of struct_declarations.long_array.6 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.6" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.6" + +# Test: c_variable-4.39 +# Desc: children of struct_declarations.long_array.7 +mi_gdb_test "-var-list-children struct_declarations.long_array.7" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.7" + +# Test: c_variable-4.40 +# Desc: number of children of struct_declarations.long_array.7 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.7" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.7" + +# Test: c_variable-4.41 +# Desc: children of struct_declarations.long_array.8 +mi_gdb_test "-var-list-children struct_declarations.long_array.8" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.8" + +# Test: c_variable-4.42 +# Desc: number of children of struct_declarations.long_array.8 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.8" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.8" + + +# Test: c_variable-4.43 +# Desc: children of struct_declarations.long_array.9 +mi_gdb_test "-var-list-children struct_declarations.long_array.9" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.long_array.9" + +# Test: c_variable-4.44 +# Desc: number of children of struct_declarations.long_array.9 +mi_gdb_test "-var-info-num-children struct_declarations.long_array.9" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.long_array.9" + +# Test: c_variable-4.45 +# Desc: children of struct_declarations.u1.a +mi_gdb_test "-var-list-children struct_declarations.u1.a" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.a" + +# Test: c_variable-4.46 +# Desc: number of children of struct_declarations.u1.a +mi_gdb_test "-var-info-num-children struct_declarations.u1.a" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.a" + +# Test: c_variable-4.47 +# Desc: children of struct_declarations.u1.b +mi_gdb_test "-var-list-children struct_declarations.u1.b" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"struct_declarations.u1.b.\\*b\",exp=\"\\*b\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of struct_declarations.u1.b" + +# Test: c_variable-4.48 +# Desc: number of children of struct_declarations.u1.b +mi_gdb_test "-var-info-num-children struct_declarations.u1.b" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.u1.b" + +# Test: c_variable-4.49 +# Desc: children of struct_declarations.u1.c +mi_gdb_test "-var-list-children struct_declarations.u1.c" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.c" + +# Test: c_variable-4.50 +# Desc: number of children of struct_declarations.u1.c +mi_gdb_test "-var-info-num-children struct_declarations.u1.c" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.c" + +# Test: c_variable-4.51 +# Desc: children of struct_declarations.u1.d +mi_gdb_test "-var-list-children struct_declarations.u1.d" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.u1.d" + + +# Test: c_variable-4.52 +# Desc: number of children of struct_declarations.u1.d +mi_gdb_test "-var-info-num-children struct_declarations.u1.d" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.u1.d" + + +# Test: c_variable-4.53 +# Desc: children of struct_declarations.s2.u2 +mi_gdb_test "-var-list-children struct_declarations.s2.u2" \ + "\\^done,numchild=\"3\",children=\{child=\{name=\"struct_declarations.s2.u2.u1s1\",exp=\"u1s1\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\},child=\{name=\"struct_declarations.s2.u2.f\",exp=\"f\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.u2.u1s2\",exp=\"u1s2\",numchild=\"2\",type=\"struct \{\\.\\.\\.\}\"\}\}" \ + "get children of struct_declarations.s2.u2" + +# Test: c_variable-4.54 +# Desc: number of children of struct_declarations.s2.u2 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2" \ + "\\^done,numchild=\"3\"" \ + "get number of children of struct_declarations.s2.u2" + +# Test: c_variable-4.55 +# Desc: children of struct_declarations.s2.g +mi_gdb_test "-var-list-children struct_declarations.s2.g" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.g" + +# Test: c_variable-4.56 +# Desc: number of children of struct_declarations.s2.g +mi_gdb_test "-var-info-num-children struct_declarations.s2.g" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.g" + + +# Test: c_variable-4.57 +# Desc: children of struct_declarations.s2.h +mi_gdb_test "-var-list-children struct_declarations.s2.h" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.h" + +# Test: c_variable-4.58 +# Desc: number of children of struct_declarations.s2.h +mi_gdb_test "-var-info-num-children struct_declarations.s2.h" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.h" + + +# Test: c_variable-4.59 +# Desc: children of struct_declarations.s2.i +mi_gdb_test "-var-list-children struct_declarations.s2.i" \ + "\\^done,numchild=\"10\",children=\{child=\{name=\"struct_declarations.s2.i.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.s2.i.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of struct_declarations.s2.i" + +# Test: c_variable-4.60 +# Desc: number of children of struct_declarations.s2.i +mi_gdb_test "-var-info-num-children struct_declarations.s2.i" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.s2.i" + +# Test: c_variable-4.61 +# Desc: children of struct_declarations.s2.u2.u1s1 +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"struct_declarations.s2.u2.u1s1.d\",exp=\"d\",numchild=\"0\",type=\"int\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e\",exp=\"e\",numchild=\"10\",type=\"char \\\[10\\\]\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.func\",exp=\"func\",numchild=\"0\",type=\"int \\*\\(\\*\\)\\(\\)\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.foo\",exp=\"foo\",numchild=\"0\",type=\"efoo\"\}\}" \ + "get children of struct_declarations.s2.u2.u1s1" + +# Test: c_variable-4.62 +# Desc: number of children of struct_declarations.s2.u2.u1s1 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1" \ + "\\^done,numchild=\"4\"" \ + "get number of children of struct_declarations.s2.u2.u1s1" + +# Test: c_variable-4.63 +# Desc: children of struct_declarations.s2.u2.f +mi_gdb_test "-var-list-children struct_declarations.s2.u2.f" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.f" + +# Test: c_variable-4.64 +# Desc: number of children of struct_declarations.s2.u2.f +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.f" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.f" + +# Test: c_variable-4.65 +# Desc: children of struct_declarations.s2.u2.u1s2 +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2" \ + "\\^done,numchild=\"2\",children=\{child=\{name=\"struct_declarations.s2.u2.u1s2.array_ptr\",exp=\"array_ptr\",numchild=\"2\",type=\"char \\\[2\\\]\"\},child=\{name=\"struct_declarations.s2.u2.u1s2.func\",exp=\"func\",numchild=\"0\",type=\"int \\(\\*\\)\\(\\)\"\}\}" \ + "get children of struct_declarations.s2.u2.u1s2" + +# Test: c_variable-4.66 +# Desc: number of children of struct_declarations.s2.u2.u1s2 +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2" \ + "\\^done,numchild=\"2\"" \ + "get number of children of struct_declarations.s2.u2.u1s2" + +# Test: c_variable-4.67 +# Desc: children of struct_declarations.s2.u2.u1s1.d +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.d" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.d" + +# Test: c_variable-4.68 +# Desc: number of children of struct_declarations.s2.u2.u1s1.d +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.d" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.d" + +# Test: c_variable-4.69 +# Desc: children of struct_declarations.s2.u2.u1s1.e +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.e" \ + "\\^done,numchild=\"10\",children=\{child=\{name=\"struct_declarations.s2.u2.u1s1.e.0\",exp=\"0\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.1\",exp=\"1\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.2\",exp=\"2\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.s2.u2.u1s1.e.3\",exp=\"3\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.4\",exp=\"4\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.5\",exp=\"5\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.6\",exp=\"6\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.7\",exp=\"7\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.8\",exp=\"8\",numchild=\"0\",type=\"char\"\},child=\{name=\"struct_declarations.s2.u2.u1s1.e.9\",exp=\"9\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of struct_declarations.s2.u2.u1s1.e" + +# Test: c_variable-4.70 +# Desc: number of children of struct_declarations.s2.u2.u1s1.e +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.e" \ + "\\^done,numchild=\"10\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.e" + + +# Test: c_variable-4.71 +# Desc: children of struct_declarations.s2.u2.u1s1.func +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.func" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.func" + +# Test: c_variable-4.72 +# Desc: number of children of struct_declarations.s2.u2.u1s1.func +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.func" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.func" + + +# Test: c_variable-4.73 +# Desc: children of struct_declarations.s2.u2.u1s1.foo +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s1.foo" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s1.foo" + +# Test: c_variable-4.74 +# Desc: number of children of struct_declarations.s2.u2.u1s1.foo +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s1.foo" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s1.foo" + + +# Test: c_variable-4.75 +# Desc: children of struct_declarations.s2.u2.u1s2.array_ptr +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2.array_ptr" \ + "\\^done,numchild=\"2\",children=\{child=\{name=\"struct_declarations.s2.u2.u1s2.array_ptr.0\",exp=\"0\",numchild=\"0\",type=\"char\"\},child={name=\"struct_declarations.s2.u2.u1s2.array_ptr.1\",exp=\"1\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of struct_declarations.s2.u2.u1s2.array_ptr" + +# Test: c_variable-4.76 +# Desc: number of children of struct_declarations.s2.u2.u1s2.array_ptr +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.array_ptr" \ + "\\^done,numchild=\"2\"" \ + "get number of children of struct_declarations.s2.u2.u1s2.array_ptr" + +# Test: c_variable-4.77 +# Desc: children of struct_declarations.s2.u2.u1s2.func +mi_gdb_test "-var-list-children struct_declarations.s2.u2.u1s2.func" \ + "\\^done,numchild=\"0\"" \ + "get children of struct_declarations.s2.u2.u1s2.func" + +# Test: c_variable-4.78 +# Desc: number of children of struct_declarations.s2.u2.u1s2.func +mi_gdb_test "-var-info-num-children struct_declarations.s2.u2.u1s2.func" \ + "\\^done,numchild=\"0\"" \ + "get number of children of struct_declarations.s2.u2.u1s2.func" + +# Test: c_variable-4.79 +# Desc: children of struct_declarations.int_ptr_ptr.*int_ptr_ptr +mi_gdb_test "-var-list-children struct_declarations.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",exp=\"\\*\\*int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\}" \ + "get children of struct_declarations.int_ptr_ptr.*int_ptr_ptr" +#} {**int_ptr_ptr} + +# Test: c_variable-4.80 +# Desc: Number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr +mi_gdb_test "-var-info-num-children struct_declarations.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of struct_declarations.int_ptr_ptr.*int_ptr_ptr" + + +# Step to "struct_declarations.integer = 123;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"192\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + + +# Test: c_variable-4.81 +# Desc: create local variable "weird" +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",type=\"weird_struct \\*\"" \ + "create local variable weird" + +# Test: c_variable-4.82 +# Desc: children of weird +mi_gdb_test "-var-list-children weird" \ + "\\^done,numchild=\"11\",children=\{child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\(\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\(\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\(\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\}" \ + "get children of weird" + +# Test: c_variable-4.83 +# Desc: number of children of weird +mi_gdb_test "-var-info-num-children weird" \ + "\\^done,numchild=\"11\"" \ + "get number of children of weird" + + +# Test: c_variable-4.84 +# Desc: children of weird->long_array +mi_gdb_test "-var-list-children weird.long_array" \ + "\\^done,numchild=\"10\",children=\{child=\{name=\"weird.long_array.0\",exp=\"0\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.1\",exp=\"1\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.2\",exp=\"2\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.3\",exp=\"3\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.4\",exp=\"4\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.5\",exp=\"5\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.6\",exp=\"6\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.7\",exp=\"7\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.8\",exp=\"8\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.9\",exp=\"9\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of weird.long_array" +#gdbtk_test c_variable-4.84 {children of weird->long_array} { +# get_children weird.long_array +#} {0 1 2 3 4 5 6 7 8 9} + +# Test: c_variable-4.85 +# Desc: number of children of weird.long_array +mi_gdb_test "-var-info-num-children weird.long_array" \ + "\\^done,numchild=\"10\"" \ + "get number of children of weird.long_array" + +# Test: c_variable-4.86 +# Desc: children of weird.int_ptr_ptr +mi_gdb_test "-var-list-children weird.int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"weird.int_ptr_ptr.\\*int_ptr_ptr\",exp=\"\\*int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\}" \ + "get children of weird.int_ptr_ptr" +#gdbtk_test c_variable-4.86 {children of weird->int_ptr_ptr} { +# get_children weird.int_ptr_ptr +#} {*int_ptr_ptr} + +# Test: c_variable-4.87 +# Desc: number of children of weird.int_ptr_ptr +mi_gdb_test "-var-info-num-children weird.int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird.int_ptr_ptr" + +# Test: c_variable-4.88 +# Desc: children of *weird->int_ptr_ptr +mi_gdb_test "-var-list-children weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"weird.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",exp=\"\\*\\*int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\}" \ + "get children of weird.int_ptr_ptr.*int_ptr_ptr" +#gdbtk_test c_variable-4.88 {children of *weird->int_ptr_ptr} { +# get_children weird.int_ptr_ptr.*int_ptr_ptr +#} {**int_ptr_ptr} + +# Test: c_variable-4.89 +# Desc: number of children *weird->int_ptr_ptr +mi_gdb_test "-var-info-num-children weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird.int_ptr_ptr.*int_ptr_ptr" + +# Test: c_variable-4.90 +# Desc: create weird->int_ptr_ptr +mi_gdb_test "-var-create weird->int_ptr_ptr * weird->int_ptr_ptr" \ + "\\^done,name=\"weird->int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"" \ + "create local variable weird->int_ptr_ptr" + +# Test: c_variable-4.91 +# Desc: children of weird->int_ptr_ptr +mi_gdb_test "-var-list-children weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr\",exp=\"\\*weird->int_ptr_ptr\",numchild=\"1\",type=\"int \\*\"\}\}" \ + "get children of weird->int_ptr_ptr" + + +# Test: c_variable-4.92 +# Desc: number of children of (weird->int_ptr_ptr) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird->int_ptr_ptr" + +# Test: c_variable-4.93 +# Desc: children of *(weird->int_ptr_ptr) +mi_gdb_test "-var-list-children weird->int_ptr_ptr.*weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr.\\*\\*weird->int_ptr_ptr\",exp=\"\\*\\*weird->int_ptr_ptr\",numchild=\"0\",type=\"int\"\}\}" \ + "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr" + +# Test: c_variable-4.94 +# Desc: number of children of *(weird->int_ptr_ptr) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr.*weird->int_ptr_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr" + +# Test: c_variable-4.95 +# Desc: children of *(*(weird->int_ptr_ptr)) +mi_gdb_test "-var-list-children weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" + +# Test: c_variable-4.96 +# Desc: number of children of *(*(weird->int_ptr_ptr)) +mi_gdb_test "-var-info-num-children weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of weird->int_ptr_ptr.*weird->int_ptr_ptr.**weird->int_ptr_ptr" + +# Test: c_variable-4.97 +# Desc: is weird editable +mi_gdb_test "-var-show-attributes weird" \ + "\\^done,attr=\"editable\"" \ + "is weird editable" + +# Test: c_variable-4.98 +# Desc: is weird->int_ptr_ptr editable +mi_gdb_test "-var-show-attributes weird->int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird->int_ptr_ptr editable" + +# Test: c_variable-4.99 +# Desc: is *(weird->int_ptr_ptr) editable +mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird.int_ptr_ptr.*int_ptr_ptr editable" + +# Test: c_variable-4.100 +# Desc: is *(*(weird->int_ptr_ptr)) editable +mi_gdb_test "-var-show-attributes weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr" \ + "\\^done,attr=\"editable\"" \ + "is weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr editable" + +# Test: c_variable-4.101 +# Desc: is weird->u1 editable +mi_gdb_test "-var-show-attributes weird.u1" \ + "\\^done,attr=\"noneditable\"" \ + "is weird.u1 editable" + +# Test: c_variable-4.102 +# Desc: is weird->s2 editable +mi_gdb_test "-var-show-attributes weird.s2" \ + "\\^done,attr=\"noneditable\"" \ + "is weird.s2 editable" + +# Test: c_variable-4.103 +# Desc: is struct_declarations.u1.a editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.a" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.a editable" + +# Test: c_variable-4.104 +# Desc: is struct_declarations.u1.b editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.b" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.b editable" + +# Test: c_variable-4.105 +# Desc: is struct_declarations.u1.c editable +mi_gdb_test "-var-show-attributes struct_declarations.u1.c" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.u1.c editable" + +# Test: c_variable-4.106 +# Desc: is struct_declarations.long_array editable +mi_gdb_test "-var-show-attributes struct_declarations.long_array" \ + "\\^done,attr=\"noneditable\"" \ + "is struct_declarations.long_array editable" + +# Test: c_variable-4.107 +# Desc: is struct_declarations.long_array[0] editable +mi_gdb_test "-var-show-attributes struct_declarations.long_array.0" \ + "\\^done,attr=\"editable\"" \ + "is struct_declarations.long_array.0 editable" + +# Test: c_variable-4.108 +# Desc: is struct_declarations editable +mi_gdb_test "-var-show-attributes struct_declarations" \ + "\\^done,attr=\"noneditable\"" \ + "is struct_declarations editable" + +mi_gdb_test "-var-delete weird" \ + "\\^done,ndeleted=\"24\"" \ + "delete var weird" + +##### ##### +# # +# children and update tests # +# # +##### ##### + +# Test: c_variable-5.1 +# Desc: check that nothing changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{\}" \ + "update all vars. None changed" + +# Step over "struct_declarations.integer = 123;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"193\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.2 +# Desc: check that integer changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.integer\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.integer" + +# Step over: +# weird->char_ptr = "hello"; +# bar = 2121; +# foo = &bar; + +send_gdb "-exec-step 3\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"196\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.3 +# Desc: check that char_ptr changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.char_ptr" + +# Step over "struct_declarations.int_ptr_ptr = &foo;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"197\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.4 +# Desc: check that int_ptr_ptr and children changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"weird->int_ptr_ptr.\\*weird->int_ptr_ptr.\\*\\*weird->int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.int_ptr_ptr.\\*int_ptr_ptr.\\*\\*int_ptr_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars int_ptr_ptr and children changed" + +# Step over "weird->long_array[0] = 1234;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"198\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.5 +# Desc: check that long_array[0] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.long_array.0\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.long_array.0 changed" + +# Step over "struct_declarations.long_array[1] = 2345;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"199\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.6 +# Desc: check that long_array[1] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.long_array.1\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.long_array.1 changed" + +# Step over "weird->long_array[2] = 3456;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"200\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.7 +# Desc: check that long_array[2] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.long_array.2\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.long_array.2 changed" + +# Step over: +# struct_declarations.long_array[3] = 4567; +# weird->long_array[4] = 5678; +# struct_declarations.long_array[5] = 6789; +# weird->long_array[6] = 7890; +# struct_declarations.long_array[7] = 8901; +# weird->long_array[8] = 9012; +# struct_declarations.long_array[9] = 1234; +send_gdb "-exec-step 7\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"208\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.8 +# Desc: check that long_array[3-9] changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.long_array.3\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.4\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.5\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.6\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.7\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.8\",in_scope=\"true\",type_changed=\"false\",name=\"struct_declarations.long_array.9\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.long_array.3-9 changed" + + +# Step over "weird->func_ptr = nothing;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"211\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.9 +# Desc: check that func_ptr changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"struct_declarations.func_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars struct_declarations.func_ptr changed" + +# Delete all variables +mi_gdb_test "-var-delete struct_declarations" \ + "\\^done,ndeleted=\"65\"" \ + "delete var struct_declarations" + +mi_gdb_test "-var-delete weird->int_ptr_ptr" \ + "\\^done,ndeleted=\"3\"" \ + "delete var weird->int_ptr_ptr" + +# Step over all lines: +# ... +# psnp = &snp0; +send_gdb "-exec-step 43\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"254\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.10 +# Desc: create psnp->char_ptr +mi_gdb_test "-var-create psnp->char_ptr * psnp->char_ptr" \ + "\\^done,name=\"psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"" \ + "create local variable psnp->char_ptr" + +# Test: c_variable-5.11 +# Desc: children of psnp->char_ptr +mi_gdb_test "-var-list-children psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr\",exp=\"\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\"\}\}" \ + "get children of psnp->char_ptr" + +# Test: c_variable-5.12 +# Desc: number of children of psnp->char_ptr +mi_gdb_test "-var-info-num-children psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr" + +# Test: c_variable-5.13 +# Desc: children of *(psnp->char_ptr) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr\",exp=\"\\*\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\\*\"\}\}" \ + "get children of psnp->char_ptr.*psnp->char_ptr" + +# Test: c_variable-5.14 +# Desc: number of children of *(psnp->char_ptr) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr" + +# Test: c_variable-5.15 +# Desc: children of *(*(psnp->char_ptr)) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*psnp->char_ptr\",numchild=\"1\",type=\"char \\*\"\}\}" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.15B +# Desc: children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*\\*psnp->char_ptr\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.16 +# Desc: number of children of *(*(psnp->char_ptr)) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr" + +# Test: c_variable-5.17 +# Desc: children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",exp=\"\\*\\*\\*\\*psnp->char_ptr\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" + +# Test: c_variable-5.18 +# Desc: number of children of *(*(*(psnp->char_ptr))) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr" + +# Test: c_variable-5.17B +# Desc: children of *(*(*(*(psnp->char_ptr)))) +mi_gdb_test "-var-list-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" + +# Test: c_variable-5.18B +# Desc: number of children of *(*(*(*(psnp->char_ptr)))) +mi_gdb_test "-var-info-num-children psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr.****psnp->char_ptr" + + +# Test: c_variable-5.19 +# Desc: create psnp->long_ptr +mi_gdb_test "-var-create psnp->long_ptr * psnp->long_ptr" \ + "\\^done,name=\"psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"" \ + "create local variable psnp->long_ptr" + +# Test: c_variable-5.20 +# Desc: children of psnp->long_ptr +mi_gdb_test "-var-list-children psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr\",exp=\"\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\"\}\}" \ + "get children of psnp->long_ptr" + +# Test: c_variable-5.21 +# Desc: number of children of psnp->long_ptr +mi_gdb_test "-var-info-num-children psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr" + +# Test: c_variable-5.22 +# Desc: children of *(psnp->long_ptr) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr\",exp=\"\\*\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\\*\"\}\}" \ + "get children of psnp->long_ptr.*psnp->long_ptr" + + +# Test: c_variable-5.23 +# Desc: number of children of *(psnp->long_ptr) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr" + +# Test: c_variable-5.24 +# Desc: children of *(*(psnp->long_ptr)) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr\",exp=\"\\*\\*\\*psnp->long_ptr\",numchild=\"1\",type=\"long int \\*\"\}\}" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" + +# Test: c_variable-5.25 +# Desc: number of children of *(*(psnp->long_ptr)) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr" + +# Test: c_variable-5.26 +# Desc: children of *(*(*(psnp->long_ptr))) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr.\\*\\*\\*\\*psnp->long_ptr\",exp=\"\\*\\*\\*\\*psnp->long_ptr\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" + +# Test: c_variable-5.27 +# Desc: number of children of *(*(*(psnp->long_ptr))) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr" + +# Test: c_variable-5.28 +# Desc: children of *(*(*(*(psnp->long_ptr)))) +mi_gdb_test "-var-list-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" + +# Test: c_variable-5.29 +# Desc: number of children of *(*(*(*(psnp->long_ptr)))) +mi_gdb_test "-var-info-num-children psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->long_ptr.*psnp->long_ptr.**psnp->long_ptr.***psnp->long_ptr.****psnp->long_ptr" + +# Test: c_variable-5.30 +# Desc: create psnp->ptrs +mi_gdb_test "-var-create psnp->ptrs * psnp->ptrs" \ + "\\^done,name=\"psnp->ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"" \ + "create local variable psnp->ptrs" + +# Test: c_variable-5.31 +# Desc: children of psnp->ptrs +mi_gdb_test "-var-list-children psnp->ptrs" \ + "\\^done,numchild=\"3\",children=\{child=\{name=\"psnp->ptrs.0\",exp=\"0\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.1\",exp=\"1\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.2\",exp=\"2\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\}" \ + "get children of psnp->ptrs" + +# Test: c_variable-5.32 +# Desc: number of children of psnp->ptrs +mi_gdb_test "-var-info-num-children psnp->ptrs" \ + "\\^done,numchild=\"3\"" \ + "get number of children of psnp->ptrs" + +# Test: c_variable-5.33 +# Desc: children of psnp->ptrs[0] +mi_gdb_test "-var-list-children psnp->ptrs.0" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"psnp->ptrs.0.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\}" \ + "get children of psnp->ptrs.0" + +# Test: c_variable-5.34 +# Desc: number of children of psnp->ptrs[0] +mi_gdb_test "-var-info-num-children psnp->ptrs.0" \ + "\\^done,numchild=\"4\"" \ + "get number of children of psnp->ptrs.0" + +# Test: c_variable-5.35 +# Desc: children of psnp->ptrs[0]->next +mi_gdb_test "-var-list-children psnp->ptrs.0.next" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\}" \ + "get children of psnp->ptrs.0.next" + +#} {char_ptr long_ptr ptrs next} + +# Test: c_variable-5.36 +# Desc: number of children of psnp->ptrs[0]->next +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next" \ + "\\^done,numchild=\"4\"" \ + "get number of children of psnp->ptrs.0.next" + + +# Test: c_variable-5.37 +# Desc: children of psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr\",exp=\"\\*char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\"\}\}" \ + "get children of psnp->ptrs.0.next.char_ptr" + +#gdbtk_test c_variable-5.37 {children of psnp->ptrs[0]->next->char_ptr} { +# get_children psnp->ptrs.0.next.char_ptr +#} {*char_ptr} + +# Test: c_variable-5.38 +# Desc: number of children of psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr" + +# Test: c_variable-5.39 +# Desc: children of *psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr\",exp=\"\\*\\*char_ptr\",numchild=\"1\",type=\"char \\*\\*\"\}\}" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr" + +# Test: c_variable-5.40 +# Desc: number of children of *psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr" + +# Test: c_variable-5.41 +# Desc: children of **psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*char_ptr\",numchild=\"1\",type=\"char \\*\"\}\}" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.41B +# Desc: children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*\\*char_ptr\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.42 +# Desc: number of children of **psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr" + +# Test: c_variable-5.43 +# Desc: children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\",children=\{child=\{name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",exp=\"\\*\\*\\*\\*char_ptr\",numchild=\"0\",type=\"char\"\}\}" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.44 +# Desc: number of children of ***psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" \ + "\\^done,numchild=\"1\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.43B +# Desc: children of ****psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-list-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.44B +# Desc: number of children of ****psnp->ptrs[0]->next->char_ptr +mi_gdb_test "-var-info-num-children psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr.****char_ptr" \ + "\\^done,numchild=\"0\"" \ + "get number of children of psnp->ptrs.0.next.char_ptr.*char_ptr.**char_ptr.***char_ptr" + +# Test: c_variable-5.45 +# Desc: children of psnp->ptrs[0]->next->next +mi_gdb_test "-var-list-children psnp->ptrs.0.next.next" \ + "\\^done,numchild=\"4\",children=\{child=\{name=\"psnp->ptrs.0.next.next.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.next.long_ptr\",exp=\"long_ptr\",numchild=\"1\",type=\"long int \\*\\*\\*\\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs\",exp=\"ptrs\",numchild=\"3\",type=\"struct _struct_n_pointer \\*\\\[3\\\]\"\},child=\{name=\"psnp->ptrs.0.next.next.next\",exp=\"next\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\}" \ + "get children of psnp->ptrs.0.next.next" + +# Test: c_variable-5.46 +# Desc: children of psnp->ptrs[0]->next->next->ptrs +mi_gdb_test "-var-list-children psnp->ptrs.0.next.next.ptrs" \ + "\\^done,numchild=\"3\",children=\{child=\{name=\"psnp->ptrs.0.next.next.ptrs.0\",exp=\"0\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs.1\",exp=\"1\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\},child=\{name=\"psnp->ptrs.0.next.next.ptrs.2\",exp=\"2\",numchild=\"4\",type=\"struct _struct_n_pointer \\*\"\}\}" \ + "get children of psnp->ptrs.0.next.next.ptrs" + +# Step over "snp0.char_ptr = &b3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"255\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.47 +# Desc: check that psnp->char_ptr (and [0].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"psnp->ptrs.0.char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->char_ptr.\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->char_ptr.\\*psnp->char_ptr.\\*\\*psnp->char_ptr.\\*\\*\\*psnp->char_ptr.\\*\\*\\*\\*psnp->char_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->char_ptr (and 0.char_ptr) changed" + +# Step over "snp1.char_ptr = &c3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"256\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + + +# Test: c_variable-5.48 +# Desc: check that psnp->next->char_ptr (and [1].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"psnp->ptrs.0.next.char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->ptrs.0.next.char_ptr.\\*char_ptr.\\*\\*char_ptr.\\*\\*\\*char_ptr.\\*\\*\\*\\*char_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->next->char_ptr (and 1.char_ptr) changed" + + +# Step over "snp2.char_ptr = &a3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"257\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + + +# Test: c_variable-5.49 +# Desc: check that psnp->next->next->char_ptr (and [2].char_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"psnp->ptrs.0.next.next.char_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->next->next->char_ptr (and 2.char_ptr) changed" + + +# Step over "snp0.long_ptr = &y3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"258\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + +# Test: c_variable-5.50 +# Desc: check that psnp->long_ptr (and [0].long_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"psnp->ptrs.0.long_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->long_ptr.\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\",name=\"psnp->long_ptr.\\*psnp->long_ptr.\\*\\*psnp->long_ptr.\\*\\*\\*psnp->long_ptr.\\*\\*\\*\\*psnp->long_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->long_ptr (and 0.long_ptr) changed" + + +# Step over "snp1.long_ptr = &x3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"259\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + + +# Test: c_variable-5.51 +# Desc: check that psnp->next->long_ptr (and [1].long_ptr) changed +# Why does this have a FIXME? +setup_xfail *-*-* +mi_gdb_test "-var-update *" \ + "FIXME\\^done,changelist=\{name=\"psnp->ptrs.0.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->next->long_ptr (and 1.long_ptr) changed" +clear_xfail *-*-* + +# This command produces this error message: +# &"warning: varobj_list: assertion failed - mycount <> 0\n" +# + +# Step over "snp2.long_ptr = &z3;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"260\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_children_tests" + } + timeout { + fail "step at do_children_tests (timeout)" + } +} + + +# Test: c_variable-5.52 +# Desc: check that psnp->next->next->long_ptr (and [2].long_ptr) changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed" + + + + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: diff --git a/gdb/testsuite/gdb.mi/mi0-var-cmd.exp b/gdb/testsuite/gdb.mi/mi0-var-cmd.exp new file mode 100644 index 0000000..f1fcedd --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-var-cmd.exp @@ -0,0 +1,609 @@ +# Copyright (C) 1999 2000 Cygnus Solutions +# +# 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 + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + + +##### ##### +# # +# Variable Creation tests # +# # +##### ##### + +# Test: c_variable-1.1 +# Desc: Create global variable + +mi_gdb_test "111-var-create global_simple * global_simple" \ + "111\\^done,name=\"global_simple\",numchild=\"6\",type=\"simpleton\"" \ + "create global variable" + +# Test: c_variable-1.2 +# Desc: Create non-existent variable + +mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create non-existent variable" + +# Test: c_variable-1.3 +# Desc: Create out of scope variable + +mi_gdb_test "113-var-create argc * argc" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create out of scope variable" + +mi_gdb_test "200-break-insert do_locals_tests" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_locals_tests\",file=\".*var-cmd.c\",line=\"106\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"106\"\}\r\n$mi_gdb_prompt$" { + pass "run to do_locals_tests" + } + -re ".*$mi_gdb_prompt$" {fail "run todo_locals_tests (2)"} + timeout {fail "run to do_locals_tests (timeout 2)"} +} + +# Test: c_variable-1.4 +# Desc: create local variables + +mi_gdb_test "-var-create linteger * linteger" \ + "\\^done,name=\"linteger\",numchild=\"0\",type=\"int\"" \ + "create local variable linteger" + +mi_gdb_test "-var-create lpinteger * lpinteger" \ + "\\^done,name=\"lpinteger\",numchild=\"1\",type=\"int \\*\"" \ + "create local variable lpinteger" + +mi_gdb_test "-var-create lcharacter * lcharacter" \ + "\\^done,name=\"lcharacter\",numchild=\"0\",type=\"char\"" \ + "create local variablelcharacter " + +mi_gdb_test "-var-create lpcharacter * lpcharacter" \ + "\\^done,name=\"lpcharacter\",numchild=\"0\",type=\"char \\*\"" \ + "create local variable lpcharacter" + +mi_gdb_test "-var-create llong * llong" \ + "\\^done,name=\"llong\",numchild=\"0\",type=\"long int\"" \ + "create local variable llong" + +mi_gdb_test "-var-create lplong * lplong" \ + "\\^done,name=\"lplong\",numchild=\"1\",type=\"long int \\*\"" \ + "create local variable lplong" + +mi_gdb_test "-var-create lfloat * lfloat" \ + "\\^done,name=\"lfloat\",numchild=\"0\",type=\"float\"" \ + "create local variable lfloat" + +mi_gdb_test "-var-create lpfloat * lpfloat" \ + "\\^done,name=\"lpfloat\",numchild=\"1\",type=\"float \\*\"" \ + "create local variable lpfloat" + +mi_gdb_test "-var-create ldouble * ldouble" \ + "\\^done,name=\"ldouble\",numchild=\"0\",type=\"double\"" \ + "create local variable ldouble" + +mi_gdb_test "-var-create lpdouble * lpdouble" \ + "\\^done,name=\"lpdouble\",numchild=\"1\",type=\"double \\*\"" \ + "create local variable lpdouble" + +mi_gdb_test "-var-create lsimple * lsimple" \ + "\\^done,name=\"lsimple\",numchild=\"6\",type=\"struct _simple_struct\"" \ + "create local variable lsimple" + +mi_gdb_test "-var-create lpsimple * lpsimple" \ + "\\^done,name=\"lpsimple\",numchild=\"6\",type=\"struct _simple_struct \\*\"" \ + "create local variable lpsimple" + +mi_gdb_test "-var-create func * func" \ + "\\^done,name=\"func\",numchild=\"0\",type=\"void \\(\\*\\)\\(\\)\"" \ + "create local variable func" + +# Test: c_variable-1.5 +# Desc: create lsimple.character +mi_gdb_test "-var-create lsimple.character * lsimple.character" \ + "\\^done,name=\"lsimple.character\",numchild=\"0\",type=\"char\"" \ + "create lsimple.character" + +# Test: c_variable-1.6 +# Desc: create lpsimple->integer +mi_gdb_test "-var-create lsimple->integer * lsimple->integer" \ + "\\^done,name=\"lsimple->integer\",numchild=\"0\",type=\"int\"" \ + "create lsimple->integer" + +# Test: c_variable-1.7 +# Desc: ceate lsimple.integer +mi_gdb_test "-var-create lsimple.integer * lsimple.integer" \ + "\\^done,name=\"lsimple.integer\",numchild=\"0\",type=\"int\"" \ + "create lsimple->integer" + + +# Test: c_variable-1.9 +# Desc: create type name +# Type names (like int, long, etc..) are all proper expressions to gdb. +# make sure variable code does not allow users to create variables, though. +mi_gdb_test "-var-create int * int" \ + "&\"Attempt to use a type name as an expression.mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create int" + + +##### ##### +# # +# Value changed tests # +# # +##### ##### + +# Test: c_variable-2.1 +# Desc: check whether values changed at do_block_tests +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{\}" \ + "update all vars" + +# Step over "linteger = 1234;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"107\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.2 +# Desc: check whether only linteger changed values +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: linteger changed" + +# Step over "lpinteger = &linteger;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"108\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.3 +# Desc: check whether only lpinteger changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: lpinteger changed" + +# Step over "lcharacter = 'a';" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"109\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.4 +# Desc: check whether only lcharacter changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: lcharacter changed" + +# Step over "lpcharacter = &lcharacter;" +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"110\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.5 +# Desc: check whether only lpcharacter changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: lpcharacter changed" + + +# Step over: +# llong = 2121L; +# lplong = &llong; +# lfloat = 2.1; +# lpfloat = &lfloat; +# ldouble = 2.718281828459045; +# lpdouble = &ldouble; +# lsimple.integer = 1234; +# lsimple.unsigned_integer = 255; +# lsimple.character = 'a'; + +send_gdb "-exec-step 9\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"119\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.6 +# Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer, +# lsimple.unsigned_character lsimple.integer lsimple.character changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\",name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\",name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\",name=\"lpdouble\",in_scope=\"true\",type_changed=\"false\",name=\"ldouble\",in_scope=\"true\",type_changed=\"false\",name=\"lpfloat\",in_scope=\"true\",type_changed=\"false\",name=\"lfloat\",in_scope=\"true\",type_changed=\"false\",name=\"lplong\",in_scope=\"true\",type_changed=\"false\",name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: many changed" + +# Step over: +# lsimple.signed_character = 21; +# lsimple.char_ptr = &lcharacter; +# lpsimple = &lsimple; +# func = nothing; + +send_gdb "-exec-step 4\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"125\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.7 +# Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"func\",in_scope=\"true\",type_changed=\"false\",name=\"lpsimple\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: func and lpsimple changed" + +# Step over +# linteger = 4321; +# lcharacter = 'b'; +# llong = 1212L; +# lfloat = 1.2; +# ldouble = 5.498548281828172; +# lsimple.integer = 255; +# lsimple.unsigned_integer = 4321; +# lsimple.character = 'b'; + +send_gdb "-exec-step 8\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"133\"\}\r\n$mi_gdb_prompt$" { + pass "step at do_locals_tests" + } + timeout { + fail "step at do_locals_tests (timeout)" + } +} + +# Test: c_variable-2.8 +# Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer, +# lpsimple.integer lsimple.character changed +# Note: this test also checks that lpsimple->integer and lsimple.integer have +# changed (they are the same) +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"lsimple.integer\",in_scope=\"true\",type_changed=\"false\",name=\"lsimple->integer\",in_scope=\"true\",type_changed=\"false\",name=\"lsimple.character\",in_scope=\"true\",type_changed=\"false\",name=\"ldouble\",in_scope=\"true\",type_changed=\"false\",name=\"lfloat\",in_scope=\"true\",type_changed=\"false\",name=\"llong\",in_scope=\"true\",type_changed=\"false\",name=\"lcharacter\",in_scope=\"true\",type_changed=\"false\",name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: func and lpsimple changed" + + +### +# +# Test assignment to variables. More tests on assignment are in other files. +# +### +mi_gdb_test "-var-assign global_simple 0" \ + "&\"mi_cmd_var_assign: Variable object is not editable\\\\n\".*\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \ + "assign to global_simple" + +mi_gdb_test "-var-assign linteger 3333" \ + "\\^done,value=\"3333\"" \ + "assign to linteger" + +mi_gdb_test "-var-evaluate-expression linteger" \ + "\\^done,value=\"3333\"" \ + "eval linteger" + +mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \ + "\\^done,value=\"$hex\"" \ + "assign to lpinteger" + +mi_gdb_test "-var-evaluate-expression lpinteger" \ + "\\^done,value=\"$hex\"" \ + "eval lpinteger" + +# reset the values to the original ones so that the rest of the file doesn't suffer. + +mi_gdb_test "-var-assign linteger 4321" \ + "\\^done,value=\"4321\"" \ + "assign to linteger" + +mi_gdb_test "-var-assign lpinteger &linteger" \ + "\\^done,value=\"$hex\"" \ + "assign to lpinteger" + +mi_gdb_test "-var-assign lcharacter 'z'" \ + "\\^done,value=\"122 'z'\"" \ + "assign to lcharacter" + +mi_gdb_test "-var-evaluate-expression lcharacter" \ + "\\^done,value=\"122 'z'\"" \ + "eval lcharacter" + +mi_gdb_test "-var-assign llong 1313L" \ + "\\^done,value=\"1313\"" \ + "assign to llong" +mi_gdb_test "-var-evaluate-expression llong" \ + "\\^done,value=\"1313\"" \ + "eval llong" +mi_gdb_test "-var-assign llong 1212L" \ + "\\^done,value=\"1212\"" \ + "assign to llong" + +mi_gdb_test "-var-assign lplong &llong+4" \ + "\\^done,value=\"$hex\"" \ + "assign to lplong" +mi_gdb_test "-var-evaluate-expression lplong" \ + "\\^done,value=\"$hex\"" \ + "eval lplong" +mi_gdb_test "-var-assign lplong &llong" \ + "\\^done,value=\"$hex\"" \ + "assign to lplong" + +mi_gdb_test "-var-assign lfloat 3.4" \ + "\\^done,value=\"3.4.*\"" \ + "assign to lfloat" +mi_gdb_test "-var-evaluate-expression lfloat" \ + "\\^done,value=\"3.4.*\"" \ + "eval lfloat" +mi_gdb_test "-var-assign lfloat 1.2" \ + "\\^done,value=\"1.2.*\"" \ + "assign to lfloat" + +mi_gdb_test "-var-assign lpfloat &lfloat+4" \ + "\\^done,value=\"$hex\"" \ + "assign to lpfloat" + +mi_gdb_test "-var-assign ldouble 5.333318284590435" \ + "\\^done,value=\"5.333318284590435\"" \ + "assign to ldouble" + +mi_gdb_test "-var-assign func do_block_tests" \ + "\\^done,value=\"$hex <do_block_tests>\"" \ + "assign to func" + +mi_gdb_test "-var-assign lsimple.character 'd'" \ + "\\^done,value=\"100 'd'\"" \ + "assign to lsimple.character" + +mi_gdb_test "-var-assign lsimple->integer 222" \ + "\\^done,value=\"222\"" \ + "assign to lsimple->integer" + +mi_gdb_test "-var-assign lsimple.integer 333" \ + "\\^done,value=\"333\"" \ + "assign to lsimple.integer" + +###### +# End of assign tests +##### + +mi_gdb_test "-break-insert subroutine1" \ + "\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine1\",file=\".*var-cmd.c\",line=\"146\",times=\"0\"\}" \ + "break-insert subroutine1" +send_gdb "-exec-continue\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"subroutine1\",args=\{\{name=\"i\",value=\"4321\"\},\{name=\"l\",value=\"$hex\"\}\},file=\".*var-cmd.c\",line=\"146\"\}\r\n$mi_gdb_prompt$" { + pass "continue to subroutine1" + } + timeout { + fail "continue to subroutine1 (timeout)" + } +} + +# Test: c_variable-2.10 +# Desc: create variable for locals i,l in subroutine1 +mi_gdb_test "-var-create i * i" \ + "\\^done,name=\"i\",numchild=\"0\",type=\"int\"" \ + "create i" + +mi_gdb_test "-var-create l * l" \ + "\\^done,name=\"l\",numchild=\"1\",type=\"long int \\*\"" \ + "create l" + +# Test: c_variable-2.11 +# Desc: create do_locals_tests local in subroutine1 +mi_gdb_test "-var-create linteger * linteger" \ + "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ + "create linteger" + +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"subroutine1\",args=\{\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}\},file=\".*var-cmd.c\",line=\"147\"\}\r\n$mi_gdb_prompt$" { + pass "step at subroutine1" + } + timeout { + fail "step at subroutine1 (timeout)" + } +} + +# Test: c_variable-2.12 +# Desc: change global_simple.integer +# Note: This also tests whether we are reporting changes in structs properly. +# gdb normally would say that global_simple has changed, but we +# special case that, since it is not what a human expects to +# see. + +setup_xfail *-*-* +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{FIXME: WHAT IS CORRECT HERE\}" \ + "update all vars: changed FIXME" +clear_xfail *-*-* + +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"subroutine1\",args=\{\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}\},file=\".*var-cmd.c\",line=\"148\"\}\r\n$mi_gdb_prompt$" { + pass "step at subroutine1" + } + timeout { fail "step at subroutine1 (timeout)" } +} + +# Test: c_variable-2.13 +# Desc: change subroutine1 local i +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"i\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: i changed" + +send_gdb "-exec-step\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"subroutine1\",args=\{\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}\},file=\".*var-cmd.c\",line=\"149\"\}\r\n$mi_gdb_prompt$" { + pass "step at subroutine1" + } + timeout { fail "step at subroutine1 (timeout)" } +} + +# Test: c_variable-2.14 +# Desc: change do_locals_tests local llong +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"llong\",in_scope=\"true\",type_changed=\"false\"\}" \ + "update all vars: llong changed" + +send_gdb "-exec-next\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_locals_tests\",args=\{\},file=\".*var-cmd.c\",line=\"136\"\}\r\n$mi_gdb_prompt$" { + pass "next out of subroutine1" + } + timeout { fail "next out of subroutine1 (timeout)" } +} + +# Test: c_variable-2.15 +# Desc: check for out of scope subroutine1 locals +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\{name=\"l\",in_scope=\"false\",name=\"i\",in_scope=\"false\"\}" \ + "update all vars: all now out of scope" + +# Done with locals/globals tests. Erase all variables +#delete_all_variables +mi_gdb_test "-var-delete global_simple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var" + +mi_gdb_test "-var-delete linteger" \ + "\\^done,ndeleted=\"1\"" \ + "delete var linteger" + +mi_gdb_test "-var-delete lpinteger" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpinteger" + +mi_gdb_test "-var-delete lcharacter" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lcharacter" + +mi_gdb_test "-var-delete lpcharacter" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpcharacter" + +mi_gdb_test "-var-delete llong" \ + "\\^done,ndeleted=\"1\"" \ + "delete var llong" + +mi_gdb_test "-var-delete lplong" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lplong" + +mi_gdb_test "-var-delete lfloat" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lfloat" + +mi_gdb_test "-var-delete lpfloat" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpfloat" + +mi_gdb_test "-var-delete ldouble" \ + "\\^done,ndeleted=\"1\"" \ + "delete var ldouble" + +mi_gdb_test "-var-delete lpdouble" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpdouble" + +mi_gdb_test "-var-delete lsimple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple" + +mi_gdb_test "-var-delete lpsimple" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lpsimple" + +mi_gdb_test "-var-delete func" \ + "\\^done,ndeleted=\"1\"" \ + "delete var func" + +mi_gdb_test "-var-delete lsimple.character" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple.character" + +mi_gdb_test "-var-delete lsimple->integer" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple->integer" + +mi_gdb_test "-var-delete lsimple.integer" \ + "\\^done,ndeleted=\"1\"" \ + "delete var lsimple.integer" + +mi_gdb_test "-var-delete i" \ + "\\^done,ndeleted=\"1\"" \ + "delete var i" + +mi_gdb_test "-var-delete l" \ + "\\^done,ndeleted=\"1\"" \ + "delete var l" + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + diff --git a/gdb/testsuite/gdb.mi/mi0-var-display.exp b/gdb/testsuite/gdb.mi/mi0-var-display.exp new file mode 100644 index 0000000..4f231d0 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-var-display.exp @@ -0,0 +1,628 @@ +# Copyright (C) 1999 2000 Cygnus Solutions +# +# 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 + +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can create, update, delete variables. +# + + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "var-cmd" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_gdb_test "200-break-insert 260" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"260\",times=\"0\"\}" \ + "break-insert operation" + +mi_run_cmd +# The running part has been checked already by mi_run_cmd +gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\{\},file=\".*var-cmd.c\",line=\"260\"\}\r\n$mi_gdb_prompt$" { + pass "run to do_children_tests" + } + -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"} + timeout {fail "run to do_children_tests (timeout 2)"} +} + +##### ##### +# # +# Display tests # +# # +##### ##### + +# Test: c_variable-6.1 +# Desc: create variable bar +mi_gdb_test "-var-create bar * bar" \ + "\\^done,name=\"bar\",numchild=\"0\",type=\"int\"" \ + "create local variable bar" + +# Test: c_variable-6.2 +# Desc: type of variable bar +mi_gdb_test "-var-info-type bar" \ + "\\^done,type=\"int\"" \ + "info type variable bar" + +# Test: c_variable-6.3 +# Desc: format of variable bar +mi_gdb_test "-var-show-format bar" \ + "\\^done,format=\"natural\"" \ + "show format variable bar" + +# Test: c_variable-6.4 +# Desc: value of variable bar +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"2121\"" \ + "eval variable bar" + +# Test: c_variable-6.5 +# Desc: change format of bar to hex +mi_gdb_test "-var-set-format bar hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable bar" + +# Test: c_variable-6.6 +# Desc: value of bar with new format +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"0x849\"" \ + "eval variable bar with new format" + +# Test: c_variable-6.7 +# Desc: change value of bar +mi_gdb_test "-var-assign bar 3" \ + "\\^done,value=\"0x3\"" \ + "assing to variable bar" + +mi_gdb_test "-var-set-format bar decimal" \ + "\\^done,format=\"decimal\"" \ + "set format variable bar" + +mi_gdb_test "-var-evaluate-expression bar" \ + "\\^done,value=\"3\"" \ + "eval variable bar with new value" + +mi_gdb_test "-var-delete bar" \ + "\\^done,ndeleted=\"1\"" \ + "delete var bar" + +# Test: c_variable-6.11 +# Desc: create variable foo +mi_gdb_test "-var-create foo * foo" \ + "\\^done,name=\"foo\",numchild=\"1\",type=\"int \\*\"" \ + "create local variable foo" + +# Test: c_variable-6.12 +# Desc: type of variable foo +mi_gdb_test "-var-info-type foo" \ + "\\^done,type=\"int \\*\"" \ + "info type variable foo" + +# Test: c_variable-6.13 +# Desc: format of variable foo +mi_gdb_test "-var-show-format foo" \ + "\\^done,format=\"natural\"" \ + "show format variable foo" + +# Test: c_variable-6.14 +# Desc: value of variable foo +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"$hex\"" \ + "eval variable foo" + +# Test: c_variable-6.15 +# Desc: change format of var to octal +mi_gdb_test "-var-set-format foo octal" \ + "\\^done,format=\"octal\"" \ + "set format variable foo" + +mi_gdb_test "-var-show-format foo" \ + "\\^done,format=\"octal\"" \ + "show format variable foo" + +# Test: c_variable-6.16 +# Desc: value of foo with new format +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"\[0-7\]+\"" \ + "eval variable foo" + +# Test: c_variable-6.17 +# Desc: change value of foo +mi_gdb_test "-var-assign foo 3" \ + "\\^done,value=\"03\"" \ + "assing to variable foo" + +mi_gdb_test "-var-set-format foo decimal" \ + "\\^done,format=\"decimal\"" \ + "set format variable foo" + +# Test: c_variable-6.18 +# Desc: check new value of foo +mi_gdb_test "-var-evaluate-expression foo" \ + "\\^done,value=\"3\"" \ + "eval variable foo" + +mi_gdb_test "-var-delete foo" \ + "\\^done,ndeleted=\"1\"" \ + "delete var foo" + +# Test: c_variable-6.21 +# Desc: create variable weird and children +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",type=\"weird_struct \\*\"" \ + "create local variable weird" + +mi_gdb_test "-var-list-children weird" \ + "\\^done,numchild=\"11\",children=\{child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"0\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\(\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\(\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\(\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\}" \ + "get children local variable weird" + + +# Test: c_variable-6.23 +# Desc: change format of weird.func_ptr and weird.func_ptr_ptr +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-show-format weird.func_ptr" \ + "\\^done,format=\"hexadecimal\"" \ + "show format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-show-format weird.func_ptr_ptr" \ + "\\^done,format=\"hexadecimal\"" \ + "show format variable weird.func_ptr_ptr" + +# Test: c_variable-6.24 +# Desc: format of weird and children +mi_gdb_test "-var-set-format weird natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird" + +mi_gdb_test "-var-set-format weird.integer natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.integer" + +mi_gdb_test "-var-set-format weird.character natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.character" + +mi_gdb_test "-var-set-format weird.char_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.char_ptr" + +mi_gdb_test "-var-set-format weird.long_int natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.long_int" + +mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.int_ptr_ptr" + +mi_gdb_test "-var-set-format weird.long_array natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.long_array" + +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ + "\\^done,format=\"hexadecimal\"" \ + "set format variable weird.func_ptr_struct" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-set-format weird.u1 natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.u1" + +mi_gdb_test "-var-set-format weird.s2 natural" \ + "\\^done,format=\"natural\"" \ + "set format variable weird.s2" + +# Test: c_variable-6.25 +# Desc: value of weird and children +#gdbtk_test c_variable-6.25 {value of weird and children} { +# set values {} +# foreach v [lsort [array names var]] f [list x "" "" x x x x d d d d d] { +# lappend values [value $v $f] +# } + +# set values +#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} + +# Test: c_variable-6.26 +# Desc: change format of weird and children to octal +#gdbtk_test c_variable-6.26 {change format of weird and children to octal} { +# set formats {} +# foreach v [lsort [array names var]] { +# $var($v) format octal +# lappend formats [$var($v) format] +# } + +# set formats +#} {octal octal octal octal octal octal octal octal octal octal octal octal} + +# Test: c_variable-6.27 +# Desc: value of weird and children with new format +#gdbtk_test c_variable-6.27 {value of foo with new format} { +# set values {} +# foreach v [lsort [array names var]] { +# lappend values [value $v o] +# } + +# set values +#} {ok ok ok ok ok ok ok ok weird.long_array ok weird.s2 weird.u1} + +# Test: c_variable-6.30 +# Desc: create more children of weird +#gdbtk_test c_variable-6.30 {create more children of weird} { +# foreach v [array names var] { +# get_children $v +# } + +# # Do it twice to get more children +# foreach v [array names var] { +# get_children $v +# } + +# lsort [array names var] +#} {weird weird.char_ptr weird.character weird.func_ptr weird.func_ptr_ptr weird.func_ptr_struct weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.integer weird.long_array weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.long_int weird.s2 weird.s2.g weird.s2.h weird.s2.i weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9 weird.s2.u2 weird.s2.u2.f weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.u1 weird.u1.a weird.u1.b weird.u1.c weird.u1.d} + +# Test: c_variable-6.31 +# Desc: check that all children of weird change +# Ok, obviously things like weird.s2 and weird.u1 will not change! +#gdbtk_test *c_variable-6.31 {check that all children of weird change (ops, we are now reporting array names as changed in this case - seems harmless though)} { +# $var(weird) value 0x2121 +# check_update +#} {{weird.integer weird.character weird.char_ptr weird.long_int weird.int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr weird.int_ptr_ptr.*int_ptr_ptr.**int_ptr_ptr weird.long_array.0 weird.long_array.1 weird.long_array.2 weird.long_array.3 weird.long_array.4 weird.long_array.5 weird.long_array.6 weird.long_array.7 weird.long_array.8 weird.long_array.9 weird.func_ptr weird.func_ptr_struct weird.func_ptr_ptr weird.u1.a weird.u1.b weird.u1.c weird.u1.d weird.s2.u2.f weird.s2.g weird.s2.h weird.s2.i.0 weird.s2.i.1 weird.s2.i.2 weird.s2.i.3 weird.s2.i.4 weird.s2.i.5 weird.s2.i.6 weird.s2.i.7 weird.s2.i.8 weird.s2.i.9} {weird.s2.i weird.s2.u2 weird weird.s2.u2.u1s1 weird.s2.u2.u1s2 weird.s2 weird.long_array weird.u1} {}} + +mi_gdb_test "-var-delete weird" \ + "\\^done,ndeleted=\"12\"" \ + "delete var weird" + + +##### ##### +# # +# Special Display Tests # +# # +##### ##### + +# Stop in "do_special_tests" +mi_gdb_test "200-break-insert do_special_tests" \ + "200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"282\",times=\"0\"\}" \ + "break-insert operation" + +send_gdb "-exec-continue\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\{\},file=\".*var-cmd.c\",line=\"282\"\}\r\n$mi_gdb_prompt$" { + pass "continue to do_special_tests" + } + timeout { + fail "continue to do_special_tests (timeout)" + } +} + +# Test: c_variable-7.10 +# Desc: create union u +mi_gdb_test "-var-create u * u" \ + "\\^done,name=\"u\",numchild=\"2\",type=\"union named_union\"" \ + "create local variable u" + +# Test: c_variable-7.11 +# Desc: value of u +mi_gdb_test "-var-evaluate-expression u" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable u" + +# Test: c_variable-7.12 +# Desc: type of u +mi_gdb_test "-var-info-type u" \ + "\\^done,type=\"union named_union\"" \ + "info type variable u" + +# Test: c_variable-7.13 +# Desc: is u editable +mi_gdb_test "-var-show-attributes u" \ + "\\^done,attr=\"noneditable\"" \ + "is u editable" + +# Test: c_variable-7.14 +# Desc: number of children of u +mi_gdb_test "-var-info-num-children u" \ + "\\^done,numchild=\"2\"" \ + "get number of children of u" + +# Test: c_variable-7.15 +# Desc: children of u +mi_gdb_test "-var-list-children u" \ + "\\^done,numchild=\"2\",children=\{child=\{name=\"u.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"u.char_ptr\",exp=\"char_ptr\",numchild=\"0\",type=\"char \\*\"\}\}" \ + "get children of u" + +# Test: c_variable-7.20 +# Desc: create anonu +mi_gdb_test "-var-create anonu * anonu" \ + "\\^done,name=\"anonu\",numchild=\"3\",type=\"union \{\\.\\.\\.\}\"" \ + "create local variable anonu" + +# Test: c_variable-7.21 +# Desc: value of anonu +mi_gdb_test "-var-evaluate-expression anonu" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable anonu" + +# Test: c_variable-7.22 +# Desc: type of anonu +mi_gdb_test "-var-info-type anonu" \ + "\\^done,type=\"union \{\\.\\.\\.\}\"" \ + "info type variable anonu" + +# Test: c_variable-7.23 +# Desc: is anonu editable +mi_gdb_test "-var-show-attributes anonu" \ + "\\^done,attr=\"noneditable\"" \ + "is anonu editable" + +# Test: c_variable-7.24 +# Desc: number of children of anonu +mi_gdb_test "-var-info-num-children anonu" \ + "\\^done,numchild=\"3\"" \ + "get number of children of anonu" + +# Test: c_variable-7.25 +# Desc: children of anonu +mi_gdb_test "-var-list-children anonu" \ + "\\^done,numchild=\"3\",children=\{child=\{name=\"anonu.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anonu.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anonu.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of anonu" + +# Test: c_variable-7.30 +# Desc: create struct s +mi_gdb_test "-var-create s * s" \ + "\\^done,name=\"s\",numchild=\"6\",type=\"struct _simple_struct\"" \ + "create local variable s" + + +# Test: c_variable-7.31 +# Desc: value of s +mi_gdb_test "-var-evaluate-expression s" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable s" + +# Test: c_variable-7.32 +# Desc: type of s +mi_gdb_test "-var-info-type s" \ + "\\^done,type=\"struct _simple_struct\"" \ + "info type variable s" + +# Test: c_variable-7.33 +# Desc: is s editable +mi_gdb_test "-var-show-attributes s" \ + "\\^done,attr=\"noneditable\"" \ + "is s editable" + +# Test: c_variable-7.34 +# Desc: number of children of s +mi_gdb_test "-var-info-num-children s" \ + "\\^done,numchild=\"6\"" \ + "get number of children of s" + +# Test: c_variable-7.35 +# Desc: children of s +mi_gdb_test "-var-list-children s" \ + "\\^done,numchild=\"6\",children=\{child=\{name=\"s.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"s.unsigned_integer\",exp=\"unsigned_integer\",numchild=\"0\",type=\"unsigned int\"\},child=\{name=\"s.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"s.signed_character\",exp=\"signed_character\",numchild=\"0\",type=\"signed char\"\},child=\{name=\"s.char_ptr\",exp=\"char_ptr\",numchild=\"0\",type=\"char \\*\"\},child=\{name=\"s.array_of_10\",exp=\"array_of_10\",numchild=\"10\",type=\"int \\\[10\\\]\"\}\}" \ + "get children of s" +#} {integer unsigned_integer character signed_character char_ptr array_of_10} + +# Test: c_variable-7.40 +# Desc: create anons +mi_gdb_test "-var-create anons * anons" \ + "\\^done,name=\"anons\",numchild=\"3\",type=\"struct \{\\.\\.\\.\}\"" \ + "create local variable anons" + +# Test: c_variable-7.41 +# Desc: value of anons +mi_gdb_test "-var-evaluate-expression anons" \ + "\\^done,value=\"\{\\.\\.\\.\}\"" \ + "eval variable anons" + +# Test: c_variable-7.42 +# Desc: type of anons +mi_gdb_test "-var-info-type anons" \ + "\\^done,type=\"struct \{\\.\\.\\.\}\"" \ + "info type variable anons" + +# Test: c_variable-7.43 +# Desc: is anons editable +mi_gdb_test "-var-show-attributes anons" \ + "\\^done,attr=\"noneditable\"" \ + "is anons editable" + +# Test: c_variable-7.44 +# Desc: number of children of anons +mi_gdb_test "-var-info-num-children anons" \ + "\\^done,numchild=\"3\"" \ + "get number of children of anons" + +# Test: c_variable-7.45 +# Desc: children of anons +mi_gdb_test "-var-list-children anons" \ + "\\^done,numchild=\"3\",children=\{child=\{name=\"anons.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anons.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anons.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\}" \ + "get children of anons" + + +# Test: c_variable-7.50 +# Desc: create enum e +mi_gdb_test "-var-create e * e" \ + "\\^done,name=\"e\",numchild=\"0\",type=\"enum foo\"" \ + "create local variable e" + +setup_xfail "*-*-*" +# Test: c_variable-7.51 +# Desc: value of e +mi_gdb_test "-var-evaluate-expression e" \ + "\\^done,value=\"FIXME\"" \ + "eval variable e" +clear_xfail "*-*-*" + +# Test: c_variable-7.52 +# Desc: type of e +mi_gdb_test "-var-info-type e" \ + "\\^done,type=\"enum foo\"" \ + "info type variable e" + +# Test: c_variable-7.53 +# Desc: is e editable +mi_gdb_test "-var-show-attributes e" \ + "\\^done,attr=\"editable\"" \ + "is e editable" + +# Test: c_variable-7.54 +# Desc: number of children of e +mi_gdb_test "-var-info-num-children e" \ + "\\^done,numchild=\"0\"" \ + "get number of children of e" + +# Test: c_variable-7.55 +# Desc: children of e +mi_gdb_test "-var-list-children e" \ + "\\^done,numchild=\"0\"" \ + "get children of e" + +# Test: c_variable-7.60 +# Desc: create anone +mi_gdb_test "-var-create anone * anone" \ + "\\^done,name=\"anone\",numchild=\"0\",type=\"enum \{\\.\\.\\.\}\"" \ + "create local variable anone" + +setup_xfail "*-*-*" +# Test: c_variable-7.61 +# Desc: value of anone +mi_gdb_test "-var-evaluate-expression anone" \ + "\\^done,value=\"A\"" \ + "eval variable anone" +clear_xfail "*-*-*" + + +# Test: c_variable-7.70 +# Desc: create anone +mi_gdb_test "-var-create anone * anone" \ + "&\"Duplicate variable object name\\\\n\".*\\^error,msg=\"Duplicate variable object name\"" \ + "create duplicate local variable anone" + + +# Test: c_variable-7.72 +# Desc: type of anone +mi_gdb_test "-var-info-type anone" \ + "\\^done,type=\"enum \{\\.\\.\\.\}\"" \ + "info type variable anone" + + +# Test: c_variable-7.73 +# Desc: is anone editable +mi_gdb_test "-var-show-attributes anone" \ + "\\^done,attr=\"editable\"" \ + "is anone editable" + +# Test: c_variable-7.74 +# Desc: number of children of anone +mi_gdb_test "-var-info-num-children anone" \ + "\\^done,numchild=\"0\"" \ + "get number of children of anone" + +# Test: c_variable-7.75 +# Desc: children of anone +mi_gdb_test "-var-list-children anone" \ + "\\^done,numchild=\"0\"" \ + "get children of anone" + + +# Record fp + +send_gdb "p/x \$fp\n" +gdb_expect { + -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" { + pass "print FP register" + set fp $expect_out(1,string) + } +# -re ".*" { fail "print FP register"} + timeout { fail "print FP register (timeout)"} +} + +mi_gdb_test "200-break-insert incr_a" \ + "200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"85\",times=\"0\"\}" \ + "break-insert operation" +send_gdb "-exec-continue\n" +gdb_expect { + -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\{\{name=\"a\",value=\"2\.*\"\}\},file=\".*var-cmd.c\",line=\"85\"\}\r\n$mi_gdb_prompt$" { + pass "continue to incr_a" + } + timeout { + fail "continue to incr_a (timeout)" + } +} + +# Test: c_variable-7.81 +# Desc: Create variables in different scopes +mi_gdb_test "-var-create a1 * a" \ + "\\^done,name=\"a1\",numchild=\"0\",type=\"char\"" \ + "create local variable a1" + +mi_gdb_test "-var-create a2 $fp a" \ + "\\^done,name=\"a2\",numchild=\"0\",type=\"int\"" \ + "create variable a2 in different scope" + +#gdbtk_test c_variable-7.81 {create variables in different scopes} { +# set a1 [gdb_variable create -expr a] +# set a2 [gdb_variable create -expr a -frame $fp] + +# set vals {} +# lappend vals [$a1 value] +# lappend vals [$a2 value] +# set vals +#} {2 1} + + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + + + + diff --git a/gdb/testsuite/gdb.mi/mi0-watch.exp b/gdb/testsuite/gdb.mi/mi0-watch.exp new file mode 100644 index 0000000..5b8908a --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi0-watch.exp @@ -0,0 +1,195 @@ +# Copyright 1999, 2000 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 + +# +# Test essential Machine interface (MI) operations +# +# Verify that, using the MI, we can run a simple program and perform basic +# debugging activities like: insert breakpoints, run the program, +# step, next, continue until it ends and, last but not least, quit. +# +# The goal is not to test gdb functionality, which is done by other tests, +# but to verify the correct output response to MI operations. +# + +load_lib mi-support.exp + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +proc test_watchpoint_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert a watchpoint and list + # Tests: + # -break-watch C + # -break-list + + mi_gdb_test "111-break-watch C" \ + "111\\^done,wpt=\{number=\"2\",exp=\"C\"\}" \ + "break-watch operation" + + mi_gdb_test "222-break-list" \ + "222\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"1\"\},bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\}" \ + "list of watchpoints" + +} + +# UNUSED at the time +proc test_awatch_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert an access watchpoint and list it + # Tests: + # -break-watch -a A + # -break-list + + mi_gdb_test "333-break-watch -a A" \ + "333\\^done,bkpt=\{number=\"1\",addr=\"$hex\",file=\".*basics.c\",line=\"32\"\}" \ + "break-watch -a operation" + + mi_gdb_test "444-break-list" \ + "444\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \ + "list of watchpoints awatch" + + mi_gdb_test "777-break-delete 3" \ + "777\\^done" \ + "delete access watchpoint" +} + +# UNUSED at the time +proc test_rwatch_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + + # Insert a read watchpoint and list it. + # Tests: + # -break-insert -r B + # -break-list + + mi_gdb_test "200-break-watch -r C" \ + "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"32\",times=\"0\"\}" \ + "break-insert -r operation" + + mi_gdb_test "300-break-list" \ + "300\\^done,BreakpointTable=\{hdr=\{.*\},bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"32\",times=\"0\"\},.*\}\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete 4" \ + "177\\^done" \ + "delete read watchpoint" +} + +proc test_running_the_program {} { + global mi_gdb_prompt + global hex + + # Run the program without args, then specify srgs and rerun the program + # Tests: + # -exec-run + + mi_gdb_test "300-break-insert callee4" \ + "300\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\",times=\"0\"\}" \ + "insert breakpoint at callee4" + + # mi_gdb_test cannot be used for asynchronous commands because there are + # two prompts involved and this can lead to a race condition. + # The following is equivalent to a send_gdb "000-exec-run\n" + mi_run_cmd + # The running part has been checked already by mi_run_cmd + gdb_expect { + -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"8\"\}\r\n$mi_gdb_prompt$" \ + { pass "run to callee4" } + -re ".*$mi_gdb_prompt$" {fail "run to callee4 (2)"} + timeout {fail "run to callee4 (timeout 2)"} + } +} + +proc test_watchpoint_triggering {} { + global mi_gdb_prompt + global hex + + # Continue execution until the watchpoint is reached, continue again, + # to see the watchpoint go out of scope. + # Does: + # -exec-continue (Here wp triggers) + # -exec-continue (Here wp goes out of scope) + + send_gdb "222-exec-continue\n" + gdb_expect { + -re "222\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee4\",args=\{\},file=\".*basics.c\",line=\"13\"\}\r\n$mi_gdb_prompt$" { + pass "watchpoint trigger" + } + -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"} + timeout {fail "watchpoint trigger (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"} + timeout {fail "watchpoint trigger (timeout 1)"} + } + + send_gdb "223-exec-continue\n" + gdb_expect { + -re "223\\^running\r\n$mi_gdb_prompt" { + gdb_expect { + -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"callee3\",args=\{.*\},file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" { + pass "wp out of scope" + } + -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"} + timeout {fail "wp out of scope (timeout 2)"} + } + } + -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"} + timeout {fail "wp out of scope (timeout 1)"} + } +} + +test_running_the_program +test_watchpoint_creation_and_listing +#test_rwatch_creation_and_listing +#test_awatch_creation_and_listing +test_watchpoint_triggering + +mi_gdb_exit +return 0 + +# Local variables: +# change-log-default-name: "ChangeLog-mi" +# End: + |