aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-02-22 09:47:37 -0700
committerTom Tromey <tromey@adacore.com>2021-02-22 09:47:37 -0700
commit15908a11ba92bcc30a92b70ee75e2576d915e0c1 (patch)
treed1c0d3641e03d26ae3c013956833bac05a2fc851 /gdb
parentf53fc42716c042e560a824244fecab215ba036d1 (diff)
downloadgdb-15908a11ba92bcc30a92b70ee75e2576d915e0c1.zip
gdb-15908a11ba92bcc30a92b70ee75e2576d915e0c1.tar.gz
gdb-15908a11ba92bcc30a92b70ee75e2576d915e0c1.tar.bz2
Change target_bfd_reopen to take a gdb_bfd_ref_ptr
While looking at Andrew's recent target sections series, I saw that target_bfd_reopen took a "bfd *", leading to a call to new_reference. However, because the only caller of target_bfd_reopen is already using gdb_bfd_ref_ptr, this code can be simplified and the explicit call to new_reference can be removed. gdb/ChangeLog 2021-02-22 Tom Tromey <tromey@adacore.com> * solib-svr4.c (enable_break): Update. * bfd-target.c (class target_bfd) <target_bfd>: Change parameter type. (target_bfd_reopen): Change parameter type. * bfd-target.h (target_bfd_reopen): Change parameter type.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/bfd-target.c10
-rw-r--r--gdb/bfd-target.h9
-rw-r--r--gdb/solib-svr4.c5
4 files changed, 19 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9de0e23..00ac68a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2021-02-22 Tom Tromey <tromey@adacore.com>
+
+ * solib-svr4.c (enable_break): Update.
+ * bfd-target.c (class target_bfd) <target_bfd>: Change parameter
+ type.
+ (target_bfd_reopen): Change parameter type.
+ * bfd-target.h (target_bfd_reopen): Change parameter type.
+
2021-02-22 Simon Marchi <simon.marchi@polymtl.ca>
* thread.c (add_thread_silent): Add assert.
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index 90d247a..689dbb1 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -34,7 +34,7 @@ static const target_info target_bfd_target_info = {
class target_bfd : public target_ops
{
public:
- explicit target_bfd (struct bfd *bfd);
+ explicit target_bfd (const gdb_bfd_ref_ptr &bfd);
const target_info &info () const override
{ return target_bfd_target_info; }
@@ -88,14 +88,14 @@ target_bfd::get_section_table ()
return &m_table;
}
-target_bfd::target_bfd (struct bfd *abfd)
- : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd)),
- m_table (build_section_table (abfd))
+target_bfd::target_bfd (const gdb_bfd_ref_ptr &abfd)
+ : m_bfd (abfd),
+ m_table (build_section_table (abfd.get ()))
{
}
target_ops *
-target_bfd_reopen (struct bfd *abfd)
+target_bfd_reopen (const gdb_bfd_ref_ptr &abfd)
{
return new target_bfd (abfd);
}
diff --git a/gdb/bfd-target.h b/gdb/bfd-target.h
index 199ada8..3d37b5f 100644
--- a/gdb/bfd-target.h
+++ b/gdb/bfd-target.h
@@ -20,12 +20,11 @@
#ifndef BFD_TARGET_H
#define BFD_TARGET_H
-struct bfd;
+#include "gdb_bfd.h"
+
struct target_ops;
-/* Given an existing BFD, re-open it as a "struct target_ops". This
- acquires a new reference to the BFD. This reference will be
- released when the target is closed. */
-struct target_ops *target_bfd_reopen (struct bfd *bfd);
+/* Given an existing BFD, re-open it as a "struct target_ops". */
+struct target_ops *target_bfd_reopen (const gdb_bfd_ref_ptr &bfd);
#endif
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 0416faa..5d0d380 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2333,9 +2333,8 @@ enable_break (struct svr4_info *info, int from_tty)
goto bkpt_at_symbol;
/* Now convert the TMP_BFD into a target. That way target, as
- well as BFD operations can be used. target_bfd_reopen
- acquires its own reference. */
- tmp_bfd_target = target_bfd_reopen (tmp_bfd.get ());
+ well as BFD operations can be used. */
+ tmp_bfd_target = target_bfd_reopen (tmp_bfd);
/* On a running target, we can get the dynamic linker's base
address from the shared library table. */