From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eKvVLm/ldF+XdgAAWB0awg (envelope-from ) for ; Wed, 30 Sep 2020 16:07:11 -0400 Received: by simark.ca (Postfix, from userid 112) id BDFAD1EF44; Wed, 30 Sep 2020 16:07:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 40CDC1E590 for ; Wed, 30 Sep 2020 16:07:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBDCE397201D; Wed, 30 Sep 2020 20:07:09 +0000 (GMT) Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id B81BA3971C41 for ; Wed, 30 Sep 2020 20:07:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B81BA3971C41 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 004381175F7; Wed, 30 Sep 2020 16:06:08 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com 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 0U0jddUoIj5V; Wed, 30 Sep 2020 16:06:07 -0400 (EDT) Received: from murgatroyd.Home (97-118-100-18.hlrn.qwest.net [97.118.100.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id AF2F51175B8; Wed, 30 Sep 2020 16:06:07 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 9/9] Recognize names of array types Date: Wed, 30 Sep 2020 14:06:00 -0600 Message-Id: <20200930200600.1207702-10-tromey@adacore.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930200600.1207702-1-tromey@adacore.com> References: <20200930200600.1207702-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" With -fgnat-encodings=minimal, Gnat will emit DW_TAG_array_type that has a name -- and this is the only time the name is emitted for the type. (For comparison, in C a typedef would be emitted in this situation.) This patch changes gdb to recognize the name of an array type. This is limited to Ada, to avoid any potential problems if some rogue DWARF happens to name an array type in some other language, and to avoid loading unnecessary partial DIEs. 2020-09-30 Tom Tromey * dwarf2/read.c (add_partial_symbol, process_die): Handle DW_TAG_array_type. (is_type_tag_for_partial): Add "lang" parameter. (load_partial_dies, new_symbol): Handle DW_TAG_array_type. gdb/testsuite/ChangeLog 2020-09-30 Tom Tromey * gdb.ada/tick_length_array_enum_idx.exp: Add ptype test. * gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb (PT_Full): New variable. * gdb.ada/tick_length_array_enum_idx/pck.adb (Full_PT): New type. --- gdb/ChangeLog | 7 +++++ gdb/dwarf2/read.c | 26 +++++++++++++++---- gdb/testsuite/ChangeLog | 8 ++++++ .../gdb.ada/tick_length_array_enum_idx.exp | 1 + .../foo_n207_004.adb | 2 ++ .../tick_length_array_enum_idx/pck.ads | 3 +++ 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9a94c5b349f..1a124519b6f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -8575,6 +8575,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) where = psymbol_placement::STATIC; } break; + case DW_TAG_array_type: case DW_TAG_typedef: case DW_TAG_base_type: case DW_TAG_subrange_type: @@ -10194,7 +10195,6 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) read them on-demand through read_type_die. */ case DW_TAG_subroutine_type: case DW_TAG_set_type: - case DW_TAG_array_type: case DW_TAG_pointer_type: case DW_TAG_ptr_to_member_type: case DW_TAG_reference_type: @@ -10202,6 +10202,13 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_string_type: break; + case DW_TAG_array_type: + /* We only need to handle this case for Ada -- in other + languages, it's normal for the compiler to emit a typedef + instead. */ + if (cu->language != language_ada) + break; + /* FALLTHROUGH */ case DW_TAG_base_type: case DW_TAG_subrange_type: case DW_TAG_typedef: @@ -18976,20 +18983,27 @@ read_full_die (const struct die_reader_specs *reader, symbol for. */ static int -is_type_tag_for_partial (int tag) +is_type_tag_for_partial (int tag, enum language lang) { switch (tag) { #if 0 /* Some types that would be reasonable to generate partial symbols for, - that we don't at present. */ - case DW_TAG_array_type: + that we don't at present. Note that normally this does not + matter, mainly because C compilers don't give names to these + types, but instead emit DW_TAG_typedef. */ case DW_TAG_file_type: case DW_TAG_ptr_to_member_type: case DW_TAG_set_type: case DW_TAG_string_type: case DW_TAG_subroutine_type: #endif + + /* GNAT may emit an array with a name, but no typedef, so we + need to make a symbol in this case. */ + case DW_TAG_array_type: + return lang == language_ada; + case DW_TAG_base_type: case DW_TAG_class_type: case DW_TAG_interface_type: @@ -19083,7 +19097,7 @@ load_partial_dies (const struct die_reader_specs *reader, later variables referencing them via DW_AT_specification (for static members). */ if (!load_all - && !is_type_tag_for_partial (abbrev->tag) + && !is_type_tag_for_partial (abbrev->tag, cu->language) && abbrev->tag != DW_TAG_constant && abbrev->tag != DW_TAG_enumerator && abbrev->tag != DW_TAG_subprogram @@ -19127,6 +19141,7 @@ load_partial_dies (const struct die_reader_specs *reader, && pdi.is_declaration == 0 && ((pdi.tag == DW_TAG_typedef && !pdi.has_children) || pdi.tag == DW_TAG_base_type + || pdi.tag == DW_TAG_array_type || pdi.tag == DW_TAG_subrange_type)) { if (building_psymtab && pdi.raw_name != NULL) @@ -22020,6 +22035,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, SYMBOL_DOMAIN (sym) = VAR_DOMAIN; list_to_add = cu->list_in_scope; break; + case DW_TAG_array_type: case DW_TAG_base_type: case DW_TAG_subrange_type: SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF; diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp index 52715cf68e1..6dd01aca2b6 100644 --- a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp +++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp @@ -41,3 +41,4 @@ gdb_test "ptype vars'length" "type = <$decimal-byte integer>" gdb_test "ptype full_table'length" "type = <$decimal-byte integer>" gdb_test "ptype primary_table'length" "type = <$decimal-byte integer>" gdb_test "ptype variable_table'length" "type = <$decimal-byte integer>" +gdb_test "ptype full_pt'length" "type = <$decimal-byte integer>" diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb index 934a7f8ae85..0b2584fa73c 100644 --- a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb +++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb @@ -20,9 +20,11 @@ procedure Foo_n207_004 is Prim : Primary_Table := (True, False, False); Cold : Variable_Table := (Green => False, Blue => True, White => True); Vars : Variable_Table := New_Variable_Table (Low => Red, High => Green); + PT_Full : Full_PT := (False, True, False, True, False); begin Do_Nothing (Full'Address); -- STOP Do_Nothing (Prim'Address); Do_Nothing (Cold'Address); Do_Nothing (Vars'Address); + Do_Nothing (PT_Full'Address); end Foo_n207_004; diff --git a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads index 112caf1f651..461bee5377a 100644 --- a/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads +++ b/gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads @@ -21,6 +21,9 @@ package Pck is type Primary_Table is array (Color range Red .. Blue) of Boolean; type Variable_Table is array (Color range <>) of Boolean; + type Full_PT is array (Color) of Boolean; + pragma Pack (Full_PT); + function New_Variable_Table (Low: Color; High: Color) return Variable_Table; procedure Do_Nothing (A : System.Address); -- 2.26.2