⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dfp-test.exp

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 EXP
📖 第 1 页 / 共 2 页
字号:
# Copyright (C) 2007, 2008 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 was written by Wu Zhou. (woodzltc@cn.ibm.com)# This file is part of the gdb testsuite.  It is intended to test that# gdb could correctly handle decimal floating point introduced in IEEE 754R.if $tracelevel then {  strace $tracelevel}set testfile "dfp-test"set srcfile ${testfile}.cset binfile ${objdir}/${subdir}/${testfile}# Try to compile the test case.  If we can't, assume the# toolchain does not yet provide DFP support and bail out.if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } {    verbose "Skipping DFP tests."    return -1}gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_load ${binfile}if ![runto_main] then {    perror "couldn't run to breakpoint"    continue}# Detect the size of the target's basic types (from gdb.base/long_long.exp).proc get_valueof { fmt exp default } {    global gdb_prompt    send_gdb "print${fmt} ${exp}\n"    gdb_expect {	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {	    set val $expect_out(1,string)	}	timeout {	    set val ${default}	}    }    return ${val}}proc get_sizeof { type default } {    return [get_valueof "/d" "sizeof (${type})" $default]}set sizeof_long [get_sizeof "long" 4]proc d32_set_tests {} {    gdb_test "p d32=123.45df" " = 123.45"    gdb_test "p d32=12345.df" " = 12345"    gdb_test "p d32=12345.67df" " = 12345.67"    gdb_test "p d32=1234567.df" " = 1234567"    gdb_test "p d32=1.234567E0df" " = 1.234567"    gdb_test "p d32=1.234567E10df" " = 1.234567E\\+10"    gdb_test "p d32=1.234567E+96df" " = 1.234567E\\+96"    # Test that gdb could handle the max, normalized min and subnormalized min.    gdb_test "p d32=9.999999E96df" " = 9.999999E\\+96"    gdb_test "p d32=1.0E-95df" " = 1.0E\\-95"    gdb_test "p d32=1.E-101df" " = 1E\\-101"    gdb_test "p d32=0.000001E-95df" " = 1E\\-101"    # Test that gdb could detect coefficient/exponent out of range.    # The coefficient out of range will be rounded to its nearest value.    # And the exponent out of range will be handled as infinity.    gdb_test "p d32=1.2345678df" " = 1.234568" "1.2345678 is rounded to 1.234568"    gdb_test "p d32=1.0E-101df" " = 1E-101" "1.0E-101 is rounded to 1E-101"    gdb_test "p d32=1.234567E+97df" " = Infinity" "1.234567E+97 is Infinity"    # Test that gdb could detect the errors in the string representation of _Decimal32    gdb_test "p d32=12345.df" " = 12345" "12345. is a valid number"    gdb_test "p d32=12345df" ".*Invalid number.*" "12345 is an invalid number"    gdb_test "p d32=1.23Edf" ".*Conversion syntax.*" "1.23E is an invalid number"    gdb_test "p d32=1.23E45Adf" ".*Conversion syntax.*" "1.23E45A is an invalid number"}proc d64_set_tests {} {    gdb_test "p d64=123.45dd" " = 123.45"    gdb_test "p d64=12345.dd" " = 12345"    gdb_test "p d64=12345.67dd" " = 12345.67"    gdb_test "p d64=1.234567890123456dd" " = 1.234567890123456"    gdb_test "p d64=1.234567890123456E10dd" " = 12345678901.23456"    gdb_test "p d64=1.234567890123456E100dd" " = 1.234567890123456E\\+100"    gdb_test "p d64=1.234567890123456E384dd" " = 1.234567890123456E\\+384"    # Test that gdb could handle the max, normalized min and subnormalized min.    gdb_test "p d64=9.999999999999999E384dd" " = 9.999999999999999E\\+384"    gdb_test "p d64=1.E-383dd" " = 1E\\-383"    gdb_test "p d64=1.E-398dd" " = 1E\\-398"    gdb_test "p d64=0.000000000000001E-383dd" " = 1E\\-398"    # Test that gdb could detect coefficient/exponent out of range.    # The coefficient out of range will be rounded to its nearest value.    # And the exponent out of range will be handled as infinity.    gdb_test "p d64=1.2345678901234567dd" " = 1.234567890123457" "1.2345678901234567 is rounded to 1.234567890123457"    gdb_test "p d64=9.9999999999999999E384dd" " = Infinity" "d64=9.9999999999999999E384 is Infinity"    gdb_test "p d64=1.234567890123456E385dd" " = Infinity" "d64=1.234567890123456E385 is Infinity"    # Test that gdb could detect the errors in the string representation of _Decimal64    gdb_test "p d64=12345dd" ".*Invalid number.*" "12345dd is an invalid number"    gdb_test "p d64=1.23Edd" ".*Conversion syntax.*" "1.23E is an invalid number"    gdb_test "p d64=1.23E45Add" ".*Conversion syntax.*" "1.23E45A is an invalid number"}proc d128_set_tests {} {    gdb_test "p d128=123.45dl" " = 123.45"    gdb_test "p d128=12345.dl" " = 12345"    gdb_test "p d128=12345.67dl" " = 12345.67"    gdb_test "p d128=1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234"    gdb_test "p d128=1.234567890123456E10dl" " = 12345678901.23456"    gdb_test "p d128=1.234567890123456E100dl" " = 1.234567890123456E\\+100"    gdb_test "p d128=1.234567890123456E1000dl" " = 1.234567890123456E\\+1000"    # Test that gdb could handle the max, normalized min and subnormalized min.    gdb_test "p d128=9.999999999999999999999999999999999E6144dl" " = 9.999999999999999999999999999999999E\\+6144"    gdb_test "p d128=1.E-6143dl" " = 1E\\-6143"    gdb_test "p d128=1.E-6176dl" " = 1E\\-6176"    gdb_test "p d128=0.000000000000000000000000000000001E-6143dl" " = 1E\\-6176"    # Test that gdb could detect coefficient/exponent out of range.    # The coefficient out of range will be rounded to its nearest value.    # And the exponent out of range will be handled as infinity.    gdb_test "p d128=1.2345678901234567890123456789012345dl" "1.234567890123456789012345678901234" "1.2345678901234567890123456789012345 is rounded to 1.234567890123456789012345678901234"    gdb_test "p d128=1.234567890123456E6145dl" "Infinity" "d128=1.234567890123456E6145 is Infinity"    # Test that gdb could detect the errors in the string representation of _Decimal128    gdb_test "p d128=12345dl" ".*Invalid number.*" "12345dl is an invalid number"    gdb_test "p d128=1.23Edl" ".*Conversion syntax.*" "1.23E is an invalid number"    gdb_test "p d128=1.23E45Adl" ".*Conversion syntax.*" "1.23E45A is an invalid number"}# Different tests on 32-bits decimal floating point, including the printing# of finite numbers, infinite and NaN, and also the setting of different# decimal value.if [gdb_test "next" \    ".*Positive infd32.*" \    "next after initializing d32"] then { gdb_suppress_tests }gdb_test "print d32" "1.2345" "d32 is initialized to 1.2345"if [gdb_test "next" \    ".*Negative infd32.*" \    "next after assigning builtin infinity to d32"] then { gdb_suppress_tests }gdb_test "print d32" "Infinity" "d32 is positive Infinity"if [gdb_test "next" \    ".*__builtin_nand32.*" \    "next after assigning negative builtin infinity to d32"] then { gdb_suppress_tests }gdb_test "print d32" "-Infinity" "d32 is negative Infinity"if [gdb_test "next" \    ".*d64 = 1.2345.*" \    "next after assigning builtin NaN to d32"] then { gdb_suppress_tests }gdb_test "print d32" "NaN" "d32 is NaN"d32_set_tests

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -