* fbsd-proc.c (child_pid_to_exec_file, fbsd_find_memory_regions):
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / method.exp
1 # Copyright 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
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 misc. C++ method stuff
21 # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
22
23 # This file is part of the gdb testsuite
24
25 # This tests:
26 # 0. method arguments are correct
27 # 1. access to class data members inside method scopes
28 # 2. correct param types for methods in ptype.
29 # 3. const and volatile methods
30
31 # (#0 and #1 above relate to an HP specific problem -- GDB must correctly
32 # integrate FPARAM symbols in HP debug info into the local var list
33 # for the function or method's block.)
34
35 if $tracelevel then {
36 strace $tracelevel
37 }
38
39 #
40 # test running programs
41 #
42 set prms_id 0
43 set bug_id 0
44
45 if { [skip_cplus_tests] } { continue }
46
47 set testfile "method"
48 set srcfile ${testfile}.cc
49 set binfile ${objdir}/${subdir}/${testfile}
50
51 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
52 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
53 }
54
55 if [get_compiler_info $binfile "c++"] {
56 return -1
57 }
58
59 gdb_exit
60 gdb_start
61 gdb_reinitialize_dir $srcdir/$subdir
62 gdb_load ${binfile}
63
64
65 #
66 # set it up at a breakpoint so we can play with the variable values
67 #
68 if ![runto_main] then {
69 perror "couldn't run to breakpoint"
70 continue
71 }
72
73 gdb_test "break A::foo" \
74 "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 38\\."
75
76 gdb_test "continue" \
77 "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::foo(\\(int\\)|) \\(this=$hex, arg=13\\) at .*method\\.cc:38\r\n38\[\t \]*x \\+= arg;" \
78 "continue to A::foo"
79
80 # Check ability to access this-relative stuff.
81
82 gdb_test "print x" \
83 "\\$\[0-9\]* = 20" \
84 "print x in A::foo"
85
86 # Check access to this pointer
87
88 gdb_test "print this" \
89 "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex" \
90 "print this in A::foo"
91
92 # Now do everything over again for A::bar, because sometimes processing one method
93 # (the first one) is fine, but the second one's debug info gets munged beyond recognition.
94
95 gdb_test "break A::bar" \
96 "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\."
97
98 gdb_test "continue" \
99 "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(\\(int\\) const|) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \
100 "continue to A::bar"
101
102 # Check ability to access this-relative stuff.
103
104 gdb_test "print x" \
105 "\\$\[0-9\]* = 33" \
106 "print x in A::bar"
107
108 # Check access to this pointer
109
110 gdb_test "print this" \
111 "\\$\[0-9\]* = \\((const |)(class |)A *\\* *(const|)\\) $hex" \
112 "print this in A::bar"
113
114 # Check again with funk::getFunky (this is the original test case
115 # for CHFts23426); sometimes having a constructor with no arguments
116 # will nuke the debug info read in for other methods in the class.
117
118 gdb_test "break 21" \
119 "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 21\\."
120
121 gdb_test "continue" \
122 "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, funk::getFunky(\\(int, int\\)|) \\(this=$hex, a=1, b=2\\) at .*method\\.cc:21\r\n21\[\t \]*data_ = res;" \
123 "continue to 21"
124
125 # Check ability to access this-relative stuff.
126
127 gdb_test "print data_" \
128 "\\$\[0-9\]* = 33" \
129 "print data_ in funk::getFunky"
130
131 # Check access to this pointer
132
133 gdb_test "print this" \
134 "\\$\[0-9\]* = \\((class |)funk *\\* *(const|)\\) $hex" \
135 "print this in funk::getFunky"
136
137 # Check access to local variable
138
139 gdb_test "print res" \
140 "\\$\[0-9\]* = -30" \
141 "print res in funk::getFunky"
142
143 # Check ptype of class -- should show const/volatile methods
144
145 send_gdb "ptype A\n"
146 gdb_expect {
147 -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" {
148 pass "ptype A"
149 }
150 -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" {
151 pass "ptype A"
152 }
153 -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\);\r\n\[ \]*int qux\\(int, float\\) const;\r\n\}\r\n$gdb_prompt $" {
154 pass "ptype A (HP aCC bug -- volatile not indicated)"
155 }
156 -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) const volatile;\r\n\}\r\n$gdb_prompt $" {
157 pass "ptype A"
158 }
159 -re ".*$gdb_prompt $" { fail "ptype A" }
160 timeout { fail "(timeout) ptype A" }
161 }
162
163 gdb_test "cont" \
164 "Continuing.\r\n\r\nProgram exited normally." \
165 "finish program"
This page took 0.036899 seconds and 4 git commands to generate.