diff options
author | Tom Tromey <tom@tromey.com> | 2019-04-30 23:47:54 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-05-08 16:01:51 -0600 |
commit | 814cf43a1f16157fcbe2c662f567d064393a0fcb (patch) | |
tree | 66d0d0c948fdf020cd7a31849db9edc26ea138ac /gdb/dtrace-probe.c | |
parent | 02dc647ed65b1429b9af4986ed467f90fbe0c33b (diff) | |
download | gdb-814cf43a1f16157fcbe2c662f567d064393a0fcb.zip gdb-814cf43a1f16157fcbe2c662f567d064393a0fcb.tar.gz gdb-814cf43a1f16157fcbe2c662f567d064393a0fcb.tar.bz2 |
Convert probes to type-safe registry API
This changes the probes code in elfread.c to use the type-safe
registry API. While doing this, I saw that the caller of get_probes
owns the probes, so I went through the code and changed the vectors to
store unique_ptrs, making the ownership relationship more clear.
gdb/ChangeLog
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.
Diffstat (limited to 'gdb/dtrace-probe.c')
-rw-r--r-- | gdb/dtrace-probe.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index a51f358..5297378 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -81,7 +81,7 @@ public: 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. */ @@ -380,7 +380,7 @@ struct dtrace_dof_probe 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, @@ -507,7 +507,7 @@ dtrace_process_dof_probe (struct objfile *objfile, std::move (enablers_copy)); /* Successfully created probe. */ - probesp->push_back (ret); + probesp->emplace_back (ret); } } @@ -518,7 +518,8 @@ dtrace_process_dof_probe (struct objfile *objfile, 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; @@ -833,8 +834,9 @@ dtrace_static_probe_ops::is_linespec (const char **linespecp) const /* 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; |