Commit | Line | Data |
---|---|---|
c0f55cc6 AV |
1 | # Copyright 1999-2017 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 <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Tests for reference types with short type variables in GDB, based on | |
17 | # gdb.cp/ref-types.exp. | |
18 | ||
19 | if { [skip_cplus_tests] } { continue } | |
20 | ||
21 | standard_testfile .cc | |
22 | ||
23 | if {[prepare_for_testing $testfile.exp $testfile $srcfile \ | |
24 | {debug c++ additional_flags="-std=gnu++11"}]} { | |
25 | return -1 | |
26 | } | |
27 | ||
28 | # | |
29 | # Set it up at a breakpoint so we can play with the variable values. | |
30 | # | |
31 | if {![runto_main]} { | |
32 | untested "couldn't run to breakpoint" | |
33 | return -1 | |
34 | } | |
35 | ||
36 | if {![runto 'marker1']} { | |
37 | untested "couldn't run to marker1" | |
38 | return -1 | |
39 | } | |
40 | ||
41 | gdb_test "up" ".*main.*" "up from marker1 1" | |
42 | ||
43 | gdb_test "print rrt" " = \\(short( int)? &&\\) @$hex: -1" "print value of rrt" | |
44 | ||
45 | gdb_test "ptype rrt" "type = short( int)? &&" "ptype rrt" | |
46 | ||
47 | gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt" | |
48 | ||
49 | # gdb had a bug about dereferencing a pointer type | |
50 | # that would lead to wrong results | |
51 | # if we try to examine memory at pointer value. | |
52 | ||
53 | gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt" | |
54 | ||
55 | gdb_test "ptype rrpt" "type = short( int)? \\*&&" "ptype rrpt" | |
56 | ||
57 | gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]" | |
58 | ||
59 | gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]" "ptype rrat" | |
60 | ||
61 | gdb_test "print rrat\[1\]" ".$decimal = 1" "print value of rrat\[1\]" | |
62 | gdb_test "print rrat\[2\]" ".$decimal = 2" "print value of rrat\[2\]" | |
63 | gdb_test "print rrat\[3\]" ".$decimal = 3" "print value of rrat\[3\]" | |
64 | ||
65 | ||
66 | if {![runto 'f']} then { | |
67 | perror "couldn't run to f" | |
68 | continue | |
69 | } | |
70 | ||
71 | gdb_test "up" ".main2.*" "up from f" | |
72 | ||
73 | gdb_test "ptype rrC" "type = char &&" | |
74 | ||
75 | gdb_test "ptype rrUC" "type = unsigned char &&" | |
76 | ||
77 | gdb_test "ptype rrS" "type = short( int)? &&" "ptype rrS" | |
78 | ||
79 | gdb_test "ptype rrUS" "type = unsigned short( int)? &&" "ptype rrUS" | |
80 | ||
81 | gdb_test "ptype rrI" "type = int &&" | |
82 | ||
83 | gdb_test "ptype rrUI" "type = unsigned int &&" | |
84 | ||
85 | gdb_test "ptype rrL" "type = long( int)? &&" "ptype rrL" | |
86 | ||
87 | gdb_test "ptype rrUL" "type = unsigned long( int)? &&" "ptype rrUL" | |
88 | ||
89 | gdb_test "ptype rrF" "type = float &&" | |
90 | ||
91 | gdb_test "ptype rrD" "type = double &&" | |
92 | ||
93 | gdb_test "print rrC" "$decimal = \\(char &&\\) @$hex: 65 \'A\'" \ | |
94 | "print value of rrC" | |
95 | ||
96 | gdb_test "print rrUC" \ | |
97 | "$decimal = \\(unsigned char &&\\) @$hex: 21 \'.025\'" \ | |
98 | "print value of rrUC" | |
99 | ||
100 | gdb_test "print rrS" "$decimal = \\(short( int)? &&\\) @$hex: -14" \ | |
101 | "print value of rrS" | |
102 | ||
103 | gdb_test "print rrUS" \ | |
104 | "$decimal = \\(unsigned short( int)? &&\\) @$hex: 7" \ | |
105 | "print value of rrUS" | |
106 | ||
107 | gdb_test "print rrI" "$decimal = \\(int &&\\) @$hex: 102" \ | |
108 | "print value of rrI" | |
109 | ||
110 | gdb_test "print rrUI" \ | |
111 | "$decimal = \\(unsigned int &&\\) @$hex: 1002" \ | |
112 | "print value of rrUI" | |
113 | ||
114 | gdb_test "print rrL" \ | |
115 | "$decimal = \\(long( int)? &&\\) @$hex: -234" \ | |
116 | "print value of rrL" | |
117 | ||
118 | gdb_test "print rrUL" \ | |
119 | "$decimal = \\((unsigned long|long unsigned int)? &&\\) @$hex: 234" \ | |
120 | "print value of rrUL" | |
121 | ||
122 | gdb_test "print rrF" \ | |
123 | "$decimal = \\(float &&\\) @$hex: 1.2${decimal}e\\+0?10.*" \ | |
124 | "print value of rrF" | |
125 | ||
126 | gdb_test "print rrD" \ | |
127 | "$decimal = \\(double &&\\) @$hex: -1.375e-123.*" \ | |
128 | "print value of rrD" |