binutils-gdb/gdb/testsuite/gdb.c++/local.exp

229 lines
9.1 KiB
Plaintext

# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# tests for local variables
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
# Cleaned by Michael Chastain <mec@shout.net> 2002-04-08
# This file is part of the gdb testsuite
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
if { [skip_cplus_tests] } { continue }
set testfile "local"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
if [get_compiler_info $binfile "c++"] {
return -1
}
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
if ![runto 'marker1'] then {
perror "couldn't run to marker1"
continue
}
gdb_test "up" ".*foobar.*" "up from marker1"
# Local classes in g++ get names like "main.1::InnerLocal", just like local
# static variables. Some targets use "___" instead of ".".
# ---
# Pattern 1:
# PASS
# dwarf-2
# gcc 2.95.3
#
# Pattern 2:
# FAIL
# This has a duplicate "char loc_foo" line. This is a bug.
# Historically this has been an XFAIL.
# dwarf-2
# gcc 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# Pattern 3:
# PASS
# stabs+
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# Pattern 4:
# This an old pattern from the hppa aCC version of this file.
# I left it alone.
#
# chastain 2002-04-08
set sep "(\[.\]|___)\[0-9\]"
send_gdb "ptype Local\n"
gdb_expect {
-re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
-re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
kfail "gdb/483" "ptype Local"
}
-re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
-re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" }
-re ".*$gdb_prompt $" { fail "ptype Local" }
timeout { fail "(timeout) ptype Local" }
}
gdb_test "break marker2"
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
"continuing to marker2"
gdb_test "up" ".*main.*" "up from marker2"
# Make sure that `Local' isn't in scope here; it's local to foobar.
# setup_kfail "gdb/825"
send_gdb "ptype Local\n"
set eol "\[\t \]*\[\r\n\]+\[\t \]*"
gdb_expect {
-re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
pass "Local out of scope"
}
-re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol}.*${eol} char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
# GCC emits STABS debugging information in a way that doesn't
# properly preserve the scoping of local classes. I think
# we'd need to start using Sun's extensions to stabs to get
# this right.
kfail gdb/825 "Local out of scope"
}
-re ".*${gdb_prompt} $" {
fail "Local out of scope"
}
timeout {
fail "Local out of scope (timeout)"
}
}
# DTS CLLbs14316 and CLLbs17058
# coulter - I added a clause for HP's aCC compiler. We print out the type
# as xx instead of const unsigned char, but we still have an expected failure
# because of two reasons:
# There is a number at the end of InnerLocal4 which should not be there,
# DTS CLLbs14316
# The line number for the class
# setup_xfail "hppa*-*-*" CLLbs14316
# ---
# Pattern 1:
# PASS
# dwarf-2
# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
#
# Pattern 2:
# PASS
# stabs+
# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
#
# Pattern 3:
# Old hppa pattern.
#
# Pattern 4:
# Old hppa pattern.
#
# chastain 2002-05-27
send_gdb "ptype InnerLocal\n"
gdb_expect {
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 1)" }
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 2)" }
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
-re ".*$gdb_prompt $" { fail "ptype InnerLocal" }
timeout { fail "(timeout) ptype InnerLocal" }
}
#---
# Pattern 1:
# PASS
# dwarf-2
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# Pattern 2:
# PASS
# stabs+
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# chastain 2002-04-08
send_gdb "ptype NestedInnerLocal\n"
gdb_expect {
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
-re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
timeout { fail "(timeout) ptype NestedInnerLocal" }
}
# gdb incorrectly interprets the NestedInnerLocal in
# InnerLocal::NestedInnerLocal as field name instead of a type name;
# See CLLbs14784.
#---
# Pattern 3:
# FAIL
# The comment above, about CLLbs14784, is still correct.
# dwarf-2
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
# stabs+
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# chastain 2002-04-08
send_gdb "ptype InnerLocal::NestedInnerLocal\n"
gdb_expect {
-re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
-re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
-re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
setup_kfail "gdb/482" *-*-*
fail "ptype InnerLocal::NestedInnerLocal"
}
-re "No symbol .*NestedInnerLocal.* in current context.*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal (bogus symbol lookup)" }
-re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" }
timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
}