From dadace266aa0b7a639f68f449d9282ebb224cc72 Mon Sep 17 00:00:00 2001 From: Bob Manson Date: Thu, 20 Feb 1997 22:13:52 +0000 Subject: [PATCH] * gdb.base/scope.exp: Use gdb_test. * gdb.base/ptype.exp: Don't call "gdb_exit; gdb_start" if we're aborting; the testsuite driver will do that for us (see gdb_finish). Also, use gdb_test in a few more places. --- gdb/testsuite/ChangeLog | 8 + gdb/testsuite/gdb.base/ptype.exp | 270 ++----------- gdb/testsuite/gdb.base/scope.exp | 818 ++++++++------------------------------- 3 files changed, 217 insertions(+), 879 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 992ca82..a6b97f2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +Thu Feb 20 13:57:01 1997 Bob Manson + + * gdb.base/scope.exp: Use gdb_test. + + * gdb.base/ptype.exp: Don't call "gdb_exit; gdb_start" if we're + aborting; the testsuite driver will do that for us (see + gdb_finish). Also, use gdb_test in a few more places. + Thu Feb 20 13:32:24 1997 Stan Shebs * gdb.base/help.exp: Fix syntax of "help info all-registers" test. diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp index fec31eb..78ff2ca 100644 --- a/gdb/testsuite/gdb.base/ptype.exp +++ b/gdb/testsuite/gdb.base/ptype.exp @@ -73,128 +73,52 @@ expect { # Here and elsewhere, we accept # "long", "long int", or "int" for long variables (whatis.exp already # has an XFAIL for "int" (Sun cc bug), so no need to fail it here). -send_gdb "ptype struct t_struct\n" -expect { - -re "type = struct t_struct \{.* - (unsigned |)char v_char_member;.* - (short|short int) v_short_member;.* - int v_int_member;.* - (long|long int|int) v_long_member;.* - float v_float_member;.* - double v_double_member;.* -\}.*$gdb_prompt $" { pass "ptype structure" } - -re ".*$gdb_prompt $" { fail "ptype structure" } - timeout { fail "(timeout) ptype structure" } -} +gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure" + # Test the equivalence between '.' and '->' for struct member references. if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then { - gdb_exit - gdb_start return -1 } if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then { - gdb_exit - gdb_start return -1 } if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then { - gdb_exit - gdb_start return -1 } if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then { - gdb_exit - gdb_start return -1 } -send_gdb "ptype struct link\n" -expect { - -re "type = struct link \{.* - struct link \[*\]next;.* - struct link \[*(\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.* - struct t_struct stuff.1..2..3.;.* -\}.*$gdb_prompt $" { pass "ptype linked list structure" } - -re ".*$gdb_prompt $" { - - # IBM's xlc puts out bogus stabs--the stuff field is type 42, - # which isn't defined. - - fail "ptype linked list structure (compiler bug in IBM's xlc)" - } - timeout { fail "(timeout) ptype linked list structure" } -} +# IBM's xlc puts out bogus stabs--the stuff field is type 42, +# which isn't defined. +gdb_test "ptype struct link" "type = struct link \{.*\[\r\n\] struct link \[*\]next;.*\[\r\n\] struct link \[*(\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*\[\r\n\] struct t_struct stuff.1..2..3.;.*\[\r\n\]\}.*" "ptype linked list structure" # # test ptype command with unions # -send_gdb "ptype union t_union\n" -expect { - -re "type = union t_union \{.* - (unsigned |)char v_char_member;.* - (short|short int) v_short_member;.* - int v_int_member;.* - (long|long int|int) v_long_member;.* - float v_float_member;.* - double v_double_member;.* -\}.*$gdb_prompt $" { pass "ptype union" } - -re ".*$gdb_prompt $" { fail "ptype union" } - timeout { fail "(timeout) ptype union" } -} - - -send_gdb "ptype union tu_link\n" -expect { - -re "type = union tu_link .* - struct link \[*\]next;.* - struct link \[(\*\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.* - struct t_struct stuff.1..2..3.;.* -\}.*$gdb_prompt $" { pass "ptype linked list union" } - -re ".*$gdb_prompt $" { - - # IBM's xlc puts out bogus stabs--the stuff field is type 42, - # which isn't defined. - - fail "ptype linked list union (compiler bug in IBM's xlc)" - } - timeout { fail "(timeout) ptype linked list union" } -} +gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union" +# IBM's xlc puts out bogus stabs--the stuff field is type 42, +# which isn't defined. +gdb_test "ptype union tu_link" "type = union tu_link .*\[\r\n\] struct link \[*\]next;.*\[\r\n\] struct link \[(\*\]+linkfunc\[)(\]+(struct link \[*\], int\[)\]|);.*\[\r\n\] struct t_struct stuff.1..2..3.;.*\[\r\n\]\}.*" "ptype linked list union" # # test ptype command with enums # -send_gdb "ptype primary\n" -expect { - -re "type = enum .red, green, blue.*$gdb_prompt $" { pass "ptype unnamed enumeration" } - -re ".*$gdb_prompt $" { fail "ptype unnamed enumeration" } - timeout { fail "(timeout) ptype unnamed enumeration" } -} - +gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" -send_gdb "ptype enum colors\n" -expect { - -re "type = enum colors \{yellow, purple, pink\}.*$gdb_prompt $"\ - { pass "ptype named enumeration" } - -re ".*$gdb_prompt $" { fail "ptype named enumeration" } - timeout { fail "(timeout) ptype named enumeration" } -} +gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" # # test ptype command with enums as typedef # -send_gdb "ptype boolean\n" -expect { - -re "type = enum \{FALSE, TRUE\}.*$gdb_prompt $" { pass "ptype unnamed typedef'd enumeration" } - -re ".*$gdb_prompt $" { fail "ptype unnamed typedef'd enumeration" } - timeout { fail "(timeout) ptype unnamed typedef'd enumeration" } -} +gdb_test "ptype boolean" "type = enum \{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" # And check that whatis shows the name, not "enum {...}". @@ -218,46 +142,19 @@ gdb_test "ptype t_union3" "type = union \{.* *double v_double_member;.* *int v_int_member;.*\}" "printing typedef'd union" -send_gdb "ptype enum bvals\n" -expect { - -re "type = enum bvals \{false, true\}.*$gdb_prompt $" { pass "ptype named typedef'd enumf'd enum" } - -re ".*$gdb_prompt $" { fail "ptype named typedef'd enumeration" } - timeout { fail "(timeout) ptype named typedef'd enumeration" } -} - +gdb_test "ptype enum bvals" "type = enum bvals \{false, true\}.*" "ptype named typedef'd enumf'd enum" # # test ptype command with out-of-order enum values # -send_gdb "ptype enum misordered\n" -expect { - -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$gdb_prompt $"\ - { pass "ptype misordered enumeration" } - -re ".*$gdb_prompt $" { fail "ptype misordered enumeration" } - timeout { fail "(timeout) ptype misordered enumeration" } -} - +gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" # # test ptype command with a named enum's value # -send_gdb "ptype three\n" -expect { - -re "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*$gdb_prompt $"\ - { pass "ptype named enumeration member" } - -re ".*$gdb_prompt $" { fail "ptype named enumeration member" } - timeout { fail "(timeout) ptype named enumeration member" } -} - - -send_gdb "ptype red\n" -expect { - -re "type = enum \{red, green, blue\}.*$gdb_prompt $"\ - { pass "ptype unnamed enumeration member" } - -re ".*$gdb_prompt $" { fail "ptype unnamed enumeration member" } - timeout { fail "(timeout) ptype unnamed enumeration member" } -} +gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" +gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member" # # test ptype command with basic C types @@ -293,14 +190,7 @@ expect { # timeout { fail "(timeout) ptype unsigned char" } #} - -send_gdb "ptype v_short\n" -expect { - -re "type = short(| int).*$gdb_prompt $" { pass "ptype short" } - -re ".*$gdb_prompt $" { fail "ptype short" } - timeout { fail "(timeout) ptype short" } -} - +gdb_test "ptype v_short" "type = short(| int).*" "ptype short" #send "ptype v_signed_short\n" #expect { @@ -318,13 +208,7 @@ expect { #} -send_gdb "ptype v_int\n" -expect { - -re "type = int.*$gdb_prompt $" { pass "ptype int" } - -re ".*$gdb_prompt $" { fail "ptype int" } - timeout { fail "(timeout) ptype int" } -} - +gdb_test "ptype v_int" "type = int.*" "ptype int" #send "ptype v_signed_int\n" #expect { @@ -604,90 +488,21 @@ gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]" # # test ptype command with nested structure and union # -send_gdb "ptype struct outer_struct\n" -expect { - -re "type = struct outer_struct \{.* - int outer_int;.* - struct inner_struct inner_struct_instance;.* - union inner_union inner_union_instance;.* - (long|long int|int) outer_long;.* -\}.*$gdb_prompt $" { pass "ptype outer structure" } - -re ".*$gdb_prompt $" { fail "ptype outer structure" } - timeout { fail "(timeout) ptype outer structure" } -} - - -send_gdb "ptype struct inner_struct\n" -expect { - -re "type = struct inner_struct \{.* - int inner_int;.* - (long|long int|int) inner_long;.* -\}.*$gdb_prompt $" { pass "ptype inner structure" } - -re ".*$gdb_prompt $" { fail "ptype inner structure" } - timeout { fail "(timeout) ptype inner structure" } -} - - -send_gdb "ptype union inner_union\n" -expect { - -re "type = union inner_union \{.* - int inner_union_int;.* - (long|long int|int) inner_union_long;.* -\}.*$gdb_prompt $" { pass "ptype inner union" } - -re ".*$gdb_prompt $" { fail "ptype inner union" } - timeout { fail "(timeout) ptype inner union" } -} - - -send_gdb "ptype nested_su\n" -expect { - -re "type = struct outer_struct \{.* - int outer_int;.* - struct inner_struct inner_struct_instance;.* - union inner_union inner_union_instance;.* - (long|long int|int) outer_long;.* -\}.*$gdb_prompt $" { pass "ptype nested structure" } - -re ".*$gdb_prompt $" { fail "ptype nested structure" } - timeout { fail "(timeout) ptype nested structure" } -} - +gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] struct inner_struct inner_struct_instance;.*\[\r\n\] union inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure" -send_gdb "ptype nested_su.outer_int\n" -expect { - -re "type = int.*$gdb_prompt $" { pass "ptype outer int" } - -re ".*$gdb_prompt $" { fail "ptype outer int" } - timeout { fail "(timeout) ptype outer int" } -} +gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure" +gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union" -send_gdb "ptype nested_su.inner_struct_instance\n" -expect { - -re "type = struct inner_struct \{.* - int inner_int;.* - (long|long int|int) inner_long;.* -\}.*$gdb_prompt $" { pass "ptype nested structure" } - -re ".*$gdb_prompt $" { fail "ptype nested structure" } - timeout { fail "(timeout) ptype nested structure" } -} +gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] struct inner_struct inner_struct_instance;.*\[\r\n\] union inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure" +gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int" -send_gdb "ptype nested_su.inner_struct_instance.inner_int\n" -expect { - -re "type = int.*$gdb_prompt $" { pass "ptype inner int" } - -re ".*$gdb_prompt $" { fail "ptype inner int" } - timeout { fail "(timeout) ptype inner int" } -} +gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure" +gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int" -send_gdb "ptype nested_su.inner_union_instance\n" -expect { - -re "type = union inner_union \{.* - int inner_union_int;.* - (long|long int|int) inner_union_long;.* -\}.*$gdb_prompt $" { pass "ptype nested union" } - -re ".*$gdb_prompt $" { fail "ptype nested union" } - timeout { fail "(timeout) ptype nested union" } -} +gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union" # Test printing type of string constants and array constants, but # requires a running process. These call malloc, and can take a long @@ -696,23 +511,20 @@ expect { # UDI can't do this (PR 2416). XFAIL is not suitable, because attempting # the operation causes a slow painful death rather than a nice simple failure. -if ![istarget "*-*-udi*"] then { - if [runto_main] then { - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype \"abc\"" "type = char \\\[4\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype {4,5,6}\[2\]" "type = int" - setup_xfail "a29k-*-udi" 2416 - gdb_test "ptype *&{4,5,6}\[1\]" "type = int" +if [runto_main] then { + + if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + continue } + + gdb_test "ptype \"abc\"" "type = char \\\[4\\\]" + gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]" + gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]" + gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]" + gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]" + gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]" + gdb_test "ptype {4,5,6}\[2\]" "type = int" + gdb_test "ptype *&{4,5,6}\[1\]" "type = int" } diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp index e5a4fe8..9a0cd7c 100644 --- a/gdb/testsuite/gdb.base/scope.exp +++ b/gdb/testsuite/gdb.base/scope.exp @@ -44,7 +44,7 @@ if [get_compiler_info ${binfile}] { # first one and quit. If all pass, then we print the pass results. proc test_at_main {} { - global prompt + global gdb_prompt global decimal global det_file global srcdir @@ -53,374 +53,176 @@ proc test_at_main {} { # skip past init. There may be a call to __main at the start of # main, so the first next may only get us to the init call. - send_gdb "next\n" - expect { - -re "$decimal.*foo \\(\\);\r\n$prompt $" { - pass "next over init() in main" - } - -re "$decimal.*init \\(\\);\r\n$prompt $"\ - { send_gdb "next\n" ; exp_continue } - -re "$prompt $" { fail "next over init() in main" ; return } - timeout { fail "(timeout) next over init() in main" ; return } + if [gdb_test "next" "$decimal.*foo \\(\\);" "next over init() in main" "$decimal.*init \\(\\);" "next"] { + return ; } + # Print scope0.c::filelocal, which is 1 - send_gdb "print filelocal\n" - expect { - -re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" } - -re "$prompt $" { fail "print filelocal" ; return } - timeout { - fail "(timeout) print filelocal" ; return - } + if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] { + return ; } - send_gdb "print 'scope0.c'::filelocal\n" - expect { - -re "\\\$$decimal = 1\r\n$prompt $" { - pass "print 'scope0.c'::filelocal at main" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return } - timeout { - fail "(timeout) print 'scope0.c'::filelocal at main" ; return - } + + if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { + return ; } + # Print scope0.c::filelocal_bss, which is 101 - send_gdb "print filelocal_bss\n" - expect { - -re "\\\$$decimal = 101\r\n$prompt $" { - pass "print filelocal_bss" - } - -re "$prompt $" { fail "print filelocal_bss" ; return } - timeout { - fail "(timeout) print filelocal_bss" ; return - } + if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] { + return ; } - send_gdb "print 'scope0.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 101\r\n$prompt $" { - pass "print 'scope0.c'::filelocal_bss in test_at_main" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope0.c'::filelocal_bss in test_at_main" ; return - } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_main" - return - } + + if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { + return ; } + # Print scope0.c::filelocal_ro, which is 201 # No clue why the powerpc fails this test. setup_xfail "powerpc-*-*" if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print filelocal_ro\n" - expect { - -re "\\\$$decimal = 201\r\n$prompt $" { - pass "print filelocal_ro in test_at_main" - } - -re "$prompt $" { - fail "print filelocal_ro in test_at_main" - return - } - timeout { - fail "(timeout) print filelocal_ro in test_at_main" - return - } + if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" - send_gdb "print 'scope0.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 201\r\n$prompt $" { - pass "print 'scope0.c'::filelocal_ro" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_ro" ; return - } + if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { + return ; } + # Print scope1.c::filelocal, which is 2 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal\n" - expect { - -re "\\\$$decimal = 2\r\n$prompt $" { - pass "print 'scope1.c'::filelocal" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return } - timeout { - fail "(timeout) print 'scope1.c'::filelocal" ; return - } + if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { + return ; } + # Print scope1.c::filelocal_bss, which is 102 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 102\r\n$prompt $" { - pass "print 'scope1.c'::filelocal_bss" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_bss" ; return - } + if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { + return ; } + # Print scope1.c::filelocal_ro, which is 202 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 202\r\n$prompt $" { - pass "print 'scope1.c'::filelocal_ro" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_ro" ; return - } + if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { + return ; } + # Print scope1.c::foo::funclocal, which is 3 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print foo::funclocal\n" - expect { - -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" } - -re "$prompt $" { fail "print foo::funclocal" ; return } - timeout { - fail "(timeout) print foo::funclocal" ; return - } + if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::foo::funclocal\n" - expect { - -re "\\\$$decimal = 3\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal" ; return - } + if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { + return ; } + # Print scope1.c::foo::funclocal_ro, which is 203 - send_gdb "print foo::funclocal_ro\n" - expect { - -re "\\\$$decimal = 203\r\n$prompt $" { - pass "print foo::funclocal_ro" - } - -re "$prompt $" { fail "print foo::funclocal_ro" ; return } - timeout { - fail "(timeout) print foo::funclocal_ro" ; return - } + if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::foo::funclocal_ro\n" - expect { - -re "\\\$$decimal = 203\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal_ro" } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return - } + if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { + return ; } + # Print scope1.c::bar::funclocal, which is 4 - send_gdb "print bar::funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" } - -re "$prompt $" { fail "print bar::funclocal" ; return } - timeout { - fail "(timeout) print bar::funclocal" ; return - } + if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::bar::funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { - pass "print 'scope1.c'::bar::funclocal" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return } - timeout { - fail "(timeout) print 'scope1.c'::bar::funclocal" ; return - } + if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { + return ; } + } proc test_at_foo {} { - global prompt + global gdb_prompt global decimal global det_file global srcdir global subdir global gcc_compiled - send_gdb "next\n" - expect { - -re ".*bar \\(\\);\r\n$prompt $" {} - -re "$prompt $" { fail "continue to foo()" ; return } - timeout { fail "(timeout) continue to foo()" ; return } + if [gdb_test "next" ".*bar \\(\\);" "" ] { + return ; } + # Print scope0.c::filelocal, which is 1 - send_gdb "print 'scope0.c'::filelocal\n" - expect { - -re "\\\$$decimal = 1\r\n$prompt $" { - pass "print 'scope0.c'::filelocal at foo" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return } - timeout { - fail "(timeout) print 'scope0.c'::filelocal at foo" ; return - } + if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { + return ; } + # Print scope0.c::filelocal_bss, which is 101 - send_gdb "print 'scope0.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 101\r\n$prompt $" { - pass "print 'scope0.c'::filelocal_bss in test_at_foo" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope0.c'::filelocal_bss in test_at_foo" - return - } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo" - return - } + if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { + return ; } + # Print scope0.c::filelocal_ro, which is 201 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" - send_gdb "print 'scope0.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_ro" ; return - } + if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { + return ; } + gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo" # Print scope1.c::filelocal, which is 2 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal\n" - expect { - -re "\\\$$decimal = 2\r\n$prompt $" { - pass "print 'scope1.c'::filelocal at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::filelocal at foo" ; return } - timeout { - fail "(timeout) print 'scope1.c'::filelocal at foo" ; return - } + if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { + return ; } + gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ "print filelocal_bss at foo" if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 102\r\n$prompt $" { - pass "print 'scope1.c'::filelocal_bss at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss at foo" } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_bss at foo" - } - } + gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss" + gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ "print filelocal_ro at foo" if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro at foo" } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro at foo" } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_ro at foo" - } - } + gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro" + # Print scope1.c::foo::funclocal, which is 3 @@ -432,20 +234,8 @@ proc test_at_foo {} { if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print 'scope1.c'::foo::funclocal\n" - expect { - -re "\\\$$decimal = 3\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal at foo" } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal at foo" - } - } + gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal" + # Print scope1.c::foo::funclocal_bss, which is 103 @@ -458,22 +248,8 @@ proc test_at_foo {} { if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print 'scope1.c'::foo::funclocal_bss\n" - expect { - -re "\\\$$decimal = 103\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal_bss at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::foo::funclocal_bss at foo" - } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal_bss at foo" - } - } + gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss" + # Print scope1.c::foo::funclocal_ro, which is 203 @@ -486,20 +262,8 @@ proc test_at_foo {} { if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print 'scope1.c'::foo::funclocal_ro\n" - expect { - -re "\\\$$decimal = 203\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal_ro at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro at foo" } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal_ro at foo" - } - } + gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro" + # Print scope1.c::bar::funclocal, which is 4 @@ -509,429 +273,189 @@ proc test_at_foo {} { if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print 'scope1.c'::bar::funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { - pass "print 'scope1.c'::bar::funclocal at foo" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n" - exp_continue - } - -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal at foo" } - timeout { - fail "(timeout) print 'scope1.c'::bar::funclocal at foo" - } - } + gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal" + } proc test_at_bar {} { - global prompt + global gdb_prompt global decimal global det_file global srcdir global subdir global gcc_compiled - send_gdb "next\n" - expect { - -re ".*$prompt $" {} - timeout { fail "(timeout) next in bar()" ; return } + if [gdb_test "next" ".*" "" ] { + return ; } + # Print scope0.c::filelocal, which is 1 - send_gdb "print 'scope0.c'::filelocal\n" - expect { - -re "\\\$$decimal = 1\r\n$prompt $" { - pass "print 'scope0.c'::filelocal at bar" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope0.c'::filelocal at bar" ; return - } - timeout { - fail "(timeout) print 'scope0.c'::filelocal at bar" ; return - } + if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { + return ; } + # Print scope0.c::filelocal_bss, which is 101 - send_gdb "print 'scope0.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 101\r\n$prompt $" { - pass "print 'scope0.c'::filelocal_bss in test_at_bar" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope0.c'::filelocal_bss in test_at_bar" - return - } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar" - return - } + if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { + return ; } + # Print scope0.c::filelocal_ro, which is 201 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" - send_gdb "print 'scope0.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 201\r\n$prompt $" { - pass "print 'scope0.c'::filelocal_ro at bar" - } - -re "No symbol \"scope0.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope0.c'::filelocal_ro at bar" ; return - } - timeout { - fail "(timeout) print 'scope0.c'::filelocal_ro at bar" ; return - } + if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { + return ; } + # Print scope1.c::filelocal, which is 2 - send_gdb "print filelocal\n" - expect { - -re "\\\$$decimal = 2\r\n$prompt $" { - pass "print filelocal at bar" - } - -re "$prompt $" { - fail "print filelocal at bar" ; return - } - timeout { - fail "(timeout) print filelocal at bar" ; return - } + if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal\n" - expect { - -re "\\\$$decimal = 2\r\n$prompt $" { - pass "print 'scope1.c'::filelocal at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::filelocal at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::filelocal at bar" ; return - } + if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { + return ; } + # Print scope1.c::filelocal_bss, which is 102 - send_gdb "print filelocal_bss\n" - expect { - -re "\\\$$decimal = 102\r\n$prompt $" { - pass "print filelocal_bss at bar" - } - -re "$prompt $" { - fail "print filelocal_bss at bar" ; return - } - timeout { - fail "(timeout) print filelocal_bss at bar" ; return - } + if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_bss\n" - expect { - -re "\\\$$decimal = 102\r\n$prompt $" { - pass "print 'scope1.c'::filelocal_bss at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::filelocal_bss at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_bss at bar" ; return - } + if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { + return ; } + # Print scope1.c::filelocal_ro, which is 202 - send_gdb "print filelocal_ro\n" - expect { - -re "\\\$$decimal = 202\r\n$prompt $" { - pass "print filelocal_ro in test_at_bar" - } - -re "$prompt $" { - fail "print filelocal_ro in test_at_bar" - return - } - timeout { - fail "(timeout) print filelocal_ro in test_at_bar" - return - } + if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::filelocal_ro\n" - expect { - -re "\\\$$decimal = 202\r\n$prompt $" { - pass "print 'scope1.c'::filelocal_ro at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::filelocal_ro at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::filelocal_ro at bar" ; return - } + if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { + return ; } + # Print scope1.c::foo::funclocal, which is 3 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" } - send_gdb "print foo::funclocal\n" - expect { - -re "\\\$$decimal = 3\r\n$prompt $" { - pass "print foo::funclocal at bar" - } - -re "$prompt $" { - fail "print foo::funclocal at bar" ; return - } - timeout { - fail "(timeout) print foo::funclocal at bar" ; return - } + if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::foo::funclocal\n" - expect { - -re "\\\$$decimal = 3\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::foo::funclocal at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal at bar" ; return - } + if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { + return ; } + # Print scope1.c::foo::funclocal_bss, which is 103 - send_gdb "print foo::funclocal_bss\n" - expect { - -re "\\\$$decimal = 103\r\n$prompt $" { - pass "print foo::funclocal_bss at bar" - } - -re "$prompt $" { - fail "print foo::funclocal_bss at bar" ; return - } - timeout { - fail "(timeout) print foo::funclocal_bss at bar" ; return - } + if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::foo::funclocal_bss\n" - expect { - -re "\\\$$decimal = 103\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal_bss at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::foo::funclocal_bss at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal_bss at bar" ; return - } + if [gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss"] { + return ; } + # Print scope1.c::foo::funclocal_ro, which is 203 - send_gdb "print foo::funclocal_ro\n" - expect { - -re "\\\$$decimal = 203\r\n$prompt $" { - pass "print foo::funclocal_ro at bar" - } - -re "$prompt $" { - fail "print foo::funclocal_ro at bar" ; return - } - timeout { - fail "(timeout) print foo::funclocal_ro at bar" ; return - } + if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::foo::funclocal_ro\n" - expect { - -re "\\\$$decimal = 203\r\n$prompt $" { - pass "print 'scope1.c'::foo::funclocal_ro at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::foo::funclocal_ro at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::foo::funclocal_ro at bar" ; return - } + if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { + return ; } + # Print scope1.c::bar::funclocal, which is 4 - send_gdb "print funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { - pass "print funclocal at bar" - } - -re "$prompt $" { - fail "print funclocal at bar" ; return - } - timeout { - fail "(timeout) print funclocal at bar" ; return - } + if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] { + return ; } - send_gdb "print bar::funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { - pass "print bar::funclocal at bar" - } - -re "$prompt $" { - fail "print bar::funclocal at bar" ; return - } - timeout { - fail "(timeout) print bar::funclocal at bar" ; return - } + + if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::bar::funclocal\n" - expect { - -re "\\\$$decimal = 4\r\n$prompt $" { - pass "print 'scope1.c'::bar::funclocal at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::bar::funclocal at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::bar::funclocal at bar" ; return - } + if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { + return ; } + # Print scope1.c::bar::funclocal_bss, which is 104 - send_gdb "print funclocal_bss\n" - expect { - -re "\\\$$decimal = 104\r\n$prompt $" { - pass "print funclocal_bss at bar" - } - -re "$prompt $" { - fail "print funclocal_bss at bar" ; return - } - timeout { - fail "(timeout) print funclocal_bss at bar" ; return - } + if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] { + return ; } - send_gdb "print bar::funclocal_bss\n" - expect { - -re "\\\$$decimal = 104\r\n$prompt $" { - pass "print bar::funclocal_bss at bar" - } - -re "$prompt $" { - fail "print bar::funclocal_bss at bar" ; return - } - timeout { - fail "(timeout) print bar::funclocal_bss at bar" ; return - } + + if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] { + return ; } + if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - send_gdb "print 'scope1.c'::bar::funclocal_bss\n" - expect { - -re "\\\$$decimal = 104\r\n$prompt $" { - pass "print 'scope1.c'::bar::funclocal_bss at bar" - } - -re "No symbol \"scope1.c\" in current context.*$prompt $" { - send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n" - exp_continue - } - -re "$prompt $" { - fail "print 'scope1.c'::bar::funclocal_bss at bar" ; return - } - timeout { - fail "(timeout) print 'scope1.c'::bar::funclocal_bss at bar" ; return - } + if [gdb_test "print 'scope1.c'::bar::funclocal_bss" "\\\$$decimal = 104" "print 'scope1.c'::bar::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss"] { + return ; } + } # This test has little to do with local scopes, but it is in scope.exp anyway. # That's life. proc test_at_autovars {} { - global prompt + global gdb_prompt global decimal global hex global srcfile # Test symbol table lookup with 100 local (auto) variables. - send_gdb "break marker1\n" ; expect -re ".*$prompt $" + gdb_breakpoint marker1 - send_gdb "cont\n" - expect { - -re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" { - send_gdb "up\n" - expect { - -re ".*$prompt $" {} - timeout { fail "(timeout) up from marker1" ; return } - } - } - -re "$prompt $" { fail "continue to marker1" ; return } - timeout { fail "(timeout) continue to marker1" ; return } + if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] { + return; + } + + if [gdb_test "up" ".*" "" ] { + return ; } set count 0 while {$count < 100} { - send_gdb "print i$count\n" - expect { - -re ".* = $count\r\n$prompt $" {} - -re "$prompt $" { - fail "bad value for auto variable i$count"; return - } - timeout { - fail "(timeout) bad value for auto variable i$count"; return - } + if [gdb_test "print i$count" ".* = $count" "" ] { + return ; } + set count [expr $count+1] } clear_xfail "*-*-*" @@ -942,26 +466,20 @@ proc test_at_autovars {} { } proc test_at_localscopes {} { - global prompt + global gdb_prompt global decimal global hex global srcfile - send_gdb "break marker2\n" ; expect -re ".*$prompt $" - send_gdb "break marker3\n" ; expect -re ".*$prompt $" - send_gdb "break marker4\n" ; expect -re ".*$prompt $" - - send_gdb "cont\n" - expect { - -re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" { - send_gdb "up\n" - expect { - -re ".*$prompt $" {} - timeout { fail "(timeout) up from marker2" ; return } - } - } - -re "$prompt $" { fail "continue to marker2" ; return } - timeout { fail "(timeout) continue to marker2" ; return } + gdb_breakpoint marker2 + gdb_breakpoint marker3 + gdb_breakpoint marker4 + + if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] { + return; + } + if [gdb_test "up" ".*" "" ] { + return ; } # Should be at first (outermost) scope. Check values. @@ -1030,14 +548,14 @@ gdb_test "print 'scope0.c'::filelocal_ro" "= 201" setup_xfail "hppa*-*-*pro*" send_gdb "print 'scope0.c'::filelocal_bss\n" expect { - -re " = 0\r\n$prompt $" { + -re " = 0\r\n$gdb_prompt $" { pass "print 'scope0.c'::filelocal_bss before run" } - -re "Cannot access memory.*$prompt $" { + -re "Cannot access memory.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print 'scope0.c'::filelocal_bss before run" } - -re ".*$prompt $" { + -re ".*$gdb_prompt $" { fail "print 'scope0.c'::filelocal_bss before run" } default { -- 2.7.4