import gdb-1999-12-06 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / local.exp
CommitLineData
d4f3574e 1# Copyright (C) 1998, 1999 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
64send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
65
66 send_gdb "cont\n"
67 gdb_expect {
68 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
69 send_gdb "up\n"
70 gdb_expect {
71 -re ".*$gdb_prompt $" {}
72 timeout { fail "up from marker1" }
73 }
74 }
75 -re "$gdb_prompt $" { fail "continue to marker1" }
76 timeout { fail "(timeout) continue to marker1" }
77 }
78
a0b3c4fd
JM
79# srikanth, These tests have always been run only with aCC. Now in
80# the new scheme of things, we run it twice, once with aCC, and once
81# with g++. Flag these tests as expected failures when run with g++.
82# as these are failing now and were never known to pass with g++.
83global gcc_compiled
84if {$gcc_compiled} then {
85setup_xfail "*-*-*"
86}
87
c2d11a7d
JM
88# Local classes in g++ get names like "main.1::InnerLocal", just like local
89# static variables. Some targets use "___" instead of ".".
90set sep "(\[.\]|___)\[0-9\]"
91
c906108c
SS
92send_gdb "ptype Local\n"
93gdb_expect {
a0b3c4fd
JM
94 -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" }
95 -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 96 -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 97 -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
98 -re ".*$gdb_prompt $" { fail "ptype Local" }
99 timeout { fail "(timeout) ptype Local" }
100}
101
a0b3c4fd
JM
102# DTS CLLbs14316 and CLLbs17058
103# coulter - I added a clause for HP's aCC compiler. We print out the type
104# as xx instead of const unsigned char, but we still have an expected failure
105# because of two reasons:
106# There is a number at the end of InnerLocal4 which should not be there,
107# DTS CLLbs14316
108# The line number for the class
109setup_xfail "hppa*-*-*" CLLbs14316
c906108c
SS
110send_gdb "ptype InnerLocal\n"
111gdb_expect {
a0b3c4fd
JM
112 -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" }
113 -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" }
114 -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?" }
115 -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?" }
116 -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 117 -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 118 -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
119 -re ".*$gdb_prompt $" { fail "ptype InnerLocal" }
120 timeout { fail "(timeout) ptype InnerLocal" }
121}
122
c906108c
SS
123send_gdb "ptype NestedInnerLocal\n"
124gdb_expect {
a0b3c4fd
JM
125 -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" }
126 -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 127 -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
128 -re "No symbol.*in current context.*$gdb_prompt $" { pass "ptype NestedInnerLocal (known aCC limitation)" }
129 -re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
130 timeout { fail "(timeout) ptype NestedInnerLocal" }
131}
132
a0b3c4fd
JM
133# gdb incorrectly interprets the NestedInnerLocal in
134# InnerLocal::NestedInnerLocal as field name instead of a type name;
135# See CLLbs14784.
104c1213 136setup_xfail *-*-* CLLbs14784
c906108c
SS
137send_gdb "ptype InnerLocal::NestedInnerLocal\n"
138gdb_expect {
a0b3c4fd
JM
139 -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" }
140 -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
141 -re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" }
142 timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
143}
144
145
This page took 0.041784 seconds and 4 git commands to generate.