From patchwork Mon Mar 18 12:52:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 31887 Received: (qmail 23565 invoked by alias); 18 Mar 2019 12:52:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23436 invoked by uid 89); 18 Mar 2019 12:52:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=REF, stars X-HELO: mail-wr1-f45.google.com Received: from mail-wr1-f45.google.com (HELO mail-wr1-f45.google.com) (209.85.221.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Mar 2019 12:52:42 +0000 Received: by mail-wr1-f45.google.com with SMTP id p1so16895740wrs.8 for ; Mon, 18 Mar 2019 05:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Ok/XoZp2nIfnz4/h2fa9bqlCxbVzoXmhvvYbjt9rndk=; b=JmkxAsieuH7TWaKnDVA7q6962y1iy/hqyXUyzJCzHk7mMv1Za+kmZuzZJg+aC3iO/L MyxasquAmYZknwi7iQ271jmUJu4x6iQ34i4Kh4TTTFn8AdJYOhLfvyXeskf7a+YOfQuN hVMmj/cXzm1vOO1VdL7nrTxVuEMyWsym7U+sLPnGHU2ABAhLldku2AzMwasUepNjs5hn nvPh4TKAt7bU74S8SMa15hvx0Owm1ZfEKIU80BrFBuaXPgHAK2+UFUQdH1gNMIsorlHz TVOXw8kZ8rCczQRhXXfNjajGdFwR0keIHZj2r6R0MXoTMTDGvGZpyTXuu4hH7wzXoDb/ X09A== Return-Path: Received: from localhost (host86-142-70-198.range86-142.btcentralplus.com. [86.142.70.198]) by smtp.gmail.com with ESMTPSA id z6sm7224478wml.40.2019.03.18.05.52.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Mar 2019 05:52:39 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Richard Bunt , Andrew Burgess Subject: [PATCH 7/8] gdb/fortran: Update rules for printing whitespace in types Date: Mon, 18 Mar 2019 12:52:22 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 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. --- gdb/ChangeLog | 6 ++++++ gdb/f-typeprint.c | 21 ++++++++++++++------- gdb/testsuite/ChangeLog | 7 +++++++ gdb/testsuite/gdb.fortran/ptr-indentation.exp | 2 +- gdb/testsuite/gdb.fortran/ptype-on-functions.exp | 2 +- gdb/testsuite/gdb.fortran/vla-ptr-info.exp | 2 +- gdb/testsuite/gdb.fortran/vla-value.exp | 8 ++++---- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0a84aea84af..1183f6bf2f4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-03-18 Andrew Burgess + + * f-typeprint.c (f_print_type): Update rules for printing + whitespace. + (f_type_print_varspec_suffix): Likewise. + 2019-03-18 Andrew Burgess Chris January diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index c89816f7a39..64ee980aab5 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -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, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 931ed5a348b..0dbe1ce91ef 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-03-18 Andrew Burgess + + * 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-03-18 Andrew Burgess * gdb.fortran/ptype-on-functions.exp: New file. diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp index b0eb941eaa9..0c5d2255802 100644 --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp @@ -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"] diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp index 4ce78623b47..528828663c4 100644 --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp @@ -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\\) \\)\\) \\)" diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp index 58f3395122f..6b9625ad996 100644 --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp @@ -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" diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp index 3582d47c946..507137bed21 100644 --- a/gdb/testsuite/gdb.fortran/vla-value.exp +++ b/gdb/testsuite/gdb.fortran/vla-value.exp @@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"] gdb_continue_to_breakpoint "vla1-init" gdb_test "print vla1" " = " "print non-allocated vla1" gdb_test "print &vla1" \ - " = \\\(PTR TO -> \\\( $real \\\(\\\)\\\)\\\) $hex" \ + " = \\\(PTR TO -> \\\( $real \\\(\\\) \\\)\\\) $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" " = " "print undefined pvla" gdb_test "print &pvla" \ - " = \\\(PTR TO -> \\\( $real \\\(\\\)\\\)\\\) $hex" \ + " = \\\(PTR TO -> \\\( $real \\\(\\\) \\\)\\\) $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)"