gdb/fortran: Update rules for printing whitespace in types

The whitespace produced as types are printed seems inconsistent.  This
commit updates the rules in an attempt to make whitespace more
balanced and consistent.  Expected results are updated.

gdb/ChangeLog:

	* f-typeprint.c (f_print_type): Update rules for printing
	whitespace.
	(f_type_print_varspec_suffix): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.fortran/ptr-indentation.exp: Update expected results.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
This commit is contained in:
Andrew Burgess 2019-02-17 00:37:20 +00:00
parent bf7a4de172
commit f1fdc96066
7 changed files with 34 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2019-04-30 Andrew Burgess <andrew.burgess@embecosm.com>
* f-typeprint.c (f_print_type): Update rules for printing
whitespace.
(f_type_print_varspec_suffix): Likewise.
2019-04-30 Andrew Burgess <andrew.burgess@embecosm.com>
Chris January <chris.january@arm.com>

View File

@ -68,13 +68,20 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
f_type_print_base (type, stream, show, level);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
/* Need a space if going to print stars or brackets;
but not if we will print just a type name. */
|| ((show > 0 || TYPE_NAME (type) == 0)
&& (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
/* Need a space if going to print stars or brackets; but not if we
will print just a type name. */
|| ((show > 0
|| TYPE_NAME (type) == 0)
&& (code == TYPE_CODE_FUNC
|| code == TYPE_CODE_METHOD
|| code == TYPE_CODE_ARRAY
|| code == TYPE_CODE_REF)))
|| ((code == TYPE_CODE_PTR
|| code == TYPE_CODE_REF)
&& (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
|| (TYPE_CODE (TYPE_TARGET_TYPE (type))
== TYPE_CODE_METHOD)
|| (TYPE_CODE (TYPE_TARGET_TYPE (type))
== TYPE_CODE_ARRAY))))))
fputs_filtered (" ", stream);
f_type_print_varspec_prefix (type, stream, show, 0);
@ -222,7 +229,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
case TYPE_CODE_REF:
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
arrayprint_recurse_level);
fprintf_filtered (stream, ")");
fprintf_filtered (stream, " )");
break;
case TYPE_CODE_FUNC:
@ -232,7 +239,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
passed_a_ptr, 0, arrayprint_recurse_level);
if (passed_a_ptr)
fprintf_filtered (stream, ")");
fprintf_filtered (stream, ") ");
fprintf_filtered (stream, "(");
if (nfields == 0 && TYPE_PROTOTYPED (type))
f_print_type (builtin_f_type (get_type_arch (type))->builtin_void,

View File

@ -1,3 +1,10 @@
2019-04-30 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/ptr-indentation.exp: Update expected results.
* gdb.fortran/ptype-on-functions.exp: Likewise.
* gdb.fortran/vla-ptr-info.exp: Likewise.
* gdb.fortran/vla-value.exp: Likewise.
2019-04-30 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/ptype-on-functions.exp: New file.

View File

@ -37,5 +37,5 @@ gdb_continue_to_breakpoint "BP1"
gdb_test "ptype tinsta" \
[multi_line "type = Type tuserdef" \
" $int :: i" \
" PTR TO -> \\( $real :: ptr\\)" \
" PTR TO -> \\( $real :: ptr \\)" \
"End Type tuserdef"]

View File

@ -42,4 +42,4 @@ gdb_test "ptype say_numbers" \
"type = void \\(integer\\(kind=4\\), integer\\(kind=4\\), integer\\(kind=4\\)\\)"
gdb_test "ptype fun_ptr" \
"type = PTR TO -> \\( integer\\(kind=4\\) \\(\\)\\(REF TO -> \\( integer\\(kind=4\\) \\)\\)\\)"
"type = PTR TO -> \\( integer\\(kind=4\\) \\(\\) \\(REF TO -> \\( integer\\(kind=4\\) \\)\\) \\)"

View File

@ -28,5 +28,5 @@ if ![runto_main] {
# Check the status of a pointer to a dynamic array.
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print &pvla" " = \\(PTR TO -> \\( real\\(kind=4\\) \\(10,10,10\\)\\)\\) ${hex}" \
gdb_test "print &pvla" " = \\(PTR TO -> \\( real\\(kind=4\\) \\(10,10,10\\) \\)\\) ${hex}" \
"print pvla pointer information"

View File

@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
gdb_continue_to_breakpoint "vla1-init"
gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
gdb_test "print &vla1" \
" = \\\(PTR TO -> \\\( $real \\\(<not allocated>\\\)\\\)\\\) $hex" \
" = \\\(PTR TO -> \\\( $real \\\(<not allocated>\\\) \\\)\\\) $hex" \
"print non-allocated &vla1"
gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
"print member in non-allocated vla1 (1)"
@ -56,7 +56,7 @@ with_timeout_factor 15 {
"step over value assignment of vla1"
}
gdb_test "print &vla1" \
" = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
" = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
"print allocated &vla1"
gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
# Try to access values in undefined pointer to VLA (dangling)
gdb_test "print pvla" " = <not associated>" "print undefined pvla"
gdb_test "print &pvla" \
" = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\)\\\)\\\) $hex" \
" = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\) \\\)\\\) $hex" \
"print non-associated &pvla"
gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
"print undefined pvla(1,3,8)"
@ -85,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print &pvla" \
" = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
" = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
"print associated &pvla"
gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"