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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [lib/] [gcc-gdb-test.exp] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 306 jeremybenn
#   Copyright (C) 2009 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
# Utility for testing variable values using gdb, invoked via dg-final.
18
# Call pass if variable has the desired value, otherwise fail.
19
#
20
# Argument 0 is the line number on which to put a breakpoint
21
# Argument 1 is the name of the variable to be checked
22
# Argument 2 is the expected value of the variable
23
# Argument 3 handles expected failures and the like
24
proc gdb-test { args } {
25
    if { ![isnative] || [is_remote target] } { return }
26
 
27
    if { [llength $args] >= 4 } {
28
        switch [dg-process-target [lindex $args 3]] {
29
            "S" { }
30
            "N" { return }
31
            "F" { setup_xfail "*-*-*" }
32
            "P" { }
33
        }
34
    }
35
 
36
    # This assumes that we are three frames down from dg-test, and that
37
    # it still stores the filename of the testcase in a local variable "name".
38
    # A cleaner solution would require a new DejaGnu release.
39
    upvar 2 name testcase
40
    upvar 2 prog prog
41
 
42
    set gdb_name $::env(GUALITY_GDB_NAME)
43
    set testname "$testcase line [lindex $args 0] [lindex $args 1] == [lindex $args 2]"
44
    set output_file "[file rootname [file tail $prog]].exe"
45
    set cmd_file "[file rootname [file tail $prog]].gdb"
46
 
47
    set fd [open $cmd_file "w"]
48
    puts $fd "break [lindex $args 0]"
49
    puts $fd "run"
50
    puts $fd "print [lindex $args 1]"
51
    puts $fd "print [lindex $args 2]"
52
    puts $fd "quit"
53
    close $fd
54
 
55
    send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$output_file\n"
56
    set res [remote_spawn target "$gdb_name -nx -nw -quiet -x $cmd_file ./$output_file"]
57
    if { $res < 0 || $res == "" } {
58
        unsupported "$testname"
59
        return
60
    }
61
 
62
    remote_expect target [timeout_value] {
63
        -re {[\n\r]\$1 = ([^\n\r]*)[\n\r]+\$2 = ([^\n\r]*)[\n\r]} {
64
            set first $expect_out(1,string)
65
            set second $expect_out(2,string)
66
            if { $first == $second } {
67
                pass "$testname"
68
            } else {
69
                send_log "$first != $second\n"
70
                fail "$testname"
71
            }
72
            remote_close target
73
            return
74
        }
75
        # Too old GDB
76
        -re "Unhandled dwarf expression|Error in sourced command file" {
77
            unsupported "$testname"
78
            remote_close target
79
            return
80
        }
81
        timeout {
82
            unsupported "$testname"
83
            remote_close target
84
            return
85
        }
86
    }
87
 
88
    remote_close target
89
    unsupported "$testname"
90
    return
91
}

powered by: WebSVN 2.1.0

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