From patchwork Fri Jan 5 04:48:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 25221 Received: (qmail 58263 invoked by alias); 5 Jan 2018 04:49:41 -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 57862 invoked by uid 89); 5 Jan 2018 04:49:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 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.2 spammy=Hx-languages-length:3556 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 05 Jan 2018 04:48:57 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id AC7211177C6; Thu, 4 Jan 2018 23:48:46 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5frBUdJkpKQQ; Thu, 4 Jan 2018 23:48:46 -0500 (EST) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 92BF31177B2; Thu, 4 Jan 2018 23:48:46 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4233) id 8EE284F2; Thu, 4 Jan 2018 23:48:46 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Xavier Roirand Subject: [pushed] (Ada) Remove printing of array's first index when unneeded Date: Thu, 4 Jan 2018 23:48:41 -0500 Message-Id: <1515127721-145030-1-git-send-email-brobecker@adacore.com> From: Xavier Roirand Hello, I pushed the following change for Xavier... Consider the following code: type Table is array (Character) of Natural; My_Table : Table := (others => 4874); Printing this table in gdb leads to: (gdb) p my_table $1 = ('["00"]' => 4874 ) In this case, the index of the first element in this array is also the first element of the index type (character type). Similar to what we do we enumeration types, we do not need to print the index of the first element when printing the array. This patch fixes this issue and changes the output as follow: (gdb) p my_table $1 = (4874 ) gdb/ChangeLog: * ada-valprint.c (print_optional_low_bound): Handle character-indexed array printing like boolean-indexed array printing. gdb/testuite/ChangeLog: * testsuite/gdb.ada/array_char_idx/pck.ads (Table): New type. (My_Table): New global variable. * testsuite/gdb.ada/array_char_idx.exp: Add test. Tested on x86_64-linux. Pushed to master. Thank you, diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b632382..ab98fb4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-01-03 Xavier Roirand + + * ada-valprint.c (print_optional_low_bound): Handle + character-indexed array printing like boolean-indexed array + printing. + 2018-01-05 Joel Brobecker * NEWS: Create a new section for the next release branch. diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index c5efdf1..f5a2c3c 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -88,9 +88,11 @@ print_optional_low_bound (struct ui_file *stream, struct type *type, index_type = TYPE_TARGET_TYPE (index_type); } + /* Don't print the lower bound if it's the default one. */ switch (TYPE_CODE (index_type)) { case TYPE_CODE_BOOL: + case TYPE_CODE_CHAR: if (low_bound == 0) return 0; break; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ea9d65c..f45ae0c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-01-05 Xavier Roirand + + * testsuite/gdb.ada/array_char_idx/pck.ads (Table): New type. + (My_Table): New global variable. + * testsuite/gdb.ada/array_char_idx.exp: Add test. + 2018-01-04 Joel Brobecker PR gdb/22670 diff --git a/gdb/testsuite/gdb.ada/array_char_idx.exp b/gdb/testsuite/gdb.ada/array_char_idx.exp index 2608a8e..89805fb 100644 --- a/gdb/testsuite/gdb.ada/array_char_idx.exp +++ b/gdb/testsuite/gdb.ada/array_char_idx.exp @@ -30,3 +30,6 @@ gdb_test "ptype char_table" \ gdb_test "ptype global_char_table" \ "= array \\(character\\) of natural" + +gdb_test "print my_table" "= \\(0 \\)" \ + "Display my_table" diff --git a/gdb/testsuite/gdb.ada/array_char_idx/pck.ads b/gdb/testsuite/gdb.ada/array_char_idx/pck.ads index a26393a..699fef9 100644 --- a/gdb/testsuite/gdb.ada/array_char_idx/pck.ads +++ b/gdb/testsuite/gdb.ada/array_char_idx/pck.ads @@ -19,5 +19,8 @@ package Pck is of Natural; Global_Char_Table : Char_Table := (others => 0); + type Table is array (Character) of Natural; + My_Table : Table := (others => 4874); + procedure Do_Nothing (A : System.Address); end Pck;