From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 8/9] Change program_space::ebfd to a gdb_bfd_ref_ptr
Date: Tue, 21 Jul 2020 21:34:43 -0600 [thread overview]
Message-ID: <20200722033444.18522-9-tom@tromey.com> (raw)
In-Reply-To: <20200722033444.18522-1-tom@tromey.com>
This changes program_space::ebfd to a gdb_bfd_ref_ptr, removing some
manual management.
gdb/ChangeLog
2020-07-21 Tom Tromey <tom@tromey.com>
* exec.c (exec_file_attach): Update.
* progspace.c (program_space::exec_close): Update.
* progspace.h (struct program_space) <ebfd>: Now a
gdb_bfd_ref_ptr.
<set_exec_bfd>: Change argument type.
<exec_bfd>: Update.
---
gdb/ChangeLog | 9 +++++++++
gdb/exec.c | 2 +-
gdb/progspace.c | 6 ++----
gdb/progspace.h | 8 ++++----
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/gdb/exec.c b/gdb/exec.c
index 75f3990e0f0..ee5e948ec75 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -450,7 +450,7 @@ exec_file_attach (const char *filename, int from_tty)
FOPEN_RUB, scratch_chan);
else
temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
- current_program_space->set_exec_bfd (temp.release ());
+ current_program_space->set_exec_bfd (std::move (temp));
if (!current_program_space->exec_bfd ())
{
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 49243a6394d..15cdc9f90e1 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -223,13 +223,11 @@ program_space::solibs () const
void
program_space::exec_close ()
{
- if (ebfd)
+ if (ebfd != nullptr)
{
- gdb_bfd_unref (ebfd);
-
/* Removing target sections may close the exec_ops target.
Clear ebfd before doing so to prevent recursion. */
- ebfd = NULL;
+ ebfd.reset (nullptr);
ebfd_mtime = 0;
remove_target_sections (&ebfd);
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 5f952ea9b84..70b32198c20 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -279,13 +279,13 @@ struct program_space
/* Return the exec BFD for this program space. */
bfd *exec_bfd () const
{
- return ebfd;
+ return ebfd.get ();
}
/* Set the exec BFD for this program space to ABFD. */
- void set_exec_bfd (bfd *abfd)
+ void set_exec_bfd (gdb_bfd_ref_ptr &&abfd)
{
- ebfd = abfd;
+ ebfd = std::move (abfd);
}
/* Unique ID number. */
@@ -295,7 +295,7 @@ struct program_space
managed by the exec target. */
/* The BFD handle for the main executable. */
- bfd *ebfd = NULL;
+ gdb_bfd_ref_ptr ebfd;
/* The last-modified time, from when the exec was brought in. */
long ebfd_mtime = 0;
/* Similar to bfd_get_filename (exec_bfd) but in original form given
--
2.17.2
next prev parent reply other threads:[~2020-07-22 3:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 3:34 [PATCH 0/9] Remove some macros from exec.h and progspace.h Tom Tromey
2020-07-22 3:34 ` [PATCH 1/9] Remove exec_filename macro Tom Tromey
2020-07-22 3:34 ` [PATCH 2/9] Change exec_close to be a method on program_space Tom Tromey
2020-07-22 3:34 ` [PATCH 3/9] Remove commented-out code from gcore.c Tom Tromey
2020-07-22 3:34 ` [PATCH 4/9] Remove exec_bfd_mtime define Tom Tromey
2020-07-22 3:34 ` [PATCH 5/9] Remove current_target_sections macro Tom Tromey
2020-07-22 12:20 ` Simon Marchi
2020-07-22 12:39 ` Simon Marchi
2020-07-22 14:11 ` Tom Tromey
2020-07-22 3:34 ` [PATCH 6/9] Don't change current program space in exec_target::close Tom Tromey
2020-07-22 12:22 ` Simon Marchi
2020-07-22 3:34 ` [PATCH 7/9] Remove the exec_bfd macro Tom Tromey
2020-07-22 3:34 ` Tom Tromey [this message]
2020-07-22 3:34 ` [PATCH 9/9] Remove symfile_objfile macro Tom Tromey
2020-07-22 12:38 ` [PATCH 0/9] Remove some macros from exec.h and progspace.h 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=20200722033444.18522-9-tom@tromey.com \
--to=tom@tromey.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