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
|
# Copyright 2016-2019 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/>.
# This file is part of the gdb testsuite. It is intended to test that
# gdb could correctly handle floating point constant with a suffix.
standard_testfile .c
proc do_compile { {opts {}} } {
global srcdir subdir srcfile binfile
set ccopts {debug quiet}
foreach opt $opts {lappend ccopts "additional_flags=$opt"}
gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $ccopts
}
if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
untested "compiler can't handle _FloatN/_FloatNx types?"
return -1
}
clean_restart ${binfile}
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
# Run to the breakpoint at return.
gdb_breakpoint [gdb_get_line_number "return"]
gdb_continue_to_breakpoint "return"
# Print the original values of f32, f64, f128, f32x, f64x.
gdb_test "print f32" ".* = 1\\.5.*" "the original value of f32 is 1.5"
gdb_test "print f64" ".* = 2\\.25.*" "the original value of f64 is 2.25"
gdb_test "print f128" ".* = 3\\.375.*" "the original value of f128 is 3.375"
gdb_test "print f32x" ".* = 10\\.5.*" "the original value of f32x is 10.5"
gdb_test "print f64x" ".* = 20\\.25.*" "the original value of f64x is 20.25"
# Test that gdb could correctly recognize float constant expression with a suffix.
# FIXME: gdb does not yet recognize the suffix for _FloatN/_FloatNx types.
gdb_test "print f32=-1.5" ".* = -1\\.5.*" "try to change f32 to -1.5 with 'print f32=-1.5'"
gdb_test "print f64=-2.25" ".* = -2\\.25.*" "try to change f64 to -2.25 with 'print f64=-2.25'"
gdb_test "print f128=-3.375" ".* = -3\\.375.*" "try to change f128 to -3.375 with 'print f128=-3.375'"
gdb_test "print f32x=-10.5" ".* = -10\\.5.*" "try to change f32x to -10.5 with 'print f32=-1.5x'"
gdb_test "print f64x=-20.25" ".* = -20\\.25.*" "try to change f64x to -20.25 with 'print f64=-2.25x'"
# Test that gdb could handle the above correctly with "set var" command.
set test "set variable f32 = 10.5"
gdb_test_multiple "set var f32=10.5" "$test" {
-re "$gdb_prompt $" {
pass "$test"
}
-re "Invalid number.*$gdb_prompt $" {
fail "$test (do not recognize 10.5)"
}
}
set test "set variable f64 = 20.25"
gdb_test_multiple "set var f64=20.25" "$test" {
-re "$gdb_prompt $" {
pass "$test"
}
-re "Invalid number.*$gdb_prompt $" {
fail "$test (do not recognize 20.25)"
}
}
set test "set variable f128 = 30.375"
gdb_test_multiple "set var f128=30.375" "$test" {
-re "$gdb_prompt $" {
pass "$test"
}
-re "Invalid number.*$gdb_prompt $" {
fail "$test (do not recognize 30.375)"
}
}
set test "set variable f32x = 100.5"
gdb_test_multiple "set var f32x=100.5" "$test" {
-re "$gdb_prompt $" {
pass "$test"
}
-re "Invalid number.*$gdb_prompt $" {
fail "$test (do not recognize 100.5)"
}
}
set test "set variable f64x = 200.25"
gdb_test_multiple "set var f64x=200.25" "$test" {
-re "$gdb_prompt $" {
pass "$test"
}
-re "Invalid number.*$gdb_prompt $" {
fail "$test (do not recognize 200.25)"
}
}
gdb_test "print f32" ".* = 10\\.5.*" "the value of f32 is changed to 10.5"
gdb_test "print f64" ".* = 20\\.25.*" "the value of f64 is changed to 20.25"
gdb_test "print f128" ".* = 30\\.375.*" "the value of f128 is changed to 30.375"
gdb_test "print f32x" ".* = 100\\.5.*" "the value of f32x is changed to 100.5"
gdb_test "print f64x" ".* = 200\\.25.*" "the value of f64x is changed to 200.25"
# Print the original values of c32, c64, c128, c32x, c64x.
gdb_test "print c32" ".* = 1\\.5 \\+ 1 \\* I.*" "the original value of c32 is 1.5 + 1 * I"
gdb_test "print c64" ".* = 2\\.25 \\+ 1 \\* I.*" "the original value of c64 is 2.25 + 1 * I"
gdb_test "print c128" ".* = 3\\.375 \\+ 1 \\* I.*" "the original value of c128 is 3.375 + 1 * I"
gdb_test "print c32x" ".* = 10\\.5 \\+ 1 \\* I.*" "the original value of c32x is 10.5 + 1 * I"
gdb_test "print c64x" ".* = 20\\.25 \\+ 1 \\* I.*" "the original value of c64x is 20.25 + 1 * I"
# FIXME: GDB cannot parse non-trivial complex constants yet.
|