From: Wei-min Pan <weimin.pan@oracle.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] gdb/ctf: don't create a buildsym_compunit when building partial symbols
Date: Thu, 31 Mar 2022 16:56:23 -0700 [thread overview]
Message-ID: <90ec7aeb-6e9d-bd6c-236e-d74c2c6bf2a6@oracle.com> (raw)
In-Reply-To: <20220331212019.2811099-1-simon.marchi@polymtl.ca>
On 3/31/2022 2:20 PM, Simon Marchi wrote:
> I am trying to do some changes to buildsym_compunit, so I am auditing
> the current uses. Something seems odd with this use of
> buildsym_compunit (that this patch removes).
>
> A buildsym_compunit is normally used when building a compunit_symtab.
> That is, when expanding a partial symtab into a full compunit symtab.
> In ctfread.c, a buildsym_compunit is created in ctf_start_archive, which
> is only used when creating partial symtabs. At this moment, I don't
> see how that's useful. ctf_start_archive creates a new
> buildsym_compunit and starts a subfile. But that buildsym_compunit is
> never used again. It's just overriden in ctf_start_symtab, which means
> we leak the old buildsym_compunit, I suppose.
>
> Remove ctf_start_archive completely. Add an assert in
> ctf_start_symtab to verify that we are not overwriting an existing
> buildsym_compunit (meaning we'd leak the existing one). This assert
> triggers without the other part of the fix. When doing:
>
> $ ./gdb --data-directory=data-directory /tmp/babeltrace-ctf/src/lib/.libs/libbabeltrace2.so.0.0.0
> ...
> (gdb) maintenance expand-symtabs
> /home/simark/src/binutils-gdb/gdb/ctfread.c:1255: internal-error: ctf_start_symtab: Assertion `!ccp->builder' failed.
>
> Change-Id: I666d146454a019f08e7305f3a1c4a974d27b4592
> ---
> gdb/ctfread.c | 20 +-------------------
> 1 file changed, 1 insertion(+), 19 deletions(-)
>
> diff --git a/gdb/ctfread.c b/gdb/ctfread.c
> index 8da38cc70af8..8636692e2e1b 100644
> --- a/gdb/ctfread.c
> +++ b/gdb/ctfread.c
> @@ -1531,21 +1531,6 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg)
> return 0;
> }
>
> -/* Start a subfile for CTF. FNAME is the name of the archive. */
> -
> -static void
> -ctf_start_archive (struct ctf_context *ccx, struct objfile *of,
> - const char *fname)
> -{
> - if (ccx->builder == nullptr)
> - {
> - ccx->builder = new buildsym_compunit (of,
> - of->original_name, nullptr, language_c, 0);
> - ccx->builder->record_debugformat ("ctf");
> - }
> - ccx->builder->start_subfile (fname);
> -}
> -
> /* Setup partial_symtab's describing each source file for which
> debugging information is available. */
>
> @@ -1567,10 +1552,7 @@ scan_partial_symbols (ctf_dict_t *cfp, psymtab_storage *partial_symtabs,
>
> struct ctf_context *ccx = &pst->context;
> if (isparent == false)
> - {
> - ctf_start_archive (ccx, of, fname);
> - ccx->pst = pst;
> - }
> + ccx->pst = pst;
>
> if (ctf_type_iter (cfp, ctf_psymtab_type_cb, ccx) == CTF_ERR)
> complaint (_("ctf_type_iter scan_partial_symbols failed - %s"),
A CTF archive contains conflicting type info and is treated as a CU.
Since one can't switch scope among CUs in CTF, not reading archives
might not be a problem. Please go ahead and make the change. It can
be revisited when we come up a test case that shows otherwise.
Thanks.
>
> base-commit: 59f837cb11e3b96c581fe23b79f6995b7c8177ee
next prev parent reply other threads:[~2022-03-31 23:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 21:20 Simon Marchi
2022-03-31 21:20 ` [PATCH 2/3] gdb: print compunit_symtab name in "maint info symtabs" Simon Marchi
2022-03-31 21:20 ` [PATCH 3/3] gdb/ctf: pass partial symtab's filename to buildsym_compunit Simon Marchi
2022-04-01 0:07 ` Wei-min Pan
2022-03-31 23:56 ` Wei-min Pan [this message]
2022-04-01 0:14 ` [PATCH 1/3] gdb/ctf: don't create a buildsym_compunit when building partial symbols Simon Marchi
2022-04-01 0:57 ` Wei-min Pan
2022-04-01 1:32 ` Simon Marchi
2022-04-04 17:08 ` 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=90ec7aeb-6e9d-bd6c-236e-d74c2c6bf2a6@oracle.com \
--to=weimin.pan@oracle.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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).