diff options
author | Tom Tromey <tom@tromey.com> | 2020-04-01 14:09:52 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-01 14:09:53 -0600 |
commit | 981c08ce72f5b8729381ddebf2f3fe5f1e000638 (patch) | |
tree | 30b053f9551c0ed8a5df73d42b09385ed5f271b8 /gdb | |
parent | 4c99290df04ba757b74a21ac5a6d16fe300e49ed (diff) | |
download | fsf-binutils-gdb-981c08ce72f5b8729381ddebf2f3fe5f1e000638.zip fsf-binutils-gdb-981c08ce72f5b8729381ddebf2f3fe5f1e000638.tar.gz fsf-binutils-gdb-981c08ce72f5b8729381ddebf2f3fe5f1e000638.tar.bz2 |
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/c-valprint.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/callfuncs.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/complex-parts.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/complex.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/endianity.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/floatn.exp | 13 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/funcargs.exp | 20 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/varargs.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.compile/compile-cplus.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.compile/compile.exp | 2 |
12 files changed, 48 insertions, 34 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d1f408f..174ac70 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 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. * value.h (value_real_part, value_imaginary_part): Declare. * valops.c (value_real_part, value_imaginary_part): New diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 76a86fa..bde9c6c 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -121,7 +121,7 @@ static const struct generic_val_print_decorations c_decorations = { "", " + ", - " * I", + "i", "true", "false", "void", diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index cc17eba..15db7ec 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -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. diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 5d98541..642fe0d 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -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" } diff --git a/gdb/testsuite/gdb.base/complex-parts.exp b/gdb/testsuite/gdb.base/complex-parts.exp index 02fab04..071de5c 100644 --- a/gdb/testsuite/gdb.base/complex-parts.exp +++ b/gdb/testsuite/gdb.base/complex-parts.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp index 442b830..b60d937 100644 --- a/gdb/testsuite/gdb.base/complex.exp +++ b/gdb/testsuite/gdb.base/complex.exp @@ -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" } diff --git a/gdb/testsuite/gdb.base/endianity.exp b/gdb/testsuite/gdb.base/endianity.exp index 52d5ff5..2fa9ed3 100644 --- a/gdb/testsuite/gdb.base/endianity.exp +++ b/gdb/testsuite/gdb.base/endianity.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/floatn.exp b/gdb/testsuite/gdb.base/floatn.exp index 564d01d..0f08745 100644 --- a/gdb/testsuite/gdb.base/floatn.exp +++ b/gdb/testsuite/gdb.base/floatn.exp @@ -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" diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index b45a8a1..743c4c2 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -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" } # diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp index 1b5ad00..f6f4f65 100644 --- a/gdb/testsuite/gdb.base/varargs.exp +++ b/gdb/testsuite/gdb.base/varargs.exp @@ -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" } diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp index ffc62ea..cca5b20 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp @@ -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" diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index 9ad4181..d9c3e66 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -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" |