]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change how complex types are printed in C
authorTom Tromey <tom@tromey.com>
Wed, 1 Apr 2020 20:09:52 +0000 (14:09 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 1 Apr 2020 20:09:53 +0000 (14:09 -0600)
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.

12 files changed:
gdb/ChangeLog
gdb/c-valprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/callfuncs.exp
gdb/testsuite/gdb.base/complex-parts.exp
gdb/testsuite/gdb.base/complex.exp
gdb/testsuite/gdb.base/endianity.exp
gdb/testsuite/gdb.base/floatn.exp
gdb/testsuite/gdb.base/funcargs.exp
gdb/testsuite/gdb.base/varargs.exp
gdb/testsuite/gdb.compile/compile-cplus.exp
gdb/testsuite/gdb.compile/compile.exp

index d1f408f1a47971d0fdaa13c62d5b8e1e55d21921..174ac70096759010677a9487ba72954810a6332c 100644 (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.
index 76a86faea6aca84f07327afd94bf00eca044d44b..bde9c6cc88330dbf7a04d19e5c8301d02e020939 100644 (file)
@@ -121,7 +121,7 @@ static const struct generic_val_print_decorations c_decorations =
 {
   "",
   " + ",
-  " * I",
+  "i",
   "true",
   "false",
   "void",
index cc17eba77007f3cb98a243d997e234c280034597..15db7ecc822d208a301d00d04b8ac36662c9a0eb 100644 (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.
index 5d98541745a80a958b809ffbf681d030859e4c77..642fe0d7fd94d3f743fe4d4285d2d7d235d09bdf 100644 (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"
     }
 
index 02fab04bc392be905ca7adce65c2d9dc6bd99506..071de5c56d722762e869faa196ab609103b0c81b 100644 (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"
index 442b830466ab9e4fcfc520a76a7c2a7952ce2866..b60d9372414f462dfa7da6ebd10a6e994d6b629e 100644 (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"
 }
 
index 52d5ff5104866bbef56d76ea8a6df443b985c1d3..2fa9ed3bf162749735dbfa0fdcdd266b78a8614c 100644 (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"
index 564d01d64b07b0a93b4bd35147e6c54c031bc218..0f087451b7cb9a8f78da90897cf0c491abef69b2 100644 (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"
index b45a8a11aa08d9b63137c8d9ca30259828f8ab4d..743c4c2758d89f9647174bef88fc2e339363eaf2 100644 (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"
 }
 
 #
index 1b5ad0085f547ff01bd00e728371fbb4c8fa0ed4..f6f4f659653d543fae77bbec054dabeba25d2bdd 100644 (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"
 
 }
index ffc62eab244e617a7353e0959e462c51b818c7f8..cca5b20520056b49d980cb8b9b6ad47e3a1e1c49 100644 (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"
index 9ad4181b2fe80c0fabe58e3e0c50b5fac0230d91..d9c3e6668ecfc332e2b10900e5d3160e2993fd9c 100644 (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"