Change how complex types are printed in C

GCC accepts the "i" suffix for complex numbers.  I think this is nicer
to read than the current output, so this patch changes the C code to
print complex numbers this way.

gdb/ChangeLog
2020-04-01  Tom Tromey  <tom@tromey.com>

	* c-valprint.c (c_decorations): Change complex suffix to "i".

gdb/testsuite/ChangeLog
2020-04-01  Tom Tromey  <tom@tromey.com>

	* gdb.compile/compile.exp: Update.
	* gdb.compile/compile-cplus.exp: Update.
	* gdb.base/varargs.exp: Update.
	* gdb.base/floatn.exp: Update.
	* gdb.base/endianity.exp: Update.
	* gdb.base/callfuncs.exp (do_function_calls): Update.
	* gdb.base/funcargs.exp (complex_args, complex_integral_args)
	(complex_float_integral_args): Update.
	* gdb.base/complex.exp: Update.
	* gdb.base/complex-parts.exp: Update.
This commit is contained in:
Tom Tromey 2020-04-01 14:09:52 -06:00 committed by Tom Tromey
parent 4c99290df0
commit 981c08ce72
12 changed files with 48 additions and 34 deletions

View File

@ -1,3 +1,7 @@
2020-04-01 Tom Tromey <tom@tromey.com>
* c-valprint.c (c_decorations): Change complex suffix to "i".
2020-04-01 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_complex): Use accessors.

View File

@ -121,7 +121,7 @@ static const struct generic_val_print_decorations c_decorations =
{
"",
" + ",
" * I",
"i",
"true",
"false",
"void",

View File

@ -1,3 +1,16 @@
2020-04-01 Tom Tromey <tom@tromey.com>
* gdb.compile/compile.exp: Update.
* gdb.compile/compile-cplus.exp: Update.
* gdb.base/varargs.exp: Update.
* gdb.base/floatn.exp: Update.
* gdb.base/endianity.exp: Update.
* gdb.base/callfuncs.exp (do_function_calls): Update.
* gdb.base/funcargs.exp (complex_args, complex_integral_args)
(complex_float_integral_args): Update.
* gdb.base/complex.exp: Update.
* gdb.base/complex-parts.exp: Update.
2020-04-01 Tom Tromey <tromey@adacore.com>
* gdb.rust/union.rs: New file.

View File

@ -224,13 +224,13 @@ proc do_function_calls {prototypes} {
if [support_complex_tests] {
gdb_test "p t_structs_fc(struct_val1)" ".*= 3 \\+ 3 \\* I" \
gdb_test "p t_structs_fc(struct_val1)" ".*= 3 \\+ 3i" \
"call inferior func with struct - returns float _Complex"
gdb_test "p t_structs_dc(struct_val1)" ".*= 4 \\+ 4 \\* I" \
gdb_test "p t_structs_dc(struct_val1)" ".*= 4 \\+ 4i" \
"call inferior func with struct - returns double _Complex"
gdb_test "p t_structs_ldc(struct_val1)" "= 5 \\+ 5 \\* I" \
gdb_test "p t_structs_ldc(struct_val1)" "= 5 \\+ 5i" \
"call inferior func with struct - returns long double _Complex"
}

View File

@ -27,9 +27,9 @@ if { ![runto_main] } then {
gdb_breakpoint [gdb_get_line_number "Break Here"]
gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*"
gdb_test "p z1" " = 1.5 \\+ 4.5 \\* I"
gdb_test "p z2" " = 2.5 \\+ -5.5 \\* I"
gdb_test "p z3" " = 3.5 \\+ 6.5 \\* I"
gdb_test "p z1" " = 1.5 \\+ 4.5i"
gdb_test "p z2" " = 2.5 \\+ -5.5i"
gdb_test "p z3" " = 3.5 \\+ 6.5i"
gdb_test "ptype z1" " = complex double"
gdb_test "ptype z2" " = complex float"

View File

@ -29,12 +29,12 @@ if [runto f2] then {
if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } then {
setup_xfail "*-*-*"
}
gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0 \\* I\}" \
gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0i\}" \
"print complex packed value in C"
}
if [runto f4] then {
gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0 \\* I\}" \
gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0i\}" \
"print complex value in C"
}

View File

@ -25,7 +25,7 @@ if ![runto "endianity.c:$bp_location" ] then {
return -1
}
gdb_test "print o" "= {v = 3, w = 2, x = 7, f = 23.5, cplx = 1.25 \\+ 7.25 \\* I, d = 75}" \
gdb_test "print o" "= {v = 3, w = 2, x = 7, f = 23.5, cplx = 1.25 \\+ 7.25i, d = 75}" \
"print o before assignment"
gdb_test "print o.v = 4" "= 4"
@ -41,5 +41,5 @@ if { ([test_compiler_info {gcc-[0-5]-*}] || ![test_compiler_info gcc*]) } {
gdb_test "x/x &o.v" "0x04000000"
gdb_test "x/xh &o.w" "0x0300"
gdb_test "print o" "= {v = 4, w = 3, x = 2, f = 1.5, cplx = 1.25 \\+ 7.25 \\* I, d = -23.125}" \
gdb_test "print o" "= {v = 4, w = 3, x = 2, f = 1.5, cplx = 1.25 \\+ 7.25i, d = -23.125}" \
"print o after assignment"

View File

@ -114,11 +114,8 @@ 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.
gdb_test "print c32" ".* = 1\\.5 \\+ 1i.*" "the original value of c32 is 1.5 + 1i"
gdb_test "print c64" ".* = 2\\.25 \\+ 1i.*" "the original value of c64 is 2.25 + 1i"
gdb_test "print c128" ".* = 3\\.375 \\+ 1i.*" "the original value of c128 is 3.375 + 1i"
gdb_test "print c32x" ".* = 10\\.5 \\+ 1i.*" "the original value of c32x is 10.5 + 1i"
gdb_test "print c64x" ".* = 20\\.25 \\+ 1i.*" "the original value of c64x is 20.25 + 1i"

View File

@ -248,13 +248,13 @@ proc complex_args {} {
# Run; should stop at call1a and print actual arguments.
gdb_run_cmd
gdb_test "" " callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*" "run to call2a"
gdb_test "" " callca \\(f1=1 \\+ 2i, f2=1 \\+ 2i, f3=1 \\+ 2i\\) .*" "run to call2a"
gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb"
gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcc"
gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd"
gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce"
gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf"
gdb_test "cont" ".* callcb \\(d1=3 \\+ 4i, d2=3 \\+ 4i, d3=3 \\+ 4i\\) .*" "continue to callcb"
gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6i, ld2=5 \\+ 6i, ld3=5 \\+ 6i\\) .*" "continue to callcc"
gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "continue to callcd"
gdb_test "cont" ".* callce \\(dc1=3 \\+ 4i, ldc1=5 \\+ 6i, fc1=1 \\+ 2i\\) .*" "continue to callce"
gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6i, fc1=1 \\+ 2i, dc1=3 \\+ 4i\\) .*" "continue to callcf"
}
@ -271,9 +271,9 @@ proc complex_integral_args {} {
# Run; should stop at call1a and print actual arguments.
gdb_run_cmd
gdb_test "" " callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "run to callc1a"
gdb_test "" " callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "run to callc1a"
gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b"
gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6i\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2i, ui=7, l=3, dc1=3 \\+ 4i\\) .*" "continue to callc1b"
}
#
@ -289,9 +289,9 @@ proc complex_float_integral_args {} {
# Run; should stop at call1a and print actual arguments.
gdb_run_cmd
gdb_test "" " callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "run to callc2a"
gdb_test "" " callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "run to callc2a"
gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b"
gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2i, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6i\\, l=3, f=4, d=5, dc1=3 \\+ 4i\\) .*" "continue to callc2b"
}
#

View File

@ -101,12 +101,12 @@ if [support_complex_tests] {
global gdb_prompt
set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
gdb_test $test ".*= 4 \\+ 4 \\* I"
gdb_test $test ".*= 4 \\+ 4i"
set test "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
gdb_test $test ".*= 4 \\+ 4 \\* I"
gdb_test $test ".*= 4 \\+ 4i"
set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
gdb_test $test ".*= 4 \\+ 4 \\* I"
gdb_test $test ".*= 4 \\+ 4i"
}

View File

@ -219,7 +219,7 @@ gdb_test "print struct_object.arrayfield" \
" = \\{0, 0, 7, 0, 0\\}"
gdb_test_no_output "compile code struct_object.complexfield = 7 + 5i"
gdb_test "print struct_object.complexfield" " = 7 \\+ 5 \\* I"
gdb_test "print struct_object.complexfield" " = 7 \\+ 5i"
gdb_test_no_output "compile code struct_object.boolfield = 1"
gdb_test "print struct_object.boolfield" " = true"

View File

@ -237,7 +237,7 @@ if {$skip_struct_object} {
" = \\{0, 0, 7, 0, 0\\}"
gdb_test_no_output "compile code struct_object.complexfield = 7 + 5i"
gdb_test "print struct_object.complexfield" " = 7 \\+ 5 \\* I"
gdb_test "print struct_object.complexfield" " = 7 \\+ 5i"
gdb_test_no_output "compile code struct_object.boolfield = 1"
gdb_test "print struct_object.boolfield" " = true"