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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.c++/] [misc.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002 Free Software
2
# Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
18
# Please email any bugs, comments, and/or additions to this file to:
19
# bug-gdb@prep.ai.mit.edu
20
 
21
# This file was written by Fred Fish. (fnf@cygnus.com)
22
 
23
if $tracelevel then {
24
        strace $tracelevel
25
}
26
 
27
if { [skip_cplus_tests] } { continue }
28
 
29
set testfile "misc"
30
set srcfile ${testfile}.cc
31
set binfile ${objdir}/${subdir}/${testfile}
32
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
33
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
34
}
35
 
36
#
37
# Deduce language of main()
38
#
39
 
40
proc deduce_language_of_main {} {
41
    global gdb_prompt
42
 
43
    # See what language gdb thinks main() is, prior to reading full symbols.
44
    # I think this fails for COFF targets.
45
    send_gdb "show language\n"
46
    gdb_expect {
47
        -re ".* source language is \"auto; currently c\[+\]+\".*$gdb_prompt $" {
48
            pass "deduced language is C++, before full symbols"
49
        }
50
        -re ".*$gdb_prompt $" {
51
            fail "source language not correct for C++ (psymtabs only)"
52
            return
53
        }
54
        timeout {
55
            fail "can't show language (timeout)"
56
            return
57
        }
58
    }
59
 
60
    runto_main
61
 
62
    # See if our idea of the language has changed.
63
 
64
    send_gdb "show language\n"
65
    gdb_expect {
66
        -re ".* source language is \"auto; currently c\[+\]+\".*$gdb_prompt $" {
67
            pass "deduced language is C++, after full symbols"
68
        }
69
        -re ".*$gdb_prompt $" {
70
            fail "source language not correct for C++ (full symbols)"
71
            return
72
        }
73
        timeout {
74
            fail "can't show language (timeout)"
75
            return
76
        }
77
    }
78
}
79
 
80
proc test_expr { args } {
81
    if { [llength $args] % 2 } {
82
        warning "an even # of arguments should be passed to test_expr"
83
    }
84
    set last_ent [expr [llength $args] - 1];
85
    set testname [lindex $args $last_ent];
86
    if [gdb_test [lindex $args 0] "" "$testname (setup)"] {
87
        gdb_suppress_tests;
88
    }
89
    for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
90
        if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] {
91
            gdb_suppress_tests;
92
        }
93
    }
94
    gdb_stop_suppressing_tests;
95
}
96
 
97
proc do_tests {} {
98
    global prms_id
99
    global bug_id
100
    global subdir
101
    global objdir
102
    global srcdir
103
    global binfile
104
    global gdb_prompt
105
 
106
    set prms_id 0
107
    set bug_id 0
108
 
109
    # Start with a fresh gdb.
110
 
111
    gdb_exit
112
    gdb_start
113
    gdb_reinitialize_dir $srcdir/$subdir
114
    gdb_load $binfile
115
 
116
    deduce_language_of_main
117
    # Check for fixes for PRs 8916 and 8630
118
    gdb_test "print s.a" ".* = 0" "print s.a for foo struct (known gcc 2.7.2 and earlier bug)"
119
}
120
 
121
do_tests
122
 
123
test_expr "set language c++" \
124
    "print 1 == 1" "print.*\\$\[0-9\]* = true" \
125
    "print 1 == 2" "print.*\\$\[0-9\]* = false" \
126
    "print as bool"
127
 
128
# Test bool type printing, etc.
129
# Note: Language is already set to C++ above!
130
gdb_test "print v_bool" "\\$\[0-9\]* = false" "print a bool var"
131
 
132
# set a bool variable
133
test_expr "set variable v_bool = true" \
134
    "print v_bool" "\\$\[0-9\]* = true" \
135
    "set a bool var"
136
 
137
# next print an array of bool
138
gdb_test "print v_bool_array" "\\$\[0-9\]* = \\{false, false\\}" "print a bool array"
139
 
140
# set elements of a bool array
141
test_expr "set variable v_bool_array\[1\] = true" \
142
    "print v_bool_array" "\\$\[0-9\]* = \\{false, true\\}" \
143
    "set a bool array elem"
144
 
145
# bool constants
146
gdb_test "print true" "\\$\[0-9\]* = true" "print true"
147
gdb_test "print false" "\\$\[0-9\]* = false" "print false"
148
 
149
# arithmetic conversions
150
gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true"
151
gdb_test "print 3 + false" "\\$\[0-9\]* = 3" "3 + false"
152
gdb_test "print 1 < 2 < 3" "\\$\[0-9\]* = true" "1 < 2 < 3"
153
gdb_test "print 2 < 1 > 4" "\\$\[0-9\]* = false" "2 < 1 > 4"
154
gdb_test "print (bool)43" "\\$\[0-9\]* = true" "(bool)43"
155
gdb_test "print (bool)0" "\\$\[0-9\]* = false" "(bool)0"
156
gdb_test "print (bool)17.93" "\\$\[0-9\]* = true" "(bool)17.93"
157
gdb_test "print (bool)0.0" "\\$\[0-9\]* = false" "(bool)0.0"
158
gdb_test "print (int)true" "\\$\[0-9\]* = 1" "(int)true"
159
gdb_test "print (int)false" "\\$\[0-9\]* = 0" "(int)false"

powered by: WebSVN 2.1.0

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