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.ada/] [formatted_ref.exp] - Blame information for rev 229

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2007, 2008, 2009, 2010 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 this program.  If not, see .
15
 
16
# Author: P. N. Hilfinger, AdaCore Inc.
17
 
18
# Note: This test is essentially a transcription of gdb.cp/formatted-ref.exp,
19
# and is thus much more wordy than it needs to be. There are fewer
20
# tests because only a few parameter types in Ada are required to be
21
# passed by reference, and there is no equivalent of &(&x) for reference
22
# values.
23
# This also tests that some other arithmetic operations on references
24
# work properly: condition expression using a reference object as one of its
25
# operand.
26
 
27
if $tracelevel then {
28
        strace $tracelevel
29
}
30
 
31
load_lib "ada.exp"
32
 
33
set testdir "formatted_ref"
34
set testfile "${testdir}/formatted_ref"
35
set srcfile ${srcdir}/${subdir}/${testfile}.adb
36
set binfile ${objdir}/${subdir}/${testfile}
37
 
38
 
39
file mkdir ${objdir}/${subdir}/${testdir}
40
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
41 229 jeremybenn
    # JPB. This should just be unsupported (like all the other tests) when
42
    # compilation fails (that will happen with gdb_compile_ada
43
    # automatically). No need for "untested" here.
44
 
45
    # untested formatted-ref.exp
46 227 jeremybenn
    return -1
47
}
48
 
49
proc get_address { var } {
50
    global expect_out
51
    global gdb_prompt
52
 
53
    send_gdb "print $var'access\n"
54
    gdb_expect {
55
        -re "\\$\[0-9\]+ = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
56
            return $expect_out(1,string)
57
        }
58
        timeout {
59
            perror "couldn't find address of $var"
60
            return ""
61
        }
62
    }
63
}
64
 
65
proc test_p_x { var val addr } {
66
    global gdb_prompt
67
 
68
    set test "print/x $var"
69
    gdb_test_multiple "$test" $test {
70
        -re "\\$\[0-9\]+ = [string_to_regexp $val].*$gdb_prompt $" {
71
            pass $test
72
        }
73
        -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
74
            fail "$test (prints just address)"
75
        }
76
        -re "\\$\[0-9\]+ = 0x\[a-f0-9\]+.*$gdb_prompt $" {
77
            fail "$test (prints unexpected address)"
78
        }
79
    }
80
    return 0
81
}
82
 
83
proc test_p_x_addr { var addr } {
84
    global gdb_prompt
85
 
86
    set test "print/x $var'access"
87
    gdb_test_multiple $test $test {
88
        -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
89
            pass $test
90
        }
91
        -re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
92
            fail "$test (prints unexpected address)"
93
        }
94
    }
95
    return 0
96
}
97
 
98
proc test_p_op1_equals_op2 {op1 op2} {
99
    set test "print $op1 = $op2"
100
    gdb_test $test "\\$\[0-9\]+ = true"
101
}
102
 
103
gdb_exit
104
gdb_start
105
gdb_reinitialize_dir $srcdir/$subdir
106
gdb_load ${binfile}
107
 
108
runto defs.adb:[gdb_get_line_number "marker here" ${testdir}/defs.adb ]
109
 
110
set s1_address  [get_address "s1"]
111
 
112
test_p_x "s" "(x => 0xd, y => 0x13)" $s1_address
113
 
114
test_p_x_addr "s" $s1_address
115
 
116
test_p_op1_equals_op2 "s.x" "13"

powered by: WebSVN 2.1.0

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