From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9uhOEfx/F2OGnzQAWB0awg (envelope-from ) for ; Tue, 06 Sep 2022 13:14:36 -0400 Received: by simark.ca (Postfix, from userid 112) id 380101E4A7; Tue, 6 Sep 2022 13:14:36 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=u5LK82g8; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 733FC1E21F for ; Tue, 6 Sep 2022 13:14:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C23B6385085D for ; Tue, 6 Sep 2022 17:14:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C23B6385085D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662484471; bh=3+mj91HgqjPvD7XoiLlTdJAHHktUnb7jO3qRksxE69U=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=u5LK82g8HeF/rmxWNzivP+1y+Frg3lzbFeZpjBToaKchxYgUde+oq8zeMZfkMoh7P Rt4SClvqqGIoaiqcQT9sdqiDqIjHCCEJ5/gfcbzyj5vI3LvwCARD7bmJjURcKoEez/ PEEqgDBc6Z4sVCao4ozaNfnqkVQidnXl08aojrIs= Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 1E977385354A for ; Tue, 6 Sep 2022 17:14:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E977385354A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4740A33939 for ; Tue, 6 Sep 2022 17:14:11 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 33F8813A7A for ; Tue, 6 Sep 2022 17:14:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jIx9C+N/F2NATAAAMHmgww (envelope-from ) for ; Tue, 06 Sep 2022 17:14:11 +0000 Date: Tue, 6 Sep 2022 19:14:09 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Support .gdb_index section with TUs in .debug_info Message-ID: <20220906171408.GA4642@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, The .gdb_index variant of commit d878bb39e41 ("[gdb/symtab] Support .debug_names section with TUs in .debug_info"). Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/symtab] Support .gdb_index section with TUs in .debug_info --- gdb/dwarf2/read.c | 7 ++-- gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.c | 29 +++++++++++++++ .../gdb.dwarf2/gdb-index-types-dwarf5.exp | 41 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3ca441c4cae..d9fadd796a2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2707,13 +2707,16 @@ dwarf2_read_gdb_index { /* We can only handle a single .debug_types when we have an index. */ - if (per_bfd->types.size () != 1) + if (per_bfd->types.size () > 1) { per_bfd->all_comp_units.clear (); return 0; } - dwarf2_section_info *section = &per_bfd->types[0]; + dwarf2_section_info *section + = (per_bfd->types.size () == 1 + ? &per_bfd->types[0] + : &per_bfd->info); create_signatured_type_table_from_index (per_bfd, section, types_list, types_list_elements); diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.c b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.c new file mode 100644 index 00000000000..f568c82917e --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.c @@ -0,0 +1,29 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2022 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + . */ + +struct struct_with_int_member { + int member; +}; + +struct struct_with_int_member var; + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp new file mode 100644 index 00000000000..27cadc523cd --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp @@ -0,0 +1,41 @@ +# Copyright 2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile + +set flags {} +lappend flags {additional_flags=-fdebug-types-section} +lappend flags {additional_flags=-gdwarf-5} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + $srcfile $flags] } { + return -1 +} + +require {ensure_gdb_index $binfile} == 1 + +clean_restart ${binfile} + +# Verify that .gdb_index section is not ignored. +set index [have_index $binfile] +gdb_assert { [string equal $index "gdb_index"] } ".gdb_index used" + +# Verify that we can find the type in the type unit. +set re \ + [multi_line \ + "type = struct struct_with_int_member {" \ + " int member;" \ + "}"] +gdb_test "ptype struct struct_with_int_member" $re