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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 701 jeremybenn
#   Copyright (C) 2009, 2011 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
        file delete $cmd_file
60
        return
61
    }
62
 
63
    remote_expect target [timeout_value] {
64
        # Too old GDB
65
        -re "Unhandled dwarf expression|Error in sourced command file" {
66
            unsupported "$testname"
67
            remote_close target
68
            file delete $cmd_file
69
            return
70
        }
71
        -re {[\n\r]\$1 = ([^\n\r]*)[\n\r]+\$2 = ([^\n\r]*)[\n\r]} {
72
            set first $expect_out(1,string)
73
            set second $expect_out(2,string)
74
            if { $first == $second } {
75
                pass "$testname"
76
            } else {
77
                send_log "$first != $second\n"
78
                fail "$testname"
79
            }
80
            remote_close target
81
            file delete $cmd_file
82
            return
83
        }
84
        timeout {
85
            unsupported "$testname"
86
            remote_close target
87
            file delete $cmd_file
88
            return
89
        }
90
    }
91
 
92
    unsupported "$testname"
93
    remote_close target
94
    file delete $cmd_file
95
    return
96
}

powered by: WebSVN 2.1.0

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