diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2022-03-31 17:20:17 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-03-31 21:26:48 -0400 |
commit | 8458fb44b45ed25ae08237771fa4ada9a8f463f4 (patch) | |
tree | 66c76aa8cbabc70823124e72e884c8747eede9c5 /gdb/ctfread.c | |
parent | 8839e3f3b0d1af5d93ba1d4f667ce33936bb7db2 (diff) | |
download | gdb-8458fb44b45ed25ae08237771fa4ada9a8f463f4.zip gdb-8458fb44b45ed25ae08237771fa4ada9a8f463f4.tar.gz gdb-8458fb44b45ed25ae08237771fa4ada9a8f463f4.tar.bz2 |
gdb/ctf: don't create a buildsym_compunit when building partial symbols
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
Diffstat (limited to 'gdb/ctfread.c')
-rw-r--r-- | gdb/ctfread.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 8da38cc..8636692 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"), |