From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 81AD43858D1E for ; Thu, 3 Aug 2023 13:34:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81AD43858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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 B53522191E; Thu, 3 Aug 2023 13:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691069670; 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=2vttZwZn9xLIj1T6ZR2tPhs1BZlmTx+QTDg51ksosbI=; b=W9SF2FxUgYRT3fcnhzkyvA21InOUJ4EdQs7h7qdXJrdw52nii7UwaIUkhjIQX1LJE4YT3E DGAChRawqyNJ9l1gTz8kAKaxVjBryTsO//Id8r9KkIFWUcFrs5v4Td8N7NmWHhSKDQ3gz/ t0O3KE2M/kwi767gyJJ8C31Ll0sr4qs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691069670; 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=2vttZwZn9xLIj1T6ZR2tPhs1BZlmTx+QTDg51ksosbI=; b=Mb58u+5BtsBUGGCOM8AUrsRnSI1ha+VulVPj5jkYlopVltGuII+Wxaqdc72sw3XdSA5gW7 b/78z/oG9HQbDUBg== 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 9E135134B0; Thu, 3 Aug 2023 13:34:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 18CEJeasy2SRcwAAMHmgww (envelope-from ); Thu, 03 Aug 2023 13:34:30 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] [gdb/symtab] Remove superfluous handling of Ada main in write_cooked_index Date: Thu, 3 Aug 2023 15:34:14 +0200 Message-Id: <20230803133414.22219-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HEXHASH_WORD,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 List-Id: I filed PR29179 about the following FAIL in test-case gdb.ada/O2_float_param.exp with target board cc-with-gdb-index: ... (gdb) break increment^M Function "increment" not defined.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.ada/O2_float_param.exp: scenario=all: gdb_breakpoint: \ set breakpoint at increment ... The FAIL was a regression since commit 2cf349be0e3 ("Do not put linkage names into .gdb_index"). Before that commit we had: ... $ readelf -w foo > READELF $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... but after only: ... $ grep callee.*increment READELF [3115] callee.increment: 5 [global, function] ... The regression was fixed by commit 67e83a0deef ("Fix regression in c-linkage-name.exp with gdb index"), which got us again: ... $ grep callee.*increment READELF [1568] callee__increment: 5 [global, function] [3115] callee.increment: 5 [global, function] ... The commit however did not claim that particular PR. A subsequent commit, commit 5fea9794325 ("Improve Ada support in .gdb_index") did claim to fix it, together with commit dd05fc7071a ("Change .gdb_index de-duplication implementation"). The commit 5fea9794325 contained the following addition in write_cooked_index: ... + if (entry->per_cu->lang () == language_ada) + { + /* We want to ensure that the Ada main function's name + appears verbatim in the index. However, this name will + be of the form "_ada_mumble", and will be rewritten by + ada_decode. So, recognize it specially here and add it + to the index by hand. */ + if (entry->tag == DW_TAG_subprogram + && strcmp (main_for_ada, name) == 0) + { + /* Leave it alone. */ + } + else + { + /* In order for the index to work when read back into + gdb, it has to use the encoded name, with any + suffixes stripped. */ + std::string encoded = ada_encode (name, false); + name = obstack_strdup (&symtab->m_string_obstack, + encoded.c_str ()); + } + } ... The code contains some special handling related to the Ada main function, so let's look at that one: foo. Before commit 67e83a0deef we have: ... $ grep foo.*function READELF [3733] foo: 7 [global, function] ... and after: ... $ grep foo.*function READELF [2738] _ada_foo: 7 [global, function] [3733] foo: 7 [global, function] ... so that looks identical to the callee.increment case. At commit 5fea9794325, we have slightly different index numbers: ... $ grep foo.*function READELF [1658] foo: 7 [global, function] [2738] _ada_foo: 7 [global, function] ... but otherwise the same result. If we disable the special handling of the Ada main function like so: ... - if (entry->tag == DW_TAG_subprogram + if (false && entry->tag == DW_TAG_subprogram ... we still have the exact same result because: ... (gdb) p main_for_ada $1 = 0x352e6a0 "_ada_foo" ... and ada_encode ("_ada_foo", false) == "_ada_foo". The comment seems to be copied from debug_names::insert, which does indeed use ada_decode, while the code in write_cooked_index uses ada_encode instead. Remove the superfluous special handling of Ada main in write_cooked_index. Tested on x86_64-linux, with target boards unix and cc-with-gdb-index. --- gdb/dwarf2/index-write.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 62c2cc6ac7d..66c5378d677 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1128,8 +1128,6 @@ write_cooked_index (cooked_index *table, const cu_index_map &cu_index_htab, struct mapped_symtab *symtab) { - const char *main_for_ada = main_name (); - for (const cooked_index_entry *entry : table->all_entries ()) { const auto it = cu_index_htab.find (entry->per_cu); @@ -1139,25 +1137,12 @@ write_cooked_index (cooked_index *table, if (entry->per_cu->lang () == language_ada) { - /* We want to ensure that the Ada main function's name - appears verbatim in the index. However, this name will - be of the form "_ada_mumble", and will be rewritten by - ada_decode. So, recognize it specially here and add it - to the index by hand. */ - if (entry->tag == DW_TAG_subprogram - && strcmp (main_for_ada, name) == 0) - { - /* Leave it alone. */ - } - else - { - /* In order for the index to work when read back into - gdb, it has to use the encoded name, with any - suffixes stripped. */ - std::string encoded = ada_encode (name, false); - name = obstack_strdup (&symtab->m_string_obstack, - encoded.c_str ()); - } + /* In order for the index to work when read back into + gdb, it has to use the encoded name, with any + suffixes stripped. */ + std::string encoded = ada_encode (name, false); + name = obstack_strdup (&symtab->m_string_obstack, + encoded.c_str ()); } else if (entry->per_cu->lang () == language_cplus && (entry->flags & IS_LINKAGE) != 0) base-commit: 1720b64f735ff2798ab50ea9e2a40ab42af6cc6e -- 2.35.3