From patchwork Thu Jan 4 14:19:09 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: 83310 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 51002385803B for ; Thu, 4 Jan 2024 14:19:26 +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 2A7843858D32 for ; Thu, 4 Jan 2024 14:18:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A7843858D32 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 2A7843858D32 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=1704377933; cv=none; b=hhQReDt6CTHhZ4VQDhIX9eLZcN+6ir4ocOrbG6ZeRn6D54Ou59y7VdQ8+p9YGPDSkWp72t0GzAzCg4zjYpM81ar/auzst57unTGsSgZLl6MrHTxjB2g2SAFCMrU7D3GymYHo7b+qHfjf9/DpARvOpPPPmN5OLBqUg4L2bRZ8WHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704377933; c=relaxed/simple; bh=hVdp5c/60+SVyLdU9zFj1aL6/XVJtUGZmXfVUFSyY38=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=Lpu8/HUlxWz/1Bt3gWN7jqpDfTL1hqlm7qsppukmRaeX09znnCAFv9l3bLdx39kgzJlh4YDy7vf6kupI9uUbXoR4ApwKHZWPYVqcYjR/mHOTOtk5vwC3uzYFtH96l4ZcnwWIplkAO+LMI3MxaF6gAR4Ks6XSDY69jDk8EWGD/CU= 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 1D3C121E1A for ; Thu, 4 Jan 2024 14:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iMhYGyT6+DxWyMmOLpf8of9SV02jeb5+TJAPJHKSIEE=; b=BQJ92FD76eWdFlbrSYErs6+TXKcGBQEk4v/w85aSwft8DkJ1ZiPQo9vVMw7uqV9UZ5aT18 5FGtYQ/iT4SVQeUArXAS4YPr8y66Z/OPx036Y6NC7tri8WNmaBkP7+1QkRw6q3KS4ynOLa qxOv+VZIeOw3tMoIKZrLFowFfOgfPgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iMhYGyT6+DxWyMmOLpf8of9SV02jeb5+TJAPJHKSIEE=; b=HoAYppZq91f13skWFFfYZueRAOG64R2WK80MIdvygU9fJSADmb0GjQHcEk53AInC3uy73h BAd6FBN3v/G9ulBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iMhYGyT6+DxWyMmOLpf8of9SV02jeb5+TJAPJHKSIEE=; b=BQJ92FD76eWdFlbrSYErs6+TXKcGBQEk4v/w85aSwft8DkJ1ZiPQo9vVMw7uqV9UZ5aT18 5FGtYQ/iT4SVQeUArXAS4YPr8y66Z/OPx036Y6NC7tri8WNmaBkP7+1QkRw6q3KS4ynOLa qxOv+VZIeOw3tMoIKZrLFowFfOgfPgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iMhYGyT6+DxWyMmOLpf8of9SV02jeb5+TJAPJHKSIEE=; b=HoAYppZq91f13skWFFfYZueRAOG64R2WK80MIdvygU9fJSADmb0GjQHcEk53AInC3uy73h BAd6FBN3v/G9ulBw== 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 0343013C96 for ; Thu, 4 Jan 2024 14:18: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 2DUbO0q+lmUSOwAAD6G6ig (envelope-from ) for ; Thu, 04 Jan 2024 14:18:50 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [gdb/symtab] Allow changing of added cooked_index entries Date: Thu, 4 Jan 2024 15:19:09 +0100 Message-Id: <20240104141911.7596-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240104141911.7596-1-tdevries@suse.de> References: <20240104141911.7596-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: **** X-Spamd-Result: default: False [-1.81 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; RCPT_COUNT_ONE(0.00)[1]; URIBL_BLOCKED(0.00)[suse.de:dkim]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 1D3C121E1A Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=BQJ92FD7; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=HoAYppZq X-Spam-Score: -1.81 X-Spam-Status: No, score=-12.3 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, T_SCC_BODY_TEXT_LINE 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 Make cooked_index_storage::add and cooked_index_entry::add return a "cooked_index_entry *" instead of a "const cooked_index_entry *". Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.c | 2 +- gdb/dwarf2/cooked-index.h | 10 +++++----- gdb/dwarf2/read.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index ba77f9cb373..f9850d39bd0 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -228,7 +228,7 @@ cooked_index_entry::write_scope (struct obstack *storage, /* See cooked-index.h. */ -const cooked_index_entry * +cooked_index_entry * cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, const cooked_index_entry *parent_entry, diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 3c6b9c35fd5..452a07ffb80 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -257,11 +257,11 @@ class cooked_index_shard /* Create a new cooked_index_entry and register it with this object. Entries are owned by this object. The new item is returned. */ - const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, - const cooked_index_entry *parent_entry, - dwarf2_per_cu_data *per_cu); + cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, + cooked_index_flag flags, + const char *name, + const cooked_index_entry *parent_entry, + dwarf2_per_cu_data *per_cu); /* Install a new fixed addrmap from the given mutable addrmap. */ void install_addrmap (addrmap_mutable *map) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6c62932520f..61646a5fba0 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4468,11 +4468,11 @@ class cooked_index_storage /* Add an entry to the index. The arguments describe the entry; see cooked-index.h. The new entry is returned. */ - const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, - const cooked_index_entry *parent_entry, - dwarf2_per_cu_data *per_cu) + cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, + cooked_index_flag flags, + const char *name, + const cooked_index_entry *parent_entry, + dwarf2_per_cu_data *per_cu) { return m_index->add (die_offset, tag, flags, name, parent_entry, per_cu); } From patchwork Thu Jan 4 14:19:10 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: 83311 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 E56B93858025 for ; Thu, 4 Jan 2024 14:19:36 +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 [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 5DE643858C41 for ; Thu, 4 Jan 2024 14:18:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DE643858C41 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 5DE643858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704377934; cv=none; b=O2H/ck/v3qfy0wbpnlxeY9o+DtXalrn6sawLm/EhXNlnPnJ0OtrjQY5txL3+OnYcx4rYIbmN2wwjN4k7wdHKXYYeppvwWgYd06bLbwgeROVlwvvdgQjppz8vGYvmdjaR0dhJvvPB7sSwXYi3/ZSvYfjWojc93/gm3NNJA8UXUy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704377934; c=relaxed/simple; bh=zLO483VnPDrB5/6U920k2lkeH+2sv656+RyzyGS4RrU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=j+PnI/DUcAyw92OTVU+YCBYSNK7rGcZ9OyeZLaQmCmP/7YbZrc1G4Ajv002UXEDQR9jjzgkiDhhnFvcgVw+aCm3ezchHgh8T1F7QhC4Yxc5LbmglD8jcbJda9gntyIwcwm0ShgA2fCfBiYDCzQcJufNtlHp+RK5ggjejNkSa+78= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 359D221E1D for ; Thu, 4 Jan 2024 14:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1A7VGC+2+n/PAU9H0rqSSw4vOTxIGfkawfENCjoXLuU=; b=orP3DPgb8Jy7Iu/K+lzNGL4rxGJ4mSMD4I43zJdf6OJMKTrkN0yO4logm9OAV5ygQU2qSQ EUSx7ZEZDHdtCgqy7P7l/yVsF7gb4PYTMc40u6OuFYhPDwuAQr1th5zavi/2uSA/UJ9iMY TRhLmrtvi6egvVtBrq2va6xgjwfrWZk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1A7VGC+2+n/PAU9H0rqSSw4vOTxIGfkawfENCjoXLuU=; b=Stn58ZeRLoC9M8oEfU5TDyH784bp4VSBDj/zDXVgnQKzCkYGaQ5RFSZ6gEg16fqh0vSfQ/ hnEgLPO1ox4o8TAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1A7VGC+2+n/PAU9H0rqSSw4vOTxIGfkawfENCjoXLuU=; b=orP3DPgb8Jy7Iu/K+lzNGL4rxGJ4mSMD4I43zJdf6OJMKTrkN0yO4logm9OAV5ygQU2qSQ EUSx7ZEZDHdtCgqy7P7l/yVsF7gb4PYTMc40u6OuFYhPDwuAQr1th5zavi/2uSA/UJ9iMY TRhLmrtvi6egvVtBrq2va6xgjwfrWZk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1A7VGC+2+n/PAU9H0rqSSw4vOTxIGfkawfENCjoXLuU=; b=Stn58ZeRLoC9M8oEfU5TDyH784bp4VSBDj/zDXVgnQKzCkYGaQ5RFSZ6gEg16fqh0vSfQ/ hnEgLPO1ox4o8TAA== 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 1EE9313C99 for ; Thu, 4 Jan 2024 14:18:51 +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 6DQ8Bku+lmUSOwAAD6G6ig (envelope-from ) for ; Thu, 04 Jan 2024 14:18:51 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/3] [gdb/symtab] Make cooked_index_entry::parent_entry private Date: Thu, 4 Jan 2024 15:19:10 +0100 Message-Id: <20240104141911.7596-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240104141911.7596-1-tdevries@suse.de> References: <20240104141911.7596-1-tdevries@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; URIBL_BLOCKED(0.00)[tail.data:url]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 1.90 X-Spam-Status: No, score=-12.3 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, T_SCC_BODY_TEXT_LINE 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 Make cooked_index_entry::parent_entry private, and add member functions to access it. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.c | 14 +++++++------- gdb/dwarf2/cooked-index.h | 25 +++++++++++++++++++------ gdb/dwarf2/read.c | 6 +++--- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index f9850d39bd0..307cfe74a87 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -186,7 +186,7 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main) const { const char *local_name = for_main ? name : canonical; - if ((flags & IS_LINKAGE) != 0 || parent_entry == nullptr) + if ((flags & IS_LINKAGE) != 0 || get_parent () == nullptr) return local_name; const char *sep = nullptr; @@ -207,7 +207,7 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main) const return local_name; } - parent_entry->write_scope (storage, sep, for_main); + get_parent ()->write_scope (storage, sep, for_main); obstack_grow0 (storage, local_name, strlen (local_name)); return (const char *) obstack_finish (storage); } @@ -219,8 +219,8 @@ cooked_index_entry::write_scope (struct obstack *storage, const char *sep, bool for_main) const { - if (parent_entry != nullptr) - parent_entry->write_scope (storage, sep, for_main); + if (get_parent () != nullptr) + get_parent ()->write_scope (storage, sep, for_main); const char *local_name = for_main ? name : canonical; obstack_grow (storage, local_name, strlen (local_name)); obstack_grow (storage, sep, strlen (sep)); @@ -299,7 +299,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, parent = last; } - entry->parent_entry = parent; + entry->set_parent (parent); return make_unique_xstrndup (tail.data (), tail.length ()); } @@ -585,9 +585,9 @@ cooked_index::dump (gdbarch *arch) const gdb_printf (" flags: %s\n", to_string (entry->flags).c_str ()); gdb_printf (" DIE offset: %s\n", sect_offset_str (entry->die_offset)); - if (entry->parent_entry != nullptr) + if (entry->get_parent () != nullptr) gdb_printf (" parent: ((cooked_index_entry *) %p) [%s]\n", - entry->parent_entry, entry->parent_entry->name); + entry->get_parent (), entry->get_parent ()->name); else gdb_printf (" parent: ((cooked_index_entry *) 0)\n"); diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 452a07ffb80..2b2f2f79bab 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -84,8 +84,8 @@ struct cooked_index_entry : public allocate_on_obstack tag (tag_), flags (flags_), die_offset (die_offset_), - parent_entry (parent_entry_), - per_cu (per_cu_) + per_cu (per_cu_), + m_parent_entry (parent_entry_) { } @@ -210,6 +210,18 @@ struct cooked_index_entry : public allocate_on_obstack return compare (canonical, other.canonical, SORT) < 0; } + /* Set parent entry to PARENT. */ + void set_parent (const cooked_index_entry *parent) + { + m_parent_entry = parent; + } + + /* Return parent entry. */ + const cooked_index_entry *get_parent () const + { + return m_parent_entry; + } + /* The name as it appears in DWARF. This always points into one of the mapped DWARF sections. Note that this may be the name or the linkage name -- two entries are created for DIEs which have both @@ -224,10 +236,6 @@ struct cooked_index_entry : public allocate_on_obstack cooked_index_flag flags; /* The offset of this DIE. */ sect_offset die_offset; - /* The parent entry. This is NULL for top-level entries. - Otherwise, it points to the parent entry, such as a namespace or - class. */ - const cooked_index_entry *parent_entry; /* The CU from which this entry originates. */ dwarf2_per_cu_data *per_cu; @@ -238,6 +246,11 @@ struct cooked_index_entry : public allocate_on_obstack a parent, its write_scope method is called first. */ void write_scope (struct obstack *storage, const char *sep, bool for_name) const; + + /* The parent entry. This is NULL for top-level entries. + Otherwise, it points to the parent entry, such as a namespace or + class. */ + const cooked_index_entry *m_parent_entry; }; class cooked_index; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 61646a5fba0..841746b7473 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16421,7 +16421,7 @@ cooked_indexer::index_dies (cutu_reader *reader, /* The scope of a DW_TAG_entry_point cooked_index_entry is the one of its surrounding subroutine. */ if (abbrev->tag == DW_TAG_entry_point) - this_parent_entry = parent_entry->parent_entry; + this_parent_entry = parent_entry->get_parent (); info_ptr = scan_attributes (reader->cu->per_cu, reader, info_ptr, info_ptr, abbrev, &name, &linkage_name, &flags, &sibling, &this_parent_entry, @@ -16764,7 +16764,7 @@ cooked_index_functions::expand_symtabs_matching matches. */ bool found = true; - const cooked_index_entry *parent = entry->parent_entry; + const cooked_index_entry *parent = entry->get_parent (); for (int i = name_vec.size () - 1; i > 0; --i) { /* If we ran out of entries, or if this segment doesn't @@ -16777,7 +16777,7 @@ cooked_index_functions::expand_symtabs_matching break; } - parent = parent->parent_entry; + parent = parent->get_parent (); } if (!found) From patchwork Thu Jan 4 14:19:11 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: 83312 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 9728B385801C for ; Thu, 4 Jan 2024 14:19:57 +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 [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 618443858C50 for ; Thu, 4 Jan 2024 14:18:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 618443858C50 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 618443858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704377934; cv=none; b=JtF73OdTAA3UvRZ2KvrJ4XbjwMRGfeY6KYqzGTWgeodstQewZ9lyaPK660YVh7x7OXzXjHO3BsRJqt9Tjx1nlVPXpM4YiESzn19wbBSkfW4D6t0pgNsOPPxRDKVIdTISD3cApWdHLG63Z+ie+/T4OKxJ7fLKO/93zg+7DakLQ5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704377934; c=relaxed/simple; bh=GWW+fFPd1zJGLy6d4g4WsWNmMNQKvrwBkhQqNRhB/Sk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=GhGGJLHA7BfJmlr9toPZvMB5OGKtcYOizpfqIue0C2NMt7Smy6NQzrcD27jC940O8Ys7rTuuiZmZcRK8LqcifpxOXdG6ngYehUNol6ecC/kGT9k69UwfCDthVxxU3zYJgOB0l9SnYkAffdsPtN9SRJ5ouS00oofHS86Ujsc+2Uw= 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 5357421E22 for ; Thu, 4 Jan 2024 14:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mu2vrafai0Dz+Zh8cErnFbrHidRMX+9se0Nq//3kWGk=; b=gWTWKiHePO308FAgoeepiu4LbKUxwRmhDbt7QH1DlYMhNxHfDLQcAyNjebZhSk2LnmJUfc uVVSa7FeFDc8ZOcTuZoBOwYRFbKZPVRqYkrX4LmoBS4bZ4iqcLjP2td/2iOE4UeGZf+0Zs aecB8h/qGBGQiBHLsL+oLOtshbjWqRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mu2vrafai0Dz+Zh8cErnFbrHidRMX+9se0Nq//3kWGk=; b=50xQWutaQRVCLfdZE0teEYHe0FenhNehydg4H9c1GZhVX91teCzZJJHhOTZ5KRtmA5Zw69 f6NAHayDQZSyrIDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mu2vrafai0Dz+Zh8cErnFbrHidRMX+9se0Nq//3kWGk=; b=gWTWKiHePO308FAgoeepiu4LbKUxwRmhDbt7QH1DlYMhNxHfDLQcAyNjebZhSk2LnmJUfc uVVSa7FeFDc8ZOcTuZoBOwYRFbKZPVRqYkrX4LmoBS4bZ4iqcLjP2td/2iOE4UeGZf+0Zs aecB8h/qGBGQiBHLsL+oLOtshbjWqRY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704377931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mu2vrafai0Dz+Zh8cErnFbrHidRMX+9se0Nq//3kWGk=; b=50xQWutaQRVCLfdZE0teEYHe0FenhNehydg4H9c1GZhVX91teCzZJJHhOTZ5KRtmA5Zw69 f6NAHayDQZSyrIDQ== 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 3A3F013C9C for ; Thu, 4 Jan 2024 14:18:51 +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 IJnkDEu+lmUSOwAAD6G6ig (envelope-from ) for ; Thu, 04 Jan 2024 14:18:51 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [gdb/symtab] Eliminate deferred_entry Date: Thu, 4 Jan 2024 15:19:11 +0100 Message-Id: <20240104141911.7596-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240104141911.7596-1-tdevries@suse.de> References: <20240104141911.7596-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: **** X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=gWTWKiHe; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=50xQWuta X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-0.997]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 5357421E22 X-Spam-Status: No, score=-12.3 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, T_SCC_BODY_TEXT_LINE 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 Currently cooked_index entry creation is either: - done immediately if the parent_entry is known, or - deferred if the parent_entry is not yet known, and done later while resolving the deferred entries. Instead, create all cooked_index entries immediately, and keep track of which entries have a parent_entry that needs resolving later using the new IS_PARENT_DEFERRED flag. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.c | 7 ++++-- gdb/dwarf2/cooked-index.h | 51 ++++++++++++++++++++++++++++++++++----- gdb/dwarf2/read.c | 37 ++++++++++++---------------- 3 files changed, 65 insertions(+), 30 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 307cfe74a87..05d277bf215 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -231,7 +231,7 @@ cooked_index_entry::write_scope (struct obstack *storage, cooked_index_entry * cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu) { cooked_index_entry *result = create (die_offset, tag, flags, name, @@ -585,7 +585,10 @@ cooked_index::dump (gdbarch *arch) const gdb_printf (" flags: %s\n", to_string (entry->flags).c_str ()); gdb_printf (" DIE offset: %s\n", sect_offset_str (entry->die_offset)); - if (entry->get_parent () != nullptr) + if ((entry->flags & IS_PARENT_DEFERRED) != 0) + gdb_printf (" parent: deferred (%" PRIx64 ")\n", + entry->get_deferred_parent ()); + else if (entry->get_parent () != nullptr) gdb_printf (" parent: ((cooked_index_entry *) %p) [%s]\n", entry->get_parent (), entry->get_parent ()->name); else diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 2b2f2f79bab..1bfad27f263 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -38,6 +38,7 @@ struct dwarf2_per_cu_data; struct dwarf2_per_bfd; struct index_cache_store_context; +struct cooked_index_entry; /* Flags that describe an entry in the index. */ enum cooked_index_flag_enum : unsigned char @@ -53,9 +54,30 @@ enum cooked_index_flag_enum : unsigned char /* True if this entry is just for the declaration of a type, not the definition. */ IS_TYPE_DECLARATION = 16, + /* True is parent_entry.deferred has a value rather than parent_entry + .resolved. */ + IS_PARENT_DEFERRED = 32, }; DEF_ENUM_FLAGS_TYPE (enum cooked_index_flag_enum, cooked_index_flag); +/* Type representing either a resolved or deferred cooked_index_entry. */ + +union cooked_index_entry_ref +{ + cooked_index_entry_ref (CORE_ADDR deferred_) + { + deferred = deferred_; + } + + cooked_index_entry_ref (const cooked_index_entry *resolved_) + { + resolved = resolved_; + } + + const cooked_index_entry *resolved; + CORE_ADDR deferred; +}; + /* Return a string representation of FLAGS. */ std::string to_string (cooked_index_flag flags); @@ -78,7 +100,7 @@ struct cooked_index_entry : public allocate_on_obstack { cooked_index_entry (sect_offset die_offset_, enum dwarf_tag tag_, cooked_index_flag flags_, const char *name_, - const cooked_index_entry *parent_entry_, + cooked_index_entry_ref parent_entry_, dwarf2_per_cu_data *per_cu_) : name (name_), tag (tag_), @@ -213,13 +235,30 @@ struct cooked_index_entry : public allocate_on_obstack /* Set parent entry to PARENT. */ void set_parent (const cooked_index_entry *parent) { - m_parent_entry = parent; + gdb_assert ((flags & IS_PARENT_DEFERRED) == 0); + m_parent_entry.resolved = parent; + } + + /* Resolve deferred parent entry to PARENT. */ + void resolve_parent (const cooked_index_entry *parent) + { + gdb_assert ((flags & IS_PARENT_DEFERRED) != 0); + flags = flags & ~IS_PARENT_DEFERRED; + m_parent_entry.resolved = parent; } /* Return parent entry. */ const cooked_index_entry *get_parent () const { - return m_parent_entry; + gdb_assert ((flags & IS_PARENT_DEFERRED) == 0); + return m_parent_entry.resolved; + } + + /* Return deferred parent entry. */ + CORE_ADDR get_deferred_parent () const + { + gdb_assert ((flags & IS_PARENT_DEFERRED) != 0); + return m_parent_entry.deferred; } /* The name as it appears in DWARF. This always points into one of @@ -250,7 +289,7 @@ struct cooked_index_entry : public allocate_on_obstack /* The parent entry. This is NULL for top-level entries. Otherwise, it points to the parent entry, such as a namespace or class. */ - const cooked_index_entry *m_parent_entry; + cooked_index_entry_ref m_parent_entry; }; class cooked_index; @@ -273,7 +312,7 @@ class cooked_index_shard cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu); /* Install a new fixed addrmap from the given mutable addrmap. */ @@ -332,7 +371,7 @@ class cooked_index_shard enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu) { return new (&m_storage) cooked_index_entry (die_offset, tag, flags, diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 841746b7473..c897a222a9f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4471,7 +4471,7 @@ class cooked_index_storage cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu) { return m_index->add (die_offset, tag, flags, name, parent_entry, per_cu); @@ -4620,16 +4620,6 @@ class cooked_indexer understand this. */ addrmap_mutable m_die_range_map; - /* A single deferred entry. */ - struct deferred_entry - { - sect_offset die_offset; - const char *name; - CORE_ADDR spec_offset; - dwarf_tag tag; - cooked_index_flag flags; - }; - /* The generated DWARF can sometimes have the declaration for a method in a class (or perhaps namespace) scope, with the definition appearing outside this scope... just one of the many @@ -4637,7 +4627,7 @@ class cooked_indexer defer certain entries until the end of scanning, at which point we'll know the containing context of all the DIEs that we might have scanned. This vector stores these deferred entries. */ - std::vector m_deferred_entries; + std::vector m_deferred_entries; }; /* Subroutine of dwarf2_build_psymtabs_hard to simplify it. @@ -16438,17 +16428,21 @@ cooked_indexer::index_dies (cutu_reader *reader, name = nullptr; } - const cooked_index_entry *this_entry = nullptr; + cooked_index_entry *this_entry = nullptr; if (name != nullptr) { if (defer != 0) - m_deferred_entries.push_back ({ - this_die, name, defer, abbrev->tag, flags - }); + { + this_entry + = m_index_storage->add (this_die, abbrev->tag, + flags | IS_PARENT_DEFERRED, name, + defer, m_per_cu); + m_deferred_entries.push_back (this_entry); + } else - this_entry = m_index_storage->add (this_die, abbrev->tag, flags, - name, this_parent_entry, - m_per_cu); + this_entry + = m_index_storage->add (this_die, abbrev->tag, flags, name, + this_parent_entry, m_per_cu); } if (linkage_name != nullptr) @@ -16549,10 +16543,9 @@ cooked_indexer::make_index (cutu_reader *reader) for (const auto &entry : m_deferred_entries) { - void *obj = m_die_range_map.find (entry.spec_offset); + void *obj = m_die_range_map.find (entry->get_deferred_parent ()); cooked_index_entry *parent = static_cast (obj); - m_index_storage->add (entry.die_offset, entry.tag, entry.flags, - entry.name, parent, m_per_cu); + entry->resolve_parent (parent); } }