From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/4] gdb: remove objfile parameter from get_objfile_bfd_data
Date: Mon, 22 Mar 2021 15:34:17 -0400 [thread overview]
Message-ID: <20210322193417.2376788-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20210322193417.2376788-1-simon.marchi@efficios.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
I noticed it was unused. I think that makes sense, as it shows that
objfile_per_bfd_storage is not specific to one objfile (it can be shared
by multiple objfiles that have the same bfd).
There is one thing I wonder though, maybe I'm missing something. If
the BFD doesn't require relocation, get_objfile_bfd_data stores the
newly allocated object in objfiles_bfd_data, so we can assume that
objfiles_bfd_data is the owner of the object. When the bfd's refcount
drops to 0, the corresponding objfile_per_bfd_storage object in
objfiles_bfd_data is deleted.
But if the BFD requires relocation, get_objfile_bfd_data returns a newly
allocated object that isn't kept anywhere else (and isn't shared). So
the objfile becomes the owner of the objfile_per_bfd_storage object. In
objfile::~objfile, we have this:
if (obfd)
gdb_bfd_unref (obfd);
else
delete per_bfd;
I'm thinking that obfd could be non-nullptr, and it could require
relocation. In that case, it would never be freed. Anyway, that's not
really connected to this patch.
gdb/ChangeLog:
* objfiles.c (get_objfile_bfd_data): Remove objfile parameter,
adjust callers.
Change-Id: Ifa3158074ea6b42686780ba09d0c964b0cf14cf1
---
gdb/objfiles.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 702900761f3..f68e97bd08f 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -125,7 +125,7 @@ objfile_per_bfd_storage::~objfile_per_bfd_storage ()
only be called when allocating or re-initializing OBJFILE. */
static struct objfile_per_bfd_storage *
-get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
+get_objfile_bfd_data (bfd *abfd)
{
struct objfile_per_bfd_storage *storage = NULL;
@@ -154,7 +154,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
void
set_objfile_per_bfd (struct objfile *objfile)
{
- objfile->per_bfd = get_objfile_bfd_data (objfile, objfile->obfd);
+ objfile->per_bfd = get_objfile_bfd_data (objfile->obfd);
}
/* Set the objfile's per-BFD notion of the "main" name and
@@ -363,7 +363,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
build_objfile_section_table (this);
}
- per_bfd = get_objfile_bfd_data (this, abfd);
+ per_bfd = get_objfile_bfd_data (abfd);
}
/* If there is a valid and known entry point, function fills *ENTRY_P with it
--
2.30.0
next prev parent reply other threads:[~2021-03-22 19:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 19:34 [PATCH 0/4] Small Misc psymtabs / objfile cleanups Simon Marchi
2021-03-22 19:34 ` [PATCH 1/4] gdb: add intern method to objfile_per_bfd_storage Simon Marchi
2021-03-23 14:47 ` Christian Biesinger
2021-03-23 15:48 ` Simon Marchi
2021-03-23 15:53 ` Christian Biesinger
2021-03-23 16:08 ` Simon Marchi
2021-04-01 17:44 ` Tom Tromey
2021-04-02 15:38 ` Simon Marchi
2021-03-22 19:34 ` [PATCH 2/4] gdb: use std::string in partial_symtab::partial_symtab / allocate_symtab Simon Marchi
2021-04-01 17:43 ` Tom Tromey
2021-03-22 19:34 ` [PATCH 3/4] gdb: pass objfile_per_bfd_storage instead of objfile to partial_symtab Simon Marchi
2021-04-01 17:47 ` Tom Tromey
2021-04-02 15:42 ` Simon Marchi
2021-03-22 19:34 ` Simon Marchi [this message]
2021-04-01 17:52 ` [PATCH 4/4] gdb: remove objfile parameter from get_objfile_bfd_data Tom Tromey
2021-04-02 15:52 ` Simon Marchi
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=20210322193417.2376788-5-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/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).