* configure: Rebuild.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / local.exp
index f4e8d22441b12e9944752d0bdf3698d029e042b7..7f1633c48da14c588b0fa1ff67cbc1d2607aaf93 100644 (file)
@@ -1,22 +1,18 @@
-# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
 # 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
+# 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, 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
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # tests for local variables
 # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
@@ -35,8 +31,6 @@ if $tracelevel then {
 #
 # test running programs
 #
-set prms_id 0
-set bug_id 0
 
 if { [skip_cplus_tests] } { continue }
 
@@ -45,7 +39,8 @@ 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."
+     untested local.exp
+     return -1
 }
 
 if [get_compiler_info $binfile "c++"] {
@@ -73,53 +68,104 @@ if ![runto 'marker1'] then {
 
 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 ".".
+set sep "(\[.\]|___)\[0-9\]"
 
-# ---
-# Pattern 1:
-# PASS
-#   dwarf-2
-#     gcc 2.95.3
+# ptype on a local variable.
 #
-# 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
+# This test has six arms.  The first three arms accept normal output:
+# no synthetic methods; synthetic methods before user methods;
+# synthetic methods after user methods.
 #
-# Pattern 3:
-# PASS
-#   stabs+
-#     gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
+# The next two arms accept "foobar__Fi.0::Local" instead of "Local".
+# This is a bug.  It happens in various places with various versions of
+# gcc and gdb and various debugging types.
 #
-# Pattern 4:
-# This an old pattern from the hppa aCC version of this file.
-# I left it alone.
+# The last arm accepts the user methods in duplicate.  This bug happens
+# with gcc 3.3.2 -gdwarf-2, and has been fixed in gcc HEAD 2004-01-22.
 #
-# chastain 2002-04-08
+# -- chastain 2004-01-24
 
-# pattern #5
-# PASS
-#   stabs+
-#     gcc HEAD abi-2
-#
-# chastain 2004-01-02
+set re_class           "((struct|class) Local \{${ws}public:|struct Local \{)"
+set re_fields          "int loc1;"
+set re_methods         "char loc_foo\\(char\\);"
+set re_synth_gcc_23    "Local & operator=\\(Local const ?&\\);${ws}Local\\(Local const ?&\\);${ws}Local\\((void|)\\);"
 
-set sep "(\[.\]|___)\[0-9\]"
+set XX_class           "((struct|class) foobar__Fi.0::Local \{${ws}public:|struct foobar__Fi.0:Local \{)"
+set XX_synth_gcc_2     "Local & operator=\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\((void|)\\);"
+set YY_methods         "$re_methods${ws}$re_methods"
 
-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 "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\(char\\);\[\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 \]*\}.*$gdb_prompt $" { pass "ptype Local" }
-  -re ".*$gdb_prompt $"   {  fail "ptype Local" }
-  timeout             { fail "(timeout) ptype Local" }
+set name "ptype l"
+gdb_test_multiple "ptype l" $name {
+    -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 2.95.3, dwarf-2
+       # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
+       # gdb HEAD 2004-01-23, gcc HEAD 2004-01,22, dwarf-2
+       pass "$name"
+    }
+    -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 3.3.2, stabs+
+       # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
+       pass "$name"
+    }
+    -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc HEAD 2004-01-22, stabs+
+       # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
+       pass "$name"
+    }
+    -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
+       kfail "gdb/1516" "$name"
+    }
+    -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 2.95.3, stabs+
+       # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
+       kfail "gdb/1516" "$name"
+    }
+    -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 3.3.2, dwarf-2
+       # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
+       kfail "gdb/483" "$name"
+    }
+}
+
+# This is the same test with "ptype Local" (the type name)
+# instead of "ptype l" (the variable name).
+
+set name "ptype Local"
+gdb_test_multiple "ptype Local" $name {
+    -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 2.95.3, dwarf-2
+       # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
+       # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, dwarf-2
+       pass "$name"
+    }
+    -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 3.3.2, stabs+
+       # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
+       pass "$name"
+    }
+    -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc HEAD 2004-01-22, stabs+
+       # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
+       pass "$name"
+    }
+    -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       kfail "gdb/1516" "$name"
+    }
+    -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 2.95.3, stabs+
+       # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
+       kfail "gdb/1516" "$name"
+    }
+    -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
+       # gdb 6.0, gcc 3.3.2, dwarf-2
+       # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
+       kfail "gdb/483" "$name"
+    }
+    -re "No symbol \"Local\" in current context.$nl$gdb_prompt $" {
+       # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
+       fail "$name"
+    }
 }
 
 gdb_test "break marker2"
@@ -130,9 +176,9 @@ 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 {
+gdb_test_multiple "ptype Local" "Local out of scope" {
     -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
         pass "Local out of scope"
     }
@@ -147,12 +193,6 @@ gdb_expect {
        # gcc 3.X abi-2 -gstabs+
         kfail gdb/825 "Local out of scope"
     }
-    -re ".*${gdb_prompt} $" {
-        fail "Local out of scope"
-    }
-    timeout {
-        fail "Local out of scope (timeout)"
-    }
 }
         
 
@@ -191,15 +231,22 @@ gdb_expect {
 #
 # chastain 2004-01-02
 
-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 "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 *&\\);\[\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 \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 5)" }
-  -re ".*$gdb_prompt $"   {  fail "ptype InnerLocal" }
-  timeout             { fail "(timeout) ptype InnerLocal" }
+gdb_test_multiple "ptype InnerLocal" "ptype InnerLocal" {
+    -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 "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 *&\\);\[\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 \]*\}.*$gdb_prompt $" {
+       pass "ptype InnerLocal (pattern 5)"
+    }
 }
 
 #---
@@ -215,12 +262,23 @@ gdb_expect {
 #
 # 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" }
+# NOTE (2004-02-24, carlton): This test really is invalid -
+# 'NestedInnerLocal' shouldn't be visible, so only the third
+# expression should count as a pass.  I'm leaving in the earlier
+# passes, however, given the current problematic state of our local
+# class support, but once we fix PR gdb/482, we should delete this
+# test.
+
+gdb_test_multiple "ptype NestedInnerLocal" "ptype NestedInnerLocal" {
+    -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 "No symbol \"NestedInnerLocal\" in current context\.\r\n$gdb_prompt $" {
+       pass "ptype NestedInnerLocal"
+    }
 }
 
 set re_class           "((struct|class) InnerLocal::NestedInnerLocal \{${ws}public:|struct InnerLocal::NestedInnerLocal \{)"
This page took 0.028874 seconds and 4 git commands to generate.