From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 9D5F43858D1E for ; Fri, 4 Aug 2023 20:52:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D5F43858D1E 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-out2.suse.de (Postfix) with ESMTPS id 8E1F11F37C; Fri, 4 Aug 2023 20:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691182336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ejCBuieShUIj3Ql4klW6FsbZyXdPPP+5P5B/3xK5jsE=; b=c7+l1cyRtZKNZ/YE1yH0d58J6keJj6jCTM6HX1bw7XfkdWIB7eeTiYVKlG9vhdHZSR1xzr BjydwKEJ9ifQvSmQxmh6WiXVBQjMAQktia9gbwqIXVQ4496Xxtxlqj8XC3VyaL8u+Nic7T tlRK7ZbyYXWcQPlJEBOXYd0cL2CGRxg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691182336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ejCBuieShUIj3Ql4klW6FsbZyXdPPP+5P5B/3xK5jsE=; b=g8dZ0RUp4/fF19Pha1+tRTx4TPXZQ/8hgq4tPwLBYCdSEZlvVRWnS/l6StYOgNQRXHiapM WvhL/DnVi+E9k+DA== 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 70B9A13904; Fri, 4 Aug 2023 20:52:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kiu7GQBlzWStTwAAMHmgww (envelope-from ); Fri, 04 Aug 2023 20:52:16 +0000 Message-ID: <54b57454-5758-94ed-e5bc-f1b894c98c4f@suse.de> Date: Fri, 4 Aug 2023 22:52:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/symtab] Find main language without symtab expansion To: Tom Tromey , Tom de Vries via Gdb-patches References: <20230804112243.11537-1-tdevries@suse.de> <87pm42afsh.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <87pm42afsh.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: On 8/4/23 19:17, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> Reimplement the feature by adding > Tom> cooked_index_functions::lookup_global_symbol_language. > > Thanks for the patch. > > Tom> + /* Expansion of large CUs can be slow. By returning the language of main > Tom> + here for C and C++, we avoid CU expansion during set_initial_language. > Tom> + But by doing a symbol lookup in the cooked index, we are forced to wait > Tom> + for finalization to complete. See PR symtab/30174 for ideas how to > Tom> + bypass that as well. */ > Tom> + cooked_index *table = per_bfd->index_table->index_for_writing (); > > I think it's more normal to use: > > cooked_index *table > = (gdb::checked_static_cast > (per_bfd->index_table.get ())); > > in the body of cooked_index_functions. > Ack, updated (not reposting for this), thanks. > Tom> + for (const cooked_index_entry *entry : table->find (name, false)) > > I think this is probably racy, if the intent is not to wait for > finalization, because cooked_index_shard::find uses the canonical name. > The intent is to wait for finalization, as I've tried to make clear in the comment quoted above. Indeed cooked_index_shard::find uses the canonical name, and I think that's why it uses "wait ()" to wait for finalization. So, I don't think this is racy. I've also checked by building with -fsanitizer=thread and running the two test-cases with make-check-all.sh. > Maybe we need to resurrect the approach of looking for "main" in C/C++ > CUs. Um, AFAICT that's exactly what this patch does, so I suppose you mean something else. Maybe you mean reverting this bit of commit 47fe57c9281 ("Fix "start" for D, Rust, etc"): ... @@ -218,10 +232,6 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, implicit "main" discovery. */ if ((flags & IS_MAIN) != 0) m_main = result; - else if (per_cu->lang () != language_ada - && m_main == nullptr - && strcmp (name, "main") == 0) - m_main = result; return result; } ... That was my initial approach, but it required a lot of reasoning about why it's not racy, so I like this approach better, which is not racy by design. I'll commit this tomorrow unless there are further comments. Thanks, - Tom > I don't really remember all the state of this right now, there's > been a lot of flux. I did also reimplement some of this on my > background DWARF reading branch, but I think that's kind of invasive. > > Tom