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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [lib/] [gdb-test.exp] - Blame information for rev 866

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

Line No. Rev Author Line
1 742 jeremybenn
#   Copyright (C) 2009, 2011, 2012 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 GCC; see the file COPYING3.  If not see
15
# .
16
 
17
global gdb_tests
18
set gdb_tests {}
19
 
20
# Scan a file for markers and fill in the gdb_marker array for that
21
# file.  Any error in this script is simply thrown; errors here are
22
# programming errors in the test suite itself and should not be
23
# caught.
24
proc scan_gdb_markers {filename} {
25
    global gdb_markers
26
 
27
    if {[info exists gdb_markers($filename,-)]} {
28
        return
29
    }
30
 
31
    set fd [open $filename]
32
    set lineno 1
33
    while {! [eof $fd]} {
34
        set line [gets $fd]
35
        if {[regexp -- "Mark (\[a-zA-Z0-9\]+)" $line ignore marker]} {
36
            set gdb_markers($filename,$marker) $lineno
37
        }
38
        incr lineno
39
    }
40
    close $fd
41
 
42
    set gdb_markers($filename,-) {}
43
}
44
 
45
# Find a marker in a source file, and return the marker's line number.
46
proc get_line_number {filename marker} {
47
    global gdb_markers
48
 
49
    scan_gdb_markers $filename
50
    return $gdb_markers($filename,$marker)
51
}
52
 
53
# Make note of a gdb test.  A test consists of a variable name and an
54
# expected result.
55
proc note-test {var result} {
56
    global gdb_tests
57
 
58
    lappend gdb_tests $var $result 0
59
}
60
 
61
# A test that uses a regular expression.  This is like note-test, but
62
# the result is a regular expression that is matched against the
63
# output.
64
proc regexp-test {var result} {
65
    global gdb_tests
66
 
67
    lappend gdb_tests $var $result 1
68
}
69
 
70
# Utility for testing variable values using gdb, invoked via dg-final.
71
# Tests all tests indicated by note-test and regexp-test.
72
#
73
# Argument 0 is the marker on which to put a breakpoint
74
# Argument 2 handles expected failures and the like
75
proc gdb-test { marker {selector {}} } {
76
    if { ![isnative] || [is_remote target] } { return }
77
 
78
    if {[string length $selector] > 0} {
79
        switch [dg-process-target $selector] {
80
            "S" { }
81
            "N" { return }
82
            "F" { setup_xfail "*-*-*" }
83
            "P" { }
84
        }
85
    }
86
 
87
    # This assumes that we are three frames down from dg-test, and that
88
    # it still stores the filename of the testcase in a local variable "name".
89
    # A cleaner solution would require a new DejaGnu release.
90
    upvar 2 name testcase
91
    upvar 2 prog prog
92
 
93
    set line [get_line_number $prog $marker]
94
 
95
    set gdb_name $::env(GUALITY_GDB_NAME)
96
    set testname "$testcase"
97
    set output_file "[file rootname [file tail $prog]].exe"
98
    set cmd_file "[file rootname [file tail $prog]].gdb"
99
 
100
    global srcdir
101
    set pycode [file join $srcdir .. python libstdcxx v6 printers.py]
102
 
103
    global gdb_tests
104
 
105
    set fd [open $cmd_file "w"]
106
    puts $fd "source $pycode"
107
    puts $fd "python register_libstdcxx_printers(None)"
108
    puts $fd "break $line"
109
    puts $fd "run"
110
 
111
    set count 0
112
    foreach {var result is_regexp} $gdb_tests {
113
        puts $fd "print $var"
114
        incr count
115
        set gdb_var($count) $var
116
        set gdb_expected($count) $result
117
        set gdb_is_regexp($count) $is_regexp
118
    }
119
    set gdb_tests {}
120
 
121
    puts $fd "quit"
122
    close $fd
123
 
124
    send_log "Spawning: $gdb_name -nx -nw -quiet -batch -x $cmd_file ./$output_file\n"
125
    set res [remote_spawn target "$gdb_name -nx -nw -quiet -batch -x $cmd_file ./$output_file"]
126
    if { $res < 0 || $res == "" } {
127
        unsupported "$testname"
128
        return
129
    }
130
 
131
    remote_expect target [timeout_value] {
132
        -re {^\$([0-9]+) = ([^\n\r]*)[\n\r]+} {
133
            send_log "got: $expect_out(buffer)"
134
 
135
            set num $expect_out(1,string)
136
            set first $expect_out(2,string)
137
 
138
            if {$gdb_is_regexp($num)} {
139
                set match [regexp -- $gdb_expected($num) $first]
140
            } else {
141
                set match [expr {![string compare $first $gdb_expected($num)]}]
142
            }
143
 
144
            if {$match} {
145
                pass "$testname print $gdb_var($num)"
146
            } else {
147
                fail "$testname print $gdb_var($num)"
148
                verbose "     got =>$first<="
149
                verbose "expected =>$gdb_expected($num)<="
150
            }
151
 
152
            if {$num == $count} {
153
                remote_close target
154
                return
155
            } else {
156
                exp_continue
157
            }
158
        }
159
 
160
        -re {Python scripting is not supported in this copy of GDB.[\n\r]+} {
161
            unsupported "$testname"
162
            remote_close target
163
            return
164
        }
165
 
166
        -re {^[^$][^\n\r]*[\n\r]+} {
167
            send_log "skipping: $expect_out(buffer)"
168
            exp_continue
169
        }
170
 
171
        timeout {
172
            unsupported "$testname"
173
            remote_close target
174
            return
175
        }
176
    }
177
 
178
    remote_close target
179
    unsupported "$testname"
180
    return
181
}
182
 
183
# Check for a new-enough version of gdb.  The pretty-printer tests
184
# require gdb 7.3, but we don't want to test versions, so instead we
185
# check for the python "lookup_global_symbol" method, which is in 7.3
186
# but not earlier versions.
187
# Return 1 if the version is ok, 0 otherwise.
188
proc gdb_version_check {} {
189
    global gdb_version
190
 
191
    set gdb_name $::env(GUALITY_GDB_NAME)
192
    set cmd "$gdb_name -nw -nx -quiet -batch -ex \"python print gdb.lookup_global_symbol\""
193
    send_log "Spawning: $cmd\n"
194
    set res [remote_spawn target "$cmd"]
195
    if { $res < 0 || $res == "" } {
196
        return 0
197
    }
198
 
199
    remote_expect target [timeout_value] {
200
        -re "" {
201
            return 1
202
        }
203
 
204
        -re {^[^\n\r]*[\n\r]+} {
205
            verbose "skipping: $expect_out(buffer)"
206
            exp_continue
207
        }
208
 
209
        timeout {
210
            remote_close target
211
            return 0
212
        }
213
    }
214
 
215
    remote_close target
216
    return 0
217
}

powered by: WebSVN 2.1.0

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