From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] [gdb/symtab] Find main language without symtab expansion
Date: Fri, 4 Aug 2023 22:52:03 +0200 [thread overview]
Message-ID: <54b57454-5758-94ed-e5bc-f1b894c98c4f@suse.de> (raw)
In-Reply-To: <87pm42afsh.fsf@tromey.com>
On 8/4/23 19:17, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> 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<cooked_index *>
> (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
next prev parent reply other threads:[~2023-08-04 20:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 11:22 Tom de Vries
2023-08-04 17:17 ` Tom Tromey
2023-08-04 20:52 ` Tom de Vries [this message]
2023-08-05 13:19 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54b57454-5758-94ed-e5bc-f1b894c98c4f@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).