📄 dfp-test.exp
字号:
# Different tests on 64-bits decimal floating point, including the display# of finite number, infinite and NaN, and also the setting of different# decimal value.if [gdb_test "next" \ ".*Positive infd64.*" \ "next after initializing d64"] then { gdb_suppress_tests }gdb_test "print d64" "1.2345" "d64 is initialized to 1.2345"if [gdb_test "next" \ ".*Negative infd64.*" \ "next after assigning builtin infinity to d64"] then { gdb_suppress_tests }gdb_test "print d64" "Infinity" "d64 is positive Infinity"if [gdb_test "next" \ ".*__builtin_nand64.*" \ "next after assigning negative builtin infinity to d64"] then { gdb_suppress_tests }gdb_test "print d64" "-Infinity" "d64 is negative Infinity"if [gdb_test "next" \ ".*d128 = 1.2345.*" \ "next after assigning builtin NaN to d64"] then { gdb_suppress_tests }gdb_test "print d64" "NaN" "d64 is NaN"d64_set_tests# Different tests on 128-bits decimal floating point, including the display# of finite number, infinite and NaN, and also the setting of different# decimal value.if [gdb_test "next" \ ".*Positive infd128.*" \ "next after initializing d128"] then { gdb_suppress_tests }gdb_test "print d128" "1.2345" "d128 is initialized to 1.2345"d128_set_testsif [gdb_test "next" \ ".*Negative infd128.*" \ "next after assigning builtin infinity to d128"] then { gdb_suppress_tests }gdb_test "print d128" "Infinity" "d128 is positive Infinity"if [gdb_test "next" \ ".*__builtin_nand128.*" \ "next after assigning negative builtin infinity to d128"] then { gdb_suppress_tests }gdb_test "print d128" "-Infinity" "d128 is negative Infinity"if [gdb_test "next" \ ".*arg0_32.*" \ "next after assigning builtin NaN to d128"] then { gdb_suppress_tests }gdb_test "print d128" "NaN" "d128 is NaN"# The following tests are intended to verify that gdb can correctly handle# DFP types in function arguments.gdb_breakpoint arg0_32gdb_continue_to_breakpoint "entry to arg0_32"gdb_test "backtrace" ".*arg0_32 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_32"gdb_breakpoint arg0_64gdb_continue_to_breakpoint "entry to arg0_64"gdb_test "backtrace" ".*arg0_64 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_64"gdb_breakpoint arg0_128gdb_continue_to_breakpoint "entry to arg0_128"gdb_test "backtrace" ".*arg0_128 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_128"# Test calling inferior function with DFP arguments or return value.send_gdb "call arg0_32 (1.2df, 2.2df, 3.2df, 4.2df, 5.2df, 6.2df)\n"gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_32 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal32 arguments."gdb_test "finish" " = 1.2" "Correct _Decimal32 return value from called function."send_gdb "call arg0_64 (1.2dd, 2.2dd, 3.2dd, 4.2dd, 5.2dd, 6.2dd)\n"gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_64 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal64 arguments."gdb_test "finish" " = 1.2" "Correct _Decimal64 return value from called function."send_gdb "call arg0_128 (1.2dl, 2.2dl, 3.2dl, 4.2dl, 5.2dl, 6.2dl)\n"gdb_test "backtrace 1" "\n#\[0-9\]+ arg0_128 \\(arg0=1.2, arg1=2.2, arg2=3.2, arg3=4.2, arg4=5.2, arg5=6.2\\).*" "Call function with correct _Decimal128 arguments."gdb_test "finish" " = 1.2" "Correct _Decimal128 return value from called function."gdb_test "call decimal_dec128_align (double_val1, dec128_val2, double_val3, double_val4, double_val5, double_val6, double_val7, double_val8, double_val9, double_val10, double_val11, double_val12, double_val13, double_val14)" " = 1" \ "Call function with mixed decimal float arguments TEST."gdb_test "call decimal_mixed (dec32_val1, dec64_val1, dec128_val1)" " = 1" \ "Call function with mixed decimal float arguments."gdb_test "call decimal_many_args_dec32 (dec32_val1, dec32_val2, dec32_val3, dec32_val4, dec32_val5, dec32_val6, dec32_val7, dec32_val8, dec32_val9, dec32_val10, dec32_val11, dec32_val12, dec32_val13, dec32_val14, dec32_val15, dec32_val16)" " = 1" \ "Call function with many _Decimal32 arguments."gdb_test "call decimal_many_args_dec64 (dec64_val1, dec64_val2, dec64_val3, dec64_val4, dec64_val5, dec64_val6, dec64_val7, dec64_val8, dec64_val9, dec64_val10, dec64_val11, dec64_val12, dec64_val13, dec64_val14, dec64_val15, dec64_val16)" " = 1" \ "Call function with many _Decimal64 arguments."gdb_test "call decimal_many_args_dec128 (dec128_val1, dec128_val2, dec128_val3, dec128_val4, dec128_val5, dec128_val6, dec128_val7, dec128_val8, dec128_val9, dec128_val10, dec128_val11, dec128_val12, dec128_val13, dec128_val14, dec128_val15, dec128_val16)" " = 1" \ "Call function with many _Decimal128 arguments."gdb_test "call decimal_many_args_mixed (dec32_val1, dec32_val2, dec32_val3, dec64_val4, dec64_val5, dec64_val6, dec64_val7, dec128_val8, dec128_val9, dec128_val10, dec32_val11, dec64_val12, dec32_val13, dec64_val14, dec128_val15)" " = 1" \ "Call function with many mixed decimal float arguments."# The following tests are intended to verify that gdb can handle DFP types# correctly in struct.gdb_breakpoint [gdb_get_line_number "Exit point"]gdb_continue_to_breakpoint "Setting a decimal struct"gdb_test "print ds.dec32" " = 1.2345"gdb_test "print ds.dec64" " = 1.2345"gdb_test "print ds.dec128" " = 1.2345"# Test expressions with DFP variables.gdb_test "print d32 + ds.dec32" " = 1.3345"gdb_test "print d64 + ds.dec64" " = 1.3345"gdb_test "print d128 + ds.dec128" " = 1.3345"# Test conversion between different _Decimal sizes.gdb_test "ptype d64 + ds.dec32" " = volatile _Decimal64"gdb_test "ptype d128 + ds.dec32" " = volatile _Decimal128"gdb_test "ptype d128 + ds.dec64" " = volatile _Decimal128"# Mixture of Decimal and integral operandsgdb_test "p d32 + 1" " = 1.1"gdb_test "p 2 + d64" " = 2.1"gdb_test "p ds.int4 + d128" " = 1.1"gdb_test "ptype d32 + 1" " = volatile _Decimal32"gdb_test "ptype ds.int4 + d128" " = volatile _Decimal128"# Test other operations with DFP operandsgdb_test "p !d32" " = 0"gdb_test "p !d64" " = 0"gdb_test "p !d128" " = 0"gdb_test "p +d32" " = 0.1"gdb_test "p +d64" " = 0.1"gdb_test "p +d128" " = 0.1"gdb_test "p d64 == d128" " = 1"gdb_test "p d128 == ds.dec32" " = 0"gdb_test "p d128 == d32" " = 1"gdb_test "p ds.dec32 == ds.dec64" " = 1"gdb_test "p d32 < ds.dec32" " = 1"gdb_test "p d64 < ds.dec64" " = 1"gdb_test "p d128 < ds.dec128" " = 1"gdb_test "p ds.dec32 < d32" " = 0"gdb_test "p d64 > ds.dec64" " = 0"gdb_test "p ds.dec128 > d128 " " = 1"gdb_test "p d32 < ds.int4" " = 1"gdb_test "p ds.int4 > d32" " = 1"gdb_test "p ds.dec32 < ds.int4" " = 0"gdb_test "p ds.int4 > ds.dec64" " = 0"gdb_test "p ds.dec128 > ds.int4" " = 1"# Reject operation with integral larger than 32-bitsif { ${sizeof_long} > 4 } { gdb_test "p d32 + ds.long8" "Conversion of large integer to a decimal floating type is not supported."}# Reject operation with DFP and Binary FPgdb_test "p d64 + ds.float4" "Mixing decimal floating types with other floating types is not allowed."gdb_test "p ds.double8 + d128" "Mixing decimal floating types with other floating types is not allowed."# The following tests are intended to verify that gdb can handle "d1=d2"# and "d1=-d2" correctly.gdb_test "print ds.dec32=d32" " = 0.1"gdb_test "print ds.dec64=d64" " = 0.1"gdb_test "print ds.dec128=d128" " = 0.1"gdb_test "print ds.dec32 = -d32" " = -0.1"gdb_test "print ds.dec64 = -d64" " = -0.1"gdb_test "print ds.dec128 = -d128" " = -0.1"# Test cast to and from DFP valuesgdb_test "print ds.double8 = ds.dec64" " = -0.(0999.*|1000.*)"gdb_test "print ds.dec64 = ds.float4" " = 3.(0999.*|1000.*)"gdb_test "print ds.dec128 = -ds.double8" " = 0.(0999.*|1000.*)"gdb_test "print ds.dec128 = ds.dec32" " = -0.1"gdb_test "print ds.dec32 = ds.int4" " = 1"gdb_test "print ds.int4 = 7.3dl" " = 7"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -