2001-04-22 Michael Chastain <chastain@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / local.exp
CommitLineData
db144853 1# Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
c906108c
SS
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# tests for local variables
21# Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
22
23
24# This file is part of the gdb testsuite
25
26if $tracelevel then {
27 strace $tracelevel
28 }
29
30#
31# test running programs
32#
33set prms_id 0
34set bug_id 0
35
d4f3574e
SS
36if { [skip_cplus_tests] } { continue }
37
c906108c
SS
38set testfile "local"
39set srcfile ${testfile}.cc
40set binfile ${objdir}/${subdir}/${testfile}
41
42if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
43 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
44}
45
a0b3c4fd
JM
46if [get_compiler_info $binfile "c++"] {
47 return -1
48}
c906108c
SS
49
50gdb_exit
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53gdb_load ${binfile}
54
55
56#
57# set it up at a breakpoint so we can play with the variable values
58#
59if ![runto_main] then {
60 perror "couldn't run to breakpoint"
61 continue
62}
63
db144853
MC
64if ![runto 'marker1'] then {
65 perror "couldn't run to marker1"
66 continue
67}
68
69gdb_test "up" ".*main.*" "up from marker1"
70
c906108c 71
a0b3c4fd
JM
72# srikanth, These tests have always been run only with aCC. Now in
73# the new scheme of things, we run it twice, once with aCC, and once
74# with g++. Flag these tests as expected failures when run with g++.
75# as these are failing now and were never known to pass with g++.
76global gcc_compiled
77if {$gcc_compiled} then {
78setup_xfail "*-*-*"
79}
80
c2d11a7d
JM
81# Local classes in g++ get names like "main.1::InnerLocal", just like local
82# static variables. Some targets use "___" instead of ".".
83set sep "(\[.\]|___)\[0-9\]"
84
c906108c
SS
85send_gdb "ptype Local\n"
86gdb_expect {
a0b3c4fd
JM
87 -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 \]*\}\[\t \]*\\(Local at.*local\\.cc:10\\).*$gdb_prompt $" { pass "ptype Local" }
88 -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 \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype Local (incorrect line number?)" }
c2d11a7d 89 -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\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" }
a0b3c4fd 90 -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 $" { pass "ptype Local (aCC)" }
c906108c
SS
91 -re ".*$gdb_prompt $" { fail "ptype Local" }
92 timeout { fail "(timeout) ptype Local" }
93}
94
a0b3c4fd
JM
95# DTS CLLbs14316 and CLLbs17058
96# coulter - I added a clause for HP's aCC compiler. We print out the type
97# as xx instead of const unsigned char, but we still have an expected failure
98# because of two reasons:
99# There is a number at the end of InnerLocal4 which should not be there,
100# DTS CLLbs14316
101# The line number for the class
102setup_xfail "hppa*-*-*" CLLbs14316
c906108c
SS
103send_gdb "ptype InnerLocal\n"
104gdb_expect {
a0b3c4fd
JM
105 -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\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" }
106 -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" }
107 -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\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" }
108 -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" }
109 -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 HP aCC" }
c2d11a7d 110 -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*NestedInnerLocal nest1;\r\n\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\*\}\r\n*.*$gdb_prompt $" { pass "ptype InnerLocal" }
a0b3c4fd 111 -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 (aCC)" }
c906108c
SS
112 -re ".*$gdb_prompt $" { fail "ptype InnerLocal" }
113 timeout { fail "(timeout) ptype InnerLocal" }
114}
115
c906108c
SS
116send_gdb "ptype NestedInnerLocal\n"
117gdb_expect {
a0b3c4fd
JM
118 -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
119 -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal (incorrect line number?)" }
c2d11a7d 120 -re "type = class NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\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\}\r\n*.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
c906108c
SS
121 -re "No symbol.*in current context.*$gdb_prompt $" { pass "ptype NestedInnerLocal (known aCC limitation)" }
122 -re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
123 timeout { fail "(timeout) ptype NestedInnerLocal" }
124}
125
e5f9ba7b
MS
126# srikanth, These tests have always been run only with aCC. Now in
127# the new scheme of things, we run it twice, once with aCC, and once
128# with g++. Flag these tests as expected failures when run with g++.
129# as these are failing now and were never known to pass with g++.
130global gcc_compiled
131if {$gcc_compiled} then {
132setup_xfail "*-*-*"
133}
134
a0b3c4fd
JM
135# gdb incorrectly interprets the NestedInnerLocal in
136# InnerLocal::NestedInnerLocal as field name instead of a type name;
137# See CLLbs14784.
104c1213 138setup_xfail *-*-* CLLbs14784
c906108c
SS
139send_gdb "ptype InnerLocal::NestedInnerLocal\n"
140gdb_expect {
a0b3c4fd
JM
141 -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
142 -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal (incorrect line number?)" }
c906108c
SS
143 -re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" }
144 timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
145}
146
147
This page took 0.11513 seconds and 4 git commands to generate.