OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.objc/] [basicclass.exp] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2003, 2004, 2006, 2007, 2008 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 3 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, see .
15
 
16
# This file was written by Adam Fedor (fedor@gnu.org)
17
 
18
if $tracelevel then {
19
        strace $tracelevel
20
}
21
 
22
set testfile "basicclass"
23
set srcfile ${testfile}.m
24
set binfile ${objdir}/${subdir}/${testfile}
25
 
26
#
27
# Objective-C program compilation isn't standard. We need to figure out
28
# which libraries to link in. Most of the time it uses pthread
29
#
30
if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
31
  return -1
32
}
33
 
34
#
35
# Deduce language of main()
36
#
37
 
38
proc deduce_language_of_main {} {
39
    global gdb_prompt
40
 
41
    # See what language gdb thinks main() is, prior to reading full symbols.
42
    # I think this fails for COFF targets.
43
    send_gdb "show language\n"
44
    gdb_expect {
45
        -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
46
            pass "deduced language is Objective-C, before full symbols"
47
        }
48
        -re ".*$gdb_prompt $" {
49
            fail "source language not correct for Objective-C (psymtabs only)"
50
            return
51
        }
52
        timeout {
53
            fail "can't show language (timeout)"
54
            return
55
        }
56
    }
57
 
58
    runto_main
59
 
60
    # See if our idea of the language has changed.
61
 
62
    send_gdb "show language\n"
63
    gdb_expect {
64
        -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
65
            pass "deduced language is Objective-C, after full symbols"
66
        }
67
        -re ".*$gdb_prompt $" {
68
            fail "source language not correct for Objective-C (full symbols)"
69
            return
70
        }
71
        timeout {
72
            fail "can't show language (timeout)"
73
            return
74
        }
75
    }
76
}
77
 
78
proc do_objc_tests {} {
79
    global prms_id
80
    global bug_id
81
    global subdir
82
    global objdir
83
    global srcdir
84
    global binfile
85
    global gdb_prompt
86
 
87
    set prms_id 0
88
    set bug_id 0
89
 
90
    # Start with a fresh gdb.
91
 
92
    gdb_exit
93
    gdb_start
94
    gdb_reinitialize_dir $srcdir/$subdir
95
    gdb_load $binfile
96
 
97
    deduce_language_of_main
98
}
99
 
100
do_objc_tests
101
 
102
#
103
# Breakpoint tests
104
#
105
gdb_test "break doIt" \
106
    "Breakpoint.*at.* file .*$srcfile, line.29.*" \
107
    "breakpoint method"
108
 
109
gdb_test "break takeArg:" \
110
    "Breakpoint.*at.* file .*$srcfile, line.34.*" \
111
    "breakpoint method with colon"
112
 
113
gdb_test "break newWithArg:" \
114
    "Breakpoint.*at.* file .*$srcfile, line.22.*" \
115
    "breakpoint class method with colon"
116
 
117
#
118
# Continue until breakpoint (test re-setting breakpoint)
119
#
120
gdb_test continue \
121
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
122
    "continue until method breakpoint"
123
 
124
#
125
# Test resetting breakpoints when re-running program
126
#
127
gdb_run_cmd
128
gdb_expect {
129
    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
130
                            { pass "resetting breakpoints when rerunning" }
131
    -re ".*$gdb_prompt $"       { fail "resetting breakpoints when rerunning" }
132
    timeout                 { fail "resetting breakpoints when rerunning" }
133
}
134
 
135
#
136
# Continue until breakpoint (test re-setting breakpoint)
137
#
138
gdb_test continue \
139
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
140
    "continue until method breakpoint"
141
 
142
#
143
# Test printing objects
144
#
145
gdb_test "print object" \
146
    "\\$\[0-9\] = .*0x0" \
147
    " print an ivar of self"
148
 
149
gdb_test "print self" \
150
    "\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
151
    " print self"
152
 
153
gdb_test "print \*self" \
154
    "\\$\[0-9\] = \{{?isa = 0x\[0-9a-f\]+}?, object = 0x0\}" \
155
    " print contents of self"
156
 
157
#
158
# Break in a category
159
#
160
gdb_test "break hiddenMethod" \
161
    "Breakpoint.*at.* file .*$srcfile, line.61." \
162
    "breakpoint in category method"
163
 
164
 
165
#
166
# Continue until breakpoint (test re-setting category breakpoint)
167
#
168
gdb_test continue \
169
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
170
     "continue until category method"
171
 
172
#
173
# Test calling Objective-C methods
174
#
175
gdb_test "print \[self printHi\]" \
176
    "Hi.*\\$\[0-9\] = \\(.*objc_object \\*\\) 0x\[0-9a-f\]+" \
177
    "Call an Objective-C method with no arguments"
178
 
179
gdb_test "print \[self printNumber: 42\]" \
180
    "42.*\\$\[0-9\] = 43" \
181
    "Call an Objective-C method with one argument"
182
 
183
#
184
# Test printing the object description
185
#
186
gdb_test "print-object object" \
187
    "BasicClass gdb test object" \
188
    "Use of the print-object command"
189
 
190
gdb_test "po self" \
191
    "BasicClass gdb test object" \
192
    "Use of the po (print-object) command"
193
 
194
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.