Index: ChangeLog
authorAndrew Cagney <cagney@redhat.com>
Thu, 7 Aug 2003 17:47:42 +0000 (17:47 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 7 Aug 2003 17:47:42 +0000 (17:47 +0000)
2003-08-07  Andrew Cagney  <cagney@redhat.com>

* interps.h (INTERP_MI2, INTERP_MI3): Define.

Index: doc/ChangeLog
2003-08-07  Andrew Cagney  <cagney@redhat.com>

* gdb.texinfo (Mode Options): Mention that "mi2" was included in
GDB 6.0.

Index: mi/ChangeLog
2003-08-07  Andrew Cagney  <cagney@redhat.com>

* mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
Make "mi" select "mi2".

Index: testsuite/gdb.mi/ChangeLog
2003-08-07  Andrew Cagney  <cagney@redhat.com>

* mi2-basics.exp: Copy base MI .exp file, set MIFLAGS to -i=mi2.
* mi2-break.exp, mi2-cli.exp, mi2-console.exp: Ditto.
* mi2-disassemble.exp, mi2-eval.exp, mi2-file.exp: Ditto.
* mi2-hack-cli.exp, mi2-pthreads.exp, mi2-read-memory.exp: Ditto.
* mi2-regs.exp, mi2-return.exp, mi2-simplerun.exp: Ditto.
* mi2-stack.exp, mi2-stepi.exp, mi2-syn-frame.exp: Ditto.
* mi2-until.exp, mi2-var-block.exp, mi2-var-child.exp: Ditto.
* mi2-var-cmd.exp, mi2-var-display.exp, mi2-watch.exp: Ditto.

29 files changed:
gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/interps.h
gdb/mi/ChangeLog
gdb/mi/mi-interp.c
gdb/testsuite/gdb.mi/ChangeLog
gdb/testsuite/gdb.mi/mi2-basics.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-break.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-cli.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-console.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-disassemble.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-eval.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-file.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-hack-cli.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-pthreads.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-read-memory.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-regs.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-return.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-simplerun.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-stack.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-stepi.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-syn-frame.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-until.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-var-block.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-var-child.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-var-cmd.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-var-display.exp [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi2-watch.exp [new file with mode: 0644]

index 146ae07..4936559 100644 (file)
@@ -1,3 +1,7 @@
+2003-08-07  Andrew Cagney  <cagney@redhat.com>
+
+       * interps.h (INTERP_MI2, INTERP_MI3): Define.
+
 2003-08-07  Michal Ludvig  <mludvig@suse.cz>
 
        * x86-64-tdep.c (x86_64_dwarf_regmap): Correct register numbers.
index 7f09405..94ccfe8 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-07  Andrew Cagney  <cagney@redhat.com>
+
+       * gdb.texinfo (Mode Options): Mention that "mi2" was included in
+       GDB 6.0.
+
 2003-08-06  Andrew Cagney  <cagney@redhat.com>
 
        * gdb.texinfo (Mode Options): Mention that level three is the
index d8ec094..92a3aab 100644 (file)
@@ -1133,11 +1133,11 @@ communicate with @value{GDBN} using it as a back end.
 @xref{Interpreters, , Command Interpreters}.
 
 @samp{--interpreter=mi} (or @samp{--interpreter=mi2}) causes
-@value{GDBN} to use the current @dfn{@sc{gdb/mi} interface}
-(@pxref{GDB/MI, , The @sc{gdb/mi} Interface}).  The previous @sc{gdb/mi}
-interface, included in @value{GDBN} version 5.3, can be selected with
-@samp{--interpreter=mi1}.  Earlier @sc{gdb/mi} interfaces
-are not supported.
+@value{GDBN} to use the @dfn{@sc{gdb/mi} interface} (@pxref{GDB/MI, ,
+The @sc{gdb/mi} Interface}) included in @var{GDBN} version 6.0.  The
+previous @sc{gdb/mi} interface, included in @value{GDBN} version 5.3,
+can be selected with @samp{--interpreter=mi1}.  Earlier @sc{gdb/mi}
+interfaces are not supported.
 
 @item -write
 @cindex @code{--write}
index 74008d6..d24cf6a 100644 (file)
@@ -68,6 +68,8 @@ extern void clear_interpreter_hooks (void);
 /* well-known interpreters */
 #define INTERP_CONSOLE         "console"
 #define INTERP_MI1             "mi1"
+#define INTERP_MI2             "mi2"
+#define INTERP_MI3             "mi3"
 #define INTERP_MI              "mi"
 
 #endif
index 512d971..3122136 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-07  Andrew Cagney  <cagney@redhat.com>
+
+       * mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
+       Make "mi" select "mi2".
+
 2003-08-05  Andrew Cagney  <cagney@redhat.com>
 
        * mi-cmd-env.c (env_execute_cli_command): Use an explicit "%s %s"
index 696ae06..e00e329 100644 (file)
@@ -407,8 +407,12 @@ _initialize_mi_interp (void)
     mi_interpreter_prompt_p    /* prompt_proc_p */
   };
 
-  /* Create MI1 interpreter */
+  /* The various interpreter levels.  */
   interp_add (interp_new (INTERP_MI1, NULL, mi_out_new (1), &procs));
+  interp_add (interp_new (INTERP_MI2, NULL, mi_out_new (2), &procs));
+  interp_add (interp_new (INTERP_MI3, NULL, mi_out_new (3), &procs));
 
-  interp_add (interp_new (INTERP_MI, NULL, mi_out_new (3), &procs));
+  /* "mi" selects the most recent released version.  "mi2" was
+     released as part of GDB 6.0.  */
+  interp_add (interp_new (INTERP_MI, NULL, mi_out_new (2), &procs));
 }
index e4aec35..6f263c3 100644 (file)
@@ -1,3 +1,14 @@
+2003-08-07  Andrew Cagney  <cagney@redhat.com>
+
+       * mi2-basics.exp: Copy base MI .exp file, set MIFLAGS to -i=mi2.
+       * mi2-break.exp, mi2-cli.exp, mi2-console.exp: Ditto.
+       * mi2-disassemble.exp, mi2-eval.exp, mi2-file.exp: Ditto.
+       * mi2-hack-cli.exp, mi2-pthreads.exp, mi2-read-memory.exp: Ditto.
+       * mi2-regs.exp, mi2-return.exp, mi2-simplerun.exp: Ditto.
+       * mi2-stack.exp, mi2-stepi.exp, mi2-syn-frame.exp: Ditto.
+       * mi2-until.exp, mi2-var-block.exp, mi2-var-child.exp: Ditto.
+       * mi2-var-cmd.exp, mi2-var-display.exp, mi2-watch.exp: Ditto.
+
 2003-05-03  J. Brobecker  <brobecker@gnat.com>
 
        From Thierry Schneider  <tpschneider1@yahoo.com>:
diff --git a/gdb/testsuite/gdb.mi/mi2-basics.exp b/gdb/testsuite/gdb.mi/mi2-basics.exp
new file mode 100644 (file)
index 0000000..44d2e4b
--- /dev/null
@@ -0,0 +1,246 @@
+#   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
+set MIFLAGS "-i=mi2"
+
+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=\\\{.*,body=\\\[\\\]\\\}" \
+             "all breakpoints removed"
+}
+
+proc test_dir_specification {} {
+    global mi_gdb_prompt
+    global srcdir
+    global subdir
+
+    # Add to the search directories, display, then reset back to default
+    # Tests:
+    # -environment-directory arg
+    # -environment-directory 
+    # -environment-directory -r
+
+#exp_internal 1
+    mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
+             "\\\^done,source-path=\"${srcdir}/${subdir}.\\\$cdir.\\\$cwd\"" \
+             "environment-directory arg operation"
+
+    mi_gdb_test "203-environment-directory" \
+             "\\\^done,source-path=\"${srcdir}/${subdir}.\\\$cdir.\\\$cwd\"" \
+             "environment-directory empty-string operation"
+
+    mi_gdb_test "204-environment-directory -r" \
+             "\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \
+             "environment-directory operation"
+
+#exp_internal 0
+}
+
+proc test_cwd_specification {} {
+    global mi_gdb_prompt
+    global objdir
+    global subdir
+
+    # Change the working directory, then print the current working directory
+    # Tests:
+    # -environment-cd ${objdir}
+    # -environment-pwd
+
+    mi_gdb_test "205-environment-cd ${objdir}" \
+             "\\\^done" \
+             "environment-cd arg operation"
+
+    mi_gdb_test "206-environment-pwd" \
+             "\\\^done,cwd=\"${objdir}\"" \
+             "environment-pwd operation"
+}
+
+proc test_path_specification {} {
+    global mi_gdb_prompt
+    global orig_path
+    global objdir
+    global srcdir
+
+    # Add to the path, display, then reset 
+    # Tests:
+    # -environment-path 
+    # -environment-path dir1 dir2
+    # -environment-path -r dir
+    # -environment-path -r
+
+#exp_internal 1
+
+    send_gdb "-environment-path\n"
+    gdb_expect 20 {
+       -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { 
+         set orig_path $expect_out(1,string); 
+       }
+       timeout { 
+         perror "-environment-path (timeout)" ; 
+         return 
+       }
+    }
+
+    mi_gdb_test "207-environment-path" \
+             "\\\^done,path=\"$orig_path\"" \
+             "environment-path no-args operation"
+
+    mi_gdb_test "208-environment-path $srcdir $objdir" \
+             "\\\^done,path=\"$srcdir.$objdir.$orig_path\"" \
+             "environment-path dir1 dir2 operation"
+
+    mi_gdb_test "209-environment-path -r $objdir" \
+             "\\\^done,path=\"$objdir.$orig_path\"" \
+             "environment-path -r dir operation"
+
+    mi_gdb_test "210-environment-path -r" \
+             "\\\^done,path=\"$orig_path\"" \
+             "environment-path -r operation"
+
+#exp_internal 0
+} 
+
+if [test_mi_interpreter_selection] {
+  test_exec_and_symbol_mi_operatons
+  test_breakpoints_deletion
+  test_dir_specification
+  test_cwd_specification
+  test_path_specification
+}
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-break.exp b/gdb/testsuite/gdb.mi/mi2-break.exp
new file mode 100644 (file)
index 0000000..11cb0d9
--- /dev/null
@@ -0,0 +1,138 @@
+#   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
+set MIFLAGS "-i=mi2"
+
+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=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[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" \
+           "1\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[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
diff --git a/gdb/testsuite/gdb.mi/mi2-cli.exp b/gdb/testsuite/gdb.mi/mi2-cli.exp
new file mode 100644 (file)
index 0000000..10295a9
--- /dev/null
@@ -0,0 +1,208 @@
+# Copyright 2002, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file tests that GDB's console can be accessed via the MI.
+# Specifically, we are testing the "interpreter-exec" command and that
+# the commands that are executed via this command are properly executed.
+# Console commands executed via MI should use MI output wrappers, MI event
+# handlers, etc.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+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_gdb_reinitialize_dir $srcdir/$subdir
+
+mi_gdb_test "-interpreter-exec" \
+  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
+  "-interpreter-exec with no arguments"
+
+mi_gdb_test "-interpreter-exec console" \
+  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
+  "-interpreter-exec with one argument"
+
+mi_gdb_test "-interpreter-exec bogus command" \
+  {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
+  "-interpreter-exec with bogus interpreter"
+
+set msg {Undefined command: \\\"bogus\\\"\.  Try \\\"help\\\"\.}
+mi_gdb_test "-interpreter-exec console bogus" \
+    "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
+  "-interpreter-exec console bogus"
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
+#   {(=.*)+\^done} \
+#   "-interpreter-exec console \"file \$binfile\""
+mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
+  {\^done} \
+  "-interpreter-exec console \"file \$binfile\""
+
+mi_run_to_main
+
+mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
+  {\^done} \
+  "-interpreter-exec console \"set args foobar\""
+
+mi_gdb_test "-interpreter-exec console \"show args\"" \
+  {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
+  "-interpreter-exec console \"show args\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-interpreter-exec console \"break callee4\"" \
+#   {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
+#   "-interpreter-exec console \"break callee4\""
+mi_gdb_test "-interpreter-exec console \"break callee4\"" \
+  {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
+  "-interpreter-exec console \"break callee4\""
+
+mi_gdb_test "-interpreter-exec console \"info break\"" \
+  {\~"Num[ \t]*Type[ \t]*Disp[ \t]*Enb[ \t]*Address[ \t]*What\\n".*~"2[ \t]*breakpoint[ \t]*keep[ \t]*y[ \t]*0x[0-9A-Fa-f]+[ \t]*in callee4 at .*basics.c:[0-9]+\\n".*\^done} \
+  "-interpreter-exec console \"info break\""
+
+mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
+  {\^done} \
+  "-interpreter-exec console \"set listsize 1\""
+
+mi_gdb_test "-interpreter-exec console \"list\"" \
+  {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done} \
+  "-interpreter-exec console \"list\""
+
+# # NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-exec-continue" \
+#    {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \
+#    "-interpreter-exec console \"continue to callee4\""
+send_gdb "999-exec-continue\n"
+gdb_expect {
+    -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
+       pass "continue to callee4"
+    }
+    timeout {
+       fail "continue to callee4 (timeout)"
+    }
+}
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
+#   {.*=breakpoint-delete,number=\"2\".*\^done} \
+#   "-interpreter-exec console \"delete 2\""
+mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
+  {100\^done} \
+  "-interpreter-exec console \"delete 2\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "200-interpreter-exec console \"up\"" \
+#   {.*=selected-frame-level-changed,level="1".*\^done} \
+#   "-interpreter-exec console \"up\""
+mi_gdb_test "200-interpreter-exec console \"up\"" \
+  {200\^done} \
+  "-interpreter-exec console \"up\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "300-interpreter-exec console \"down\"" \
+#   {.*=selected-frame-level-changed,level="0".*\^done} \
+#   "-interpreter-exec console \"down\""
+mi_gdb_test "300-interpreter-exec console \"down\"" \
+  {300\^done} \
+  "-interpreter-exec console \"down\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-interpreter-exec console \"frame 2\"" \
+#   {.*=selected-frame-level-changed,level="2".*\^done} \
+#   "-interpreter-exec console \"frame 2\""
+mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
+  {400\^done} \
+  "-interpreter-exec console \"frame 2\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-stack-select-frame 0" \
+#   {.*=selected-frame-level-changed,level="0".*\^done} \
+#   "-stack-select-frame 0"
+mi_gdb_test "500-stack-select-frame 0" \
+  {500\^done} \
+  "-stack-select-frame 0"
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-break-insert -t basics.c:35" \
+#   {.*=breakpoint-create,number="3".*\^done} \
+#   "-break-insert -t basics.c:35"
+mi_gdb_test "600-break-insert -t basics.c:35" \
+       {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
+       "-break-insert -t basics.c:35"
+
+# mi_gdb_test "-exec-continue" \
+#   {.*\*stopped.*,file=".*basics.c",line="35"\}} \
+#   "-exec-continue to line 35"
+send_gdb "700-exec-continue\n"
+gdb_expect {
+    -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=.*basics.c.,line=.35.*$mi_gdb_prompt$" {
+       pass "-exec-continue to line 35"
+    }
+    timeout {
+       fail "-exec-continue to line 35"
+    }
+}
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-exec-next" \
+#   {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",line="37"\}} \
+#   "-exec-next to line 37"
+send_gdb "800-exec-next\n"
+gdb_expect {
+    -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=.*basics.c.,line=.37.*$mi_gdb_prompt$" {
+       pass "-exec-next to line 37"
+    }
+    timeout {
+       fail "-exec-next to line 37"
+    }
+}
+
+mi_gdb_test "-interpreter-exec console \"list\"" \
+  {\~"37[ \t(\\t)]*return 0;\\n".*\^done} \
+  "-interpreter-exec console \"list\" at basics.c:37"
+
+mi_gdb_test "-interpreter-exec console \"help set args\"" \
+  {\~"Set argument list to give program being debugged when it is started\.\\nFollow this command with any number of args, to be passed to the program\.".*\^done} \
+  "-interpreter-exec console \"help set args\""
+
+# NOTE: cagney/2003-02-03: Not yet.
+# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
+#   {.*=target-changed.*\^done} \
+#   "-interpreter-exec console \"set \$pc=0x0\""
+mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
+  {888\^done} \
+  "-interpreter-exec console \"set \$pc=0x0\""
+
+#mi_gdb_test "-interpreter-exec console \"\"" \
+  {} \
+  "-interpreter-exec console \"\""
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-console.exp b/gdb/testsuite/gdb.mi/mi2-console.exp
new file mode 100644 (file)
index 0000000..5e307b9
--- /dev/null
@@ -0,0 +1,97 @@
+# Copyright 1999, 2000, 2001, 2002 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.
+#
+
+# 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
+set MIFLAGS "-i=mi2"
+
+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}
+
+mi_run_to_main
+
+# 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.
+
+       kfail "gdb/623" "Hello message"
+    }
+    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
diff --git a/gdb/testsuite/gdb.mi/mi2-disassemble.exp b/gdb/testsuite/gdb.mi/mi2-disassemble.exp
new file mode 100644 (file)
index 0000000..8cd76f9
--- /dev/null
@@ -0,0 +1,178 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_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"
+
+}
+
+mi_run_to_main
+test_disassembly_only
+test_disassembly_mixed
+test_disassembly_bogus_args
+test_disassembly_lines_limit
+test_disassembly_mixed_lines_limit
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-eval.exp b/gdb/testsuite/gdb.mi/mi2-eval.exp
new file mode 100644 (file)
index 0000000..85fd991
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_runto callee4
+mi_next_to "callee4" "" "basics.c" "9" "next at callee4"
+
+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
diff --git a/gdb/testsuite/gdb.mi/mi2-file.exp b/gdb/testsuite/gdb.mi/mi2-file.exp
new file mode 100644 (file)
index 0000000..fe75a93
--- /dev/null
@@ -0,0 +1,65 @@
+#   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
+set MIFLAGS "-i=mi2"
+
+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 srcfile
+    global srcdir
+    global subdir
+    set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
+
+    # get the path and absolute path to the current executable
+    mi_gdb_test "111-file-list-exec-source-file" \
+           "111\\\^done,line=\"23\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \
+               "request path info of current source file (${srcfile})"
+}
+
+test_tbreak_creation_and_listing
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-hack-cli.exp b/gdb/testsuite/gdb.mi/mi2-hack-cli.exp
new file mode 100644 (file)
index 0000000..066eea2
--- /dev/null
@@ -0,0 +1,40 @@
+#   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
+set MIFLAGS "-i=mi2"
+
+gdb_exit
+if [mi_gdb_start] {
+    continue
+}
+
+mi_gdb_test "show architecture" \
+       "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n\\^done" \
+       "show architecture"
+
+mi_gdb_test "47show architecture" \
+       "&\"show architecture\\\\n\"\r\n~\"The target architecture.*\"\r\n47\\^done" \
+       "47show architecture"
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-pthreads.exp b/gdb/testsuite/gdb.mi/mi2-pthreads.exp
new file mode 100644 (file)
index 0000000..fe007e5
--- /dev/null
@@ -0,0 +1,221 @@
+# Copyright 2002, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file tests MI thread commands.
+# Specifically, we are testing the MI command set and the console (in MI)
+# command set ("interpreter-exec") and that the commands that are executed
+# via these command pathways are properly executed. Console commands
+# executed via MI should use MI output wrappers, MI event handlers, etc.
+
+# This only works with native configurations
+if {![isnative]} {
+  return
+}
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+gdb_exit
+if {[mi_gdb_start]} {
+    continue
+}
+
+# The procs below dealing with parsing cli/mi output for the threadlist
+# is duplicated in gdb669.exp. Any changes here will probably need to
+# be made there as well.
+
+proc get_mi_thread_list {name} {
+  global expect_out
+
+  # MI will return a list of thread ids:
+  #
+  # -thread-list-ids
+  # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N"
+  # (gdb)
+  mi_gdb_test "-thread-list-ids" \
+    {\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \
+    "-thread_list_ids ($name)"
+
+  set output {}
+  if {[info exists expect_out(buffer)]} {
+    set output $expect_out(buffer)
+  }
+
+  set thread_list {}
+  if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} {
+    fail "finding threads in MI output ($name)"
+  } else {
+    pass "finding threads in MI output ($name)"
+
+    # Make list of console threads
+    set start [expr {[string first \{ $threads] + 1}]
+    set end   [expr {[string first \} $threads] - 1}]
+    set threads [string range $threads $start $end]
+    foreach thread [split $threads ,] {
+      if {[scan $thread {thread-id="%d"} num]} {
+       lappend thread_list $num
+      }
+    }
+  }
+
+  return $thread_list
+}
+
+# Check that MI and the console know of the same threads.
+# Appends NAME to all test names.
+proc check_mi_and_console_threads {name} {
+  global expect_out
+
+  mi_gdb_test "-thread-list-ids" \
+    {\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \
+    "-thread-list-ids ($name)"
+  set mi_output {}
+  if {[info exists expect_out(buffer)]} {
+    set mi_output $expect_out(buffer)
+  }
+
+  # GDB will return a list of thread ids and some more info:
+  #
+  # (gdb) 
+  # -interpreter-exec console "info threads"
+  # ~"  4 Thread 2051 (LWP 7734)  0x401166b1 in __libc_nanosleep () at __libc_nanosleep:-1"
+  # ~"  3 Thread 1026 (LWP 7733)   () at __libc_nanosleep:-1"
+  # ~"  2 Thread 2049 (LWP 7732)  0x401411f8 in __poll (fds=0x804bb24, nfds=1, timeout=2000) at ../sysdeps/unix/sysv/linux/poll.c:63"
+  # ~"* 1 Thread 1024 (LWP 7731)  main (argc=1, argv=0xbfffdd94) at ../../../src/gdb/testsuite/gdb.mi/pthreads.c:160"
+  # FIXME: kseitz/2002-09-05: Don't use the hack-cli method.
+  mi_gdb_test "info threads" \
+    {.*(~".*"[\r\n]*)+.*} \
+    "info threads ($name)"
+  set console_output {}
+  if {[info exists $expect_out(buffer)]} {
+    set console_output $expect_out(buffer)
+  }
+
+  # Make a list of all known threads to console (gdb's thread IDs)
+  set console_thread_list {}
+  foreach line [split $console_output \n] {
+    if {[string index $line 0] == "~"} {
+      # This is a line from the console; trim off "~", " ", "*", and "\""
+      set line [string trim $line ~\ \"\*]
+      if {[scan $line "%d" id] == 1} {
+       lappend console_thread_list $id
+      }
+    }
+  }
+
+  # Now find the result string from MI
+  set mi_result ""
+  foreach line [split $mi_output \n] {
+    if {[string range $line 0 4] == "^done"} {
+      set mi_result $line
+    }
+  }
+  if {$mi_result == ""} {
+    fail "finding MI result string ($name)"
+  } else {
+    pass "finding MI result string ($name)"
+  }
+
+  # Finally, extract the thread ids and compare them to the console
+  set num_mi_threads_str ""
+  if {![regexp {number-of-threads="[0-9]+"} $mi_result num_mi_threads_str]} {
+    fail "finding number of threads in MI output ($name)"
+  } else {
+    pass "finding number of threads in MI output ($name)"
+
+    # Extract the number of threads from the MI result
+    if {![scan $num_mi_threads_str {number-of-threads="%d"} num_mi_threads]} {
+      fail "got number of threads from MI ($name)"
+    } else {
+      pass "got number of threads from MI ($name)"
+
+      # Check if MI and console have same number of threads
+      if {$num_mi_threads != [llength $console_thread_list]} {
+       fail "console and MI have same number of threads ($name)"
+      } else {
+       pass "console and MI have same number of threads ($name)"
+
+       # Get MI thread list
+       set mi_thread_list [get_mi_thread_list $name]
+
+       # Check if MI and console have the same threads
+       set fails 0
+       foreach ct [lsort $console_thread_list] mt [lsort $mi_thread_list] {
+         if {$ct != $mt} {
+           incr fails
+         }
+       }
+       if {$fails > 0} {
+         fail "MI and console have same threads ($name)"
+
+         # Send a list of failures to the log
+         send_log "Console has thread ids: $console_thread_list\n"
+         send_log "MI has thread ids: $mi_thread_list\n"
+       } else {
+         pass "MI and console have same threads ($name)"
+       }
+      }
+    }
+  }
+}
+
+# This procedure tests the various thread commands in MI.
+proc check_mi_thread_command_set {} {
+
+  mi_runto done_making_threads
+
+  set thread_list [get_mi_thread_list "in check_mi_thread_command_set"]
+  
+  mi_gdb_test "-thread-select" \
+    {\^error,msg="mi_cmd_thread_select: USAGE: threadnum."} \
+    "check_mi_thread_command_set: -thread-select"
+
+  mi_gdb_test "-thread-select 123456789" \
+    {\^error,msg="Thread ID 123456789 not known\."} \
+    "check_mi_thread_command_set: -thread-select 123456789"
+
+  foreach thread $thread_list {
+    # line and file are optional.
+    # many of the threads are blocked in libc calls,
+    # and many people have libc's with no symbols.
+    mi_gdb_test "-thread-select $thread" \
+      "\\^done,new-thread-id=\"$thread\",frame={.*}(,line=\"(-)?\[0-9\]+\",file=\".*\")?" \
+      "check_mi_thread_command_set: -thread-select $thread"
+  }
+}
+
+#
+# Start here
+#
+set testfile "pthreads"
+set srcfile "$testfile.c"
+set binfile "$objdir/$subdir/$testfile"
+
+set options [list debug incdir=$objdir]
+if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
+    return -1
+}
+
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load $binfile
+
+check_mi_thread_command_set
+
+mi_gdb_exit
+
diff --git a/gdb/testsuite/gdb.mi/mi2-read-memory.exp b/gdb/testsuite/gdb.mi/mi2-read-memory.exp
new file mode 100644 (file)
index 0000000..eee36a7
--- /dev/null
@@ -0,0 +1,86 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_to "main" "" "mi-read-memory.c" "20" "next at main"
+
+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
diff --git a/gdb/testsuite/gdb.mi/mi2-regs.exp b/gdb/testsuite/gdb.mi/mi2-regs.exp
new file mode 100644 (file)
index 0000000..a14b241
--- /dev/null
@@ -0,0 +1,129 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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 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\]+)?)|(nan\\($hex\\)))"
+    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"
+
+    mi_gdb_test "002-data-list-changed-registers" \
+           "002\\^done,changed-registers=\\\[(\"${decimal}\"(,\"${decimal}\")*)?\\\]" \
+           "list changed registers"
+}
+
+if [istarget "sparc-*-*"] then {
+    sparc_register_tests_no_exec
+    mi_run_to_main
+    sparc_register_tests
+} else {
+    verbose "mi-regs.exp tests ignored for this target"
+}
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-return.exp b/gdb/testsuite/gdb.mi/mi2-return.exp
new file mode 100644 (file)
index 0000000..b54f15a
--- /dev/null
@@ -0,0 +1,72 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_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)"
+       }
+    }
+}
+
+mi_runto callee4
+
+mi_gdb_test "205-break-delete" \
+       "205\\^done.*" \
+       "delete all breakpoints"
+
+test_return_simple
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-simplerun.exp b/gdb/testsuite/gdb.mi/mi2-simplerun.exp
new file mode 100644 (file)
index 0000000..93d4426
--- /dev/null
@@ -0,0 +1,199 @@
+#   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
+set MIFLAGS "-i=mi2"
+
+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=\\\[.*\\\],body=\\\[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=\\\[.*\\\],body=\\\[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=\"\[01\]\",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)"
+       }
+    }
+}
+
+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_next_to "main" "" "basics.c" "33" "next at main"
+
+    # FIXME: A string argument is not printed right; should be fixed and
+    #        we should look for the right thing here.
+    # NOTE: The ``\\\\\"'' is for \".
+    mi_step_to "callee1" \
+       "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \
+       "basics.c" "27" "step at main"
+
+    # FIXME: A string argument is not printed right; should be fixed and
+    #        we should look for the right thing here.
+    mi_execute_to "exec-step 3" "end-stepping-range" "callee4" "" \
+       "basics.c" "8" "" "step to callee4"
+
+    # 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"''
+    mi_finish_to "callee3" ".*" "basics.c" "18" ".1" "0" "exec-finish"
+}
+
+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
diff --git a/gdb/testsuite/gdb.mi/mi2-stack.exp b/gdb/testsuite/gdb.mi/mi2-stack.exp
new file mode 100644 (file)
index 0000000..f0a4a61
--- /dev/null
@@ -0,0 +1,203 @@
+# Copyright 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_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=\"\[01\]\",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)"
+
+}
+
+mi_runto callee4
+test_stack_frame_listing
+test_stack_args_listing
+test_stack_locals_listing
+test_stack_info_depth
+
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-stepi.exp b/gdb/testsuite/gdb.mi/mi2-stepi.exp
new file mode 100644 (file)
index 0000000..208b9e2
--- /dev/null
@@ -0,0 +1,86 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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_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=\"\[01\]\",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=\"\[01\]\",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=\"\[01\]\",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)"
+       }
+    }
+}
+
+mi_run_to_main
+test_stepi_nexti
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-syn-frame.exp b/gdb/testsuite/gdb.mi/mi2-syn-frame.exp
new file mode 100644 (file)
index 0000000..263bb39
--- /dev/null
@@ -0,0 +1,111 @@
+# Copyright 2002, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# Test MI output with synthetic frames on the stack (call dummies,
+# signal handlers).
+
+if [target_info exists gdb,nosignals] {
+    verbose "Skipping mi-syn-frame.exp because of nosignals."
+    continue
+}
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+set testfile "mi-syn-frame"
+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."
+}
+
+set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
+
+mi_gdb_exit
+mi_gdb_start
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+mi_run_to_main
+
+mi_gdb_test "400-break-insert foo" "400\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
+
+
+#
+# Call foo() by hand, where we'll hit a breakpoint.
+#
+
+mi_gdb_test "401-data-evaluate-expression foo()" "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(foo\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+401\\^error,msg=\"The program being debugged stopped while in a function called from GDB.*\"" "call inferior's function with a breakpoint set in it"
+
+mi_gdb_test "402-stack-list-frames" "402\\^done,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" "backtrace from inferior function stopped at bp, showing gdb dummy frame"
+
+#
+# Continue back to main()
+#
+
+send_gdb "403-exec-continue\n"
+gdb_expect {
+  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
+    pass "403-exec-continue"
+  }
+  timeout {
+    fail "403-exec-continue"
+  }
+}
+
+mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+
+#
+# Call have_a_very_merry_interrupt() which will eventually raise a signal
+# that's caught by handler() which calls subroutine().
+
+mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
+
+mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\""
+
+# We should have both a signal handler and a call dummy frame
+# in this next output.
+
+mi_gdb_test "407-stack-list-frames" "407\\^done,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"subroutine\",args=\\\[\{name=\"in\",value=\"$decimal\"\}\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+
+send_gdb "408-exec-continue\n"
+gdb_expect {
+  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
+    pass "408-exec-continue"
+  }
+  timeout {
+    fail "408-exec-continue"
+  }
+}
+
+mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+#
+# Call bar() by hand, which should get an exception while running.
+# 
+
+mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+
+mi_gdb_test "411-stack-list-frames" "411\\^done,reason=\"signal-received\",signal-name=\".*\",signal-meaning=\".*\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"bar\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
+
+mi_gdb_exit
+
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-until.exp b/gdb/testsuite/gdb.mi/mi2-until.exp
new file mode 100644 (file)
index 0000000..4ef296c
--- /dev/null
@@ -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
+set MIFLAGS "-i=mi2"
+
+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=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"10\"\}\r\n$mi_gdb_prompt$" {
+           pass "run to main"
+       }
+       -re ".*$mi_gdb_prompt$" {
+           fail "run to main (2)"
+       }
+       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=\"\[01\]\",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=\"\[01\]\",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=\"\[01\]\",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=\"\[01\]\",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
diff --git a/gdb/testsuite/gdb.mi/mi2-var-block.exp b/gdb/testsuite/gdb.mi/mi2-var-block.exp
new file mode 100644 (file)
index 0000000..84bc1ff
--- /dev/null
@@ -0,0 +1,173 @@
+# Copyright (C) 1999, 2000, 2002 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 create, update, delete variables.
+#
+
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+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_runto do_block_tests
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "158" "step at do_block_test"
+
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "161" "step at do_block_test"
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "164" "step at do_block_test"
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "166" "step at do_block_test"
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "168" "step at do_block_test"
+
+# 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;"
+mi_step_to "do_block_tests" "" "var-cmd.c" "171" "step at do_block_test"
+
+# 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
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
new file mode 100644 (file)
index 0000000..3f6a3fd
--- /dev/null
@@ -0,0 +1,1203 @@
+#   Copyright (C) 1999, 2000, 2002 Free Software Foundation
+
+# 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
+set MIFLAGS "-i=mi2"
+
+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_runto do_children_tests
+
+#####        #####
+#                #
+# 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
+# STABS doesn't give us argument types for the func ptr structs, but
+# Dwarf 2 does.
+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 \\(\\*\\)\\((void)?\\)\"\},child=\{name=\"struct_declarations.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"struct_declarations.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)\"\},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 \\*\\(\\*\\)\\((void)?\\)\"\},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 \\(\\*\\)\\((int, char \\*)?\\)\"\}\\\]" \
+       "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;"
+set line 192
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step to line $line"
+
+# 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 \\(\\*\\)\\((void)?\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int)?\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)\"\},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;"
+set line 193
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;
+set line 196
+mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line"
+
+# 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;"
+set line 197
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 198
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 199
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 200
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;
+set line 208
+mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line"
+
+# 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;"
+set line 211
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;
+set line 254
+mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line"
+
+# 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;"
+set line 255
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 256
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 257
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 258
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 259
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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;"
+set line 260
+mi_step_to do_children_tests {} {.*var-cmd.c} $line "step $line"
+
+# 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
diff --git a/gdb/testsuite/gdb.mi/mi2-var-cmd.exp b/gdb/testsuite/gdb.mi/mi2-var-cmd.exp
new file mode 100644 (file)
index 0000000..25326df
--- /dev/null
@@ -0,0 +1,560 @@
+# Copyright (C) 1999, 2000, 2002 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 create, update, delete variables.
+#
+
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+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_runto do_locals_tests
+
+# 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=\"1\",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 \\(\\*\\)\\((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;"
+mi_step_to "do_locals_tests" "" "var-cmd.c" "107" "step at do_locals_test"
+
+# 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;"
+mi_step_to "do_locals_tests" "" "var-cmd.c" 108 "step at do_locals_tests (2)"
+
+# 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';"
+mi_step_to "do_locals_tests" "" "var-cmd.c" "109" "step at do_locals_tests (3)"
+
+# 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;"
+mi_step_to "do_locals_tests" "" "var-cmd.c" "110" "step at do_locals_tests (4)"
+
+# 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';
+
+mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \
+       "var-cmd.c" "119" "" "step at do_locals_tests (5)"
+
+# 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;
+
+mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \
+       "var-cmd.c" "125" "" "step at do_locals_tests (6)"
+
+# 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';
+
+mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \
+       "var-cmd.c" "133" "" "step at do_locals_tests (7)"
+
+# 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-update *" \
+       "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
+       "update all vars: linteger changed after assign"
+
+mi_gdb_test "-var-assign linteger 3333" \
+       "\\^done,value=\"3333\"" \
+       "assign to linteger again, same value"
+
+mi_gdb_test "-var-update *" \
+       "\\^done,changelist=\\\[\\\]" \
+       "update all vars: linteger not changed after same assign"
+
+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-update *" \
+       "\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
+       "update all vars: lpinteger changed after assign"
+
+mi_gdb_test "-var-update *" \
+       "\\^done,changelist=\\\[\\\]" \
+       "update all vars: no changes on second update"
+
+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.4567" \
+       "\\^done,value=\"3.45.*\"" \
+       "assign to lfloat"
+mi_gdb_test "-var-evaluate-expression lfloat" \
+       "\\^done,value=\"3.45.*\"" \
+       "eval lfloat"
+mi_gdb_test "-var-assign lfloat 1.2345" \
+       "\\^done,value=\"1.23.*\"" \
+       "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"
+mi_continue_to "2" "subroutine1" \
+       "\{name=\"i\",value=\"4321\"\},\{name=\"l\",value=\"$hex\"\}" \
+       "var-cmd.c" "146" "continue to subroutine1"
+
+# 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"
+
+mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
+       "var-cmd.c" "147" "step at subroutine1"
+
+# 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 *-*-*
+
+mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
+       "var-cmd.c" "148" "step at subroutine1 (2)"
+
+# 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"
+
+mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
+       "var-cmd.c" "149" "step at subroutine1 (3)"
+
+# 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"
+
+mi_next_to "do_locals_tests" ""        "var-cmd.c" "136" "next out of subroutine1"
+
+# 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"
+
+# Test whether we can follow the name of a variable through multiple
+# stack frames.
+mi_gdb_test "-break-insert do_special_tests" \
+  {\^done,bkpt=.*} \
+  "set breakpoint at do_special_tests"
+
+mi_continue_to {.*} do_special_tests {.*} {.*var-cmd.c} {.*} {stop in do_special_tests}
+
+mi_gdb_test "-var-create selected_a @ a" \
+  {\^done,name="selected_a",numchild="0",type="int"} \
+  "create selected_a"
+
+mi_gdb_test "-break-insert incr_a" \
+  {\^done,bkpt=.*} \
+  "set breakpoint at incr_a"
+
+mi_continue_to {.*} incr_a {.*} {.*var-cmd.c} {.*} {stop in incr_a}
+
+mi_gdb_test "-var-update selected_a" \
+       "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"char\",new_num_children=\"0\"\}\\\]" \
+       "update selected_a in incr_a"
+
+mi_next "step a line in incr_a"
+mi_next "return from incr_a to do_special_tests"
+
+mi_gdb_test "-var-update selected_a" \
+       "\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
+       "update selected_a in do_special_tests"
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-var-display.exp b/gdb/testsuite/gdb.mi/mi2-var-display.exp
new file mode 100644 (file)
index 0000000..427e75e
--- /dev/null
@@ -0,0 +1,627 @@
+#   Copyright (C) 1999, 2000, 2002 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 create, update, delete variables.
+#
+
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+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=\"\[01\]\",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=\"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 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=\"\[01\]\",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=\"1\",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=\"1\",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=\"\[01\]\",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"
+    }
+    -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",line=\"8\[345\]\"\}\r\n$mi_gdb_prompt$" {
+       fail "continue to incr_a (compiler debug info incorrect)"
+    }
+    -re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" {
+       fail "continue to incr_a (unknown output)"
+    }
+    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
diff --git a/gdb/testsuite/gdb.mi/mi2-watch.exp b/gdb/testsuite/gdb.mi/mi2-watch.exp
new file mode 100644 (file)
index 0000000..ba7df2b
--- /dev/null
@@ -0,0 +1,166 @@
+# Copyright 1999, 2000, 2002 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
+set MIFLAGS "-i=mi2"
+
+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=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[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=\\\[.*\\\],body=\\\[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=\\\[.*\\\],body=\\\[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_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=\"\[01\]\",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=\"\[01\]\",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)"}
+    }
+}
+
+mi_runto callee4
+test_watchpoint_creation_and_listing
+#test_rwatch_creation_and_listing
+#test_awatch_creation_and_listing
+test_watchpoint_triggering
+
+mi_gdb_exit
+return 0