1 |
227 |
jeremybenn |
# Copyright 2005, 2007, 2008, 2009, 2010 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 .
|
15 |
|
|
|
16 |
|
|
# This file is part of the gdb testsuite. It is intended to test that
|
17 |
|
|
# gdb could correctly handle floating point constant with a suffix.
|
18 |
|
|
|
19 |
|
|
if $tracelevel {
|
20 |
|
|
strace $tracelevel
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
set testfile "bfp-test"
|
24 |
|
|
set srcfile ${testfile}.c
|
25 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
26 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
27 |
|
|
untested "Couldn't compile ${srcfile}"
|
28 |
|
|
return -1
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
gdb_exit
|
32 |
|
|
gdb_start
|
33 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
34 |
|
|
gdb_load ${binfile}
|
35 |
|
|
|
36 |
|
|
if ![runto_main] then {
|
37 |
|
|
perror "couldn't run to breakpoint"
|
38 |
|
|
continue
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
# Run to the breakpoint at return.
|
42 |
|
|
gdb_breakpoint [gdb_get_line_number "return"]
|
43 |
|
|
gdb_continue_to_breakpoint "return"
|
44 |
|
|
|
45 |
|
|
# Print the original value of b32, b64 and b128.
|
46 |
|
|
gdb_test "print b32" ".*1 = 1\.5.*" "The original value of b32 is 1.5"
|
47 |
|
|
gdb_test "print b64" ".*2 = 2\.25.*" "The original value of b64 is 2.25"
|
48 |
|
|
gdb_test "print b128" ".*3 = 3\.375.*" "The original value of b128 is 3.375"
|
49 |
|
|
|
50 |
|
|
# Test that gdb could correctly recognize float constant expression with a suffix.
|
51 |
|
|
gdb_test "print b32=-1.5f" ".*4 = -1\.5.*" "Try to change b32 to -1.5 with 'print b32=-1.5f'"
|
52 |
|
|
gdb_test "print b64=-2.25f" ".*5 = -2\.25.*" "Try to change b64 to -2.25 with 'print b64=-2.25f'"
|
53 |
|
|
gdb_test "print b128=-3.375l" ".*6 = -3\.375.*" "Try to change b128 to -3.375 with 'print b128=-3.375l'"
|
54 |
|
|
|
55 |
|
|
# Test that gdb could handle the above correctly with "set var" command.
|
56 |
|
|
set test "set variable b32 = 10.5f"
|
57 |
|
|
gdb_test_multiple "set var b32=10.5f" "$test" {
|
58 |
|
|
-re "$gdb_prompt $" {
|
59 |
|
|
pass "$test"
|
60 |
|
|
}
|
61 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
62 |
|
|
fail "$test (do not recognize 10.5f)"
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
set test "set variable b64 = 20.25f"
|
67 |
|
|
gdb_test_multiple "set var b64=20.25f" "$test" {
|
68 |
|
|
-re "$gdb_prompt $" {
|
69 |
|
|
pass "$test"
|
70 |
|
|
}
|
71 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
72 |
|
|
fail "$test (do not recognize 20.25f)"
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
set test "set variable b128 = 30.375l"
|
77 |
|
|
gdb_test_multiple "set var b128=30.375l" "$test" {
|
78 |
|
|
-re "$gdb_prompt $" {
|
79 |
|
|
pass "$test"
|
80 |
|
|
}
|
81 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
82 |
|
|
fail "$test (do not recognize 30.375l)"
|
83 |
|
|
}
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
gdb_test "print b32" ".*7 = 10\.5.*" "The value of b32 is changed to 10.5"
|
87 |
|
|
gdb_test "print b64" ".*8 = 20\.25.*" "The value of b64 is changed to 20.25"
|
88 |
|
|
gdb_test "print b128" ".*9 = 30\.375.*" "The value of b128 is changed to 30.375"
|
89 |
|
|
|
90 |
|
|
# Test that gdb could handle invalid suffix correctly.
|
91 |
|
|
|
92 |
|
|
set test "set variable b32 = 100.5a"
|
93 |
|
|
gdb_test_multiple "set var b32=100.5a" "$test" {
|
94 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
95 |
|
|
pass "$test"
|
96 |
|
|
}
|
97 |
|
|
-re "$gdb_prompt $" {
|
98 |
|
|
fail "$test (do not report error on invalid suffix)"
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
set test "set variable b64 = 200.25x"
|
103 |
|
|
gdb_test_multiple "set var b64=200.25x" "$test" {
|
104 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
105 |
|
|
pass "$test"
|
106 |
|
|
}
|
107 |
|
|
-re "$gdb_prompt $" {
|
108 |
|
|
fail "$test (do not report error on invalid suffix)"
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
set test "set variable b128 = 300.375fl"
|
113 |
|
|
gdb_test_multiple "set var b128=300.375fl" "$test" {
|
114 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
115 |
|
|
pass "$test"
|
116 |
|
|
}
|
117 |
|
|
-re "$gdb_prompt $" {
|
118 |
|
|
fail "$test (do not report error on invalid suffix)"
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
set test "set variable b128 = 300.375fff"
|
123 |
|
|
gdb_test_multiple "set var b128=300.375fff" "$test" {
|
124 |
|
|
-re "Invalid number.*$gdb_prompt $" {
|
125 |
|
|
pass "$test"
|
126 |
|
|
}
|
127 |
|
|
-re "$gdb_prompt $" {
|
128 |
|
|
fail "$test (do not report error on invalid suffix)"
|
129 |
|
|
}
|
130 |
|
|
}
|