OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2003, 2004, 2006, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Adam Fedor (fedor@gnu.org)
18
 
19
if $tracelevel then {
20
        strace $tracelevel
21
}
22
 
23
set testfile "basicclass"
24
set srcfile ${testfile}.m
25
set binfile ${objdir}/${subdir}/${testfile}
26
 
27
#
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
30
#
31
if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
32
  return -1
33
}
34
 
35
#
36
# Deduce language of main()
37
#
38
 
39
proc deduce_language_of_main {} {
40
    global gdb_prompt
41
 
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"
45
    gdb_expect {
46
        -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
47
            pass "deduced language is Objective-C, before full symbols"
48
        }
49
        -re ".*$gdb_prompt $" {
50
            fail "source language not correct for Objective-C (psymtabs only)"
51
            return
52
        }
53
        timeout {
54
            fail "can't show language (timeout)"
55
            return
56
        }
57
    }
58
 
59
    runto_main
60
 
61
    # See if our idea of the language has changed.
62
 
63
    send_gdb "show language\n"
64
    gdb_expect {
65
        -re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
66
            pass "deduced language is Objective-C, after full symbols"
67
        }
68
        -re ".*$gdb_prompt $" {
69
            fail "source language not correct for Objective-C (full symbols)"
70
            return
71
        }
72
        timeout {
73
            fail "can't show language (timeout)"
74
            return
75
        }
76
    }
77
}
78
 
79
proc do_objc_tests {} {
80
    global prms_id
81
    global bug_id
82
    global subdir
83
    global objdir
84
    global srcdir
85
    global binfile
86
    global gdb_prompt
87
 
88
    set prms_id 0
89
    set bug_id 0
90
 
91
    # Start with a fresh gdb.
92
 
93
    gdb_exit
94
    gdb_start
95
    gdb_reinitialize_dir $srcdir/$subdir
96
    gdb_load $binfile
97
 
98
    deduce_language_of_main
99
}
100
 
101
do_objc_tests
102
 
103
#
104
# Breakpoint tests
105
#
106
 
107
# Disable pending breakpoint query to avoid timeouts
108
# if Obj-C symbols cannot be found
109
gdb_test "set breakpoint pending off" "" "set breakpoint pending"
110
 
111
gdb_test "break doIt" \
112
    "Breakpoint.*at.* file .*$srcfile, line.29.*" \
113
    "breakpoint method"
114
 
115
gdb_test "break takeArg:" \
116
    "Breakpoint.*at.* file .*$srcfile, line.34.*" \
117
    "breakpoint method with colon"
118
 
119
gdb_test "break newWithArg:" \
120
    "Breakpoint.*at.* file .*$srcfile, line.22.*" \
121
    "breakpoint class method with colon"
122
 
123
#
124
# Continue until breakpoint (test re-setting breakpoint)
125
#
126
gdb_test continue \
127
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
128
    "continue until method breakpoint"
129
 
130
#
131
# Test resetting breakpoints when re-running program
132
#
133
gdb_run_cmd
134
gdb_expect {
135
    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
136
                            { pass "resetting breakpoints when rerunning" }
137
    -re ".*$gdb_prompt $"       { fail "resetting breakpoints when rerunning" }
138
    timeout                 { fail "resetting breakpoints when rerunning" }
139
}
140
 
141
#
142
# Continue until breakpoint (test re-setting breakpoint)
143
#
144
gdb_test continue \
145
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
146
    "continue until method breakpoint"
147
 
148
#
149
# Test printing objects
150
#
151
gdb_test "print object" \
152
    "\\$\[0-9\] = .*0x0" \
153
    " print an ivar of self"
154
 
155
gdb_test "print self" \
156
    "\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
157
    " print self"
158
 
159
gdb_test "print \*self" \
160
    "\\$\[0-9\] = \{{?isa = 0x\[0-9a-f\]+}?, object = 0x0\}" \
161
    " print contents of self"
162
 
163
#
164
# Break in a category
165
#
166
gdb_test "break hiddenMethod" \
167
    "Breakpoint.*at.* file .*$srcfile, line.61." \
168
    "breakpoint in category method"
169
 
170
 
171
#
172
# Continue until breakpoint (test re-setting category breakpoint)
173
#
174
gdb_test continue \
175
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
176
     "continue until category method"
177
 
178
#
179
# Test calling Objective-C methods
180
#
181
gdb_test "print \[self printHi\]" \
182
    "Hi.*\\$\[0-9\] = \\(.*objc_object \\*\\) 0x\[0-9a-f\]+" \
183
    "Call an Objective-C method with no arguments"
184
 
185
gdb_test "print \[self printNumber: 42\]" \
186
    "42.*\\$\[0-9\] = 43" \
187
    "Call an Objective-C method with one argument"
188
 
189
#
190
# Test printing the object description
191
#
192
gdb_test "print-object object" \
193
    "BasicClass gdb test object" \
194
    "Use of the print-object command"
195
 
196
gdb_test "po self" \
197
    "BasicClass gdb test object" \
198
    "Use of the po (print-object) command"
199
 
200
 

powered by: WebSVN 2.1.0

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