OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-src/gdb-6.8/gdb/testsuite/gdb.mi
    from Rev 131 to Rev 157
    Reverse comparison

Rev 131 → Rev 157

/Makefile.in
0,0 → 1,15
VPATH = @srcdir@
srcdir = @srcdir@
 
PROGS = basics c_variable cpp_variable var-cmd
 
MISCELLANEOUS = testcmds
 
all info install-info dvi install uninstall installcheck check:
@echo "Nothing to be done for $@..."
 
clean mostlyclean:
-rm -f *.ci *.o $(OBJS) $(PROGS) *~ core
 
distclean maintainer-clean realclean: clean
-rm -f Makefile config.status config.log
/mi-pending.exp
0,0 → 1,75
# Copyright 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
 
load_lib mi-support.exp
set MIFLAGS "-i=mi"
 
if $tracelevel then {
strace $tracelevel
}
 
#
# test running programs
#
set prms_id 0
set bug_id 0
 
if {[skip_shlib_tests]} {
return 0
}
 
set testfile "mi-pending"
set libfile "mi-pendshr"
set srcfile $testfile.c
set libsrc $srcdir/$subdir/$libfile.c
set binfile $objdir/$subdir/$testfile
set lib_sl $objdir/$subdir/$libfile.sl
 
set lib_opts debug
set exec_opts [list debug shlib=$lib_sl]
 
if [get_compiler_info ${binfile}] {
return -1
}
 
if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
|| [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
return -1
}
 
# Start with a fresh gdb.
 
gdb_exit
mi_gdb_start
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
gdb_load_shlibs $lib_sl
 
if [target_info exists gdb_stub] {
gdb_step_for_stub;
}
 
# Set pending breakpoint via MI
mi_gdb_test "-break-insert -f pendfunc1" \
".*\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc1\",times=\"0\"\}"\
"MI pending breakpoint on pendfunc1"
 
mi_run_cmd
 
# Make sure we hit breakpoint.
mi_gdb_test "" \
".*\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\".*func=\"pendfunc1\".*" \
"Run till MI pending breakpoint on pendfunc1"
/basics.c
0,0 → 1,77
/* Copyright 1999, 2000, 2004, 2007, 2008 Free Software Foundation, Inc.
 
This file is part of GDB.
 
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 3 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, see <http://www.gnu.org/licenses/>. */
 
/*
* This simple program that passes different types of arguments
* on function calls. Useful to test printing frames, stepping, etc.
*/
 
#include <stdio.h>
 
int callee4 (void)
{
int A=1;
int B=2;
int C;
 
C = A + B;
return 0;
}
callee3 (char *strarg)
{
callee4 ();
}
 
callee2 (int intarg, char *strarg)
{
callee3 (strarg);
}
 
callee1 (int intarg, char *strarg, double fltarg)
{
callee2 (intarg, strarg);
}
 
void callme (int i)
{
printf ("callme\n");
}
 
int return_1 ()
{
return 1;
}
 
main ()
{
callee1 (2, "A string argument.", 3.5);
callee1 (2, "A string argument.", 3.5);
 
printf ("Hello, World!");
 
callme (1);
callme (2);
 
return 0;
}
 
/*
Local variables:
change-log-default-name: "ChangeLog-mi"
End:
*/
 
basics.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-syn-frame.c =================================================================== --- mi-syn-frame.c (nonexistent) +++ mi-syn-frame.c (revision 157) @@ -0,0 +1,58 @@ +#include +#include +#include + +void foo (void); +void bar (void); + +void subroutine (int); +void handler (int); +void have_a_very_merry_interrupt (void); + +main () +{ + foo (); /* Put a breakpoint on foo() and call it to see a dummy frame */ + + + have_a_very_merry_interrupt (); +} + +void +foo (void) +{ +} + +void +bar (void) +{ + char *nuller = 0; + + *nuller = 'a'; /* try to cause a segfault */ +} + +void +handler (int sig) +{ + subroutine (sig); +} + +/* The first statement in subroutine () is a place for a breakpoint. + Without it, the breakpoint is put on the while comparison and will + be hit at each iteration. */ + +void +subroutine (int in) +{ + int count = in; + while (count < 100) + count++; +} + +void +have_a_very_merry_interrupt (void) +{ + signal (SIGALRM, handler); + alarm (1); + sleep (2); /* We'll receive that signal while sleeping */ +} +
mi-syn-frame.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-eval.exp =================================================================== --- mi-eval.exp (nonexistent) +++ mi-eval.exp (revision 157) @@ -0,0 +1,63 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008 +# 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-eval.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +set line_callee4_head [gdb_get_line_number "callee4 ("] +set line_callee4_body [expr $line_callee4_head + 2] + +mi_runto callee4 +mi_next_to "callee4" "" "basics.c" [expr $line_callee4_body + 1] "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 Index: mi-var-cp.exp =================================================================== --- mi-var-cp.exp (nonexistent) +++ mi-var-cp.exp (revision 157) @@ -0,0 +1,50 @@ +# Copyright 2006, 2007, 2008 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 3 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, see . + +if { [skip_cplus_tests] } { continue } + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile mi-var-cp +set srcfile "$testfile.cc" +set binfile $objdir/$subdir/$testfile + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} { + untested $testfile.exp + return -1 +} + +mi_gdb_load ${binfile} + +mi_prepare_inline_tests $srcfile + +mi_run_inline_test reference_update +mi_run_inline_test base_in_reference +mi_run_inline_test reference_to_pointer +mi_run_inline_test reference_to_struct +mi_run_inline_test path_expression + +mi_gdb_exit +return 0 Index: mi2-watch.exp =================================================================== --- mi2-watch.exp (nonexistent) +++ mi2-watch.exp (revision 157) @@ -0,0 +1,214 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 +# 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-watch.exp + return -1 +} + +proc test_watchpoint_creation_and_listing {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + + # 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=\"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 {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\"\}" \ + "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=\"$line_main_body\",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 {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\",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=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete 4" \ + "177\\^done" \ + "delete read watchpoint" +} + +proc test_watchpoint_triggering {type} { + global mi_gdb_prompt + global hex + + set line_callee4_return_0 [gdb_get_line_number "return 0;"] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_close_brace [expr $line_callee3_head + 3] + + # 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=\"$line_callee4_return_0\"\}\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)"} + } + + if { $type == "sw" } { + setup_xfail *-*-* + } + 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=\"$line_callee3_close_brace\"\}\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)"} + } + clear_xfail *-*-* +} + +proc test_watchpoint_all {type} { + global pf_prefix + upvar srcdir srcdir + upvar subdir subdir + upvar binfile binfile + + set old_prefix $pf_prefix + lappend pf_prefix "$type:" + + mi_delete_breakpoints + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + + mi_runto callee4 + test_watchpoint_creation_and_listing $type + #test_rwatch_creation_and_listing $type + #test_awatch_creation_and_listing $type + test_watchpoint_triggering $type + + set pf_prefix $old_prefix +} + +# Run the tests twice, once using software watchpoints... +mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \ + "567\\^done" \ + "hw watchpoints toggle (1)" +test_watchpoint_all sw + +mi_gdb_exit + +# ... and unless requested otherwise... +if [target_info exists gdb,no_hardware_watchpoints] { + return 0 +} + +mi_gdb_start + +# ... once using hardware watchpoints (if available). +mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \ + "890\\^done" \ + "hw watchpoints toggle (2)" +test_watchpoint_all hw + +mi_gdb_exit +return 0 Index: mi-var-cmd.exp =================================================================== --- mi-var-cmd.exp (nonexistent) +++ mi-var-cmd.exp (revision 157) @@ -0,0 +1,656 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-var-cmd.exp + return -1 +} + +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\",value=\"{...}\",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 + +set line_dlt_first_real [gdb_get_line_number "linteger = 1234;"] + +mi_continue_to_line $line_dlt_first_real "step to real start of do_locals_test" + + +# Test: c_variable-1.4 +# Desc: create local variables + +mi_gdb_test "-var-create linteger * linteger" \ + "\\^done,name=\"linteger\",numchild=\"0\",value=\".*\",type=\"int\"" \ + "create local variable linteger" + +mi_gdb_test "-var-create lpinteger * lpinteger" \ + "\\^done,name=\"lpinteger\",numchild=\"1\",value=\"$hex\",type=\"int \\*\"" \ + "create local variable lpinteger" + +mi_gdb_test "-var-create lcharacter * lcharacter\[0\]" \ + "\\^done,name=\"lcharacter\",numchild=\"0\",value=\".*\",type=\"char\"" \ + "create local variable lcharacter " + +mi_gdb_test "-var-create lpcharacter * lpcharacter" \ + "\\^done,name=\"lpcharacter\",numchild=\"1\",value=\"$hex.*\",type=\"char \\*\"" \ + "create local variable lpcharacter" + +mi_gdb_test "-var-create llong * llong" \ + "\\^done,name=\"llong\",numchild=\"0\",value=\".*\",type=\"long int\"" \ + "create local variable llong" + +mi_gdb_test "-var-create lplong * lplong" \ + "\\^done,name=\"lplong\",numchild=\"1\",value=\"$hex\",type=\"long int \\*\"" \ + "create local variable lplong" + +mi_gdb_test "-var-create lfloat * lfloat" \ + "\\^done,name=\"lfloat\",numchild=\"0\",value=\".*\",type=\"float\"" \ + "create local variable lfloat" + +mi_gdb_test "-var-create lpfloat * lpfloat" \ + "\\^done,name=\"lpfloat\",numchild=\"1\",value=\"$hex\",type=\"float \\*\"" \ + "create local variable lpfloat" + +mi_gdb_test "-var-create ldouble * ldouble" \ + "\\^done,name=\"ldouble\",numchild=\"0\",value=\".*\",type=\"double\"" \ + "create local variable ldouble" + +mi_gdb_test "-var-create lpdouble * lpdouble" \ + "\\^done,name=\"lpdouble\",numchild=\"1\",value=\"$hex\",type=\"double \\*\"" \ + "create local variable lpdouble" + +mi_gdb_test "-var-create lsimple * lsimple" \ + "\\^done,name=\"lsimple\",numchild=\"6\",value=\"{...}\",type=\"struct _simple_struct\"" \ + "create local variable lsimple" + +mi_gdb_test "-var-create lpsimple * lpsimple" \ + "\\^done,name=\"lpsimple\",numchild=\"6\",value=\"$hex\",type=\"struct _simple_struct \\*\"" \ + "create local variable lpsimple" + +mi_gdb_test "-var-create func * func" \ + "\\^done,name=\"func\",numchild=\"0\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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.\\\\n\".*&\"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;" +set line_dlt_linteger [gdb_get_line_number "lpinteger = &linteger;"] +mi_step_to "do_locals_tests" "" "var-cmd.c" $line_dlt_linteger "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" [expr $line_dlt_linteger + 1] "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" [expr $line_dlt_linteger + 2] "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" [expr $line_dlt_linteger + 3] "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" [expr $line_dlt_linteger + 12] "" "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; + +set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"] + +mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \ + "var-cmd.c" $line_dlt_4321 "" "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" [expr $line_dlt_4321 + 8] "" "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=\"lpcharacter\",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: lsimple and others 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" + +# Allow lpcharacter to update, optionally. Because it points to a +# char variable instead of a zero-terminated string, if linteger is +# directly after it in memory the printed characters may appear to +# change. +set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}," +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[($lpchar_update)?\{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 \"" \ + "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" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=.*" \ + "var update" + +# Check that assignment of function and array values +# promotes the assigned value to function pointer/data +# pointer before comparing with the existing value, +# and does not incorrectly make the value as changed. +mi_gdb_test "-var-assign func do_block_tests" \ + "\\^done,value=\"$hex \"" \ + "assign same value to func" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "assign same value to func (update)" + +mi_gdb_test "-var-create array_ptr * array_ptr" \ + "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\"" \ + "create global variable array_ptr" + +mi_gdb_test "-var-assign array_ptr array2" \ + "\\^done,value=\"$hex\"" \ + "assign array to pointer" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\{name=\"array_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "assign array to pointer (update)" + +mi_gdb_test "-var-assign array_ptr array2" \ + "\\^done,value=\"$hex\"" \ + "assign same array to pointer" + +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "assign same array to pointer (update)" + + +###### +# End of assign tests +##### + +set line_subroutine1_body [gdb_get_line_number "global_simple.integer = i + 3;"] + +mi_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\",value=\"4321\",type=\"int\"" \ + "create i" + +mi_gdb_test "-var-create l * l" \ + "\\^done,name=\"l\",numchild=\"1\",value=\"$hex\",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" [expr $line_subroutine1_body + 1] "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" [expr $line_subroutine1_body + 2] "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" [expr $line_subroutine1_body + 3] "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" + +set line_dlt_call_subroutine1 [gdb_get_line_number "subroutine1 (linteger, &llong);"] +mi_next_to "do_locals_tests" "" "var-cmd.c" \ + [expr $line_dlt_call_subroutine1 + 1] "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_continue_to do_special_tests + +mi_gdb_test "-var-create selected_a @ a" \ + {\^done,name="selected_a",numchild="0",value=\".*\",type="int"} \ + "create selected_a" + +mi_continue_to 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_delete_varobj selected_a "delete selected_a" +mi_delete_varobj array_ptr "delete array_ptr" + +proc set_frozen {varobjs flag} { + foreach v $varobjs { + mi_gdb_test "-var-set-frozen $v $flag" \ + "\\^done" \ + "-var-set-frozen $v $flag" + } +} + +mi_prepare_inline_tests $srcfile +mi_run_inline_test frozen + +# Test whether bad varobjs crash GDB. + +# A varobj we fail to read during -var-update should be considered +# out of scope. +mi_gdb_test "-var-create null_ptr * **0" \ + {\^done,name="null_ptr",numchild="0",value=".*",type="int"} \ + "create null_ptr" + +# Allow this to succeed, if address zero is readable, although it +# will not test what it was meant to. Most important is that GDB +# does not crash. +mi_gdb_test "-var-update null_ptr" \ + {\^done,changelist=\[.*\]} \ + "update null_ptr" + +mi_gdb_test "-var-delete null_ptr" \ + "\\^done,ndeleted=\"1\"" \ + "delete null_ptr" + +# When we fail to read a varobj created from a named variable, +# we evaluate its type instead. Make sure that doesn't blow +# up by trying to read it again. We can use _end when not running +# the program to simulate an unreadable variable, if this platform +# provides _end, but cope if it's missing. + +mi_gdb_test "kill" \ + {&"kill\\n".*\^done} \ + "kill program before endvar" + +mi_gdb_test "-var-create endvar * _end" \ + {(\^done,name="endvar",numchild="0",value=".*",type=".*"|&".*unable to.*".*\^error,msg=".*")} \ + "create endvar" + +# Allow this to succeed whether the value is readable, unreadable, or +# missing. Most important is that GDB does not crash. +mi_gdb_test "-var-update endvar" \ + {(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \ + "update endvar" + +mi_gdb_test "-var-delete endvar" \ + "\\^done,ndeleted=\"1\"" \ + "delete endvar" + +mi_gdb_exit +return 0 Index: mi-stack.c =================================================================== --- mi-stack.c (nonexistent) +++ mi-stack.c (revision 157) @@ -0,0 +1,65 @@ +/* Copyright 1999, 2000, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 3 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, see . */ + +/* + * This simple program that passes different types of arguments + * on function calls. Useful to test printing frames, stepping, etc. + */ + +#include + +int callee4 (void) +{ + int A=1; + int B=2; + int C; + int D[3] = {0, 1, 2}; + + C = A + B; + return 0; +} +callee3 (char *strarg) +{ + callee4 (); +} + +callee2 (int intarg, char *strarg) +{ + callee3 (strarg); +} + +callee1 (int intarg, char *strarg, double fltarg) +{ + callee2 (intarg, strarg); +} + +main () +{ + callee1 (2, "A string argument.", 3.5); + callee1 (2, "A string argument.", 3.5); + + printf ("Hello, World!"); + + return 0; +} + +/* +Local variables: +change-log-default-name: "ChangeLog-mi" +End: +*/ +
mi-stack.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-disassemble.exp =================================================================== --- mi-disassemble.exp (nonexistent) +++ mi-disassemble.exp (revision 157) @@ -0,0 +1,188 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-disassemble.exp + return -1 +} + +proc test_disassembly_only {} { + global mi_gdb_prompt + global hex + global decimal + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassemble -s $pc -e "$pc+8" -- 0 + # -data-disassembly -f basics.c -l $line_main_body -- 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 $line_main_body -- 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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 0 + # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 0 + # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -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 $line_main_body -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 $line_main_body -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 + + set line_callee2_head [gdb_get_line_number "callee2 ("] + set line_callee2_open_brace [expr $line_callee2_head + 1] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_callee2_open_brace -- 1 + # -data-disassembly -s $pc -e "$pc+8" -- 1 + + mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 1" \ + "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_open_brace [expr $line_main_head + 1] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 1 + # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 1 + # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 1 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -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 $line_main_body -n 0 -- 1" \ + "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_main_open_brace\",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 $line_main_body -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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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 $line_main_body -- 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 Index: mi2-pthreads.exp =================================================================== --- mi2-pthreads.exp (nonexistent) +++ mi2-pthreads.exp (revision 157) @@ -0,0 +1,220 @@ +# Copyright 2002, 2003, 2004, 2005, 2007, 2008 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 3 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, see . + +# 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/mi2-$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 + Index: pthreads.c =================================================================== --- pthreads.c (nonexistent) +++ pthreads.c (revision 157) @@ -0,0 +1,87 @@ +/* Pthreads test program. + Copyright 1996, 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. + + Written by Keith Seitz of Red Hat. + Copied from gdb.threads/pthreads.c. + Contributed by Red Hat. + + This file is part of GDB. + + 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 3 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, see . */ + +#include +#include +#include + +/* Under OSF 2.0 & 3.0 and HPUX 10, the second arg of pthread_create + is prototyped to be just a "pthread_attr_t", while under Solaris it + is a "pthread_attr_t *". Arg! */ + +#if defined (__osf__) || defined (__hpux__) +#define PTHREAD_CREATE_ARG2(arg) arg +#define PTHREAD_CREATE_NULL_ARG2 null_attr +static pthread_attr_t null_attr; +#else +#define PTHREAD_CREATE_ARG2(arg) &arg +#define PTHREAD_CREATE_NULL_ARG2 NULL +#endif + +void * +routine (void *arg) +{ + /* When gdb is running, it sets hidden breakpoints in the thread + library. The signals caused by these hidden breakpoints can + cause system calls such as 'sleep' to return early. Pay attention + to the return value from 'sleep' to get the full sleep. */ + int unslept = 9; + while (unslept > 0) + unslept = sleep (unslept); + + printf ("hello thread\n"); +} + +/* Marker function for the testsuite */ +void +done_making_threads (void) +{ + /* Nothing */ +} + +void +create_thread (void) +{ + pthread_t tid; + + if (pthread_create (&tid, PTHREAD_CREATE_NULL_ARG2, routine, (void *) 0xfeedface)) + { + perror ("pthread_create 1"); + exit (1); + } +} + +int +main (int argc, char *argv[]) +{ + int i; + + /* Create a few threads */ + for (i = 0; i < 5; i++) + create_thread (); + done_making_threads (); + + printf ("hello\n"); + printf ("hello\n"); + return 0; +} +
pthreads.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-var-child.c =================================================================== --- mi-var-child.c (nonexistent) +++ mi-var-child.c (revision 157) @@ -0,0 +1,347 @@ +/* Copyright 1999, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 3 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, see . */ + +#include +#include + +struct _simple_struct { + int integer; + unsigned int unsigned_integer; + char character; + signed char signed_character; + char *char_ptr; + int array_of_10[10]; +}; + +typedef struct _simple_struct simpleton; + +simpleton global_simple; + +enum foo { + bar = 1, + baz +}; + +typedef enum foo efoo; + +union named_union +{ + int integer; + char *char_ptr; +}; + +typedef struct _struct_decl { + int integer; + char character; + char *char_ptr; + long long_int; + int **int_ptr_ptr; + long long_array[12]; + + void (*func_ptr) (void); + struct _struct_decl (*func_ptr_struct) (int, char *, long); + struct _struct_decl *(*func_ptr_ptr) (int, char *, long); + union { + int a; + char *b; + long c; + enum foo d; + } u1; + + struct { + union { + struct { + int d; + char e[10]; + int *(*func) (void); + efoo foo; + } u1s1; + + long f; + struct { + char array_ptr[2]; + int (*func) (int, char *); + } u1s2; + } u2; + + int g; + char h; + long i[10]; + } s2; +} weird_struct; + +struct _struct_n_pointer { + char ****char_ptr; + long ****long_ptr; + struct _struct_n_pointer *ptrs[3]; + struct _struct_n_pointer *next; +}; + +void do_locals_tests (void); +void do_block_tests (void); +void subroutine1 (int, long *); +void nothing (void); +void do_children_tests (void); +void do_special_tests (void); +void incr_a (char); + +void incr_a (char a) +{ + int b; + b = a; +} + +void +do_locals_tests () +{ + int linteger; + int *lpinteger; + char lcharacter; + char *lpcharacter; + long llong; + long *lplong; + float lfloat; + float *lpfloat; + double ldouble; + double *lpdouble; + struct _simple_struct lsimple; + struct _simple_struct *lpsimple; + void (*func) (void); + + /* Simple assignments */ + linteger = 1234; + lpinteger = &linteger; + lcharacter = 'a'; + lpcharacter = &lcharacter; + llong = 2121L; + lplong = &llong; + lfloat = 2.1; + lpfloat = &lfloat; + ldouble = 2.718281828459045; + lpdouble = &ldouble; + lsimple.integer = 1234; + lsimple.unsigned_integer = 255; + lsimple.character = 'a'; + lsimple.signed_character = 21; + lsimple.char_ptr = &lcharacter; + lpsimple = &lsimple; + func = nothing; + + /* Check pointers */ + linteger = 4321; + lcharacter = 'b'; + llong = 1212L; + lfloat = 1.2; + ldouble = 5.498548281828172; + lsimple.integer = 255; + lsimple.unsigned_integer = 4321; + lsimple.character = 'b'; + lsimple.signed_character = 0; + + subroutine1 (linteger, &llong); +} + +void +nothing () +{ +} + +void +subroutine1 (int i, long *l) +{ + global_simple.integer = i + 3; + i = 212; + *l = 12; +} + +void +do_block_tests () +{ + int cb = 12; + + { + int foo; + foo = 123; + { + int foo2; + foo2 = 123; + { + int foo; + foo = 321; + } + foo2 = 0; + } + foo = 0; + } + + cb = 21; +} + +void +do_children_tests (void) +{ + weird_struct *weird; + struct _struct_n_pointer *psnp; + struct _struct_n_pointer snp0, snp1, snp2; + char a0[2] = {}, *a1, **a2, ***a3; + char b0[2] = {}, *b1, **b2, ***b3; + char c0[2] = {}, *c1, **c2, ***c3; + long z0, *z1, **z2, ***z3; + long y0, *y1, **y2, ***y3; + long x0, *x1, **x2, ***x3; + int *foo; + int bar; + + /* Avoid pointing into NULL, as that is editable on some + systems. */ + int dummy; + int *dummy_ptr = &dummy; + + struct _struct_decl struct_declarations = { 0, 0, NULL, 0, &dummy_ptr }; + weird = &struct_declarations; + + struct_declarations.integer = 123; + weird->char_ptr = "hello"; + bar = 2121; + foo = &bar; + struct_declarations.int_ptr_ptr = &foo; + weird->long_array[0] = 1234; + struct_declarations.long_array[1] = 2345; + weird->long_array[2] = 3456; + 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; + + weird->func_ptr = nothing; + struct_declarations.long_array[10] = 3456; + struct_declarations.long_array[11] = 5678; + + /* Struct/pointer/array tests */ + a0[0] = '0'; + a1 = a0; + a2 = &a1; + a3 = &a2; + b0[0] = '1'; + b1 = b0; + b2 = &b1; + b3 = &b2; + c0[1] = '2'; + c1 = c0; + c2 = &c1; + c3 = &c2; + z0 = 0xdead + 0; + z1 = &z0; + z2 = &z1; + z3 = &z2; + y0 = 0xdead + 1; + y1 = &y0; + y2 = &y1; + y3 = &y2; + x0 = 0xdead + 2; + x1 = &x0; + x2 = &x1; + x3 = &x2; + snp0.char_ptr = &a3; + snp0.long_ptr = &z3; + snp0.ptrs[0] = &snp0; + snp0.ptrs[1] = &snp1; + snp0.ptrs[2] = &snp2; + snp0.next = &snp1; + snp1.char_ptr = &b3; + snp1.long_ptr = &y3; + snp1.ptrs[0] = &snp0; + snp1.ptrs[1] = &snp1; + snp1.ptrs[2] = &snp2; + snp1.next = &snp2; + snp2.char_ptr = &c3; + snp2.long_ptr = &x3; + snp2.ptrs[0] = &snp0; + snp2.ptrs[1] = &snp1; + snp2.ptrs[2] = &snp2; + snp2.next = 0x0; + psnp = &snp0; + snp0.char_ptr = &b3; + snp1.char_ptr = &c3; + snp2.char_ptr = &a3; + snp0.long_ptr = &y3; + snp1.long_ptr = &x3; + snp2.long_ptr = &z3; +} + +void +do_special_tests (void) +{ + union named_union u; + union { + int a; + char b; + long c; + } anonu; + struct _simple_struct s; + struct { + int a; + char b; + long c; + } anons; + enum foo e; + enum { A, B, C } anone; + int array[21]; + int a; + + a = 1; + incr_a(2); +} + +struct very_simple_struct +{ + int a; + int b; +}; + +int +do_child_deletion (void) +{ + /*: BEGIN: child_deletion :*/ + struct very_simple_struct s = {1, 2}; + /*: + mi_create_varobj S s "create varobj for s" + mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}} \ + "list children of S" + mi_delete_varobj S.a "delete S.a" + mi_delete_varobj S.b "delete S.b" + mi_delete_varobj S "delete S" + :*/ + return 99; + /*: END: child_deletion :*/ +} + +int +main (int argc, char *argv []) +{ + do_locals_tests (); + do_block_tests (); + do_children_tests (); + do_special_tests (); + do_child_deletion (); + exit (0); +} + +
mi-var-child.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-basics.exp =================================================================== --- mi-basics.exp (nonexistent) +++ mi-basics.exp (revision 157) @@ -0,0 +1,290 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +gdb_exit +if [mi_gdb_start separate-inferior-tty] { + continue +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set escapedobjdir [string_to_regexp ${objdir}] +set envirodir [string_to_regexp ${objdir}/${subdir}] + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi-basics.exp + return -1 +} + +# 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" \ + "200\\\^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 objdir + global subdir + global envirodir + + # Add to the search directories, display, then reset back to default + # Tests: + # -environment-directory arg + # -environment-directory + # -environment-directory -r + + mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \ + "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory arg operation" + + mi_gdb_test "203-environment-directory" \ + "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory empty-string operation" + + mi_gdb_test "204-environment-directory -r" \ + "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \ + "environment-directory operation" +} + +proc test_cwd_specification {} { + global mi_gdb_prompt + global objdir + global escapedobjdir + 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}" \ + "205\\\^done" \ + "environment-cd arg operation" + + mi_gdb_test "206-environment-pwd" \ + "206\\\^done,cwd=\"${escapedobjdir}\"" \ + "environment-pwd operation" +} + +proc test_path_specification {} { + global mi_gdb_prompt + global orig_path + global objdir + global subdir + global escapedobjdir + global envirodir + + # Add to the path, display, then reset + # Tests: + # -environment-path + # -environment-path dir1 dir2 + # -environment-path -r dir + # -environment-path -r + + 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 + } + } + + set orig_path [string_to_regexp ${orig_path}] + set pathdir [string_to_regexp ${objdir}/${subdir}] + + mi_gdb_test "207-environment-path" \ + "207\\\^done,path=\"$orig_path\"" \ + "environment-path no-args operation" + + mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \ + "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \ + "environment-path dir1 dir2 operation" + + mi_gdb_test "209-environment-path -r $objdir" \ + "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \ + "environment-path -r dir operation" + + mi_gdb_test "210-environment-path -r" \ + "210\\\^done,path=\"$orig_path\"" \ + "environment-path -r operation" + +} + +proc test_setshow_inferior_tty {} { + global mi_gdb_prompt + global mi_inferior_tty_name + + # Test that the commands, + # -inferior-tty-set + # -inferior-tty-show + # are setting/getting the same data in GDB. + + mi_gdb_test "301-inferior-tty-show" \ + "301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \ + "initial tty is mi_inferior_tty_name" + + mi_gdb_test "302-inferior-tty-set /dev/pts/1" \ + "302\\\^done" \ + "set tty to /dev/pts/1" + + mi_gdb_test "303-inferior-tty-show" \ + "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \ + "tty was set correctly" + + mi_gdb_test "304-inferior-tty-set" \ + "304\\\^done" \ + "set tty to the empty string" + + mi_gdb_test "305-inferior-tty-show" \ + "305\\\^done" \ + "make sure tty is empty" + + mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \ + "306\\\^done" \ + "set tty to mi_inferior_tty_name (the way it was)" + + mi_gdb_test "307-inferior-tty-show" \ + "307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \ + "verify tty is correct" +} + +if [test_mi_interpreter_selection] { + test_exec_and_symbol_mi_operatons + test_breakpoints_deletion + test_dir_specification + test_cwd_specification + test_path_specification + test_setshow_inferior_tty +} + +mi_gdb_exit +return 0 Index: array.f =================================================================== --- array.f (nonexistent) +++ array.f (revision 157) @@ -0,0 +1,20 @@ +c Copyright 2006 Free Software Foundation, Inc. + +c This program is free software; you can redistribute it and/or modify +c it under the terms of the GNU General Public License as published by +c the Free Software Foundation; either version 3 of the License, or +c (at your option) any later version. +c +c This program is distributed in the hope that it will be useful, +c but WITHOUT ANY WARRANTY; without even the implied warranty of +c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +c GNU General Public License for more details. +c +c You should have received a copy of the GNU General Public License +c along with this program. If not, see . + + INTEGER array(1:2,-1:1) + DATA array/11,21,12,22,13,23/ + CONTINUE + STOP + END Index: mi-watch.exp =================================================================== --- mi-watch.exp (nonexistent) +++ mi-watch.exp (revision 157) @@ -0,0 +1,214 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-watch.exp + return -1 +} + +proc test_watchpoint_creation_and_listing {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + + # 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=\"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 {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\"\}" \ + "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=\"$line_main_body\",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 {type} { + global mi_gdb_prompt + global srcfile + global hex + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\",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=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete 4" \ + "177\\^done" \ + "delete read watchpoint" +} + +proc test_watchpoint_triggering {type} { + global mi_gdb_prompt + global hex fullname_syntax srcfile + + set line_callee4_return_0 [gdb_get_line_number "return 0;"] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_close_brace [expr $line_callee3_head + 3] + + # 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\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)"} + } + + if { $type == "sw" } { + setup_xfail *-*-* + } + 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee3_close_brace\"\}\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)"} + } + clear_xfail *-*-* +} + +proc test_watchpoint_all {type} { + global pf_prefix + upvar srcdir srcdir + upvar subdir subdir + upvar binfile binfile + + set old_prefix $pf_prefix + lappend pf_prefix "$type:" + + mi_delete_breakpoints + mi_gdb_reinitialize_dir $srcdir/$subdir + mi_gdb_load ${binfile} + + mi_runto callee4 + test_watchpoint_creation_and_listing $type + #test_rwatch_creation_and_listing $type + #test_awatch_creation_and_listing $type + test_watchpoint_triggering $type + + set pf_prefix $old_prefix +} + +# Run the tests twice, once using software watchpoints... +mi_gdb_test "567-gdb-set can-use-hw-watchpoints 0" \ + "567\\^done" \ + "hw watchpoints toggle (1)" +test_watchpoint_all sw + +mi_gdb_exit + +# ... and unless requested otherwise... +if [target_info exists gdb,no_hardware_watchpoints] { + return 0 +} + +mi_gdb_start + +# ... once using hardware watchpoints (if available). +mi_gdb_test "890-gdb-set can-use-hw-watchpoints 1" \ + "890\\^done" \ + "hw watchpoints toggle (2)" +test_watchpoint_all hw + +mi_gdb_exit +return 0 Index: mi2-stepi.exp =================================================================== --- mi2-stepi.exp (nonexistent) +++ mi2-stepi.exp (revision 157) @@ -0,0 +1,98 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-stepi.exp + return -1 +} + +proc test_stepi_nexti {} { + global mi_gdb_prompt + global hex fullname_syntax srcfile + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + set line_main_hello [gdb_get_line_number "Hello, World!"] + + 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "step-instruction at main" + } else { + fail "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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "next-instruction at main" + } else { + fail "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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "next-instruction at main" + } else { + fail "next-instruction at main" + } + } + timeout { + fail "next-instruction at main (timeout)" + } + } +} + +mi_run_to_main +test_stepi_nexti + +mi_gdb_exit +return 0 Index: mi-hack-cli.exp =================================================================== --- mi-hack-cli.exp (nonexistent) +++ mi-hack-cli.exp (revision 157) @@ -0,0 +1,39 @@ +# Copyright 1999, 2001, 2007, 2008 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 3 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, see . + +# 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=mi" + +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 Index: mi2-var-display.exp =================================================================== --- mi2-var-display.exp (nonexistent) +++ mi2-var-display.exp (revision 157) @@ -0,0 +1,632 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-var-display.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +set line_dct_end [gdb_get_line_number "{int a = 0;}"] + +mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"$line_dct_end\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\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\",value=\".*\",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\",value=\"0x849\"" \ + "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\",value=\"3\"" \ + "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\",value=\".*\",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\",value=\"$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\",value=\"3\"" \ + "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\",value=\".*\",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 \\(\\*\\)\\((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 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\",value=\"$hex\"" \ + "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\",value=\"$hex\"" \ + "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\",value=\"$hex\"" \ + "set format variable weird" + +mi_gdb_test "-var-set-format weird.integer natural" \ + "\\^done,format=\"natural\",value=\"123\"" \ + "set format variable weird.integer" + +mi_gdb_test "-var-set-format weird.character natural" \ + "\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \ + "set format variable weird.character" + +mi_gdb_test "-var-set-format weird.char_ptr natural" \ + "\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \ + "set format variable weird.char_ptr" + +mi_gdb_test "-var-set-format weird.long_int natural" \ + "\\^done,format=\"natural\",value=\"0\"" \ + "set format variable weird.long_int" + +mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ + "\\^done,format=\"natural\",value=\"$hex\"" \ + "set format variable weird.int_ptr_ptr" + +mi_gdb_test "-var-set-format weird.long_array natural" \ + "\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \ + "set format variable weird.long_array" + +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ + "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr_struct" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ + "\\^done,format=\"natural\",value=\"0\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-set-format weird.u1 natural" \ + "\\^done,format=\"natural\",value=\"\{...\}\"" \ + "set format variable weird.u1" + +mi_gdb_test "-var-set-format weird.s2 natural" \ + "\\^done,format=\"natural\",value=\"\{...\}\"" \ + "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" + +set line_dst_a_1 [gdb_get_line_number "a = 1;"] + +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=\"$line_dst_a_1\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_a_1\"\}\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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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)"} +} + +set line_incr_a_b_a [gdb_get_line_number "b = a;"] + +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=\"$line_incr_a_b_a\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\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\",value=\".*\",type=\"char\"" \ + "create local variable a1" + +mi_gdb_test "-var-create a2 $fp a" \ + "\\^done,name=\"a2\",numchild=\"0\",value=\".*\",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 Index: gdb701.exp =================================================================== --- gdb701.exp (nonexistent) +++ gdb701.exp (revision 157) @@ -0,0 +1,67 @@ +# Copyright 2002, 2007, 2008 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 3 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, see . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# test gdb/701 +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile gdb701 +set srcfile "$testfile.c" +set binfile $objdir/$subdir/$testfile +if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} { + untested gdb701.exp + return -1 +} + +# When varobj reports the types of objects, it often isn't really reporting +# the type as GDB knows it. For example, in this testcase, we have a +# structure which has been typedefed. A varobj of this type would really have +# a type of "TYPE_CODE_TYPEDEF". It's target type is "TYPE_CODE_STRUCT". Varobj +# should skip over the TYPEDEF type when figuring out the varobj's children. +# If it doesn't, Bad Things Happen(TM). + +# Run to main +mi_run_to_main + +# Step over "foo = 0" +mi_next "step over \"foo = 0\"" + +mi_gdb_test "-var-create fooPtr * foo" \ + "(&\".*\"\r\n)*\\^done,name=\"fooPtr\",numchild=\"3\",value=\".*\",type=\"Foo \\*\"" \ + "create fooPtr" + +mi_gdb_test "-var-list-children fooPtr" \ + "(&\".*\"\r\n)*\\^done,numchild=\"3\",.*" \ + "list children of fooPtr" + +foreach i [list x y z] { + mi_gdb_test "-var-list-children fooPtr.$i" \ + "(&\".*\"\r\n)*\\^done,numchild=\"0\"" \ + "list children of fooPtr.$i" +} + +mi_gdb_exit +return 0 Index: mi2-regs.exp =================================================================== --- mi2-regs.exp (nonexistent) +++ mi2-regs.exp (revision 157) @@ -0,0 +1,126 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-regs.exp + return -1 +} + +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 \\\[...\\\]\"" \ + "wrong arguments" + + mi_gdb_test "111-data-list-register-values x" \ + ".*111\\^error,msg=\"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\",\"fsr\",\"csr\",\"d0\",\"d2\",\"d4\",\"d6\",\"d8\",\"d10\",\"d12\",\"d14\",\"d16\",\"d18\",\"d20\",\"d22\",\"d24\",\"d26\",\"d28\",\"d30\"\\\]" \ + "list register names" + + mi_gdb_test "222-data-list-register-values x" \ + "222\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"87\",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=\"87\",value=\"$float\"\}\\\]" \ + "register values f" + + mi_gdb_test "444-data-list-register-values d" \ + "444\\^done,register-values=\\\[\{number=\"0\",value=\"-?$decimal\"\}.*\{number=\"87\",value=\"-?$decimal\"\}\\\]" \ + "register values d" + + mi_gdb_test "555-data-list-register-values o" \ + "555\\^done,register-values=\\\[\{number=\"0\",value=\"$octal\"\}.*\{number=\"87\",value=\"$octal\"\}\\\]" \ + "register values o" + + mi_gdb_test "666-data-list-register-values t" \ + "666\\^done,register-values=\\\[\{number=\"0\",value=\"$binary\"\}.*\{number=\"87\",value=\"$binary\"\}\\\]" \ + "register values t" + + # On the sparc, registers 0-31 are int, 32-63 float, 64-71 int, 72-87 float + + 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\"\},\{number=\"72\",value=\"$float\"\}.*\{number=\"87\",value=\"$float\"\}\\\]" \ + "register values N" + + mi_gdb_test "888-data-list-register-values r" \ + "888\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"87\",value=\"$hex\"\}\\\]" \ + "register values r" + + mi_gdb_test "999-data-list-register-names 68 69 70 71" \ + "999\\^done,register-names=\\\[\"pc\",\"npc\",\"fsr\",\"csr\"\\\]" \ + "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 Index: mi-stepi.exp =================================================================== --- mi-stepi.exp (nonexistent) +++ mi-stepi.exp (revision 157) @@ -0,0 +1,98 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-stepi.exp + return -1 +} + +proc test_stepi_nexti {} { + global mi_gdb_prompt + global hex fullname_syntax srcfile + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + set line_main_hello [gdb_get_line_number "Hello, World!"] + + 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "step-instruction at main" + } else { + fail "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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "next-instruction at main" + } else { + fail "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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" { + set line $expect_out(2,string) + if { $line >= $line_main_body && $line <= $line_main_hello } { + pass "next-instruction at main" + } else { + fail "next-instruction at main" + } + } + timeout { + fail "next-instruction at main (timeout)" + } + } +} + +mi_run_to_main +test_stepi_nexti + +mi_gdb_exit +return 0 Index: mi-var-display.exp =================================================================== --- mi-var-display.exp (nonexistent) +++ mi-var-display.exp (revision 157) @@ -0,0 +1,632 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-var-display.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +set line_dct_end [gdb_get_line_number "{int a = 0;}"] + +mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \ + "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"$line_dct_end\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\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\",value=\".*\",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\",value=\"0x849\"" \ + "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\",value=\"3\"" \ + "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\",value=\".*\",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\",value=\"$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\",value=\"3\"" \ + "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\",value=\".*\",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 \\(\\*\\)\\((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 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\",value=\"$hex\"" \ + "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\",value=\"$hex\"" \ + "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\",value=\"$hex\"" \ + "set format variable weird" + +mi_gdb_test "-var-set-format weird.integer natural" \ + "\\^done,format=\"natural\",value=\"123\"" \ + "set format variable weird.integer" + +mi_gdb_test "-var-set-format weird.character natural" \ + "\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \ + "set format variable weird.character" + +mi_gdb_test "-var-set-format weird.char_ptr natural" \ + "\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \ + "set format variable weird.char_ptr" + +mi_gdb_test "-var-set-format weird.long_int natural" \ + "\\^done,format=\"natural\",value=\"0\"" \ + "set format variable weird.long_int" + +mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \ + "\\^done,format=\"natural\",value=\"$hex\"" \ + "set format variable weird.int_ptr_ptr" + +mi_gdb_test "-var-set-format weird.long_array natural" \ + "\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \ + "set format variable weird.long_array" + +mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ + "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr" + +mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \ + "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr_struct" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \ + "\\^done,format=\"natural\",value=\"0\"" \ + "set format variable weird.func_ptr_ptr" + +mi_gdb_test "-var-set-format weird.u1 natural" \ + "\\^done,format=\"natural\",value=\"\{...\}\"" \ + "set format variable weird.u1" + +mi_gdb_test "-var-set-format weird.s2 natural" \ + "\\^done,format=\"natural\",value=\"\{...\}\"" \ + "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" + +set line_dst_a_1 [gdb_get_line_number "a = 1;"] + +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=\"$line_dst_a_1\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_a_1\"\}\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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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)"} +} + +set line_incr_a_b_a [gdb_get_line_number "b = a;"] + +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=\"$line_incr_a_b_a\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\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\",value=\".*\",type=\"char\"" \ + "create local variable a1" + +mi_gdb_test "-var-create a2 $fp a" \ + "\\^done,name=\"a2\",numchild=\"0\",value=\".*\",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 Index: gdb669.exp =================================================================== --- gdb669.exp (nonexistent) +++ gdb669.exp (revision 157) @@ -0,0 +1,194 @@ +# Copyright 2002, 2003, 2004, 2007, 2008 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 3 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, see . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file checks for the bug gdb/669, where the console +# command "info threads" and the MI command "-thread-list-ids" +# return different threads in the system. + +# This only works with native configurations +if {![isnative]} { + return +} + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if {[mi_gdb_start]} { + continue +} + +# The procs below are all stolen from mi-pthreads.exp. Any updates +# should also be made to the procs there. + +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)" + } + } + } + } +} + +# +# Start here +# +set testfile "pthreads" +set srcfile "$testfile.c" +set binfile "$objdir/$subdir/gdb669-$testfile" + +set options [list debug incdir=$objdir] +if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { + return -1 +} + +mi_run_to_main +check_mi_and_console_threads "at main" + +for {set i 0} {$i < 4} {incr i} { + mi_next "next, try $i" + check_mi_and_console_threads "try $i" +} + +mi_gdb_exit + Index: mi2-simplerun.exp =================================================================== --- mi2-simplerun.exp (nonexistent) +++ mi2-simplerun.exp (revision 157) @@ -0,0 +1,218 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 +# 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-simplerun.exp + return -1 +} + +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 + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee2_head [gdb_get_line_number "callee2 ("] + set line_callee2_body [expr $line_callee2_head + 2] + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\",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=\"$line_callee2_body\",times=\"0\"\}" \ + "insert breakpoint at basics.c:callee2" + + mi_gdb_test "202-break-insert basics.c:$line_callee3_head" \ + "202\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"$line_callee3_head\",times=\"0\"\}" \ + "insert breakpoint at basics.c:\$line_callee3_head" + + mi_gdb_test "203-break-insert \"\\\"${srcfile}\\\":$line_callee4_head\"" \ + "203\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_callee4_head\",times=\"0\"\}" \ + "insert breakpoint at \"\":\$line_callee4_head" + + 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=\"$line_main_body\",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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\"\}\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 + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_call [expr $line_callee3_head + 2] + set line_callee3_close_brace [expr $line_callee3_head + 3] + set line_callee1_head [gdb_get_line_number "callee1 ("] + set line_callee1_body [expr $line_callee1_head + 2] + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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" [expr $line_main_body + 1] "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" "$line_callee1_body" "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" $line_callee4_body "" "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" \ + "($line_callee3_call|$line_callee3_close_brace)" ".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 Index: mi2-return.exp =================================================================== --- mi2-return.exp (nonexistent) +++ mi2-return.exp (revision 157) @@ -0,0 +1,74 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-return.exp + return -1 +} + +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 fullname_syntax srcfile + + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_call [expr $line_callee3_head + 2] + set line_callee3_close_brace [expr $line_callee3_head + 3] + + send_gdb "111-exec-return\n" + gdb_expect { + -re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\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 Index: mi2-file.exp =================================================================== --- mi2-file.exp (nonexistent) +++ mi2-file.exp (revision 157) @@ -0,0 +1,74 @@ +# Copyright 1999, 2003, 2004, 2007, 2008 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-file.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_file_cmd ${binfile} + +proc test_file_list_exec_source_file {} { + global srcfile + global srcdir + global subdir + global fullname_syntax + set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}] + + # get the path and absolute path to the current executable + # + # In gdb 6.2 (at least), the default line number is set by + # select_source_symtab to the first line of "main" minus + # the value of "lines_to_list" (which defaults to 10) plus one. + # --chastain 2004-08-13 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + set gdb_lines_to_list 10 + set line_default [expr $line_main_body - $gdb_lines_to_list + 1] + + mi_gdb_test "111-file-list-exec-source-file" \ + "111\\\^done,line=\"$line_default\",file=\"${srcfilepath}\",fullname=\"$fullname_syntax${srcfile}\",macro-info=\"0\"" \ + "request path info of current source file (${srcfile})" +} + +test_file_list_exec_source_file + +mi_gdb_exit +return 0 Index: mi2-read-memory.exp =================================================================== --- mi2-read-memory.exp (nonexistent) +++ mi2-read-memory.exp (revision 157) @@ -0,0 +1,87 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-read-memory.exp + return -1 +} + + +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 Index: gdb701.c =================================================================== --- gdb701.c (nonexistent) +++ gdb701.c (revision 157) @@ -0,0 +1,15 @@ +struct _foo +{ + int x; + int y; + int z; +}; + +typedef struct _foo Foo; + +int +main (int argc, char *argv[]) +{ + Foo *foo = 0; + return 0; +}
gdb701.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi2-eval.exp =================================================================== --- mi2-eval.exp (nonexistent) +++ mi2-eval.exp (revision 157) @@ -0,0 +1,63 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 +# 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-eval.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +set line_callee4_head [gdb_get_line_number "callee4 ("] +set line_callee4_body [expr $line_callee4_head + 2] + +mi_runto callee4 +mi_next_to "callee4" "" "basics.c" [expr $line_callee4_body + 1] "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 Index: mi2-until.exp =================================================================== --- mi2-until.exp (nonexistent) +++ mi2-until.exp (revision 157) @@ -0,0 +1,131 @@ +# Copyright 1999, 2000, 2001, 2003, 2005, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-until.exp + return -1 +} + +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 fullname_syntax srcfile + + 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"12\"\}\r\n$mi_gdb_prompt$" { + pass "until after while loop" + } + -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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"9\"\}\r\n$mi_gdb_prompt$" { + kfail gdb/2104 "until after while loop (went backwards)" + } + 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\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(23|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 Index: mi-simplerun.exp =================================================================== --- mi-simplerun.exp (nonexistent) +++ mi-simplerun.exp (revision 157) @@ -0,0 +1,218 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008 +# 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-simplerun.exp + return -1 +} + +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 + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee2_head [gdb_get_line_number "callee2 ("] + set line_callee2_body [expr $line_callee2_head + 2] + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\",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=\"$line_callee2_body\",times=\"0\"\}" \ + "insert breakpoint at basics.c:callee2" + + mi_gdb_test "202-break-insert basics.c:$line_callee3_head" \ + "202\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",line=\"$line_callee3_head\",times=\"0\"\}" \ + "insert breakpoint at basics.c:\$line_callee3_head" + + mi_gdb_test "203-break-insert \"\\\"${srcfile}\\\":$line_callee4_head\"" \ + "203\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_callee4_head\",times=\"0\"\}" \ + "insert breakpoint at \"\":\$line_callee4_head" + + 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=\"$line_main_body\",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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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=\"$line_main_body\"\}\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 + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_call [expr $line_callee3_head + 2] + set line_callee3_close_brace [expr $line_callee3_head + 3] + set line_callee1_head [gdb_get_line_number "callee1 ("] + set line_callee1_body [expr $line_callee1_head + 2] + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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" [expr $line_main_body + 1] "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" "$line_callee1_body" "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" $line_callee4_body "" "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" \ + "($line_callee3_call|$line_callee3_close_brace)" ".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 Index: mi-read-memory.exp =================================================================== --- mi-read-memory.exp (nonexistent) +++ mi-read-memory.exp (revision 157) @@ -0,0 +1,86 @@ +# Copyright 1999, 2000, 2001, 2002, 2007, 2008 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-read-memory.exp + return -1 +} + + +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 Index: ChangeLog-1999-2003 =================================================================== --- ChangeLog-1999-2003 (nonexistent) +++ ChangeLog-1999-2003 (revision 157) @@ -0,0 +1,768 @@ +2003-08-07 Andrew Cagney + + * 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 + + From Thierry Schneider : + * mi1-symbol.exp (-symbol-list-lines): New test file to + validate all symbol-related commands + +2003-04-08 Andrew Cagney + + * gdb792.exp: Skip when C++. + +2003-02-23 Stephane Carrez + + * mi-syn-frame.exp: Don't run this test when gdb,nosignals is set. + +2002-12-13 Jeff Johnston + + * mi-basics.exp: Change tests for -environment-directory. Also add + tests for -environment-cd, -environment-pwd, and -environment-path. + Part of fix for PR gdb/741. + +2002-11-05 Jeff Johnston + + * gdb792.cc: New file to test patch for PR gdb/792. + * gdb792.exp: Ditto. + +2002-11-04 Elena Zannoni + + * mi-console.exp: Use mi_runto, mi_run_to_main, mi_next_to, + mi_step_to wherever possible. Update copyright notices. + * mi-disassemble.exp: Ditto. + * mi-eval.exp: Ditto. + * mi-read-memory.exp: Ditto. + * mi-regs.exp: Ditto. + * mi-return.exp: Ditto. + * mi-stack.exp: Ditto. + * mi-stepi.exp: Ditto. + * mi-var-block.exp: Ditto. + * mi-var-cmd.exp: Ditto. + * mi-watch.exp: Ditto. + * mi1-console.exp: Ditto. + * mi1-disassemble.exp: Ditto. + * mi1-eval.exp: Ditto. + * mi1-read-memory.exp: Ditto. + * mi1-regs.exp: Ditto. + * mi1-return.exp: Ditto. + * mi1-stack.exp: Ditto. + * mi1-stepi.exp: Ditto. + * mi1-var-block.exp: Ditto. + * mi1-var-cmd.exp: Ditto. + * mi1-watch.exp: Ditto. + +2002-10-23 Jeff Johnston + + * mi-var-cmd.exp: Add tests to verify that a -var-assign that changes + a value shows up in the changelist of a -var-update. Part of fix + for gdb/702. + * mi1-var-cmd.exp: Ditto. + +2002-10-03 Jeff Johnston + + * mi-return.exp: Change expected frame output to remove extraneous + space in level field when frame level is single digit. Part of + fix for PR gdb/192. + * mi-stack.exp: Ditto. + * mi1-return.exp: Ditto. + * mi1-stack.exp: Ditto. + +2002-10-03 Jeff Johnston + + * mi-var-block.exp: Change expected output from -var-update + command to expect list format for "changelist". Fix for + PR gdb/672. + * mi-var-cmd.exp: Ditto. + * mi-var-child: Ditto. + +2002-09-25 Keith Seitz + + * mi-pthreads.exp (get_mi_thread_list): Check if expect_out + exists before using it. + (check_mi_and_console_threads): Likewise. + * gdb669.exp (get_mi_thread_list): Likewise. + (check_mi_and_console_threads): Likewise. + +2002-09-24 Keith Seitz + + * configure.in: Add config header. + Check for pthread.h. + * configure: Regenerate. + * config.in: New file. + * pthreads.c: New file. + * mi-pthreads.exp: New file to test thread functionality. + * gdb669.exp: New file. + +2002-09-17 Keith Seitz + + * mi-var-cmd.exp: Add tests to check when varobj pinned to a + selected frame changes type. + +2002-09-17 Keith Seitz + + * mi-console.exp: Update copyright. + * mi-var-block.exp: Likewise. + * mi-var-cmd.exp: Likewise. + * mi-var-display.exp: Likewise. + * mi0-console.exp: Likewise. + * mi0-var-child.exp: Likewise. + * mi0-var-cmd.exp: Likewise. + * mi0-var-display.exp: Likewise. + +2002-09-16 Keith Seitz + + * gdb701.exp: New file for testing varobj target type bug. + * gdb701.c: New file. + +2002-09-13 Keith Seitz + + * mi-var-child.exp: Use mi_step_to and mi_execute_to instead + of a bunch of repeated send_gdb/gdb_expect statements. + Fix line numbers. + +2002-09-10 Keith Seitz + + * mi-simplerun.exp (test_controlled_execution): Follow renaming of + mi_run_to to mi_execute_to. + * mi-var-cmd.exp: Likewise. + * mi0-simplerun.exp: Likewise. + * mi0-var-cmd.exp: Likewise. + +2002-09-03 Keith Seitz + + * gdb680.exp: New file to test to check for uiout list/tuple + nesting bug. + +2002-03-04 Michael Chastain + + * mi-var-cmd.exp: In test "create local variable func", + accommodate gcc v3 function signature. + * mi0-var-cmd-exp: Ditto. + +2002-02-05 Jim Blandy + + * mi-regs.exp: Various cleanups for SPARC-only tests. + (test_breakpoints_creation_and_listing): Format of breakpoint + table has changed. + (sparc_register_tests): Expand floating-point number regexp to + recognize NaN values, too. Replace ineffectual single backslash + before a hyphen with a double backslash. Don't check the exact + numbers of the registers which have changed, since there's no way + to know which registers changed, exactly; just check that the + result is well-formed. + * mi0-regs.exp: (sparc_register_tests): Same as for + sparc_register_tests in mi-regs.exp. + + * mi-var-child.exp ("get children of struct_declarations", "get + children of struct_declarations.s2.u2.u1s2", "get children of + weird"): Tolerate argument types when they appear in function + types. (Dwarf 2 includes prototype info; STABS does not.) + * mi0-var-child.exp: Same. + +2001-12-19 Keith Seitz + + * mi-var-display.exp: char* variables have a child. Update all + occurences. + * mi0-var-display.exp: Likewise. + +2001-08-29 Andrew Cagney + + * mi-var-cmd.exp, mi0-var-cmd.exp: Variable lpcharacter has one + child. Soften floating point tests. + +2001-08-09 Andrew Cagney + + * mi0-var-block.exp, mi0-stack.exp, mi0-simplerun.exp, + mi0-regs.exp, mi0-watch.exp, mi0-stepi.exp, mi0-until.exp, + mi0-return.exp, mi0-read-memory.exp, mi0-eval.exp, + mi0-disassemble.exp, mi0-console.exp, mi-watch.exp, + mi-var-display.exp, mi-var-cmd.exp, mi-var-child.exp, + mi-until.exp, mi-var-block.exp, mi-stepi.exp, mi-stack.exp, + mi-simplerun.exp, mi-return.exp, mi-regs.exp, mi-read-memory.exp, + mi-disassemble.exp, mi-eval.exp, mi-console.exp: Replace pattern + matching thread=0 with one to also match thread=1. + Fix PR gdb/190. + +2001-08-18 Andrew Cagney + + * mi0-until.exp, mi-until.exp, mi0-stepi.exp, mi-stepi.exp, + mi-simplerun.exp, mi0-simplerun.exp, mi0-return.exp, + mi-return.exp, mi0-console.exp, mi-console.exp: Recognize an + unexpected run-to-main response. Report as a fail. + +2001-06-27 Andrew Cagney + + * mi-disassemble.exp: Update to accept mi1 breakpoint tables. + * mi-basics.exp: Ditto. + * mi-simplerun.exp: Ditto. + * mi-watch.exp: Ditto. Add check for full header. + * mi-break.exp: Ditto. Add check for full header. + +2001-06-26 Andrew Cagney + + * mi-stack.exp: Update. Output for args=... and + locals=... changed to a list. + +2001-06-26 Andrew Cagney + + * mi-stack.exp: Update. Output for stack=..., args=... and + stack-args=... changed to a list. + +2001-06-25 Andrew Cagney + + * mi-console.exp: Update args=... part of stop-reason + patterns. Output changed to a list of arguments. + * mi-disassemble.exp: Ditto. + * mi-simplerun.exp: Ditto. + * mi-return.exp: Ditto. + * mi-read-memory.exp: Ditto. + * mi-eval.exp: Ditto. + * mi-watch.exp: Ditto. + * mi-var-display.exp: Ditto. + * mi-var-cmd.exp: Ditto. + * mi-var-child.exp: Ditto. + * mi-var-block.exp: Ditto. + * mi-until.exp: Ditto. + * mi-stepi.exp: Ditto. + * mi-stack.exp: Ditto. + * mi-regs.exp: Ditto. + +2001-06-25 Andrew Cagney + + * mi-read-memory.exp: Update patterns matching data-read-memory. + Outputs a list. + +2001-06-25 Andrew Cagney + + * mi-regs.exp: Update patterns matching register-values. Outputs a + list. + +2001-06-25 Andrew Cagney + + * mi-regs.exp: Update patters matching register-names. Now + outputs a list. + +2001-06-25 Andrew Cagney + + * mi-regs.exp: Update patterns matching changed-registers. Now + outputs a list. + +2001-06-23 Andrew Cagney + + * ChangeLog-mi: Rename to ChangeLog. + * mi-basics.exp: Remove local emacs variable defining + change-log-default-name. + * mi-break.exp, mi-console.exp, mi-disassemble.exp: Ditto. + * mi-eval.exp, mi-hack-cli.exp, mi-read-memory.exp: Ditto. + * mi-regs.exp, mi-return.exp, mi-simplerun.exp: Ditto. + * mi-stack.exp, mi-stepi.exp, mi-until.exp: Ditto. + * mi-var-block.exp, mi-var-child.exp, mi-var-cmd.exp: Ditto. + * mi-var-display.exp, mi-watch.exp, mi0-basics.exp: Ditto. + * mi0-break.exp, mi0-console.exp, mi0-disassemble.exp: Ditto. + * mi0-eval.exp, mi0-hack-cli.exp, mi0-read-memory.exp: Ditto. + * mi0-regs.exp, mi0-return.exp, mi0-simplerun.exp: Ditto. + * mi0-stack.exp, mi0-stepi.exp, mi0-until.exp: Ditto. + * mi0-var-block.exp, mi0-var-child.exp, mi0-var-cmd.exp: Ditto. + * mi0-var-display.exp, mi0-watch.exp: Ditto. + +2001-06-23 Andrew Cagney + + * mi-disassemble.exp: Update patterns matching data-disassemble + output. Now produces a list of instructions and a list of + source/assembly lines. + +2001-06-18 Andrew Cagney + + * mi-basics.exp, mi-break.exp, mi-console.exp, mi-disassemble.exp, + mi-eval.exp, mi-hack-cli.exp, mi-read-memory.exp, mi-regs.exp, + mi-return.exp, mi-simplerun.exp, mi-stack.exp, mi-stepi.exp, + mi-until.exp, mi-var-block.exp, mi-var-child.exp, mi-var-cmd.exp, + mi-var-display.exp, mi-watch.exp, mi0-basics.exp, mi0-break.exp, + mi0-console.exp, mi0-disassemble.exp, mi0-eval.exp, + mi0-hack-cli.exp, mi0-read-memory.exp, mi0-regs.exp, + mi0-return.exp, mi0-simplerun.exp, mi0-stack.exp, mi0-stepi.exp, + mi0-until.exp, mi0-var-block.exp, mi0-var-child.exp, + mi0-var-cmd.exp, mi0-var-display.exp, mi0-watch.exp: Use MIFLAGS + to explictly select an interpreter. + +2001-06-16 Andrew Cagney + + MI0 was the never enabled MI interface included in GDB 5.0. + * mi0-basics.exp: Copy mi-basics.exp. + * mi0-break.exp: Copy mi-break.exp. + * mi0-console.exp: Copy mi-console.exp. + * mi0-disassemble.exp: Copy mi-disassemble.exp. + * mi0-eval.exp: Copy mi-eval.exp. + * mi0-hack-cli.exp: Copy mi-hack-cli.exp. + * mi0-read-memory.exp: Copy mi-read-memory.exp. + * mi0-regs.exp: Copy mi-regs.exp. + * mi0-return.exp: Copy mi-return.exp. + * mi0-simplerun.exp: Copy mi-simplerun.exp. + * mi0-stack.exp: Copy mi-stack.exp. + * mi0-stepi.exp: Copy mi-stepi.exp. + * mi0-until.exp: Copy mi-until.exp. + * mi0-var-block.exp: Copy mi-var-block.exp. + * mi0-var-child.exp: Copy mi-var-child.exp. + * mi0-var-cmd.exp: Copy mi-var-cmd.exp. + * mi0-var-display.exp: Copy mi-var-display.exp. + * mi0-watch.exp: Copy mi-watch.exp. + +2001-05-11 Fernando Nasser + + * mi-var-child.exp: Adjust for the fact that now (char *) can be + dereferenced. + +2001-03-06 Kevin Buettner + + * mi-basics.exp, mi-break.exp, mi-disassemble.exp, + mi-eval.exp, mi-hack-cli.exp, mi-read-memory.exp, mi-regs.exp, + mi-return.exp, mi-simplerun.exp, mi-stack.exp, mi-stepi.exp, + mi-until.exp, mi-watch.exp: Update/correct copyright notices. + +2001-01-20 Mark Kettenis + + * mi-support.exp (mi_gdb_start): Skip mi tests if -i flag is + recognized (i.e. if GDB was compiled with UI_OUT, but the mi + interpreter wasn't recognized (because it wasn't compiled in). + +Tue Apr 18 15:36:07 2000 Andrew Cagney + + * Makefile.in (clean mostlyclean): Do not delete $(MISCELLANEOUS). + +Tue Mar 14 15:54:57 2000 Andrew Cagney + + * basics.c: Add EMACS local variable pointing change-log at this + file. + * Makefile.in: Ditto + +2000-03-13 James Ingham + + * mi-var-block.exp: The error report from varobj_create changed + since I am now trapping parse_exp_1 errors. Change the tests to + match the new error message. + * mi-var-child.exp: Ditto. + * mi-var-cmd.exp: Ditto. + +2000-03-06 Elena Zannoni + + * mi-disassemble.exp: Don't assume numbers for the offset + values. They can be different depending on the architecture. + + * mi-watch.exp (test_watchpoint_triggering): In same cases the + type can be 'hw wathcpoint' not just 'watchpoint'. Adjust for that. + + * basics.c (callee4): Make the function return something, + otherwise the return value is undefined. + +2000-03-06 Elena Zannoni + + * mi-basics.exp: Comment out test for a still unimplemented operation. + + * mi-disassemble.exp: Rewrite most of the tests to conform to new + disassemble interface. + +Sat Mar 4 13:55:08 2000 Andrew Cagney + + From Fri 3 Mar 2000 Peter Schauer: + * mi-support.exp (mi_gdb_start): When GDB doesn't recongize -i=mi + option, assume no MI support present. + +2000-02-01 Elena Zannoni + + * mi-support.exp (mi_gdb_start): Update to recognize start up + message with 'UI_OUT' instead of 'HEADLESS'. + +2000-01-27 Elena Zannoni + + * mi-regs.exp (test_running_the_program): Add global var 'hex'. + + * mi-stack.exp, mi-stepi.exp, mi-until.exp, mi-watch.exp, + mi-var-display.exp, mi-var-cmd.exp, mi-var-child.exp, + mi-var-block.exp: Update all stopped messages. + +2000-01-17 Elena Zannoni + + * mi-console.exp, mi-disassemble.exp, mi-eval.exp, + mi-read-memory.exp, mi-regs.exp, mi-return.exp, mi-simplerun.exp: + Update stopped messages, update copyright. + + * mi-disassemble.exp: Update error messages output. + + * mi-support.exp (proc mi_step): Make gdb do a 'step' command, not + a 'next'. Update stopped message. + (proc mi_next): Update stop message. + (proc mi_run_to_main): Update stopped message. + Update copyright. + +2000-01-11 Elena Zannoni + + * mi-simplerun.exp: Remove stack frames tests from here, to: + + * mi-stack.exp: New file, tests for stack commands. + + * mi-support.exp (mi_run_to_main, mi_next, mi_step) : Update to + include thread-id in stopped message. + + * mi-regs.exp: Update break-insert output. + + * (mi-console.exp, mi-disassemble.exp, mi-eval.exp, + mi-read-memory.exp, mi-regs.exp, mi-return.exp, mi-simplerun.exp, + mi-stepi.exp, mi-until.exp, mi-var-block.exp, mi-var-child.exp, + mi-var-cmd.exp, mi-var-display.exp, mi-watch.exp): Update stopped + message to include thread-id. + +Wed Dec 29 22:06:05 1999 Andrew Cagney + + * mi-watch.exp, mi-var-display.exp, mi-var-cmd.exp, + mi-var-child.exp, mi-var-block.exp, mi-until.exp, mi-stepi.exp, + mi-simplerun.exp, mi-return.exp, mi-support.exp, mi-eval.exp, + mi-console.exp, mi-disassemble.exp, mi-break.exp: Update to + reflect extended output from -break-insert command. + + * mi-break.exp (test_rbreak_creation_and_listing): XFAIL regexp + tests. -r flag broken by above. + +Sun Dec 19 19:28:13 1999 Andrew Cagney + + * cpp_variable.cc, cpp_variable.h, c_variable.c: Delete. + +Fri Dec 17 20:59:55 1999 Andrew Cagney + + * mi-read-memory.exp: Test of ``-o '' now works. + +1999-12-16 Elena Zannoni + + * mi-var-cmd.exp: Fix 2 tests outputs. + + * mi-var-child.exp: Add many more tests. + + * mi-var-display.exp: Add many more tests. + + * var-cmd.c: Change type of incr_a parameter to char. + +1999-12-15 Elena Zannoni + + * mi-var-block.exp: Set up xfails fro known problems. + + * mi-var-display.exp: Set up printing of values of 'e' and 'anone' + as xfails. + + * mi-var-child.exp: Fix typos. + +1999-12-15 Andrew Cagney + + * mi-var-child.exp: Space was missing before ``[10]''. + +Wed Dec 15 19:23:38 1999 Andrew Cagney + + * mi-read-memory.exp: Add test for ``-o ''. Update checks + and match next-row et.al. + +1999-12-14 Elena Zannoni + + * mi-var-display.exp : New file. Tests for format and type, with + unions, structs and enums. + + * mi-var-cmd.exp: Add some var-assign tests. + +1999-12-14 Elena Zannoni + + * mi-var-cmd.exp, mi-var-block.exp, mi-var-child.exp: New files + some tests for -var* commands. + + * var-cmd.c: New source file for var-* commands tests. + * gdb.mi/Makefile.in (PROGS): Add var-cmd. + +Mon Dec 13 18:06:09 1999 Andrew Cagney + + * mi-break.exp: Fix quoting. Changed "srcfile.c":6 to + "\"srcfile.c\":6". + * mi-simplerun.exp: Fix quoting. + +Sat Dec 11 21:33:37 1999 Andrew Cagney + + * mi-simplerun.exp (exec-finish): Fix return value was zero, + should have been three. + + * mi-disassemble.exp: Reduce number of wild card matches in + * patterns. Remove all numeric constants. + +1999-12-09 Elena Zannoni + + * mi-eval.exp: New file. Some initial tests for + -data-evaluate-expression. + +1999-12-09 Fernando Nasser + + * c_variable.c, cpp_variable.cc, cpp_variable.h: New files. Used + for testing "var" operations. + * Makefile.in: Add reference to the above files. + +1999-12-08 Elena Zannoni + + * mi-regs.exp: Fix test for format 'N' for + data-list-register-values. + +1999-12-07 Elena Zannoni + + * mi-disassemble.exp: Update expected output. Break test of + disassembly in mixed mode into 2 functions. + + * mi-regs.exp: Initial register tests. Works only on sparc right + now. + +1999-12-02 Elena Zannoni + + * mi-stepi.exp: New file. Tests exec-step-instruction and + exec-next-instruction. + * mi-until.exp: New file. Tests exec-until. + * until.c: New file. + * mi-return.exp: New file. Tests exec-return. + +Thu Dec 2 09:38:23 1999 Andrew Cagney + + * mi-hack-cli.exp: New test. Check the hacked up access to the + CLI. + +Wed Dec 1 16:47:40 1999 Andrew Cagney + + * mi-basics.exp: Delete calls to mi_delete_breakpoints, + mi_gdb_reinitialize_dir and mi_gdb_load. This test is checking + that these can work. + + * mi-support.exp (mi_step, mi_next, mi_run_to_main): New + procedures. + + * mi-read-memory.exp, mi-read-memory.c: New files. Test + data-read-memory command. + +Tue Nov 30 23:54:16 1999 Andrew Cagney + + * mi-support.exp: Don't start SID until after GDB has been started + and verified. + +Tue Nov 30 22:21:33 1999 Andrew Cagney + + * mi-support.exp (mi_uncatched_gdb_exit): When SID, call sid_exit. + (mi_gdb_start): When SID, call sid_start. + (mi_gdb_start): Add MIFLAGS to spawn-GDB command. Check for + HEADLESS gdb. Return non-zero when GDB fails to start. + (mi_gdb_load): When SID or SIM, download program. + (mi_run_cmd): Don't do download here. Assume target supports the + 00-exec-run command. + (skip_mi_tests, setup_gdbmi, unset_gdbmi): Delete. Merged into + mi_gdb_start. + + * mi-basics.exp, mi-break.exp, mi-console.exp, mi-disassemble.exp, + mi-simplerun.exp, mi-watch.exp: Update. Check status from + mi_gdb_start indicating that GDB started correctly. + +Tue Nov 30 15:22:08 1999 Andrew Cagney + + * mi-support.exp (setup_gdbmi, unset_gdbmi): New + procedures. Setup/unset dejagnu for mi tests. + * mi-basics.exp, mi-console.exp, mi-simplerun.exp, mi-break.exp, + mi-disassemble.exp, mi-watch.exp: Update. + +1999-11-29 Elena Zannoni + + * mi-simplerun.exp (test_running_the_program): Remove XFAIL. The + output is fixed now. + (test_program_termination): Update output pattern. + +Tue Nov 30 00:19:10 1999 Andrew Cagney + + * mi-console.c, mi-console.exp: New files. Test console output. + +Mon Nov 29 17:59:13 1999 Andrew Cagney + + * mi-support.exp (mi_run_command): Check for exec-run command + failure due to MI not having an active target. + (mi_run_command): Check for and handle a builtin simulator target. + (mi_run_command): Don't check/handle for ``The program has been + started already'', not a valid MI response. + + * mi-simplerun.exp (test_running_the_program): Update all patterns + to match async output. + (test_running_the_program): Mark ``step to callee4'' as XFAIL. MI + output contains {,reason="end-stepping-range"}+. + + * mi-simplerun.exp: Limit the timeout for ``step to callee4'' to + 30 seconds. + +Mon Nov 29 17:30:00 1999 Andrew Cagney + + * mi-support.exp (skip_mi_tests): Print UNTESTED when MI interface + isn't available. Start/stop instead of assuming GDB is running. + (MIFLAGS): Define. + * mi-simplerun.exp, mi-disassemble.exp, mi-break.exp, + mi-basics.exp, mi-watch.exp: Update. + +1999-11-26 Elena Zannoni + + * mi-simplerun.exp: Move break-insert {-t, -r} from here. + * mi-break.exp: To here. New file. + * mi-watch.exp: New file. Tests for watchpoints. + +Wed Nov 24 17:42:07 1999 Andrew Cagney + + * gdb.mi/ChangeLog-mi: MI entries moved to here. + +Wed Nov 24 17:31:04 1999 Andrew Cagney + + * gdb.mi/mi-basics.exp, gdb.mi/mi-disassemble.exp, + gdb.mi/mi-simplerun.exp: Print warning message when test isn't + run. + +1999-11-23 Elena Zannoni + + * gdb.mi/mi-simplerun.exp: Update output of break-list to account for + "times" field. + +1999-11-05 Elena Zannoni + + * gdb.mi/mi-simplerun.exp: Add tests for temporary breakpoints + and bp based on regular expressions. + * gdb.mi/mi-disassemble.exp: Fix typo. + +1999-11-04 Elena Zannoni + + * gdb.mi/mi-disassemble.exp: Update output of execution commands + to reflect new 'reason' field. + * gdb.mi/mi-simplerun.exp: Ditto. + +1999-10-25 Elena Zannoni + + * gdb.mi/mi-simplerun.exp: Add more stack-list-frames tests. + + * gdb.mi/mi-disassemble.exp: Update 'run to main' output. + + * gdb.mi/mi-simplerun.exp: Update execution commands + output. Update backtrace output. + +1999-10-18 Elena Zannoni + + * gdb.mi/mi-disassemble.exp: Add new tests for the new + disassembly command parameter, number of lines. + +Mon Oct 11 13:57:21 1999 Andrew Cagney + + * lib/mi-support.exp: Break complicated gdb_expect containing + exp_continue into a while within an expect. Don't attempt a start + more than three times. Check return value from gdb_load. + +1999-10-06 Elena Zannoni + + * gdb.mi/mi-disassemble.exp: New file. + +Wed Oct 6 12:05:58 1999 Andrew Cagney + + * lib/mi-support.exp (mi_run_cmd): Give up after two restart + attempts. + +1999-09290 Fernando Nasser + + * gdb.mi/mi-basics.exp: Update to current syntax and output formats. + * gdb.mi/mi-simplerun.exp: Ditto. + * lib/mi-support.exp (mi_delete_breakpoints): Ditto. + +1999-06-30 Fernando Nasser + + * gdb.mi/basics.c (main): Fix return code. Add a print "Hello, + World". + * gdb.mi/mi-basics.exp: Fix message texts and numbering. + * gdb.mi/mi-simplerun.exp: Ditto. Also, add new tests and improve + some patterns. + +1999-06-30 Fernando Nasser + + * lib/mi-support.exp (mi_gdb_reinitialize_dir): Remove query as an + acceptable response to the environment-dir command. + +1999-06-30 Fernando Nasser + + * lib/mi-support.exp (mi_delete_breakpoints): Remove references to + gdb-cli. + (mi_run_cmd): Ditto. + +1999-06-25 Fernando Nasser + + * lib/mi-support.exp (skip_mi_tests): Use gdb-version to check for + headless output format. + +1999-06-24 Fernando Nasser + + * gdb.mi/mi-simplerun.exp (test_controlled_execution): Add global + spec for hex. + +1999-06-24 Fernando Nasser + + * lib/mi-support.exp (mi_run_cmd): Fix pattern and add a timeout + clause. + +1999-06-24 Fernando Nasser + + * lib/mi-support.exp: Use mi_gdb_prompt instead of a modified + gdb_prompt. Remove uneeded loading of libgloss. + (mi_gdb_exit): Remove prompt argument. + (mi_uncatched_gdb_exit): Ditto. + (mi_run_cmd): New proc. MI version of gdb_run. + (skip_mi_tests): New proc. Check if gdb is capable of producing + headless formatted output. + * gdb.mi/mi-basics.exp: Use mi_gdb_prompt instead of a modified + gdb_prompt. Eliminate parameter to mi_gdb_exit (as a result of + the above). Test for skip_mi_tests before running. + Note: The above changes are interelated (need each other). + * gdb.mi/mi-simplerun.exp: Same changes as for mi-basics.exe + above. + (test_breakpoint_creation_and_listing): Remove insertion of + breakpoint at callee1 (and renumber tokens). Add tests for + break-list, break-disable and break-info. + (test_running_the_program): Use mi_run_cmd so it can run on remote + targets. + (test_controlled_execution): Fix broken test. + (test_program_termination): Test implemented. + * gdb.mi/basic.c (main): Small change to allow for testing of both + exec-next and exec-step operations. + +1999-06-22 Fernando Nasser + + * lib/mi-support.exp (mi_gdb_test): New proc. MI version of gdb_test. + * gdb.mi/mi-basics.exp: Use the above instead of gdb_test. + * gdb.mi/mi-simplerun.exp: Ditto. + +1999-06-22 Fernando Nasser + + * gdb.mi/mi-simplerun.exp: New file. Tests simple debugging tasks. + * gdb.mi/mi-basics.exp: Remove tests moved to above new file. + * lib/mi-support.exp: New file. Support procedures for mi tests. + +1999-06-08 Fernando Nasser + + * gdb.mi/mi-basics.exp: Skip all tests if the MI interpreter is + not active. + +1999-06-03 Fernando Nasser + + * gdb.mi: New directory. + * configure.in: Configure it. + * configure: Regenerate. + * gdb.mi/{Makefile.in,configure.in,configure}: New files. + * gdb.mi/{mi-basics.exp,basics.c,testcmds}: New files. + + +Local Variables: +mode: indented-text +left-margin: 8 +fill-column: 74 +version-control: never +End: Index: gdb792.cc =================================================================== --- gdb792.cc (nonexistent) +++ gdb792.cc (revision 157) @@ -0,0 +1,59 @@ +#include +#include + +class Q +{ + int v; + protected: + int qx; + int qy; + int w; +}; + +class B +{ + int k; + public: + int bx; + int by; +}; + +class A +{ + int u; + + public: + A() + { + }; + int x; + char buffer[10]; + + protected: + int y; + B b; + + private: + float z; +}; + +class C : public A +{ + public: + C() + { + }; + int zzzz; + private: + int ssss; +}; + +int main() +{ + A a; + C c; + Q q; + strcpy( a.buffer, "test" ); + printf ( "%.10s\n", a.buffer ); + return 0; +} Index: mi2-basics.exp =================================================================== --- mi2-basics.exp (nonexistent) +++ mi2-basics.exp (revision 157) @@ -0,0 +1,253 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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} +set escapedobjdir [string_to_regexp ${objdir}] +set envirodir [string_to_regexp ${objdir}/${subdir}] + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi2-basics.exp + return -1 +} + +# 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" \ + "200\\\^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 objdir + global subdir + global envirodir + + # Add to the search directories, display, then reset back to default + # Tests: + # -environment-directory arg + # -environment-directory + # -environment-directory -r + + mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \ + "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory arg operation" + + mi_gdb_test "203-environment-directory" \ + "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \ + "environment-directory empty-string operation" + + mi_gdb_test "204-environment-directory -r" \ + "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \ + "environment-directory operation" + +#exp_internal 0 +} + +proc test_cwd_specification {} { + global mi_gdb_prompt + global objdir + global subdir + global escapedobjdir + + # Change the working directory, then print the current working directory + # Tests: + # -environment-cd ${objdir} + # -environment-pwd + + mi_gdb_test "205-environment-cd ${objdir}" \ + "205\\\^done" \ + "environment-cd arg operation" + + mi_gdb_test "206-environment-pwd" \ + "206\\\^done,cwd=\"${escapedobjdir}\"" \ + "environment-pwd operation" +} + +proc test_path_specification {} { + global mi_gdb_prompt + global orig_path + global objdir + global subdir + global escapedobjdir + global envirodir + + # Add to the path, display, then reset + # Tests: + # -environment-path + # -environment-path dir1 dir2 + # -environment-path -r dir + # -environment-path -r + + 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 + } + } + + set orig_path [string_to_regexp ${orig_path}] + set pathdir [string_to_regexp ${objdir}/${subdir}] + + mi_gdb_test "207-environment-path" \ + "207\\\^done,path=\"$orig_path\"" \ + "environment-path no-args operation" + + mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \ + "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \ + "environment-path dir1 dir2 operation" + + mi_gdb_test "209-environment-path -r $objdir" \ + "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \ + "environment-path -r dir operation" + + mi_gdb_test "210-environment-path -r" \ + "210\\\^done,path=\"$orig_path\"" \ + "environment-path -r operation" + +} + +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 Index: mi-console.c =================================================================== --- mi-console.c (nonexistent) +++ mi-console.c (revision 157) @@ -0,0 +1,20 @@ +void +hello () +{ + char *hello = "Hello \\\"!\r\n"; + int i; + for (i = 0; hello[i]; i++) + write (1, hello + i, 1); +} + +int +main () +{ + hello (); +} +/* +Local variables: +change-log-default-name: "ChangeLog-mi" +End: +*/ +
mi-console.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: gdb792.exp =================================================================== --- gdb792.exp (nonexistent) +++ gdb792.exp (revision 157) @@ -0,0 +1,92 @@ +# Copyright 2002, 2003, 2007, 2008 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 3 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, see . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# test gdb/792 +# + +if { [skip_cplus_tests] } { continue } + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile gdb792 +set srcfile "$testfile.cc" +set binfile $objdir/$subdir/$testfile + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} { + untested gdb792.exp + return -1 +} + +# Test that children of classes are properly reported + +# Run to main +mi_run_to_main + +mi_gdb_test "-var-create - * a" \ + "(&\".*\"\r\n)*\\^done,name=\"var1\",numchild=\"3\",value=\".*\",type=\"A\"" \ + "create var for class A" + +mi_gdb_test "-var-list-children var1" \ + "(&\".*\"\r\n)*\\^done,numchild=\"3\",children=\\\[child=\{name=\"var1\.public\",exp=\"public\",numchild=\"2\"\},child=\{name=\"var1\.private\",exp=\"private\",numchild=\"2\"\},child=\{name=\"var1\.protected\",exp=\"protected\",numchild=\"2\"\}\\\]" \ + "list children of class A" + +mi_gdb_test "-var-list-children var1.public" \ + "(&\".*\"\r\n)*\\^done,numchild=\"2\",children=\\\[child=\{name=\"var1\.public\.x\",exp=\"x\",numchild=\"0\",type=\"int\"\},child=\{name=\"var1\.public\.buffer\",exp=\"buffer\",numchild=\"10\",type=\"char \\\[10\\\]\"\}\\\]" \ + "list children of A.public" + +mi_gdb_test "-var-list-children var1.private" \ + "(&\".*\"\r\n)*\\^done,numchild=\"2\",children=\\\[child=\{name=\"var1\.private\.u\",exp=\"u\",numchild=\"0\",type=\"int\"\},child=\{name=\"var1\.private\.z\",exp=\"z\",numchild=\"0\",type=\"float\"\}\\\]" \ + "list children of A.private" + +mi_gdb_test "-var-list-children var1.protected" \ + "(&\".*\"\r\n)*\\^done,numchild=\"2\",children=\\\[child=\{name=\"var1\.protected\.y\",exp=\"y\",numchild=\"0\",type=\"int\"\},child=\{name=\"var1\.protected\.b\",exp=\"b\",numchild=\"2\",type=\"B\"\}\\\]" \ + "list children of A.protected" + +mi_gdb_test "-var-list-children var1.protected.b" \ + "(&\".*\"\r\n)*\\^done,numchild=\"2\",children=\\\[child=\{name=\"var1\.protected\.b\.public\",exp=\"public\",numchild=\"2\"\},child=\{name=\"var1\.protected\.b\.private\",exp=\"private\",numchild=\"1\"\}\\\]" \ + "list children of A.protected.b" + +mi_gdb_test "-var-list-children var1.protected.b.public" \ + "(&\".*\"\r\n)*\\^done,numchild=\"2\",children=\\\[child=\{name=\"var1\.protected\.b\.public\.bx\",exp=\"bx\",numchild=\"0\",type=\"int\"\},child=\{name=\"var1\.protected\.b\.public\.by\",exp=\"by\",numchild=\"0\",type=\"int\"\}\\\]" \ + "list children of A.protected.b.public" + +mi_gdb_test "-var-list-children var1.protected.b.private" \ + "(&\".*\"\r\n)*\\^done,numchild=\"1\",children=\\\[child=\{name=\"var1\.protected\.b\.private\.k\",exp=\"k\",numchild=\"0\",type=\"int\"\}\\\]" \ + "list children of A.protected.b.private" + +mi_gdb_test "-var-create - * c" \ + "(&\".*\"\r\n)*\\^done,name=\"var2\",numchild=\"3\",value=\".*\",type=\"C\"" \ + "create var for class C which has baseclass A" + +mi_gdb_test "-var-list-children var2" \ + "(&\".*\"\r\n)*\\^done,numchild=\"3\",children=\\\[child=\{name=\"var2\.A\",exp=\"A\",numchild=\"3\",type=\"A\"\},child=\{name=\"var2\.public\",exp=\"public\",numchild=\"1\"\},child=\{name=\"var2\.private\",exp=\"private\",numchild=\"1\"\}\\\]" \ + "list children of class C" + +mi_gdb_exit +return 0 Index: mi-until.exp =================================================================== --- mi-until.exp (nonexistent) +++ mi-until.exp (revision 157) @@ -0,0 +1,130 @@ +# Copyright 1999, 2000, 2001, 2005, 2007, 2008 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-until.exp + return -1 +} + +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 fullname_syntax srcfile + + 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"12\"\}\r\n$mi_gdb_prompt$" { + pass "until after while loop" + } + -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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"9\"\}\r\n$mi_gdb_prompt$" { + kfail gdb/2104 "until after while loop (went backwards)" + } + 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\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(23|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 Index: mi2-hack-cli.exp =================================================================== --- mi2-hack-cli.exp (nonexistent) +++ mi2-hack-cli.exp (revision 157) @@ -0,0 +1,39 @@ +# Copyright 1999, 2001, 2003, 2007, 2008 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 3 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, see . + +# 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 Index: mi-file-transfer.exp =================================================================== --- mi-file-transfer.exp (nonexistent) +++ mi-file-transfer.exp (revision 157) @@ -0,0 +1,99 @@ +# This testcase is part of GDB, the GNU debugger. +# Copyright 2007, 2008 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 3 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, see . + +# Test gdbserver monitor commands. + +load_lib gdbserver-support.exp +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +if { [skip_gdbserver_tests] } { + return 0 +} + +set testfile "basics" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested mi-file-transfer.exp + return -1 +} + +gdb_exit +if [mi_gdb_start] { + continue +} +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_file_cmd ${binfile} + +proc mi_gdbserver_run { } { + mi_gdb_test "kill" ".*" "" + + set res [gdbserver_spawn ""] + set protocol [lindex $res 0] + set gdbport [lindex $res 1] + + if { [mi_gdb_target_cmd $protocol $gdbport] != 0 } { + return -1 + } + + return 0 +} + +proc test_file_transfer { filename description } { + mi_gdb_test "-target-file-put \"$filename\" \"down-server\"" \ + "\\^done" "put $description" + mi_gdb_test "-target-file-get \"down-server\" \"up-server\"" \ + "\\^done" "get $description" + + if { ![is_remote target] } { + # If we can check the target copy of the file, do that too. + # This should catch symmetric errors in upload and download. + set result [remote_exec host "cmp -s $filename down-server"] + if { [lindex $result 0] == 0 } { + pass "compare intermediate $description" + } else { + fail "compare intermediate $description" + } + } + + set result [remote_exec host "cmp -s $filename up-server"] + if { [lindex $result 0] == 0 } { + pass "compare $description" + } else { + fail "compare $description" + } + + mi_gdb_test "-target-file-delete \"down-server\"" \ + "\\^done" "deleted $description" + + if { ![is_remote target] } { + if { ! [remote_file target exists down-server] } { + pass "verified deleted $description" + } else { + fail "verified deleted $description" + } + } + + catch { file delete up-server } +} + +mi_gdbserver_run + +test_file_transfer "$binfile" "binary file" + +mi_gdb_exit Index: mi2-var-block.exp =================================================================== --- mi2-var-block.exp (nonexistent) +++ mi2-var-block.exp (revision 157) @@ -0,0 +1,183 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-var-block.exp + return -1 +} + +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\",value=\".*\",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" \ + [gdb_get_line_number "foo = 123;"] \ + "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\",value=\".*\",type=\"int\"" \ + "create local variable foo" + +# step to "foo2 = 123;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "foo2 = 123;"] \ + "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" \ + [gdb_get_line_number "foo = 321;"] \ + "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\",value=\".*\",type=\"int\"" \ + "create local variable inner_foo" + +# step to "foo2 = 0;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "foo2 = 0;"] \ + "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\",value=\".*\",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" \ + [gdb_get_line_number "foo = 0;"] \ + "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" \ + [gdb_get_line_number "cb = 21;"] \ + "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 Index: mi2-break.exp =================================================================== --- mi2-break.exp (nonexistent) +++ mi2-break.exp (revision 157) @@ -0,0 +1,162 @@ +# Copyright 1999, 2001, 2003, 2004, 2006, 2007, 2008 +# 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-break.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# Locate line numbers in basics.c. +set line_callee4_head [gdb_get_line_number "callee4 ("] +set line_callee4_body [expr $line_callee4_head + 2] +set line_callee3_head [gdb_get_line_number "callee3 ("] +set line_callee3_body [expr $line_callee3_head + 2] +set line_callee2_head [gdb_get_line_number "callee2 ("] +set line_callee2_body [expr $line_callee2_head + 2] +set line_callee1_head [gdb_get_line_number "callee1 ("] +set line_callee1_body [expr $line_callee1_head + 2] +set line_main_head [gdb_get_line_number "main ("] +set line_main_body [expr $line_main_head + 2] + +set fullname "fullname=\"${fullname_syntax}${srcfile}\"" + +proc test_tbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + global line_callee4_head line_callee4_body + global line_callee3_head line_callee3_body + global line_callee2_head line_callee2_body + global line_callee1_head line_callee1_body + global line_main_head line_main_body + global fullname + + # 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:$line_callee3_head + # -break-insert -t srcfile:$line_callee4_head + # -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\",${fullname},line=\"$line_main_body\",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\",${fullname},line=\"$line_callee2_body\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:callee2" + + mi_gdb_test "444-break-insert -t basics.c:$line_callee3_head" \ + "444\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",${fullname},line=\"$line_callee3_head\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:\$line_callee3_body" + + # Getting the quoting right is tricky. That is "\"\":$line_callee4_head" + mi_gdb_test "555-break-insert -t \"\\\"${srcfile}\\\":$line_callee4_head\"" \ + "555\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",${fullname},line=\"$line_callee4_head\",times=\"0\"\}" \ + "insert temp breakpoint at \"\":\$line_callee4_head" + + 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\",${fullname},line=\"$line_main_body\",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 + global line_callee4_head line_callee4_body + global line_callee3_head line_callee3_body + global line_callee2_head line_callee2_body + global line_callee1_head line_callee1_body + global line_main_head line_main_body + global fullname + + # 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\",${fullname},line=\"$line_main_body\"\}" \ + "break-insert -r operation" + + setup_xfail "*-*-*" + mi_gdb_test "133-break-insert -r callee2" \ + "133\\^done,bkpt=\{number=\"6\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee2_body\"\}" \ + "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\",${fullname},line=\"$line_callee1_body\"\},bkpt=\{number=\"8\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee2_body\"\},bkpt=\{number=\"9\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee3_body\"\},bkpt=\{number=\"10\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee4_body\"\}" \ + "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\",${fullname},line=\"$line_callee1_body\"\},bkpt=\{number=\"12\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee2_body\"\},bkpt=\{number=\"13\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee3_body\"\},bkpt=\{number=\"14\",addr=\"$hex\",file=\".*basics.c\",${fullname},line=\"$line_callee4_body\"\}" \ + "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\",${fullname},line=\"$line_main_body\",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 Index: mi-var-invalidate.exp =================================================================== --- mi-var-invalidate.exp (nonexistent) +++ mi-var-invalidate.exp (revision 157) @@ -0,0 +1,121 @@ +# Copyright 2007, 2008 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 3 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, see . +# +# Test essential Machine interface (MI) operations +# +# Verify that once binary file has changed, GDB correctly handles +# previously defined MI variables. +# + + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +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}] != "" } { + untested mi-var-invalidate.exp + return -1 +} +# Just change the output binary. +set binfile_bis ${objdir}/${subdir}/${testfile}_bis +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_bis}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi-var-invalidate.exp + return -1 +} + +set testfile2 "basics" +set srcfile2 ${testfile2}.c +set binfile2 ${objdir}/${subdir}/${testfile2} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi-var-invalidate.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# Desc: Create global variable. +mi_gdb_test "-var-create global_simple * global_simple" \ + "\\^done,name=\"global_simple\",numchild=\"6\",value=\".*\",type=\"simpleton\"" \ + "create global variable" + +mi_runto do_locals_tests + +# Desc: create local variables +mi_gdb_test "-var-create linteger * linteger" \ + "\\^done,name=\"linteger\",numchild=\"0\",value=\".*\",type=\"int\"" \ + "create local variable linteger" + +# +# Reload the same binary. +# Global variable should remain, local should be invalidated. +# +mi_delete_breakpoints +mi_gdb_load ${binfile_bis} +mi_runto main + +# Check local variable is "invalid". +mi_gdb_test "-var-update linteger" \ + "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\"\}\\\]" \ + "linteger not anymore in scope due to binary changes" + +mi_gdb_test "-var-info-type linteger" \ + "\\^done,type=\"\"" \ + "no type for invalid variable linteger (1)" + +# Check global variable is still correct. +mi_gdb_test "-var-update global_simple" \ + "\\^done,changelist=\\\[\]" \ + "global_simple still alive" + +mi_gdb_test "-var-info-type global_simple" \ + "\\^done,type=\"simpleton\"" \ + "type simpleton for valid variable global_simple" + + +# +# Load an other binary. +# All variables must be invalidated. +# +mi_delete_breakpoints +mi_gdb_load ${binfile2} +# Check local variable are "invalid" +mi_gdb_test "-var-update linteger" \ + "\\^done,changelist=\\\[\{name=\"linteger\",in_scope=\"invalid\"\}\\\]" \ + "linteger not valid anymore due to binary changes" + +mi_gdb_test "-var-info-type linteger" \ + "\\^done,type=\"\"" \ + "no type for invalid variable linteger (2)" + +# Check global variable are still correct. +mi_gdb_test "-var-update global_simple" \ + "\\^done,changelist=\\\[\{name=\"global_simple\",in_scope=\"invalid\"\}\\\]" \ + "global_simple not anymore in scope due to binary changes" + +mi_gdb_test "-var-info-type global_simple" \ + "\\^done,type=\"\"" \ + "no type for invalid variable global_simple" + +mi_gdb_exit +return 0 Index: mi-read-memory.c =================================================================== --- mi-read-memory.c (nonexistent) +++ mi-read-memory.c (revision 157) @@ -0,0 +1,20 @@ +static char bytes[256]; + +static short shorts[256]; + +static void +initialize (void) +{ + int i; + for (i = 0; i < sizeof (bytes); i++) + { + bytes[i] = i; + shorts[i] = i * 2; + } +} + +int +main () +{ + initialize (); +}
mi-read-memory.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-pthreads.exp =================================================================== --- mi-pthreads.exp (nonexistent) +++ mi-pthreads.exp (revision 157) @@ -0,0 +1,220 @@ +# Copyright 2002, 2003, 2004, 2005, 2007, 2008 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 3 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, see . + +# 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=mi" + +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/mi-$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 + Index: mi-pending.c =================================================================== --- mi-pending.c (nonexistent) +++ mi-pending.c (revision 157) @@ -0,0 +1,34 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007, 2008 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include + +int k = 0; + +extern void pendfunc (int x); + +int main() +{ + pendfunc (3); /* break main here */ + pendfunc (4); + k = 1; + pendfunc (3); + return 0; +}
mi-pending.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: var-cmd.c =================================================================== --- var-cmd.c (nonexistent) +++ var-cmd.c (revision 157) @@ -0,0 +1,419 @@ +/* Copyright 1999, 2004, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 3 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, see . */ + +#include +#include + +struct _simple_struct { + int integer; + unsigned int unsigned_integer; + char character; + signed char signed_character; + char *char_ptr; + int array_of_10[10]; +}; + +typedef struct _simple_struct simpleton; + +simpleton global_simple; + +enum foo { + bar = 1, + baz +}; + +typedef enum foo efoo; + +union named_union +{ + int integer; + char *char_ptr; +}; + +typedef struct _struct_decl { + int integer; + char character; + char *char_ptr; + long long_int; + int **int_ptr_ptr; + long long_array[10]; + + void (*func_ptr) (void); + struct _struct_decl (*func_ptr_struct) (int, char *, long); + struct _struct_decl *(*func_ptr_ptr) (int, char *, long); + union { + int a; + char *b; + long c; + enum foo d; + } u1; + + struct { + union { + struct { + int d; + char e[10]; + int *(*func) (void); + efoo foo; + } u1s1; + + long f; + struct { + char array_ptr[2]; + int (*func) (int, char *); + } u1s2; + } u2; + + int g; + char h; + long i[10]; + } s2; +} weird_struct; + +struct _struct_n_pointer { + char ****char_ptr; + long ****long_ptr; + struct _struct_n_pointer *ptrs[3]; + struct _struct_n_pointer *next; +}; + +void do_locals_tests (void); +void do_block_tests (void); +void subroutine1 (int, long *); +void nothing (void); +void do_children_tests (void); +void do_special_tests (void); +void incr_a (char); + +void incr_a (char a) +{ + int b; + b = a; +} + +int array[] = {1,2,3}; +int array2[] = {4,5,6}; +int *array_ptr = array; + +void +do_locals_tests () +{ + int linteger = 0; + int *lpinteger = 0; + char lcharacter[2] = { 0, 0 }; + char *lpcharacter = 0; + long llong = 0; + long *lplong = 0; + float lfloat = 0; + float *lpfloat = 0; + double ldouble = 0; + double *lpdouble = 0; + struct _simple_struct lsimple; + struct _simple_struct *lpsimple; + void (*func) (void); + + /* Simple assignments */ + linteger = 1234; + lpinteger = &linteger; + lcharacter[0] = 'a'; + lpcharacter = lcharacter; + llong = 2121L; + lplong = &llong; + lfloat = 2.1; + lpfloat = &lfloat; + ldouble = 2.718281828459045; + lpdouble = &ldouble; + lsimple.integer = 1234; + lsimple.unsigned_integer = 255; + lsimple.character = 'a'; + lsimple.signed_character = 21; + lsimple.char_ptr = lcharacter; + lpsimple = &lsimple; + func = nothing; + + /* Check pointers */ + linteger = 4321; + lcharacter[0] = 'b'; + llong = 1212L; + lfloat = 1.2; + ldouble = 5.498548281828172; + lsimple.integer = 255; + lsimple.unsigned_integer = 4321; + lsimple.character = 'b'; + lsimple.signed_character = 0; + + subroutine1 (linteger, &llong); +} + +void +nothing () +{ +} + +void +subroutine1 (int i, long *l) +{ + global_simple.integer = i + 3; + i = 212; + *l = 12; +} + +void +do_block_tests () +{ + int cb = 12; + + { + int foo; + foo = 123; + { + int foo2; + foo2 = 123; + { + int foo; + foo = 321; + } + foo2 = 0; + } + foo = 0; + } + + cb = 21; +} + +void +do_children_tests (void) +{ + weird_struct *weird; + struct _struct_n_pointer *psnp; + struct _struct_n_pointer snp0, snp1, snp2; + char a0[2] = {}, *a1, **a2, ***a3; + char b0[2] = {}, *b1, **b2, ***b3; + char c0[2] = {}, *c1, **c2, ***c3; + long z0, *z1, **z2, ***z3; + long y0, *y1, **y2, ***y3; + long x0, *x1, **x2, ***x3; + int *foo; + int bar; + + /* Avoid pointing into NULL, as that is editable on some + systems. */ + int dummy; + int *dummy_ptr = &dummy; + + struct _struct_decl struct_declarations = { 0, 0, NULL, 0, &dummy_ptr }; + weird = &struct_declarations; + + struct_declarations.integer = 123; + weird->char_ptr = "hello"; + bar = 2121; + foo = &bar; + struct_declarations.int_ptr_ptr = &foo; + weird->long_array[0] = 1234; + struct_declarations.long_array[1] = 2345; + weird->long_array[2] = 3456; + 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; + + weird->func_ptr = nothing; + + /* Struct/pointer/array tests */ + a0[0] = '0'; + a1 = a0; + a2 = &a1; + a3 = &a2; + b0[0] = '1'; + b1 = b0; + b2 = &b1; + b3 = &b2; + c0[0] = '2'; + c1 = c0; + c2 = &c1; + c3 = &c2; + z0 = 0xdead + 0; + z1 = &z0; + z2 = &z1; + z3 = &z2; + y0 = 0xdead + 1; + y1 = &y0; + y2 = &y1; + y3 = &y2; + x0 = 0xdead + 2; + x1 = &x0; + x2 = &x1; + x3 = &x2; + snp0.char_ptr = &a3; + snp0.long_ptr = &z3; + snp0.ptrs[0] = &snp0; + snp0.ptrs[1] = &snp1; + snp0.ptrs[2] = &snp2; + snp0.next = &snp1; + snp1.char_ptr = &b3; + snp1.long_ptr = &y3; + snp1.ptrs[0] = &snp0; + snp1.ptrs[1] = &snp1; + snp1.ptrs[2] = &snp2; + snp1.next = &snp2; + snp2.char_ptr = &c3; + snp2.long_ptr = &x3; + snp2.ptrs[0] = &snp0; + snp2.ptrs[1] = &snp1; + snp2.ptrs[2] = &snp2; + snp2.next = 0x0; + psnp = &snp0; + snp0.char_ptr = &b3; + snp1.char_ptr = &c3; + snp2.char_ptr = &a3; + snp0.long_ptr = &y3; + snp1.long_ptr = &x3; + snp2.long_ptr = &z3; + {int a = 0;} +} + +void +do_special_tests (void) +{ + union named_union u; + union { + int a; + char b; + long c; + } anonu; + struct _simple_struct s; + struct { + int a; + char b; + long c; + } anons; + enum foo e; + enum { A, B, C } anone; + int array[21]; + int a; + + a = 1; + u.integer = a; + anonu.a = a; + s.integer = a; + anons.a = a; + e = bar; + anone = A; + incr_a(2); +} + +void do_frozen_tests () +{ + /*: BEGIN: frozen :*/ + struct { + int i; + struct { + int j; + int k; + } nested; + } v1 = {1, {2, 3}}; + + int v2 = 4; + /*: + mi_create_varobj V1 v1 "create varobj for v1" + mi_create_varobj V2 v2 "create varobj for v2" + + mi_list_varobj_children "V1" { + {"V1.i" "i" "0" "int"} + {"V1.nested" "nested" "2" "struct {...}"} + } "list children of v1" + + mi_list_varobj_children "V1.nested" { + {"V1.nested.j" "j" "0" "int"} + {"V1.nested.k" "k" "0" "int"} + } "list children of v1.nested" + + mi_check_varobj_value V1.i 1 "check V1.i: 1" + mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2" + mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3" + mi_check_varobj_value V2 4 "check V2: 4" + :*/ + v2 = 5; + /*: + mi_varobj_update * {V2} "update varobjs: V2 changed" + set_frozen V2 1 + :*/ + v2 = 6; + /*: + mi_varobj_update * {} "update varobjs: nothing changed" + mi_check_varobj_value V2 5 "check V2: 5" + mi_varobj_update V2 {V2} "update V2 explicitly" + mi_check_varobj_value V2 6 "check V2: 6" + :*/ + v1.i = 7; + v1.nested.j = 8; + v1.nested.k = 9; + /*: + set_frozen V1 1 + mi_varobj_update * {} "update varobjs: nothing changed" + mi_check_varobj_value V1.i 1 "check V1.i: 1" + mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2" + mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3" + # Check that explicit update for elements of structures + # works. + # Update v1.j + mi_varobj_update V1.nested.j {V1.nested.j} "update V1.nested.j" + mi_check_varobj_value V1.i 1 "check V1.i: 1" + mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8" + mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3" + # Update v1.nested, check that children is updated. + mi_varobj_update V1.nested {V1.nested.k} "update V1.nested" + mi_check_varobj_value V1.i 1 "check V1.i: 1" + mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8" + mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9" + # Update v1.i + mi_varobj_update V1.i {V1.i} "update V1.i" + mi_check_varobj_value V1.i 7 "check V1.i: 7" + :*/ + v1.i = 10; + v1.nested.j = 11; + v1.nested.k = 12; + /*: + # Check that unfreeze itself does not updates the values. + set_frozen V1 0 + mi_check_varobj_value V1.i 7 "check V1.i: 7" + mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8" + mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9" + mi_varobj_update V1 {V1.i V1.nested.j V1.nested.k} "update V1" + mi_check_varobj_value V1.i 10 "check V1.i: 10" + mi_check_varobj_value V1.nested.j 11 "check V1.nested.j: 11" + mi_check_varobj_value V1.nested.k 12 "check V1.nested.k: 12" + :*/ + + /*: END: frozen :*/ +} + +int +main (int argc, char *argv []) +{ + do_locals_tests (); + do_block_tests (); + do_children_tests (); + do_special_tests (); + do_frozen_tests (); + exit (0); +} + +
var-cmd.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: until.c =================================================================== --- until.c (nonexistent) +++ until.c (revision 157) @@ -0,0 +1,26 @@ +foo (void) +{ + int i, x, y, z; + + x = 0; + y = 1; + i = 0; + + while (i < 2) + i++; + + x = i; + y = 2 * x; + z = x + y; + y = x + z; + x = 9; + y = 10; +} + +main () +{ + int a = 1; + foo (); + a += 2; + return 0; +}
until.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-var-block.exp =================================================================== --- mi-var-block.exp (nonexistent) +++ mi-var-block.exp (revision 157) @@ -0,0 +1,183 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-var-block.exp + return -1 +} + +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\",value=\".*\",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" \ + [gdb_get_line_number "foo = 123;"] \ + "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\",value=\".*\",type=\"int\"" \ + "create local variable foo" + +# step to "foo2 = 123;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "foo2 = 123;"] \ + "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" \ + [gdb_get_line_number "foo = 321;"] \ + "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\",value=\".*\",type=\"int\"" \ + "create local variable inner_foo" + +# step to "foo2 = 0;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "foo2 = 0;"] \ + "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\",value=\".*\",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" \ + [gdb_get_line_number "foo = 0;"] \ + "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" \ + [gdb_get_line_number "cb = 21;"] \ + "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 Index: mi-var-cp.cc =================================================================== --- mi-var-cp.cc (nonexistent) +++ mi-var-cp.cc (revision 157) @@ -0,0 +1,216 @@ +/* Copyright 2006, 2007, 2008 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 3 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, see . +*/ + +void reference_update_tests () +{ + /*: BEGIN: reference_update :*/ + int x = 167; + /*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/ + int& rx = x; + /*: mi_varobj_update RX {RX} "update RX (1)" + mi_check_varobj_value RX 167 "check RX: expect 167" + :*/ + x = 567; + /*: mi_varobj_update RX {RX} "update RX (2)" + mi_check_varobj_value RX 567 "check RX: expect 567" + :*/ + x = 567; + /*: mi_varobj_update RX {} "update RX (3)" + mi_delete_varobj RX "delete RX" + :*/ + /* Dummy assignment to keep 'x' in scope. */ + x = 444; + + /*: END: reference_update :*/ +} + +struct S { int i; int j; }; +struct S2 : S {}; + +int base_in_reference_test (S2& s2) +{ + /*: BEGIN: base_in_reference :*/ + return s2.i; + /*: + mi_create_varobj "S2" "s2" "create varobj for s2" + mi_list_varobj_children "S2" { + {"S2.S" "S" "1" "S"} + } "list children of s2" + mi_list_varobj_children "S2.S" { + {"S2.S.public" "public" "2"} + } "list children of s2.s" + mi_list_varobj_children "S2.S.public" { + {"S2.S.public.i" "i" "0" "int"} + {"S2.S.public.j" "j" "0" "int"} + } "list children of s2.s.public" + + mi_check_varobj_value "S2.S.public.i" "67" "check S2.S.public.i" + mi_check_varobj_value "S2.S.public.j" "89" "check S2.S.public.j" + mi_delete_varobj S2 "delete S2" + + :*/ + /*: END: base_in_reference :*/ +} + +void base_in_reference_test_main () +{ + S2 s; + s.i = 67; + s.j = 89; + base_in_reference_test (s); +} + +int reference_to_pointer () +{ + /*: BEGIN: reference_to_pointer :*/ + S s, *ptr_s, *& rptr_s = ptr_s; + s.i = 67; + s.j = 89; + ptr_s = &s; + /*: + mi_create_varobj RPTR rptr_s "create varobj for rptr_s" + + mi_list_varobj_children RPTR {{RPTR.public public 2}} \ + "list public child of RPTR" + + mi_list_varobj_children RPTR.public \ + {{RPTR.public.i i 0 int} + {RPTR.public.j j 0 int}} "list children of reference to pointer" + + mi_check_varobj_value RPTR.public.i 67 "check i member" + mi_check_varobj_value RPTR.public.j 89 "check j member" + mi_delete_varobj RPTR "delete RPTR" + :*/ + return 99; + /*: END: reference_to_pointer :*/ +} + +int reference_to_struct () +{ + /*: BEGIN: reference_to_struct :*/ + S s = {7, 8}; + S& r = s; + /*: + mi_create_varobj S s "create varobj for s" + mi_create_varobj R r "create varobj for s" + mi_gdb_test "-var-show-attributes S" \ + "\\^done,attr=\"noneditable\"" \ + "check attributes of S" + mi_gdb_test "-var-show-attributes R" \ + "\\^done,attr=\"noneditable\"" \ + "check attributes of R" + :*/ + s.i = 56; + /*: mi_varobj_update * [] "-var-update should not list structure varobjs" + :*/ + return 99; + /*: END: reference_to_struct :*/ +} + +struct Base1 +{ + int i; +}; + +struct Base2 +{ + int i; +}; + +struct Derived : public Base1, public Base2 +{ + int i; +}; + +/* Test for the -var-info-path-expression command. Although + said command is not specific to C++, it's of more importance + to C++ than to C, so we test it in mi-var-cp test. */ +int path_expression () +{ + /*: BEGIN: path_expression :*/ + int i = 10; + int *ip = &i; + /*: mi_create_varobj IP ip "create varobj for ip" + mi_list_varobj_children IP {{IP.\\*ip \\*ip 0 int}} "list children of IP" + mi_gdb_test "-var-info-path-expression IP.*ip" \ + "\\^done,path_expr=\"\\*\\(ip\\)\"" \ + "-var-info-path-expression IP.*ip" + :*/ + Derived d; + Derived *dp = &d; + /*: mi_create_varobj DP dp "create varobj for dp" + mi_list_varobj_children DP \ + {{DP.Base1 Base1 1 Base1} \ + {DP.Base2 Base2 1 Base2} \ + {DP.public public 1}} "list children of DP" + mi_gdb_test "-var-info-path-expression DP.Base1" \ + "\\^done,path_expr=\"\\(\\*\\(Base1\\*\\) dp\\)\"" \ + "-var-info-path-expression DP.Base1" + mi_list_varobj_children DP.public { \ + {DP.public.i i 0 int} \ + } "list children of DP.public" + mi_gdb_test "-var-info-path-expression DP.public.i" \ + "\\^done,path_expr=\"\\(\\(dp\\)->i\\)\"" \ + "-var-info-path-expression DP.public.i" + mi_list_varobj_children DP.Base1 { \ + {DP.Base1.public public 1} \ + } "list children of DP.Base1" + mi_list_varobj_children DP.Base1.public { \ + {DP.Base1.public.i i 0 int} \ + } "list children of DP.Base1.public" + mi_gdb_test "-var-info-path-expression DP.Base1.public.i" \ + "\\^done,path_expr=\"\\(\\(\\(\\*\\(Base1\\*\\) dp\\)\\).i\\)\"" \ + "-var-info-path-expression DP.Base1.public.i" + + mi_gdb_test "-var-info-path-expression DP.public" \ + "\\^done,path_expr=\"\"" \ + "-var-info-path-expression DP.public" + + mi_create_varobj D d "create varobj for d" + mi_list_varobj_children D \ + {{D.Base1 Base1 1 Base1} \ + {D.Base2 Base2 1 Base2} \ + {D.public public 1}} "list children of D" + mi_gdb_test "-var-info-path-expression D.Base1" \ + "\\^done,path_expr=\"\\(\\(Base1\\) d\\)\"" \ + "-var-info-path-expression D.Base1" + :*/ + int array[4] = {1,2,3}; + array[3] = 10; + /*: mi_create_varobj A array "create varobj for array" + mi_list_varobj_children A { \ + {A.0 0 0 int} + {A.1 1 0 int} + {A.2 2 0 int} + {A.3 3 0 int}} "list children of A" + mi_gdb_test "-var-info-path-expression A.2" \ + "\\^done,path_expr=\"\\(array\\)\\\[2\\\]\"" \ + "-var-info-path-expression A.2" + :*/ + + return 99; + /*: END: path_expression :*/ +} + +int main () +{ + reference_update_tests (); + base_in_reference_test_main (); + reference_to_pointer (); + reference_to_struct (); + path_expression (); + return 0; +} Index: mi2-syn-frame.exp =================================================================== --- mi2-syn-frame.exp (nonexistent) +++ mi2-syn-frame.exp (revision 157) @@ -0,0 +1,120 @@ +# Copyright 2002, 2003, 2005, 2007, 2008 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 3 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, see . + +# 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}] != "" } { + untested mi2-syn-frame.exp + return -1 +} + +set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*" + +mi_gdb_exit +mi_gdb_start +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\"\}" \ + "insert breakpoint foo" + + +# +# 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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"\"\},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}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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + + +# +# 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\"\}" \ + "insert breakpoint subroutine" + +mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \ + "\\&\"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\\).\"" \ + "evaluate expression have_a_very_merry_interrupt" + +# 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,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=\"\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + + +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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + +# +# Call bar() by hand, which should get an exception while running. +# + +mi_gdb_test "410-data-evaluate-expression bar()" "\\&\"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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception" + +mi_gdb_exit + +return 0 Index: mi2-console.exp =================================================================== --- mi2-console.exp (nonexistent) +++ mi2-console.exp (revision 157) @@ -0,0 +1,96 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-console.exp + return -1 +} + +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)" + } +} + +if { ![target_info exists gdb,noinferiorio] } { + 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 Index: mi-break.exp =================================================================== --- mi-break.exp (nonexistent) +++ mi-break.exp (revision 157) @@ -0,0 +1,206 @@ +# Copyright 1999, 2001, 2004, 2006, 2007, 2008 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-break.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# Locate line numbers in basics.c. +set line_callee4_head [gdb_get_line_number "callee4 ("] +set line_callee4_body [expr $line_callee4_head + 2] +set line_callee3_head [gdb_get_line_number "callee3 ("] +set line_callee3_body [expr $line_callee3_head + 2] +set line_callee2_head [gdb_get_line_number "callee2 ("] +set line_callee2_body [expr $line_callee2_head + 2] +set line_callee1_head [gdb_get_line_number "callee1 ("] +set line_callee1_body [expr $line_callee1_head + 2] +set line_main_head [gdb_get_line_number "main ("] +set line_main_body [expr $line_main_head + 2] + +set fullname "fullname=\"${fullname_syntax}${srcfile}\"" + +proc test_tbreak_creation_and_listing {} { + global mi_gdb_prompt + global srcfile + global hex + global line_callee4_head line_callee4_body + global line_callee3_head line_callee3_body + global line_callee2_head line_callee2_body + global line_callee1_head line_callee1_body + global line_main_head line_main_body + global fullname + + # 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:$line_callee3_head + # -break-insert -t srcfile:$line_callee4_head + # -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\",${fullname},line=\"$line_main_body\",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\",${fullname},line=\"$line_callee2_body\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:callee2" + + mi_gdb_test "444-break-insert -t basics.c:$line_callee3_head" \ + "444\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee3\",file=\".*basics.c\",${fullname},line=\"$line_callee3_head\",times=\"0\"\}" \ + "insert temp breakpoint at basics.c:\$line_callee3_body" + + # Getting the quoting right is tricky. That is "\"\":$line_callee4_head" + mi_gdb_test "555-break-insert -t \"\\\"${srcfile}\\\":$line_callee4_head\"" \ + "555\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",${fullname},line=\"$line_callee4_head\",times=\"0\"\}" \ + "insert temp breakpoint at \"\":\$line_callee4_head" + + 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\",${fullname},line=\"$line_main_body\",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 + global line_callee4_head line_callee4_body + global line_callee3_head line_callee3_body + global line_callee2_head line_callee2_body + global line_callee1_head line_callee1_body + global line_main_head line_main_body + + # 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=\"$line_main_body\"\}" \ + "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=\"$line_callee2_body\"\}" \ + "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=\"$line_callee1_body\"\},bkpt=\{number=\"8\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee2_body\"\},bkpt=\{number=\"9\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee3_body\"\},bkpt=\{number=\"10\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee4_body\"\}" \ + "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=\"$line_callee1_body\"\},bkpt=\{number=\"12\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee2_body\"\},bkpt=\{number=\"13\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee3_body\"\},bkpt=\{number=\"14\",addr=\"$hex\",file=\".*basics.c\",line=\"$line_callee4_body\"\}" \ + "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=\"$line_main_body\",times=\"0\"\},.*\}\\\]\}" \ + "list of breakpoints" + + mi_gdb_test "177-break-delete" \ + "177\\^done" \ + "delete temp breakpoints" +} + +proc test_ignore_count {} { + global mi_gdb_prompt + + mi_gdb_test "-break-insert -i 1 callme" \ + "\\^done.*ignore=\"1\".*" \ + "insert breakpoint with ignore count at callme" + + mi_run_cmd + + gdb_expect { + -re ".*func=\"callme\".*args=\\\[\{name=\"i\",value=\"2\"\}\\\].*\r\n$mi_gdb_prompt$" { + pass "run to breakpoint with ignore count" + } + -re ".*$mi_gdb_prompt$" { + fail "run to breakpoint with ignore count" + } + timeout { + fail "run to breakpoint with ignore count (timeout)" + } + } +} + +proc test_error {} { + global mi_gdb_prompt + + mi_gdb_test "-break-insert function_that_does_not_exist" \ + ".*\\^error,msg=\"Function \\\\\"function_that_does_not_exist\\\\\" not defined.\"" \ + "breakpoint at nonexistent function" + + # We used to have a bug whereby -break-insert that failed would not + # clear some event hooks. As result, whenever we evaluate expression + # containing function call, the internal breakpoint created to handle + # function call would be reported, messing up MI output. + mi_gdb_test "-var-create V * return_1()" \ + "\\^done,name=\"V\",numchild=\"0\",value=\"1\",type=\"int\"" \ + "create varobj for function call" + + mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[\\\]" \ + "update varobj for function call" +} + +test_tbreak_creation_and_listing +test_rbreak_creation_and_listing + +test_ignore_count + +test_error + +mi_gdb_exit +return 0 Index: mi2-stack.exp =================================================================== --- mi2-stack.exp (nonexistent) +++ mi2-stack.exp (revision 157) @@ -0,0 +1,217 @@ +# Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# +# 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 "mi-stack" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi2-stack.exp + return -1 +} + +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 fullname_syntax srcfile + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + + # Obtain a stack trace + # Tests: + # -stack-list-frames + # -stack-list-frames 1 1 + # -stack-list-frames 1 3 + # -stack-info-frame + + mi_gdb_test "231-stack-list-frames" \ + "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},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" + + mi_gdb_test "235-stack-info-frame" \ + "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \ + "selected frame listing" + + mi_gdb_test "236-stack-list-frames 1 300" \ + "236\\^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 300" +} + +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" + + mi_gdb_test "235-stack-list-arguments 1 1 300" \ + "235\\^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\"\}\\\]\},frame=\{level=\"4\",args=\\\[\\\]\}\\\]" \ + "stack args listing 1 1 300" +} + +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 fullname_syntax srcfile + + # Obtain lists for locals for the stack frames + # Tests: + # -stack-list-locals 0 (--no-values) + # -stack-list-locals 1 (--all-values) + # -stack-list-locals 2 (--simple-values) + # -stack-list-arguments + + mi_gdb_test "232-stack-list-locals 0" \ + "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\",name=\"D\"\\\]" \ + "stack locals listing of names" + +set line_callee4_return_0 [gdb_get_line_number "return 0;"] + +# step until A, B, C, D have some reasonable values. +send_gdb "-exec-next 4\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=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\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\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \ + "stack locals listing of names and values" + + mi_gdb_test "232-stack-list-locals 2" \ + "232\\^done,locals=\\\[\{name=\"A\",type=\"int\",value=\"1\"\},\{name=\"B\",type=\"int\",value=\"2\"\},\{name=\"C\",type=\"int\",value=\"3\"\},\{name=\"D\",type=\"int \\\[3\\\]\"\}\\\]" \ + "stack locals listing, simple types: names and values, complex type: names and types" + + 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" + + 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 Index: gdb680.exp =================================================================== --- gdb680.exp (nonexistent) +++ gdb680.exp (revision 157) @@ -0,0 +1,55 @@ +# Copyright 2002, 2007, 2008 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 3 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, see . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# +# test gdb/680 +# + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +proc do_test {count} { + mi_gdb_test "-data-list-register-names -1" \ + {\^error,msg=\"bad register number\"} \ + "-data-list-register-names -1, try $count" +} + +# Tests a bug with ui-out and nested uiout types. When +# an error is encountered building a nest typed, like +# lists or tuples, the uiout is not reset to some sane +# state. As a result, uiout still thinks it is building +# this nested type. Execute enough of these errors and +# an assertion failure occurs. This is most obvious +# with invalid register number and the register commands. + +# MAX_UIOUT_LEVELS is set to 5. +set counter 0 +for {set i 0} {$i < 4} {incr i} { + do_test $i +} + +#setup_kfail "gdb/680" +do_test $i + +mi_gdb_exit +return 0 Index: testcmds =================================================================== --- testcmds (nonexistent) +++ testcmds (revision 157) @@ -0,0 +1,25 @@ +# This is a (bogus) sample user command built to test the printing +# of commands. +define test +set $a = 1 +set $b = 2 +if ($a > $b) + set $a = 1 + set $b = 2 + while ($a > $b) + set $a = 1 + set $b = 2 + end +else + set $a = 1 + set $b = 2 +end +while ($a < $b) + set $a = $a + 1 + set $c = $a + if ($a = $b) + set $c = 5 + end + set $a = 1 + set $b = 2 +end Index: mi2-cli.exp =================================================================== --- mi2-cli.exp (nonexistent) +++ mi2-cli.exp (revision 157) @@ -0,0 +1,209 @@ +# Copyright 2002, 2003, 2004, 2005, 2007, 2008 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 3 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, see . + +# 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}] != "" } { + untested mi2-cli.exp + return -1 +} + +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\"" \ + {~"Reading symbols from .*basics...".*\^done} \ + "-interpreter-exec console \"file \$binfile\"" + +mi_run_to_main + +set line_main_head [gdb_get_line_number "main ("] +set line_main_body [expr $line_main_head + 2] +set line_main_hello [gdb_get_line_number "Hello, World!"] +set line_main_return [expr $line_main_hello + 2] + +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\"" + +# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } +mi_gdb_test "-interpreter-exec console \"list\"" \ + ".*\~\"$line_main_body\[\\\\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:$line_main_hello" \ +# {.*=breakpoint-create,number="3".*\^done} \ +# "-break-insert -t basics.c:\$line_main_hello" +mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ + {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ + "-break-insert -t basics.c:\$line_main_hello" + +# mi_gdb_test "-exec-continue" \ +# {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \ +# "-exec-continue to line \$line_main_hello" +send_gdb "700-exec-continue\n" +gdb_expect { + -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" { + pass "-exec-continue to line \$line_main_hello" + } + timeout { + fail "-exec-continue to line \$line_main_hello" + } +} + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-exec-next" \ +# {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \ +# "-exec-next to line \$line_main_return" +send_gdb "800-exec-next\n" +gdb_expect { + -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" { + pass "-exec-next to line \$line_main_return" + } + timeout { + fail "-exec-next to line \$line_main_return" + } +} + +mi_gdb_test "-interpreter-exec console \"list\"" \ + "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ + "-interpreter-exec console \"list\" at basics.c:\$line_main_return" + +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 Index: mi-pendshr.c =================================================================== --- mi-pendshr.c (nonexistent) +++ mi-pendshr.c (revision 157) @@ -0,0 +1,32 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007, 2008 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 3 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, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include + +void pendfunc1 (int x) +{ + int y = x + 4; + printf ("in pendfunc1, x is %d\n", x); +} + +void pendfunc (int x) +{ + pendfunc1 (x); +}
mi-pendshr.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi2-var-child.exp =================================================================== --- mi2-var-child.exp (nonexistent) +++ mi2-var-child.exp (revision 157) @@ -0,0 +1,1209 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004 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 3 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, see . + +# 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}] != "" } { + untested mi2-var-child.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto do_children_tests + +set line_dlt_first_real [gdb_get_line_number "weird = &struct_declarations;"] +mi_continue_to_line $line_dlt_first_real "step to real start of do_children_test" + +##### ##### +# # +# 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\",value=\"{...}\",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_dct_123 [gdb_get_line_number "struct_declarations.integer = 123;"] +mi_step_to do_children_tests {} {.*var-cmd.c} \ + $line_dct_123 "step to line \$line_dct_123" + +# Test: c_variable-4.81 +# Desc: create local variable "weird" +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",value=\"$hex\",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\",value=\"$hex\",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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 1] "step \$line_dct_123 + 1" + +# 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; +mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 4] {} "step \$line_dct_123 + 4" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 5] "step \$line_dct_123 + 5" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 6] "step \$line_dct_123 + 6" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 7] "step \$line_dct_123 + 7" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_123 + 8] "step \$line_dct_123 + 8" + +# 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_dct_nothing [gdb_get_line_number "weird->func_ptr = nothing;"] +mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \ + $line_dct_nothing {} "step \$line_dct_nothing" + +# 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_dct_a0_0 [gdb_get_line_number "a0\[0\] = '0';"] +mi_step_to do_children_tests {} {.*var-cmd.c} \ + $line_dct_a0_0 "step \$line_dct_a0_0" + +# 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_dct_snp0 [gdb_get_line_number "psnp = &snp0;"] +mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 1] {} "step \$line_dct_snp0 + 1" + +# 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\",value=\".*\",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\",value=\"$hex\",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\",value=\"\\\[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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 2] "step \$line_dct_snp0 + 2" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 3] "step \$line_dct_snp0 + 3" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 4] "step \$line_dct_snp0 + 4" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 5] "step \$line_dct_snp0 + 5" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 6] "step \$line_dct_snp0 + 6" + +# 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;" +mi_step_to do_children_tests {} {.*var-cmd.c} \ + [expr $line_dct_snp0 + 7] "step \$line_dct_snp0 + 7" + +# 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 Index: mi-var-child-f.exp =================================================================== --- mi-var-child-f.exp (nonexistent) +++ mi-var-child-f.exp (revision 157) @@ -0,0 +1,49 @@ +# Copyright 2006, 2007, 2008 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 3 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, see . + +# Test variable objects treat non-zero offsets in Fortran arrays correctly. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "array" +set srcfile ${testfile}.f +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto MAIN__ + +mi_gdb_test "-var-create array * array" \ + "\\^done,name=\"array\",numchild=\"3\",value=\".*\",type=\"integer \\(2,-1:1\\)\"" \ + "create local variable array" + +mi_gdb_test "-var-list-children --all-values array" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"array.-1\",exp=\"-1\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\},child=\{name=\"array.0\",exp=\"0\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\},child=\{name=\"array.1\",exp=\"1\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\}\\\]" \ + "get children of array" + +mi_gdb_test "-var-list-children --all-values array.-1" \ + "\\^done,numchild=\"2\",children=\\\[child=\{name=\"array.-1.1\",exp=\"1\",numchild=\"0\",value=\"11\",type=\"integer\"\},child=\{name=\"array.-1.2\",exp=\"2\",numchild=\"0\",value=\"21\",type=\"integer\"\}\\\]" \ + "get grandchildren of array (children of first element of second index)" Index: mi-regs.exp =================================================================== --- mi-regs.exp (nonexistent) +++ mi-regs.exp (revision 157) @@ -0,0 +1,125 @@ +# Copyright 1999, 2000, 2001, 2002, 2007, 2008 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-regs.exp + return -1 +} + +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 \\\[...\\\]\"" \ + "wrong arguments" + + mi_gdb_test "111-data-list-register-values x" \ + ".*111\\^error,msg=\"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\",\"fsr\",\"csr\",\"d0\",\"d2\",\"d4\",\"d6\",\"d8\",\"d10\",\"d12\",\"d14\",\"d16\",\"d18\",\"d20\",\"d22\",\"d24\",\"d26\",\"d28\",\"d30\"\\\]" \ + "list register names" + + mi_gdb_test "222-data-list-register-values x" \ + "222\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"87\",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=\"87\",value=\"$float\"\}\\\]" \ + "register values f" + + mi_gdb_test "444-data-list-register-values d" \ + "444\\^done,register-values=\\\[\{number=\"0\",value=\"-?$decimal\"\}.*\{number=\"87\",value=\"-?$decimal\"\}\\\]" \ + "register values d" + + mi_gdb_test "555-data-list-register-values o" \ + "555\\^done,register-values=\\\[\{number=\"0\",value=\"$octal\"\}.*\{number=\"87\",value=\"$octal\"\}\\\]" \ + "register values o" + + mi_gdb_test "666-data-list-register-values t" \ + "666\\^done,register-values=\\\[\{number=\"0\",value=\"$binary\"\}.*\{number=\"87\",value=\"$binary\"\}\\\]" \ + "register values t" + + # On the sparc, registers 0-31 are int, 32-63 float, 64-71 int, 72-87 float + + 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\"\},\{number=\"72\",value=\"$float\"\}.*\{number=\"87\",value=\"$float\"\}\\\]" \ + "register values N" + + mi_gdb_test "888-data-list-register-values r" \ + "888\\^done,register-values=\\\[\{number=\"0\",value=\"$hex\"\}.*\{number=\"87\",value=\"$hex\"\}\\\]" \ + "register values r" + + mi_gdb_test "999-data-list-register-names 68 69 70 71" \ + "999\\^done,register-names=\\\[\"pc\",\"npc\",\"fsr\",\"csr\"\\\]" \ + "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 Index: mi-syn-frame.exp =================================================================== --- mi-syn-frame.exp (nonexistent) +++ mi-syn-frame.exp (revision 157) @@ -0,0 +1,109 @@ +# Copyright 2002, 2003, 2005, 2007, 2008 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-syn-frame.exp + return -1 +} + +mi_gdb_exit +mi_gdb_start +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\"\}" \ + "insert breakpoint foo" + + +# +# 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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"\"\},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() +# +mi_gdb_test "403-exec-continue" \ + "403\\^running" \ + "testing exec continue" + +mi_gdb_test "" "403\\*stopped" "finished 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + + +# +# 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\"\}" \ + "insert breakpoint subroutine" + +mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \ + "\\&\"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\\).\"" \ + "data evaluate expression" + +# 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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + + +mi_gdb_test "408-exec-continue" "408\\^running" + +mi_gdb_test "" "408\\*stopped.*" "finished 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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \ + "list stack frames" + +# +# Call bar() by hand, which should get an exception while running. +# + +mi_gdb_test "410-data-evaluate-expression bar()" \ + "\\&\"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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception" + +mi_gdb_exit + +return 0 Index: mi-console.exp =================================================================== --- mi-console.exp (nonexistent) +++ mi-console.exp (revision 157) @@ -0,0 +1,62 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +gdb_exit +if [mi_gdb_start separate-inferior-tty] { + 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}] != "" } { + untested mi-console.exp + return -1 +} + +mi_run_to_main + +# Next over the hello() call which will produce lots of output +mi_gdb_test "47-exec-next" \ + "47\\^running" \ + "Testing console output" \ + "Hello \\\\\"!\[\r\n\]+" + +mi_gdb_test "" "47\\*stopped.*" "Finished step over hello" + +mi_gdb_exit +return 0 Index: mi-stack.exp =================================================================== --- mi-stack.exp (nonexistent) +++ mi-stack.exp (revision 157) @@ -0,0 +1,217 @@ +# Copyright 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# +# 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=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-stack" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi-stack.exp + return -1 +} + +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 fullname_syntax srcfile + + set line_callee4_head [gdb_get_line_number "callee4 ("] + set line_callee4_body [expr $line_callee4_head + 2] + + # Obtain a stack trace + # Tests: + # -stack-list-frames + # -stack-list-frames 1 1 + # -stack-list-frames 1 3 + # -stack-info-frame + + mi_gdb_test "231-stack-list-frames" \ + "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},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" + + mi_gdb_test "235-stack-info-frame" \ + "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \ + "selected frame listing" + + mi_gdb_test "236-stack-list-frames 1 300" \ + "236\\^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 300" +} + +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" + + mi_gdb_test "235-stack-list-arguments 1 1 300" \ + "235\\^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\"\}\\\]\},frame=\{level=\"4\",args=\\\[\\\]\}\\\]" \ + "stack args listing 1 1 300" +} + +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 fullname_syntax srcfile + + # Obtain lists for locals for the stack frames + # Tests: + # -stack-list-locals 0 (--no-values) + # -stack-list-locals 1 (--all-values) + # -stack-list-locals 2 (--simple-values) + # -stack-list-arguments + + mi_gdb_test "232-stack-list-locals 0" \ + "232\\^done,locals=\\\[name=\"A\",name=\"B\",name=\"C\",name=\"D\"\\\]" \ + "stack locals listing of names" + +set line_callee4_return_0 [gdb_get_line_number "return 0;"] + +# step until A, B, C, D have some reasonable values. +send_gdb "-exec-next 4\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=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\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\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \ + "stack locals listing of names and values" + + mi_gdb_test "232-stack-list-locals 2" \ + "232\\^done,locals=\\\[\{name=\"A\",type=\"int\",value=\"1\"\},\{name=\"B\",type=\"int\",value=\"2\"\},\{name=\"C\",type=\"int\",value=\"3\"\},\{name=\"D\",type=\"int \\\[3\\\]\"\}\\\]" \ + "stack locals listing, simple types: names and values, complex type: names and types" + + 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" + + 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 Index: mi-cli.exp =================================================================== --- mi-cli.exp (nonexistent) +++ mi-cli.exp (revision 157) @@ -0,0 +1,209 @@ +# Copyright 2002, 2003, 2004, 2005, 2007, 2008 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-cli.exp + return -1 +} + +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\"" \ + {~"Reading symbols from .*basics...".*done} \ + "-interpreter-exec console \"file \$binfile\"" + +mi_run_to_main + +set line_main_head [gdb_get_line_number "main ("] +set line_main_body [expr $line_main_head + 2] +set line_main_hello [gdb_get_line_number "Hello, World!"] +set line_main_return [expr $line_main_hello + 2] + +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\"" + +# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } +mi_gdb_test "-interpreter-exec console \"list\"" \ + ".*\~\"$line_main_body\[\\\\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",fullname="${fullname_syntax}${srcfile}",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:$line_main_hello" \ +# {.*=breakpoint-create,number="3".*\^done} \ +# "-break-insert -t basics.c:\$line_main_hello" +mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ + {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ + "-break-insert -t basics.c:\$line_main_hello" + +# mi_gdb_test "-exec-continue" \ +# {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \ +# "-exec-continue to line \$line_main_hello" +send_gdb "700-exec-continue\n" +gdb_expect { + -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" { + pass "-exec-continue to line \$line_main_hello" + } + timeout { + fail "-exec-continue to line \$line_main_hello" + } +} + +# NOTE: cagney/2003-02-03: Not yet. +# mi_gdb_test "-exec-next" \ +# {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \ +# "-exec-next to line \$line_main_return" +send_gdb "800-exec-next\n" +gdb_expect { + -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" { + pass "-exec-next to line \$line_main_return" + } + timeout { + fail "-exec-next to line \$line_main_return" + } +} + +mi_gdb_test "-interpreter-exec console \"list\"" \ + "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ + "-interpreter-exec console \"list\" at basics.c:\$line_main_return" + +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 Index: mi-var-child.exp =================================================================== --- mi-var-child.exp (nonexistent) +++ mi-var-child.exp (revision 157) @@ -0,0 +1,1236 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "mi-var-child" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { + untested mi-var-child.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto do_children_tests + +set line_dlt_first_real [gdb_get_line_number "weird = &struct_declarations;"] +mi_continue_to_line $line_dlt_first_real "step to real start of do_children_test" + + +##### ##### +# # +# 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\",value=\"{...}\",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=\"12\",type=\"long int \\\[12\\\]\"\},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=\"12\",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\"\},child=\{name=\"struct_declarations.long_array.10\",exp=\"10\",numchild=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.11\",exp=\"11\",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=\"12\"" \ + "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_dct_123 [gdb_get_line_number "struct_declarations.integer = 123;"] +mi_step_to do_children_tests {} ".*${srcfile}" \ + $line_dct_123 "step to line \$line_dct_123" + +# Test: c_variable-4.81 +# Desc: create local variable "weird" +mi_gdb_test "-var-create weird * weird" \ + "\\^done,name=\"weird\",numchild=\"11\",value=\"$hex\",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=\"12\",type=\"long int \\\[12\\\]\"\},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=\"12\",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\"\},child=\{name=\"weird.long_array.10\",exp=\"10\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.long_array.11\",exp=\"11\",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 10 11} + +# 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=\"12\"" \ + "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\",value=\"$hex\",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=\"26\"" \ + "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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 1] "step \$line_dct_123 + 1" + +# 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; +mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 4] {} "step \$line_dct_123 + 4" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 5] "step \$line_dct_123 + 5" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 6] "step \$line_dct_123 + 6" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 7] "step \$line_dct_123 + 7" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_123 + 8] "step \$line_dct_123 + 8" + +# 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_dct_nothing [gdb_get_line_number "weird->func_ptr = nothing;"] +mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} ".*${srcfile}" \ + $line_dct_nothing {} "step \$line_dct_nothing" + +# 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"; +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_nothing + 1] "step \$line_dct_nothing + 1" + +# 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" + +# Step over "struct_declarations.long_array[10] = 3456"; +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_nothing + 2] "step \$line_dct_nothing + 2" + +mi_gdb_test "-var-update --no-values *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.10\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.10 changed, don't print values." + +# Step over "struct_declarations.long_array[11] = 5678"; +set line_dct_a0_0 [gdb_get_line_number "a0\[0\] = '0';"] +mi_step_to do_children_tests {} ".*${srcfile}" \ + $line_dct_a0_0 "step \$line_dct_a0_0" + +mi_gdb_test "-var-update --all-values *" \ + "\\^done,changelist=\\\[\{name=\"struct_declarations.long_array.11\",value=\"5678\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ + "update all vars struct_declarations.long_array.11 changed, print values." + +mi_gdb_test "-var-list-children --all-values struct_declarations.long_array" \ + "\\^done,numchild=\"12\",children=\\\[child=\{name=\"struct_declarations.long_array.0\",exp=\"0\",numchild=\"0\",value=\"1234\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.1\",exp=\"1\",numchild=\"0\",value=\"2345\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.2\",exp=\"2\",numchild=\"0\",value=\"3456\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.3\",exp=\"3\",numchild=\"0\",value=\"4567\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.4\",exp=\"4\",numchild=\"0\",value=\"5678\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.5\",exp=\"5\",numchild=\"0\",value=\"6789\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.6\",exp=\"6\",numchild=\"0\",value=\"7890\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.7\",exp=\"7\",numchild=\"0\",value=\"8901\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.8\",exp=\"8\",numchild=\"0\",value=\"9012\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.9\",exp=\"9\",numchild=\"0\",value=\"1234\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.10\",exp=\"10\",numchild=\"0\",value=\"3456\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.11\",exp=\"11\",numchild=\"0\",value=\"5678\",type=\"long int\"\}\\\]" \ + "listing of names and values of children" + +mi_gdb_test "-var-list-children --simple-values struct_declarations" \ + "\\^done,numchild=\"11\",children=\\\[child=\{name=\"struct_declarations.integer\",exp=\"integer\",numchild=\"0\",value=\"123\",type=\"int\"\},child=\{name=\"struct_declarations.character\",exp=\"character\",numchild=\"0\",value=\"0 '\\\\\\\\0'\",type=\"char\"\},child=\{name=\"struct_declarations.char_ptr\",exp=\"char_ptr\",numchild=\"1\",value=\"$hex \\\\\"hello\\\\\"\",type=\"char \\*\"\},child=\{name=\"struct_declarations.long_int\",exp=\"long_int\",numchild=\"0\",value=\"0\",type=\"long int\"\},child=\{name=\"struct_declarations.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\\*\"\},child=\{name=\"struct_declarations.long_array\",exp=\"long_array\",numchild=\"12\",type=\"long int \\\[12\\\]\"\},child=\{name=\"struct_declarations.func_ptr\",exp=\"func_ptr\",numchild=\"0\",value=\"(@$hex: |)$hex \",type=\"void \\(\\*\\)\\(void\\)\"\},child=\{name=\"struct_declarations.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",value=\"0\",type=\"struct _struct_decl \\(\\*\\)\\(int, char \\*, long int\\)\"\},child=\{name=\"struct_declarations.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",value=\"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 \{...\}\"\}\\\]" \ + "listing of children, simple types: names, type and values, complex types: names and types" + +# Delete all variables +mi_gdb_test "-var-delete struct_declarations" \ + "\\^done,ndeleted=\"67\"" \ + "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_dct_snp0 [gdb_get_line_number "psnp = &snp0;"] +mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 1] {} "step \$line_dct_snp0 + 1" + +# 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\",value=\".*\",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\",value=\"$hex\",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\",value=\"\\\[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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 2] "step \$line_dct_snp0 + 2" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 3] "step \$line_dct_snp0 + 3" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 4] "step \$line_dct_snp0 + 4" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 5] "step \$line_dct_snp0 + 5" + +# 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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 6] "step \$line_dct_snp0 + 6" + +# 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_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;" +mi_step_to do_children_tests {} ".*${srcfile}" \ + [expr $line_dct_snp0 + 7] "step \$line_dct_snp0 + 7" + +# 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_prepare_inline_tests $srcfile + +mi_run_inline_test child_deletion + + +mi_gdb_exit +return 0 Index: mi2-var-cmd.exp =================================================================== --- mi2-var-cmd.exp (nonexistent) +++ mi2-var-cmd.exp (revision 157) @@ -0,0 +1,562 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2004, 2007, 2008 +# 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 3 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, see . + +# 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}] != "" } { + untested mi2-var-cmd.exp + return -1 +} + +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\",value=\"{...}\",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 + +set line_dlt_first_real [gdb_get_line_number "linteger = 1234;"] + +mi_continue_to_line $line_dlt_first_real "step to real start of do_locals_test" + + +# Test: c_variable-1.4 +# Desc: create local variables + +mi_gdb_test "-var-create linteger * linteger" \ + "\\^done,name=\"linteger\",numchild=\"0\",value=\".*\",type=\"int\"" \ + "create local variable linteger" + +mi_gdb_test "-var-create lpinteger * lpinteger" \ + "\\^done,name=\"lpinteger\",numchild=\"1\",value=\"$hex\",type=\"int \\*\"" \ + "create local variable lpinteger" + +mi_gdb_test "-var-create lcharacter * lcharacter\[0\]" \ + "\\^done,name=\"lcharacter\",numchild=\"0\",value=\".*\",type=\"char\"" \ + "create local variable lcharacter " + +mi_gdb_test "-var-create lpcharacter * lpcharacter" \ + "\\^done,name=\"lpcharacter\",numchild=\"1\",value=\"$hex.*\",type=\"char \\*\"" \ + "create local variable lpcharacter" + +mi_gdb_test "-var-create llong * llong" \ + "\\^done,name=\"llong\",numchild=\"0\",value=\".*\",type=\"long int\"" \ + "create local variable llong" + +mi_gdb_test "-var-create lplong * lplong" \ + "\\^done,name=\"lplong\",numchild=\"1\",value=\"$hex\",type=\"long int \\*\"" \ + "create local variable lplong" + +mi_gdb_test "-var-create lfloat * lfloat" \ + "\\^done,name=\"lfloat\",numchild=\"0\",value=\".*\",type=\"float\"" \ + "create local variable lfloat" + +mi_gdb_test "-var-create lpfloat * lpfloat" \ + "\\^done,name=\"lpfloat\",numchild=\"1\",value=\"$hex\",type=\"float \\*\"" \ + "create local variable lpfloat" + +mi_gdb_test "-var-create ldouble * ldouble" \ + "\\^done,name=\"ldouble\",numchild=\"0\",value=\".*\",type=\"double\"" \ + "create local variable ldouble" + +mi_gdb_test "-var-create lpdouble * lpdouble" \ + "\\^done,name=\"lpdouble\",numchild=\"1\",value=\"$hex\",type=\"double \\*\"" \ + "create local variable lpdouble" + +mi_gdb_test "-var-create lsimple * lsimple" \ + "\\^done,name=\"lsimple\",numchild=\"6\",value=\"{...}\",type=\"struct _simple_struct\"" \ + "create local variable lsimple" + +mi_gdb_test "-var-create lpsimple * lpsimple" \ + "\\^done,name=\"lpsimple\",numchild=\"6\",value=\"$hex\",type=\"struct _simple_struct \\*\"" \ + "create local variable lpsimple" + +mi_gdb_test "-var-create func * func" \ + "\\^done,name=\"func\",numchild=\"0\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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\",value=\".*\",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.\\\\n\".*&\"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;" +set line_dlt_linteger [gdb_get_line_number "lpinteger = &linteger;"] +mi_step_to "do_locals_tests" "" "var-cmd.c" $line_dlt_linteger "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" [expr $line_dlt_linteger + 1] "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" [expr $line_dlt_linteger + 2] "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" [expr $line_dlt_linteger + 3] "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" [expr $line_dlt_linteger + 12] "" "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; + +set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"] + +mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \ + "var-cmd.c" $line_dlt_4321 "" "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" [expr $line_dlt_4321 + 8] "" "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=\"lpcharacter\",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: lsimple and others 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" + +# Allow lpcharacter to update, optionally. Because it points to a +# char variable instead of a zero-terminated string, if linteger is +# directly after it in memory the printed characters may appear to +# change. +set lpchar_update "\{name=\"lpcharacter\",in_scope=\"true\",type_changed=\"false\"\}," +mi_gdb_test "-var-update *" \ + "\\^done,changelist=\\\[($lpchar_update)?\{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 \"" \ + "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 +##### + +set line_subroutine1_body [gdb_get_line_number "global_simple.integer = i + 3;"] + +mi_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\",value=\"4321\",type=\"int\"" \ + "create i" + +mi_gdb_test "-var-create l * l" \ + "\\^done,name=\"l\",numchild=\"1\",value=\"$hex\",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" [expr $line_subroutine1_body + 1] "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" [expr $line_subroutine1_body + 2] "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" [expr $line_subroutine1_body + 3] "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" + +set line_dlt_call_subroutine1 [gdb_get_line_number "subroutine1 (linteger, &llong);"] +mi_next_to "do_locals_tests" "" "var-cmd.c" \ + [expr $line_dlt_call_subroutine1 + 1] "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_continue_to do_special_tests + +mi_gdb_test "-var-create selected_a @ a" \ + {\^done,name="selected_a",numchild="0",value=".*",type="int"} \ + "create selected_a" + +mi_continue_to 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 Index: mi2-disassemble.exp =================================================================== --- mi2-disassemble.exp (nonexistent) +++ mi2-disassemble.exp (revision 157) @@ -0,0 +1,188 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# +# 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}] != "" } { + untested mi2-disassemble.exp + return -1 +} + +proc test_disassembly_only {} { + global mi_gdb_prompt + global hex + global decimal + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassemble -s $pc -e "$pc+8" -- 0 + # -data-disassembly -f basics.c -l $line_main_body -- 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 $line_main_body -- 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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 0 + # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 0 + # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 0 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -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 $line_main_body -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 $line_main_body -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 + + set line_callee2_head [gdb_get_line_number "callee2 ("] + set line_callee2_open_brace [expr $line_callee2_head + 1] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_callee2_open_brace -- 1 + # -data-disassembly -s $pc -e "$pc+8" -- 1 + + mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 1" \ + "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_open_brace [expr $line_main_head + 1] + set line_main_body [expr $line_main_head + 2] + + # Test disassembly more only for the current function. + # Tests: + # -data-disassembly -f basics.c -l $line_main_body -n 20 -- 1 + # -data-disassembly -f basics.c -l $line_main_body -n 0 -- 1 + # -data-disassembly -f basics.c -l $line_main_body -n 50 -- 1 + + mi_gdb_test "print/x \$pc" "" "" + mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -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 $line_main_body -n 0 -- 1" \ + "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_main_open_brace\",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 $line_main_body -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 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + + # 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 $line_main_body -- 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 Index: mi-return.exp =================================================================== --- mi-return.exp (nonexistent) +++ mi-return.exp (revision 157) @@ -0,0 +1,74 @@ +# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008 +# 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 3 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, see . + +# 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=mi" + +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}] != "" } { + untested mi-return.exp + return -1 +} + +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 fullname_syntax srcfile + + set line_callee3_head [gdb_get_line_number "callee3 ("] + set line_callee3_call [expr $line_callee3_head + 2] + set line_callee3_close_brace [expr $line_callee3_head + 3] + + send_gdb "111-exec-return\n" + gdb_expect { + -re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\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 Index: mi-file.exp =================================================================== --- mi-file.exp (nonexistent) +++ mi-file.exp (revision 157) @@ -0,0 +1,85 @@ +# Copyright 1999, 2003, 2004, 2007, 2008 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 3 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, see . + +# +# 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=mi" + +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}] != "" } { + untested mi-file.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_file_cmd ${binfile} + +proc test_file_list_exec_source_file {} { + global srcfile + global srcdir + global subdir + global fullname_syntax + set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}] + + # get the path and absolute path to the current executable + # + # In gdb 6.2 (at least), the default line number is set by + # select_source_symtab to the first line of "main" minus + # the value of "lines_to_list" (which defaults to 10) plus one. + # --chastain 2004-08-13 + + set line_main_head [gdb_get_line_number "main ("] + set line_main_body [expr $line_main_head + 2] + set gdb_lines_to_list 10 + set line_default [expr $line_main_body - $gdb_lines_to_list + 1] + + mi_gdb_test "111-file-list-exec-source-file" \ + "111\\\^done,line=\"$line_default\",file=\"${srcfilepath}\",fullname=\"$fullname_syntax${srcfile}\",macro-info=\"0\"" \ + "request path info of current source file (${srcfile})" +} + +proc test_file_list_exec_source_files {} { + global srcfile + global fullname_syntax + + # get the path and absolute path to the current executable + mi_gdb_test "222-file-list-exec-source-files" \ + "222\\\^done,files=\\\[\{file=\".*/${srcfile}\",fullname=\"$fullname_syntax${srcfile}\"\}.*]" \ + "Getting a list of source files." +} + +test_file_list_exec_source_file +test_file_list_exec_source_files + +mi_gdb_exit +return 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.