1 # Copyright
2003, 2004 Free Software Foundation
, Inc.
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.
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.
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.
17 # This file was written by Adam Fedor
(fedor@gnu.org
)
23 set testfile
"basicclass"
24 set srcfile $
{testfile
}.m
25 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
28 # Objective
-C
program compilation isn
't standard. We need to figure out
29 # which libraries to link in. Most of the time it uses pthread
31 if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
36 # Deduce language of main()
39 proc deduce_language_of_main {} {
42 # See what language gdb thinks main() is, prior to reading full symbols.
43 # I think this fails for COFF targets.
44 send_gdb "show language\n"
46 -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
47 pass "deduced language is Objective-C, before full symbols"
49 -re ".*$gdb_prompt $" {
50 fail "source language not correct for Objective-C (psymtabs only)"
54 fail "can't
show language
(timeout
)"
61 # See
if our idea of the language has changed.
63 send_gdb
"show language\n"
65 -re
".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
66 pass
"deduced language is Objective-C, after full symbols"
68 -re
".*$gdb_prompt $" {
69 fail
"source language not correct for Objective-C (full symbols)"
73 fail
"can't show language (timeout)"
79 proc do_objc_tests
{} {
91 # Start with a fresh gdb.
95 gdb_reinitialize_dir $srcdir
/$subdir
98 deduce_language_of_main
106 gdb_test
"break doIt" \
107 "Breakpoint.*at.* file .*$srcfile, line.29.*" \
110 gdb_test
"break takeArg:" \
111 "Breakpoint.*at.* file .*$srcfile, line.34.*" \
112 "breakpoint method with colon"
114 gdb_test
"break newWithArg:" \
115 "Breakpoint.*at.* file .*$srcfile, line.22.*" \
116 "breakpoint class method with colon"
119 #
Continue until breakpoint
(test re
-setting breakpoint
)
122 "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
123 "continue until method breakpoint"
126 # Test resetting breakpoints when re
-running
program
130 -re
"Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
131 { pass
"resetting breakpoints when rerunning" }
132 -re
".*$gdb_prompt $" { fail "resetting breakpoints when rerunning" }
133 timeout
{ fail
"resetting breakpoints when rerunning" }
137 #
Continue until breakpoint
(test re
-setting breakpoint
)
140 "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
141 "continue until method breakpoint"
144 # Test printing objects
146 gdb_test
"print object" \
147 "\\$\[0-9\] = .*0x0" \
148 " print an ivar of self"
150 gdb_test
"print self" \
151 "\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
154 gdb_test
"print \*self" \
155 "\\$\[0-9\] = \{isa = 0x\[0-9a-f\]+, object = 0x0\}" \
156 " print contents of self"
159 #
Break in a category
161 gdb_test
"break hiddenMethod" \
162 "Breakpoint.*at.* file .*$srcfile, line.61." \
163 "breakpoint in category method"
167 #
Continue until breakpoint
(test re
-setting category breakpoint
)
170 "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
171 "continue until category method"
174 # Test calling Objective
-C methods
176 gdb_test
"print \[self printHi\]" \
177 "Hi.*\\$\[0-9\] = \\(.*objc_object \\*\\) 0x\[0-9a-f\]+" \
178 "Call an Objective-C method with no arguments"
180 gdb_test
"print \[self printNumber: 42\]" \
181 "42.*\\$\[0-9\] = 43" \
182 "Call an Objective-C method with one argument"
185 # Test printing the object description
187 gdb_test
"print-object object" \
188 "BasicClass gdb test object" \
189 "Use of the print-object command"
192 "BasicClass gdb test object" \
193 "Use of the po (print-object) command"