From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xv/MDGp29mIovCUAWB0awg (envelope-from ) for ; Fri, 12 Aug 2022 11:48:58 -0400 Received: by simark.ca (Postfix, from userid 112) id 286D61E5EA; Fri, 12 Aug 2022 11:48:58 -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=Ob9ymcgG; 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=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 D51A41E222 for ; Fri, 12 Aug 2022 11:48:57 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CAE63858C54 for ; Fri, 12 Aug 2022 15:48:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CAE63858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660319337; bh=07d/qWbGYTPRVmq0I/AfD4DrvA1LaTUU+mEpZ6LiQy4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ob9ymcgGHsEAyHDFqsEwD+Llksktj1cs9SIqp/HAzbEZO3KHOT/uHimWflKNn4WYJ CuRIbwE5YNzabAAV1cuIHwUMiJkY91V0Vea+u7/nUWtB0JEtTN1QHfqA+58Ap1nbtm WFNfeIWGmvwThagLRCmC2AQzF0j7nCJ0Yp0aMX/o= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 4EE263858D28 for ; Fri, 12 Aug 2022 15:48:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EE263858D28 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 D9C8E33E2A for ; Fri, 12 Aug 2022 15:48:34 +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 C5D1213305 for ; Fri, 12 Aug 2022 15:48:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zRo1L1J29mJMaAAAMHmgww (envelope-from ) for ; Fri, 12 Aug 2022 15:48:34 +0000 Date: Fri, 12 Aug 2022 17:48:33 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Support .debug_names section with TUs in .debug_info Message-ID: <20220812154831.GA30782@delia.home> 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, [ Requires "[gdb/symtab] Fix assert in set_length" submitted here ( https://sourceware.org/pipermail/gdb-patches/2022-August/191313.html ). ] When running test-case gdb.cp/cpexprs-debug-types.exp on target board cc-with-debug-names/gdb:debug_flags=-gdwarf-5, we get an executable with a .debug_names section, but no .debug_types section. For dwarf-5, the TUs are no longer put in a separate unit, but instead they're put in the .debug_info section. When loading the executable, the .debug_names section is silently ignored because of this check in dwarf2_read_debug_names: ... if (map->tu_count != 0) { /* We can only handle a single .debug_types when we have an index. */ if (per_bfd->types.size () != 1) return false; ... which triggers because per_bfd->types.size () == 0. The intention of the check is to make sure we don't have both .debug_types and .zdebug_types sections. Fix this by: - changing the check condition to "per_bfd->types.size () > 1", and - handling per_bfd->types.size () == 0. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29385 Any comments? Thanks, - Tom [gdb/symtab] Support .debug_names section with TUs in .debug_info --- gdb/dwarf2/read.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6c6ca96f8d9..8e82f464293 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4736,13 +4736,16 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) { /* 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 false; } - 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_debug_names (per_objfile, *map, section, &per_bfd->abbrev);