1 # Copyright 1999-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Tests for reference types with short type variables in GDB, based on
17 # gdb.cp/ref-types.exp.
19 if { [skip_cplus_tests] } { continue }
23 if {[prepare_for_testing $testfile.exp $testfile $srcfile \
24 {debug c++ additional_flags="-std=gnu++11"}]} {
29 # Set it up at a breakpoint so we can play with the variable values.
32 untested "couldn't run to breakpoint"
36 if {![runto 'marker1']} {
37 untested "couldn't run to marker1"
41 gdb_test "up" ".*main.*" "up from marker1 1"
43 gdb_test "print rrt" " = \\(short( int)? &&\\) @$hex: -1" "print value of rrt"
45 gdb_test "ptype rrt" "type = short( int)? &&" "ptype rrt"
47 gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt"
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.
53 gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt"
55 gdb_test "ptype rrpt" "type = short( int)? \\*&&" "ptype rrpt"
57 gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]"
59 gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]" "ptype rrat"
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\]"
66 if {![runto 'f']} then {
67 perror "couldn't run to f"
71 gdb_test "up" ".main2.*" "up from f"
73 gdb_test "ptype rrC" "type = char &&"
75 gdb_test "ptype rrUC" "type = unsigned char &&"
77 gdb_test "ptype rrS" "type = short( int)? &&" "ptype rrS"
79 gdb_test "ptype rrUS" "type = unsigned short( int)? &&" "ptype rrUS"
81 gdb_test "ptype rrI" "type = int &&"
83 gdb_test "ptype rrUI" "type = unsigned int &&"
85 gdb_test "ptype rrL" "type = long( int)? &&" "ptype rrL"
87 gdb_test "ptype rrUL" "type = unsigned long( int)? &&" "ptype rrUL"
89 gdb_test "ptype rrF" "type = float &&"
91 gdb_test "ptype rrD" "type = double &&"
93 gdb_test "print rrC" "$decimal = \\(char &&\\) @$hex: 65 \'A\'" \
96 gdb_test "print rrUC" \
97 "$decimal = \\(unsigned char &&\\) @$hex: 21 \'.025\'" \
100 gdb_test "print rrS" "$decimal = \\(short( int)? &&\\) @$hex: -14" \
103 gdb_test "print rrUS" \
104 "$decimal = \\(unsigned short( int)? &&\\) @$hex: 7" \
105 "print value of rrUS"
107 gdb_test "print rrI" "$decimal = \\(int &&\\) @$hex: 102" \
110 gdb_test "print rrUI" \
111 "$decimal = \\(unsigned int &&\\) @$hex: 1002" \
112 "print value of rrUI"
114 gdb_test "print rrL" \
115 "$decimal = \\(long( int)? &&\\) @$hex: -234" \
118 gdb_test "print rrUL" \
119 "$decimal = \\((unsigned long|long unsigned int)? &&\\) @$hex: 234" \
120 "print value of rrUL"
122 gdb_test "print rrF" \
123 "$decimal = \\(float &&\\) @$hex: 1.2${decimal}e\\+0?10.*" \
126 gdb_test "print rrD" \
127 "$decimal = \\(double &&\\) @$hex: -1.375e-123.*" \