+2019-05-08 Tom Tromey <tom@tromey.com>
+
+ * symfile.h (struct sym_probe_fns) <sym_get_probes>: Change type.
+ * symfile-debug.c (debug_sym_get_probes): Change type.
+ * stap-probe.c (handle_stap_probe):
+ (stap_static_probe_ops::get_probes): Change type.
+ * probe.h (class static_probe_ops) <get_probes>: Change type.
+ * probe.c (class any_static_probe_ops) <get_probes>: Change type.
+ (parse_probes_in_pspace): Update.
+ (find_probes_in_objfile, find_probe_by_pc, collect_probes):
+ Update.
+ (any_static_probe_ops::get_probes): Change type.
+ * elfread.c (elfread_data): New typedef.
+ (probe_key): Change type.
+ (elf_get_probes): Likewise. Update.
+ (probe_key_free): Remove.
+ (_initialize_elfread): Update.
+ * dtrace-probe.c (class dtrace_static_probe_ops) <get_probes>:
+ Change type.
+ (dtrace_process_dof_probe, dtrace_process_dof)
+ (dtrace_static_probe_ops::get_probe): Change type.
+
2019-05-08 Tom Tromey <tom@tromey.com>
* xcoffread.c (struct xcoff_symfile_info): Rename from
bool is_linespec (const char **linespecp) const override;
/* See probe.h. */
- void get_probes (std::vector<probe *> *probesp,
+ void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
struct objfile *objfile) const override;
/* See probe.h. */
static void
dtrace_process_dof_probe (struct objfile *objfile,
struct gdbarch *gdbarch,
- std::vector<probe *> *probesp,
+ std::vector<std::unique_ptr<probe>> *probesp,
struct dtrace_dof_hdr *dof,
struct dtrace_dof_probe *probe,
struct dtrace_dof_provider *provider,
std::move (enablers_copy));
/* Successfully created probe. */
- probesp->push_back (ret);
+ probesp->emplace_back (ret);
}
}
static void
dtrace_process_dof (asection *sect, struct objfile *objfile,
- std::vector<probe *> *probesp, struct dtrace_dof_hdr *dof)
+ std::vector<std::unique_ptr<probe>> *probesp,
+ struct dtrace_dof_hdr *dof)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct dtrace_dof_sect *section;
/* Implementation of the get_probes method. */
void
-dtrace_static_probe_ops::get_probes (std::vector<probe *> *probesp,
- struct objfile *objfile) const
+dtrace_static_probe_ops::get_probes
+ (std::vector<std::unique_ptr<probe>> *probesp,
+ struct objfile *objfile) const
{
bfd *abfd = objfile->obfd;
asection *sect = NULL;
asection *mdebugsect; /* Section pointer for .mdebug section */
};
+/* Type for per-BFD data. */
+
+typedef std::vector<std::unique_ptr<probe>> elfread_data;
+
/* Per-BFD data for probe info. */
-static const struct bfd_data *probe_key = NULL;
+static const struct bfd_key<elfread_data> probe_key;
/* Minimal symbols located at the GOT entries for .plt - that is the real
pointer where the given entry will jump to. It gets updated by the real
/* Implementation of `sym_get_probes', as documented in symfile.h. */
-static const std::vector<probe *> &
+static const elfread_data &
elf_get_probes (struct objfile *objfile)
{
- std::vector<probe *> *probes_per_bfd;
-
- /* Have we parsed this objfile's probes already? */
- probes_per_bfd = (std::vector<probe *> *) bfd_data (objfile->obfd, probe_key);
+ elfread_data *probes_per_bfd = probe_key.get (objfile->obfd);
if (probes_per_bfd == NULL)
{
- probes_per_bfd = new std::vector<probe *>;
+ probes_per_bfd = probe_key.emplace (objfile->obfd);
/* Here we try to gather information about all types of probes from the
objfile. */
for (const static_probe_ops *ops : all_static_probe_ops)
ops->get_probes (probes_per_bfd, objfile);
-
- set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
}
return *probes_per_bfd;
}
-/* Helper function used to free the space allocated for storing SystemTap
- probe information. */
-
-static void
-probe_key_free (bfd *abfd, void *d)
-{
- std::vector<probe *> *probes = (std::vector<probe *> *) d;
-
- for (probe *p : *probes)
- delete p;
-
- delete probes;
-}
-
\f
/* Implementation `sym_probe_fns', as documented in symfile.h. */
void
_initialize_elfread (void)
{
- probe_key = register_bfd_data_with_cleanup (NULL, probe_key_free);
add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
bool is_linespec (const char **linespecp) const override;
/* See probe.h. */
- void get_probes (std::vector<probe *> *probesp,
+ void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
struct objfile *objfile) const override;
/* See probe.h. */
objfile_namestr) != 0)
continue;
- const std::vector<probe *> &probes
+ const std::vector<std::unique_ptr<probe>> &probes
= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
- for (probe *p : probes)
+ for (auto &p : probes)
{
if (spops != &any_static_probe_ops && p->get_static_ops () != spops)
continue;
sal.explicit_pc = 1;
sal.section = find_pc_overlay (sal.pc);
sal.pspace = search_pspace;
- sal.prob = p;
+ sal.prob = p.get ();
sal.objfile = objfile;
result->push_back (std::move (sal));
if (!objfile->sf || !objfile->sf->sym_probe_fns)
return result;
- const std::vector<probe *> &probes
+ const std::vector<std::unique_ptr<probe>> &probes
= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
- for (probe *p : probes)
+ for (auto &p : probes)
{
if (p->get_provider () != provider)
continue;
if (p->get_name () != name)
continue;
- result.push_back (p);
+ result.push_back (p.get ());
}
return result;
continue;
/* If this proves too inefficient, we can replace with a hash. */
- const std::vector<probe *> &probes
+ const std::vector<std::unique_ptr<probe>> &probes
= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
- for (probe *p : probes)
+ for (auto &p : probes)
if (p->get_relocated_address (objfile) == pc)
{
result.objfile = objfile;
- result.prob = p;
+ result.prob = p.get ();
return result;
}
}
continue;
}
- const std::vector<probe *> &probes
+ const std::vector<std::unique_ptr<probe>> &probes
= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
- for (probe *p : probes)
+ for (auto &p : probes)
{
if (spops != &any_static_probe_ops && p->get_static_ops () != spops)
continue;
&& probe_pat->exec (p->get_name ().c_str (), 0, NULL, 0) != 0)
continue;
- result.emplace_back (p, objfile);
+ result.emplace_back (p.get (), objfile);
}
}
/* Implementation of 'get_probes' method. */
void
-any_static_probe_ops::get_probes (std::vector<probe *> *probesp,
+any_static_probe_ops::get_probes (std::vector<std::unique_ptr<probe>> *probesp,
struct objfile *objfile) const
{
/* No probes can be provided by this dummy backend. */
virtual bool is_linespec (const char **linespecp) const = 0;
/* Function that should fill PROBES with known probes from OBJFILE. */
- virtual void get_probes (std::vector<probe *> *probes,
+ virtual void get_probes (std::vector<std::unique_ptr<probe>> *probes,
struct objfile *objfile) const = 0;
/* Return a pointer to a name identifying the probe type. This is
bool is_linespec (const char **linespecp) const override;
/* See probe.h. */
- void get_probes (std::vector<probe *> *probesp,
+ void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
struct objfile *objfile) const override;
/* See probe.h. */
static void
handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
- std::vector<probe *> *probesp, CORE_ADDR base)
+ std::vector<std::unique_ptr<probe>> *probesp,
+ CORE_ADDR base)
{
bfd *abfd = objfile->obfd;
int size = bfd_get_arch_size (abfd) / 8;
address, gdbarch, sem_addr, probe_args);
/* Successfully created probe. */
- probesp->push_back (ret);
+ probesp->emplace_back (ret);
}
/* Helper function which tries to find the base address of the SystemTap
/* Implementation of the 'get_probes' method. */
void
-stap_static_probe_ops::get_probes (std::vector<probe *> *probesp,
- struct objfile *objfile) const
+stap_static_probe_ops::get_probes
+ (std::vector<std::unique_ptr<probe>> *probesp,
+ struct objfile *objfile) const
{
/* If we are here, then this is the first time we are parsing the
SystemTap probe's information. We basically have to count how many
\f
/* Debugging version of struct sym_probe_fns. */
-static const std::vector<probe *> &
+static const std::vector<std::unique_ptr<probe>> &
debug_sym_get_probes (struct objfile *objfile)
{
const struct debug_sym_fns_data *debug_data
= symfile_debug_objfile_data_key.get (objfile);
- const std::vector<probe *> &retval
+ const std::vector<std::unique_ptr<probe>> &retval
= debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
fprintf_filtered (gdb_stdlog,
struct sym_probe_fns
{
/* If non-NULL, return a reference to vector of probe objects. */
- const std::vector<probe *> &(*sym_get_probes) (struct objfile *);
+ const std::vector<std::unique_ptr<probe>> &(*sym_get_probes)
+ (struct objfile *);
};
/* Structure to keep track of symbol reading functions for various