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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc3/] [gdb/] [testsuite/] [gdb.objc/] [basicclass.exp] - Blame information for rev 513

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 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 subdir
81
    global objdir
82
    global srcdir
83
    global binfile
84
    global gdb_prompt
85
 
86
 
87
    # Start with a fresh gdb.
88
 
89
    gdb_exit
90
    gdb_start
91
    gdb_reinitialize_dir $srcdir/$subdir
92
    gdb_load $binfile
93
 
94
    deduce_language_of_main
95
}
96
 
97
do_objc_tests
98
 
99
#
100
# Breakpoint tests
101
#
102
 
103
# Disable pending breakpoint query to avoid timeouts
104
# if Obj-C symbols cannot be found
105
gdb_test "set breakpoint pending off" "" "set breakpoint pending"
106
 
107
gdb_test "break doIt" \
108
    "Breakpoint.*at.* file .*$srcfile, line.29.*" \
109
    "breakpoint method"
110
 
111
gdb_test "break takeArg:" \
112
    "Breakpoint.*at.* file .*$srcfile, line.34.*" \
113
    "breakpoint method with colon"
114
 
115
gdb_test "break newWithArg:" \
116
    "Breakpoint.*at.* file .*$srcfile, line.22.*" \
117
    "breakpoint class method with colon"
118
 
119
#
120
# Continue until breakpoint (test re-setting breakpoint)
121
#
122
gdb_test continue \
123
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
124
    "continue until method breakpoint"
125
 
126
#
127
# Test resetting breakpoints when re-running program
128
#
129
gdb_run_cmd
130
gdb_expect {
131
    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
132
                            { pass "resetting breakpoints when rerunning" }
133
    -re ".*$gdb_prompt $"       { fail "resetting breakpoints when rerunning" }
134
    timeout                 { fail "resetting breakpoints when rerunning" }
135
}
136
 
137
#
138
# Continue until breakpoint (test re-setting breakpoint)
139
#
140
gdb_test continue \
141
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
142
    "continue until method breakpoint"
143
 
144
#
145
# Test printing objects
146
#
147
gdb_test "print object" \
148
    "\\$\[0-9\] = .*0x0" \
149
    " print an ivar of self"
150
 
151
gdb_test "print self" \
152
    "\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
153
    " print self"
154
 
155
gdb_test "print \*self" \
156
    "\\$\[0-9\] = \{{?isa = 0x\[0-9a-f\]+}?, object = 0x0\}" \
157
    " print contents of self"
158
 
159
#
160
# Break in a category
161
#
162
gdb_test "break hiddenMethod" \
163
    "Breakpoint.*at.* file .*$srcfile, line.61." \
164
    "breakpoint in category method"
165
 
166
 
167
#
168
# Continue until breakpoint (test re-setting category breakpoint)
169
#
170
gdb_test continue \
171
    "Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
172
     "continue until category method"
173
 
174
#
175
# Test calling Objective-C methods
176
#
177
gdb_test "print \[self printHi\]" \
178
    "Hi.*\\$\[0-9\] = \\(.*objc_object \\*\\) 0x\[0-9a-f\]+" \
179
    "Call an Objective-C method with no arguments"
180
 
181
gdb_test "print \[self printNumber: 42\]" \
182
    "42.*\\$\[0-9\] = 43" \
183
    "Call an Objective-C method with one argument"
184
 
185
#
186
# Test printing the object description
187
#
188
gdb_test "print-object object" \
189
    "BasicClass gdb test object" \
190
    "Use of the print-object command"
191
 
192
gdb_test "po self" \
193
    "BasicClass gdb test object" \
194
    "Use of the po (print-object) command"
195
 
196
 

powered by: WebSVN 2.1.0

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