From patchwork Tue Oct 29 16:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99783 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 299DB3858C98 for ; Tue, 29 Oct 2024 16:58:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id AD2583858414 for ; Tue, 29 Oct 2024 16:57:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD2583858414 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AD2583858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221076; cv=none; b=C385Ek+aPBjVK7ObIKcngT3l0sSGI6AdzxkF9Fi7sEB2eLzLIMxUIpYw1UTuy0heIyOzFIBiwfYxgSoN2yQtuH921O/QPDQTjmgonlATkudmUHSuRlCeR0ugUH8k/bl1aKEp36aSuac9jdZjXJOzDgsIAhTFFP8okRD76/O3Eyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221076; c=relaxed/simple; bh=pELGAgGSA3gaEz4CIEkaZ2rL8pDudpEHB9OF7Z+GkNQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=L46rRakV68ekad8xwCjsEeBfbnYNLB7w+6fyFDQziy6wLTrlyAFctFSS54zmFZLcUiFmqNO2tNYWrtZechq4BZM1RqCe1qaHFuhbMGc3ZLl/nZDXAL7VIwBZJiRH+SgkdxAPnP+CcCZZD/Qr/tzuexx2m53hTqepZ1FBHkGJWRw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A5EF221D3B; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VxxbohuDRXzPgyRp42TTPd2i12tzburVOMOB8+EZrpE=; b=Cem66msvPGj7/F9kwC9IRo3FzHOHNbV2f3Ds5hdVKkjZe8y0d4cHdr7aqoSLlvQcv4xEkx Ik9Cn7G1eSVaEMOr9uS2n4eZjIrYL3eW2+JmBqylB94j0ZcvVOo80Z3Fg921dztuIY4RDS GHDObaH/qVAQ3dxBQhLX/wblvFYgVkQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VxxbohuDRXzPgyRp42TTPd2i12tzburVOMOB8+EZrpE=; b=vLd4vxp/MDP912timShkKxvCUk16YpueQjp/xXhx/PUkIYsL+jVl19OCq9wDz4nZY3s3Lc WG9+zzZs65FWOYAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Cem66msv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="vLd4vxp/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VxxbohuDRXzPgyRp42TTPd2i12tzburVOMOB8+EZrpE=; b=Cem66msvPGj7/F9kwC9IRo3FzHOHNbV2f3Ds5hdVKkjZe8y0d4cHdr7aqoSLlvQcv4xEkx Ik9Cn7G1eSVaEMOr9uS2n4eZjIrYL3eW2+JmBqylB94j0ZcvVOo80Z3Fg921dztuIY4RDS GHDObaH/qVAQ3dxBQhLX/wblvFYgVkQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VxxbohuDRXzPgyRp42TTPd2i12tzburVOMOB8+EZrpE=; b=vLd4vxp/MDP912timShkKxvCUk16YpueQjp/xXhx/PUkIYsL+jVl19OCq9wDz4nZY3s3Lc WG9+zzZs65FWOYAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8CB40136A5; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id F2YcIQ4UIWdfLgAAD6G6ig (envelope-from ); Tue, 29 Oct 2024 16:57:50 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] [gdb/symtab] Fix parent map when handling .debug_info and .debug_types Date: Tue, 29 Oct 2024 17:57:36 +0100 Message-Id: <20241029165738.6105-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: A5EF221D3B X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: "Author: Tom Tromey" Consider test-case: ... $ cat test.c namespace sp1 { class A { int i; const int f1 = 1; ... const int f29 = 1; }; } sp1::A a; void _start (void) {} $ cat test2.c namespace sp2 { class B { float f; const float f1 = 1; ... const float f29 = 1; }; } sp2::B b; ... compiled like this: ... $ g++ test.c -gdwarf-4 -c -g -fdebug-types-section $ g++ test2.c -gdwarf-5 -c -g -fdebug-types-section $ g++ -g test.o test2.o -nostdlib ... Using: ... $ gdb -q -batch -iex "maint set worker-threads 0" a.out -ex "maint print objfiles" ... we get a cooked index entry with incorrect parent: ... [29] ((cooked_index_entry *) 0x3c57d1a0) name: B canonical: B qualified: sp1::A::B DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x154 parent: ((cooked_index_entry *) 0x3c57d110) [A] ... The problem is that the parent map assumes that all offsets are in the same section. Fix this by using dwarf2_section_info::buffer-relative addresses instead, which get us instead: ... [29] ((cooked_index_entry *) 0x3f0962b0) name: B canonical: B qualified: sp2::B DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x154 parent: ((cooked_index_entry *) 0x3f096280) [sp2] ... Tested on x86_64-linux. PR symtab/32225 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225 --- gdb/dwarf2/parent-map.h | 11 ++++------- gdb/dwarf2/read.c | 12 +++++------- 2 files changed, 9 insertions(+), 14 deletions(-) base-commit: 7ffd4868a7e22dd2f8126822501bfa18479d715c diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h index 6cff548a2a7..a9ea34ec08c 100644 --- a/gdb/dwarf2/parent-map.h +++ b/gdb/dwarf2/parent-map.h @@ -69,18 +69,15 @@ class parent_map parent_map (parent_map &&) = default; parent_map &operator= (parent_map &&) = default; - /* A reasonably opaque type that is used here to combine a section - offset and the 'dwz' flag into a single value. */ + /* A reasonably opaque type that is used as part of a DIE range. */ enum addr_type : CORE_ADDR { }; /* Turn a section offset into a value that can be used in a parent map. */ - static addr_type form_addr (sect_offset offset, bool is_dwz) + static addr_type form_addr (const gdb_byte *info_ptr) { - CORE_ADDR value = to_underlying (offset); - if (is_dwz) - value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1); - return addr_type (value); + static_assert (sizeof (addr_type) >= sizeof (uintptr_t)); + return (addr_type) (uintptr_t) info_ptr; } /* Add a new entry to this map. DIEs from START to END, inclusive, diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2a29b844845..e9f97380d56 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16360,8 +16360,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, with a NULL result when when we see a reference to a DIE in another CU that we may or may not have imported locally. */ - parent_map::addr_type addr - = parent_map::form_addr (origin_offset, origin_is_dwz); + parent_map::addr_type addr = parent_map::form_addr (new_info_ptr); if (new_reader->cu != reader->cu || new_info_ptr > watermark_ptr) *maybe_defer = addr; else @@ -16500,11 +16499,10 @@ cooked_indexer::recurse (cutu_reader *reader, /* Both start and end are inclusive, so use both "+ 1" and "- 1" to limit the range to the children of parent_entry. */ parent_map::addr_type start - = parent_map::form_addr (parent_entry->die_offset + 1, - reader->cu->per_cu->is_dwz); - parent_map::addr_type end - = parent_map::form_addr (sect_offset (info_ptr - 1 - reader->buffer), - reader->cu->per_cu->is_dwz); + = parent_map::form_addr (reader->buffer + + to_underlying (parent_entry->die_offset) + + 1); + parent_map::addr_type end = parent_map::form_addr (info_ptr - 1); m_die_range_map->add_entry (start, end, parent_entry); } From patchwork Tue Oct 29 16:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99782 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 167D83857BBB for ; Tue, 29 Oct 2024 16:58:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id ACA493858408 for ; Tue, 29 Oct 2024 16:57:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACA493858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ACA493858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221073; cv=none; b=LSJPYGx6lcMCmn5hHRO9OapkKUbUBWvyrxWLY+v3b3oEpKZz8JC9wF+XHDx3NxInc2NuigQ8dSXPWWvBRWLYCCzpu3Z8t9GtERbeWxHiFjPGAY1g0mzmKM9nDK8ktqoVY6TF9C8Pn4rquTUN2gxFEvyUtuuBvdtQVTi/+nbtxiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221073; c=relaxed/simple; bh=+Ylhvl0irPgV4ApaQzEHvBAYMiFCQW45mIxx20Z0IYo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=VFLZzzJU+FfRoRMU70EHCmvG/9Dbo/QRPn/9mdo6DGipadfEjKGzdQSLB21xhZ8Fhf5mReyYkp/gw3jRUtOL1QLQt1+Awk1abnHkWF5ei0lcow8dN55C9zjsziBjnMp7NDuD8IHfJg2j9gGPZZFhWyhBW6VxJ0AeZ6TAR2B2Az0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C98CF21D4B; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oghd2+51zjMsNJPJnmmukrx80tFWmGXGb5hnLbiXtH8=; b=1h3NYmgTDk9KazJkZLw1XIjf8dOld7+f0muN09PF5yYc1ZMEd1IqURsGtux4Trim6Bxz21 o5VGsE1c2ahOSJitvlOyKsm7CFY3e3pDRWXyqQRqKn6mrk5kgQOvrJnIPEvoS+j6Y6Y6AB Mt06kTPBDdeQzp2/CYpQWN4qBxRthQ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oghd2+51zjMsNJPJnmmukrx80tFWmGXGb5hnLbiXtH8=; b=6+LeOAuEn9mlnoQEPD1L1wiarcynn4v/SDn7boxhATvT/lmg9SDg5nzf0ojhBrhYz8ApDK o8EEEiofS56LHyDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oghd2+51zjMsNJPJnmmukrx80tFWmGXGb5hnLbiXtH8=; b=1h3NYmgTDk9KazJkZLw1XIjf8dOld7+f0muN09PF5yYc1ZMEd1IqURsGtux4Trim6Bxz21 o5VGsE1c2ahOSJitvlOyKsm7CFY3e3pDRWXyqQRqKn6mrk5kgQOvrJnIPEvoS+j6Y6Y6AB Mt06kTPBDdeQzp2/CYpQWN4qBxRthQ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oghd2+51zjMsNJPJnmmukrx80tFWmGXGb5hnLbiXtH8=; b=6+LeOAuEn9mlnoQEPD1L1wiarcynn4v/SDn7boxhATvT/lmg9SDg5nzf0ojhBrhYz8ApDK o8EEEiofS56LHyDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AB35213A17; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KIiLKA4UIWdfLgAAD6G6ig (envelope-from ); Tue, 29 Oct 2024 16:57:50 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] [gdb/testsuite] Add gdb.dwarf2/dw2-tu-dwarf-4-5.exp Date: Tue, 29 Oct 2024 17:57:37 +0100 Message-Id: <20241029165738.6105-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241029165738.6105-1-tdevries@suse.de> References: <20241029165738.6105-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnu.org:url,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Add a regression test for PR symtab/32225. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225 --- gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5-2.c | 52 +++++++++++++++ gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.c | 58 +++++++++++++++++ gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.exp | 63 +++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5-2.c create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.c create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.exp diff --git a/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5-2.c b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5-2.c new file mode 100644 index 00000000000..8f22096c756 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5-2.c @@ -0,0 +1,52 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 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 . */ + +namespace sp2 { + class B { + float f; + const float f1 = 1; + const float f2 = 1; + const float f3 = 1; + const float f4 = 1; + const float f5 = 1; + const float f6 = 1; + const float f7 = 1; + const float f8 = 1; + const float f10 = 1; + const float f11 = 1; + const float f12 = 1; + const float f13 = 1; + const float f14 = 1; + const float f15 = 1; + const float f16 = 1; + const float f17 = 1; + const float f18 = 1; + const float f19 = 1; + const float f20 = 1; + const float f21 = 1; + const float f22 = 1; + const float f23 = 1; + const float f24 = 1; + const float f25 = 1; + const float f26 = 1; + const float f27 = 1; + const float f28 = 1; + const float f29 = 1; + }; +} + +sp2::B b; diff --git a/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.c b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.c new file mode 100644 index 00000000000..d723d730fa2 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.c @@ -0,0 +1,58 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 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 . */ + +namespace sp1 { + class A { + int i; + const int f1 = 1; + const int f2 = 1; + const int f3 = 1; + const int f4 = 1; + const int f5 = 1; + const int f6 = 1; + const int f7 = 1; + const int f8 = 1; + const int f10 = 1; + const int f11 = 1; + const int f12 = 1; + const int f13 = 1; + const int f14 = 1; + const int f15 = 1; + const int f16 = 1; + const int f17 = 1; + const int f18 = 1; + const int f19 = 1; + const int f20 = 1; + const int f21 = 1; + const int f22 = 1; + const int f23 = 1; + const int f24 = 1; + const int f25 = 1; + const int f26 = 1; + const int f27 = 1; + const int f28 = 1; + const int f29 = 1; + }; +} + +sp1::A a; + +extern "C" { + void _start (void) + { + } +} diff --git a/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.exp b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.exp new file mode 100644 index 00000000000..03c26e6b2f0 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-tu-dwarf-4-5.exp @@ -0,0 +1,63 @@ +# Copyright 2024 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 . + +load_lib dwarf.exp + +# Minimal DWARF-2 unit test + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile .c -2.c + +set opts {} +lappend opts debug +lappend opts c++ +lappend opts additional_flags=-gdwarf-4 +lappend opts additional_flags=-fdebug-types-section + +set opts2 {} +lappend opts2 debug +lappend opts2 c++ +lappend opts2 dwarf5 +lappend opts2 additional_flags=-fdebug-types-section + +set lopts {} +lappend lopts debug +lappend lopts c++ +lappend lopts additional_flags=-nostdlib + +if { [prepare_for_testing_full "failed to prepare" \ + [list $testfile $lopts \ + $srcfile $opts \ + $srcfile2 $opts2]] } { + return -1 +} + +gdb_test_no_output \ + [join \ + [list \ + "pipe maint print objfiles" \ + "grep -E \"qualified:.*::A$\"" \ + "grep -v -E \"(sp1::A|sp1::A::A)$\""] \ + "|"] + +gdb_test_no_output \ + [join \ + [list \ + "pipe maint print objfiles" \ + "grep -E \"qualified:.*::B$\"" \ + "grep -v -E \"(sp2::B|sp2::B::B)$\""] \ + "|"] From patchwork Tue Oct 29 16:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 99784 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF4D43857BBA for ; Tue, 29 Oct 2024 16:58:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 126D93858C52 for ; Tue, 29 Oct 2024 16:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 126D93858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 126D93858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221081; cv=none; b=BbTTJxfZsPvlNAWbYgLc5+58I+edixE7WYciWdYesobiH6gerlBTNQKS5QcMV8p3HYqbMd0pAiOCPOgD2L9XX/7wnaAAhb1Go+Hy46PZ+L6wsA1i9CfxfJO1JSXFDLg7cYJDZkc9G6uk7L76qtGmcypQevnLEm2C1OCV6ccV+TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730221081; c=relaxed/simple; bh=gb26wrLKVi2eY28XnxI+uJhNaX1RLjd2O4z46xC0RBw=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=mDny8w8PXWqAy4GTobsn26JQ7wiWOgJU0ynrhEigF6qI9l198D64wH25lWsSkzh7TxGCUEegMRrqmpHCF4jlMl/8+QvtuamCPzGDnnODC1ywmP+7IBPZuk4VEwDi7NAP8Ujyxxbmsw0x11bHFnP1FGSu7AUw/H8PZYcmSUN0vgk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E66AB1FDF3; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221071; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p1uYHpDpZGn7aqrUzzlaQyTw75olrQksolZ8xi3EBiU=; b=Wx4mkZNe/1BH7CVQOQYdEhnHmx8/xvEwbJXLysilKvELNCccRBOjVebuqtvRd5pVHi2QYt fd/q5dRigZmfEp5i9kM8Fe+GXqTHrANd/12FrgnNi7aaSEMeC0OM7uR9xEnDZ3qNCvRrP+ UncHYy80ZYYtkw3zbq6bbSKgUJpiRsc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221071; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p1uYHpDpZGn7aqrUzzlaQyTw75olrQksolZ8xi3EBiU=; b=FHK+Un8TcLpta1OzNkL2bPDEFIakcnguryNQA7y4WfpuizMbt7Tu/3WJ4EymkTZ6pqpne3 sPBobQG5LGj/oxDg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=XgRlWsWZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=hrRTwIfx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p1uYHpDpZGn7aqrUzzlaQyTw75olrQksolZ8xi3EBiU=; b=XgRlWsWZeAmXSYefivQ8DU7vNTwpY4EuzhNSHxvm2WsZTEC/xsktGAjSfYGPHzmrG5HyHH sSyiI2gIyuyjMDUl+vI+XetrkkwqEQmGesU8awkMUIsBWy7AagHIdx6zZ568R3Ydzy/VDg btZwiEOjdPSwFPpW1cUDinsa/5ld8ug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730221070; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p1uYHpDpZGn7aqrUzzlaQyTw75olrQksolZ8xi3EBiU=; b=hrRTwIfxANmQ16QbxL4Du2BdaeBI4KO2pYuAGJQtU13iHmezXt5XcGt9cUqeBukKNBj96+ 6TFmRnrRCPeIOvAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C9D9513AD1; Tue, 29 Oct 2024 16:57:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SC0PMA4UIWdfLgAAD6G6ig (envelope-from ); Tue, 29 Oct 2024 16:57:50 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/symtab] Fix parent map dump Date: Tue, 29 Oct 2024 17:57:38 +0100 Message-Id: <20241029165738.6105-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241029165738.6105-1-tdevries@suse.de> References: <20241029165738.6105-1-tdevries@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: E66AB1FDF3 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Before the fix for PR symtab/32225, the parent map dump showed a mapping from section offsets to cooked index entries: ... 0x0000000000000035 0x3ba9560 (0x34: sp1::A) ... but now that's no longer the case: ... 0x00000000406f5405 0x410a04d0 (0x34: sp1::A) ... Fix this by extending the annotation somewhat, such that we get: ... map start: 0x0000000012c52405 0x135fd550 (section: .debug_info, offset: 0x35) -> (0x34: sp1::A) ... Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225 --- gdb/addrmap.c | 3 ++- gdb/addrmap.h | 1 + gdb/dwarf2/parent-map.h | 4 ++-- gdb/dwarf2/read.c | 40 +++++++++++++++++++++++++++++++--------- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 696a7dc1b2a..bd5601b063e 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -356,6 +356,7 @@ addrmap_mutable::~addrmap_mutable () void addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, gdb::function_view annotate_value) { /* True if the previously printed addrmap entry was for PAYLOAD. @@ -381,7 +382,7 @@ addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, core_addr_to_string (start_addr), addr_str); if (annotate_value != nullptr) - annotate_value (outfile, obj); + annotate_value (outfile, start_addr, obj); gdb_printf (outfile, "\n"); } diff --git a/gdb/addrmap.h b/gdb/addrmap.h index 85d46452c2a..6e2111e9b52 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -225,6 +225,7 @@ struct addrmap_mutable final : public addrmap void addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, gdb::function_view annotate_value = nullptr); diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h index a9ea34ec08c..91a8b8c2c88 100644 --- a/gdb/dwarf2/parent-map.h +++ b/gdb/dwarf2/parent-map.h @@ -102,7 +102,7 @@ class parent_map } /* Dump a human-readable form of this map. */ - void dump () const; + void dump (dwarf2_per_bfd *per_bfd) const; private: @@ -142,7 +142,7 @@ class parent_map_map } /* Dump a human-readable form of this collection of parent_maps. */ - void dump () const; + void dump (dwarf2_per_bfd *per_bfd) const; private: diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e9f97380d56..18954a6ab7e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4463,19 +4463,41 @@ cooked_index_storage::eq_cutu_reader (const void *a, const void *b) /* Dump MAP as parent_map. */ static void -dump_parent_map (const struct addrmap *map) +dump_parent_map (dwarf2_per_bfd *per_bfd, const struct addrmap *map) { auto_obstack temp_storage; auto annotate_cooked_index_entry - = [&] (struct ui_file *outfile, const void *value) + = [&] (struct ui_file *outfile, CORE_ADDR start_addr, const void *value) { const cooked_index_entry *parent_entry = (const cooked_index_entry *)value; + + gdb_printf (outfile, "\n\t"); + + bool found = false; + for (auto sections : {per_bfd->infos, per_bfd->types}) + for (auto section : sections) + if ((CORE_ADDR)section.buffer <= start_addr + && start_addr < (CORE_ADDR) (section.buffer + section.size)) + { + gdb_printf (outfile, "(section: %s, offset: 0x%" PRIx64 ")", + section.get_name (), + start_addr - (CORE_ADDR)section.buffer); + found = true; + break; + } + + if (!found) + gdb_printf (outfile, "()"); + if (parent_entry == nullptr) - return; + { + gdb_printf (outfile, " -> ()"); + return; + } - gdb_printf (outfile, " (0x%" PRIx64 ": %s)", + gdb_printf (outfile, " -> (0x%" PRIx64 ": %s)", to_underlying (parent_entry->die_offset), parent_entry->full_name (&temp_storage, false)); }; @@ -4487,20 +4509,20 @@ dump_parent_map (const struct addrmap *map) /* See parent-map.h. */ void -parent_map::dump () const +parent_map::dump (dwarf2_per_bfd *per_bfd) const { - dump_parent_map (&m_map); + dump_parent_map (per_bfd, &m_map); } /* See parent-map.h. */ void -parent_map_map::dump () const +parent_map_map::dump (dwarf2_per_bfd *per_bfd) const { for (const auto &iter : m_maps) { gdb_printf (gdb_stdlog, "map start:\n"); - dump_parent_map (iter); + dump_parent_map (per_bfd, iter); } } @@ -4901,7 +4923,7 @@ class cooked_index_debug_info : public cooked_index_worker if (dwarf_read_debug > 1) { dwarf_read_debug_printf_v ("Final m_all_parents_map:"); - m_all_parents_map.dump (); + m_all_parents_map.dump (m_per_objfile->per_bfd); } }