blob: a1e107838d14675f4b5061994d14d8da3e2891e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# Copyright 1999-2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Tests for reference types with short type variables in GDB, based on
# gdb.cp/ref-types.exp.
if { [skip_cplus_tests] } { return }
standard_testfile .cc
if {[prepare_for_testing $testfile.exp $testfile $srcfile \
{debug c++ additional_flags="-std=gnu++11"}]} {
return -1
}
#
# Set it up at a breakpoint so we can play with the variable values.
#
if {![runto_main]} {
return -1
}
if {![runto 'marker1']} {
return -1
}
gdb_test "up" ".*main.*" "up from marker1 1"
gdb_test "print rrt" " = \\(short( int)? &&\\) @$hex: -1" "print value of rrt"
gdb_test "ptype rrt" "type = short( int)? &&"
gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt"
# gdb had a bug about dereferencing a pointer type
# that would lead to wrong results
# if we try to examine memory at pointer value.
gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt"
gdb_test "ptype rrpt" "type = short( int)? \\*&&"
gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]"
gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]"
gdb_test "print rrat\[1\]" ".$decimal = 1" "print value of rrat\[1\]"
gdb_test "print rrat\[2\]" ".$decimal = 2" "print value of rrat\[2\]"
gdb_test "print rrat\[3\]" ".$decimal = 3" "print value of rrat\[3\]"
if {![runto 'f']} then {
perror "couldn't run to f"
return
}
gdb_test "up" ".main2.*" "up from f"
gdb_test "ptype rrC" "type = char &&"
gdb_test "ptype rrUC" "type = unsigned char &&"
gdb_test "ptype rrS" "type = short( int)? &&"
gdb_test "ptype rrUS" "type = unsigned short( int)? &&"
gdb_test "ptype rrI" "type = int &&"
gdb_test "ptype rrUI" "type = unsigned int &&"
gdb_test "ptype rrL" "type = long( int)? &&"
gdb_test "ptype rrUL" "type = unsigned long( int)? &&"
gdb_test "ptype rrF" "type = float &&"
gdb_test "ptype rrD" "type = double &&"
gdb_test "print rrC" "$decimal = \\(char &&\\) @$hex: 65 \'A\'" \
"print value of rrC"
gdb_test "print rrUC" \
"$decimal = \\(unsigned char &&\\) @$hex: 21 \'.025\'" \
"print value of rrUC"
gdb_test "print rrS" "$decimal = \\(short( int)? &&\\) @$hex: -14" \
"print value of rrS"
gdb_test "print rrUS" \
"$decimal = \\(unsigned short( int)? &&\\) @$hex: 7" \
"print value of rrUS"
gdb_test "print rrI" "$decimal = \\(int &&\\) @$hex: 102" \
"print value of rrI"
gdb_test "print rrUI" \
"$decimal = \\(unsigned int &&\\) @$hex: 1002" \
"print value of rrUI"
gdb_test "print rrL" \
"$decimal = \\(long( int)? &&\\) @$hex: -234" \
"print value of rrL"
gdb_test "print rrUL" \
"$decimal = \\((unsigned long|long unsigned int)? &&\\) @$hex: 234" \
"print value of rrUL"
gdb_test "print rrF" \
"$decimal = \\(float &&\\) @$hex: 1.2${decimal}e\\+0?10.*" \
"print value of rrF"
gdb_test "print rrD" \
"$decimal = \\(double &&\\) @$hex: -1.375e-123.*" \
"print value of rrD"
|