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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [formatted-ref.exp] - Blame information for rev 258

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

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2007, 2008 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
# This test checks the behavior of formatted print when applied to a
19
# reference value.  The intended behavior is that a formatted print of
20
# such a value should display the same value as a plain print,
21
# modulo format, of course.  Older versions of GDB would instead print
22
# the reference's address value itself when doing a formatted print,
23
# rather than printing both that and the dereferenced value.  We also
24
# check that the (non-standard) expression &(&x), where x is of type T&,
25
# yields an appropriate value.
26
 
27
if $tracelevel then {
28
        strace $tracelevel
29
}
30
 
31
set prms_id 0
32
set bug_id 0
33
 
34
if { [skip_cplus_tests] } { continue }
35
 
36
set testfile "formatted-ref"
37
set srcfile ${testfile}.cc
38
set binfile ${objdir}/${subdir}/${testfile}
39
 
40
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
41
     untested formatted-ref.exp
42
     return -1
43
}
44
 
45
proc get_address { var } {
46
    global expect_out
47
    global gdb_prompt
48
 
49
    send_gdb "print &$var\n"
50
    gdb_expect {
51
        -re "\\$\[0-9\]+ = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
52
            return $expect_out(1,string)
53
        }
54
        timeout {
55
            perror "couldn't find address of $var"
56
            return ""
57
        }
58
    }
59
}
60
 
61
proc test_p_x { var type val addr } {
62
    global gdb_prompt
63
 
64
    set test "print/x $var"
65
    gdb_test_multiple $test $test {
66
        -re "\\$\[0-9\]+ = \\([string_to_regexp $type]\\) @0x\[a-f0-9\]+: [string_to_regexp $val].*$gdb_prompt $" {
67
            pass $test
68
        }
69
        -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
70
            fail "$test (prints just address)"
71
        }
72
        -re "\\$\[0-9\]+ = 0x\[a-f0-9\]+.*$gdb_prompt $" {
73
            fail "$test (prints unexpected address)"
74
        }
75
    }
76
    return 0
77
}
78
 
79
proc test_p_x_addr { var addr } {
80
    global gdb_prompt
81
 
82
    set test "print/x &$var"
83
    gdb_test_multiple $test $test {
84
        -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
85
            pass $test
86
        }
87
        -re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
88
            fail "$test (prints unexpected address)"
89
        }
90
    }
91
    return 0
92
}
93
 
94
proc test_p_x_ref_addr { var addr } {
95
    global gdb_prompt
96
 
97
    set test "print/x *(&(&$var))"
98
    gdb_test_multiple $test $test {
99
        -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
100
            pass $test
101
        }
102
        -re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
103
            fail "$test (prints unexpected address)"
104
        }
105
    }
106
    return 0
107
}
108
 
109
gdb_exit
110
gdb_start
111
gdb_reinitialize_dir $srcdir/$subdir
112
gdb_load ${binfile}
113
 
114
runto ${srcfile}:[gdb_get_line_number "marker here"]
115
 
116
set s1_address  [get_address "s1"]
117
set e1_address  [get_address "e1"]
118
set i1_address  [get_address "i1"]
119
 
120
test_p_x "s" "Struct1 &" "{x = 0xd, y = 0x13}" $s1_address
121
test_p_x "e" "Enum1 &" "0xb" $e1_address
122
test_p_x "i" "int &" "0x17" $i1_address
123
 
124
test_p_x_addr "s" $s1_address
125
test_p_x_addr "e" $e1_address
126
test_p_x_addr "i" $i1_address
127
 
128
test_p_x_ref_addr "s" $s1_address
129
test_p_x_ref_addr "i" $i1_address
130
test_p_x_ref_addr "e" $e1_address

powered by: WebSVN 2.1.0

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