[gdb/testsuite] Fix gdb.ada/out_of_line_in_inlined.exp with -m32 and gcc-10
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / fixed_points.exp
1 # Copyright 2004-2021 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 load_lib "ada.exp"
17
18 if { [skip_ada_tests] } { return -1 }
19
20 standard_ada_testfile fixed_points
21
22 foreach_with_prefix scenario {all minimal} {
23 set flags [list debug additional_flags=-fgnat-encodings=$scenario]
24 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
25 return -1
26 }
27
28 clean_restart ${testfile}
29
30 set bp_location [gdb_get_line_number "Set breakpoint here" ${testdir}/fixed_points.adb]
31 runto "fixed_points.adb:$bp_location"
32
33 # Fixed point subtypes:
34
35 gdb_test "print base_object" \
36 "= -50" \
37 "p on a fixed point type"
38
39 gdb_test "print subtype_object" \
40 "= -50" \
41 "p on a subtype fixed point type"
42
43 gdb_test "print new_type_object" \
44 "= -50" \
45 "p on a new fixed point type"
46
47 # Overprecise delta:
48
49 gdb_test "print Overprecise_Object" \
50 "= 0.13579135791"
51
52 gdb_test_multiple "ptype Overprecise_Object" "" {
53 -re "type = <2-byte fixed point \\(small = 135791357913579/1000000000000000\\)>\r\n$gdb_prompt $" {
54 pass $gdb_test_name
55 }
56 -re "type = delta 0.135791\r\n$gdb_prompt $" {
57 # The (legacy) output we obtain when the compiler described
58 # our fixed point types using the GNAT encodings rather than
59 # standard DWARF. OK as well.
60 pass $gdb_test_name
61 }
62 }
63
64 # FP*_Var...
65
66 gdb_test "print fp1_var" \
67 " = 0.25"
68
69 gdb_test_multiple "ptype fp1_var" "" {
70 -re "type = <1-byte fixed point \\(small = 1/16\\)>\r\n$gdb_prompt $" {
71 pass $gdb_test_name
72 }
73 -re "type = delta 0\\.1 <'small = 0\\.0625>\r\n$gdb_prompt $" {
74 # The (legacy) output we obtain when the compiler described
75 # our fixed point types using the GNAT encodings rather than
76 # standard DWARF. OK as well.
77 pass $gdb_test_name
78 }
79 }
80
81 gdb_test "print fp2_var" \
82 " = -0.01"
83
84 gdb_test_multiple "ptype fp2_var" "" {
85 -re "type = <8-byte fixed point \\(small = 1/100\\)>\r\n$gdb_prompt $" {
86 pass $gdb_test_name
87 }
88 -re "type = delta 0\\.01\r\n$gdb_prompt $" {
89 # The (legacy) output we obtain when the compiler described
90 # our fixed point types using the GNAT encodings rather than
91 # standard DWARF. OK as well.
92 pass $gdb_test_name
93 }
94 }
95
96 gdb_test "print fp3_var" \
97 " = 0.1"
98
99 gdb_test_multiple "ptype fp3_var" "" {
100 -re "type = <1-byte fixed point \\(small = 1/30\\)>\r\n$gdb_prompt $" {
101 pass $gdb_test_name
102 }
103 -re "type = delta 0\\.1 <'small = 0\\.0333333>\r\n$gdb_prompt $" {
104 # The (legacy) output we obtain when the compiler described
105 # our fixed point types using the GNAT encodings rather than
106 # standard DWARF. OK as well.
107 pass $gdb_test_name
108 }
109 }
110
111 # One of the benefits of minimal encoding is that operations work
112 # a bit better.
113 if {$scenario == "minimal"} {
114 gdb_test "print fp2_var + 0" \
115 " = -0.01"
116 gdb_test "print 0 + fp2_var" \
117 " = -0.01"
118 gdb_test "print fp2_var - 0" \
119 " = -0.01"
120
121 set fp4 "= 2e-07"
122 gdb_test "print fp4_var" $fp4
123 gdb_test "print fp4_var * 1" $fp4
124 gdb_test "print 1 * fp4_var" $fp4
125 gdb_test "print fp4_var / 1" $fp4
126
127 # This only started working in GCC 11.
128 if {[test_compiler_info {gcc-11-*}]} {
129 gdb_test "print fp5_var" " = 3e-19"
130 }
131 }
132 }
This page took 0.088704 seconds and 4 git commands to generate.