• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisiónaaa63a31909946c4f68da64a93662147d67630bd (tree)
Tiempo2017-09-12 20:37:00
AutorSimon Marchi <simon.marchi@eric...>
CommiterSimon Marchi

Log Message

Make probe_ops::get_probes fill an std::vector

This patch changes one usage of VEC to std::vector. It is a relatively
straightforward 1:1 change. The implementations of
sym_probe_fns::sym_get_probes return a borrowed reference to their probe
vectors, meaning that the caller should not free it. In the new code, I
made them return a const reference to the vector.

This patch and the following one were tested by the buildbot. I didn't
see any failures that looked related to this one.

gdb/ChangeLog:

* probe.h (struct probe_ops) <get_probes>: Change parameter from
vec to std::vector.
* probe.c (parse_probes_in_pspace): Update.
(find_probes_in_objfile): Update.
(find_probe_by_pc): Update.
(collect_probes): Update.
(probe_any_get_probes): Update.
* symfile.h (struct sym_probe_fns) <sym_get_probes> Change
return type to reference to std::vector.
* dtrace-probe.c (dtrace_process_dof_probe): Change parameter to
std::vector and update.
(dtrace_process_dof): Likewise.
(dtrace_get_probes): Likewise.
* elfread.c (elf_get_probes): Change return type to std::vector,
store an std::vector in bfd_data.
(probe_key_free): Update to std::vector.
* stap-probe.c (handle_stap_probe): Change parameter to
std::vector and update.
(stap_get_probes): Likewise.
* symfile-debug.c (debug_sym_get_probes): Change return type to
std::vector and update.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,27 @@
1+2017-09-12 Simon Marchi <simon.marchi@ericsson.com>
2+
3+ * probe.h (struct probe_ops) <get_probes>: Change parameter from
4+ vec to std::vector.
5+ * probe.c (parse_probes_in_pspace): Update.
6+ (find_probes_in_objfile): Update.
7+ (find_probe_by_pc): Update.
8+ (collect_probes): Update.
9+ (probe_any_get_probes): Update.
10+ * symfile.h (struct sym_probe_fns) <sym_get_probes> Change
11+ return type to reference to std::vector.
12+ * dtrace-probe.c (dtrace_process_dof_probe): Change parameter to
13+ std::vector and update.
14+ (dtrace_process_dof): Likewise.
15+ (dtrace_get_probes): Likewise.
16+ * elfread.c (elf_get_probes): Change return type to std::vector,
17+ store an std::vector in bfd_data.
18+ (probe_key_free): Update to std::vector.
19+ * stap-probe.c (handle_stap_probe): Change parameter to
20+ std::vector and update.
21+ (stap_get_probes): Likewise.
22+ * symfile-debug.c (debug_sym_get_probes): Change return type to
23+ std::vector and update.
24+
125 2017-09-11 Tom Tromey <tom@tromey.com>
226
327 * breakpoint.c (program_breakpoint_here_p): Update.
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -313,7 +313,8 @@ struct dtrace_dof_probe
313313
314314 static void
315315 dtrace_process_dof_probe (struct objfile *objfile,
316- struct gdbarch *gdbarch, VEC (probe_p) **probesp,
316+ struct gdbarch *gdbarch,
317+ std::vector<probe *> *probesp,
317318 struct dtrace_dof_hdr *dof,
318319 struct dtrace_dof_probe *probe,
319320 struct dtrace_dof_provider *provider,
@@ -448,7 +449,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
448449 ret->enablers = VEC_copy (dtrace_probe_enabler_s, enablers);
449450
450451 /* Successfully created probe. */
451- VEC_safe_push (probe_p, *probesp, (struct probe *) ret);
452+ probesp->push_back ((struct probe *) ret);
452453 }
453454
454455 do_cleanups (cleanup);
@@ -461,7 +462,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
461462
462463 static void
463464 dtrace_process_dof (asection *sect, struct objfile *objfile,
464- VEC (probe_p) **probesp, struct dtrace_dof_hdr *dof)
465+ std::vector<probe *> *probesp, struct dtrace_dof_hdr *dof)
465466 {
466467 struct gdbarch *gdbarch = get_objfile_arch (objfile);
467468 struct dtrace_dof_sect *section;
@@ -620,7 +621,7 @@ dtrace_get_arg (struct dtrace_probe *probe, unsigned n,
620621 /* Implementation of the get_probes method. */
621622
622623 static void
623-dtrace_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
624+dtrace_get_probes (std::vector<probe *> *probesp, struct objfile *objfile)
624625 {
625626 bfd *abfd = objfile->obfd;
626627 asection *sect = NULL;
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1309,35 +1309,30 @@ elf_symfile_init (struct objfile *objfile)
13091309
13101310 /* Implementation of `sym_get_probes', as documented in symfile.h. */
13111311
1312-static VEC (probe_p) *
1312+static const std::vector<probe *> &
13131313 elf_get_probes (struct objfile *objfile)
13141314 {
1315- VEC (probe_p) *probes_per_bfd;
1315+ std::vector<probe *> *probes_per_bfd;
13161316
13171317 /* Have we parsed this objfile's probes already? */
1318- probes_per_bfd = (VEC (probe_p) *) bfd_data (objfile->obfd, probe_key);
1318+ probes_per_bfd = (std::vector<probe *> *) bfd_data (objfile->obfd, probe_key);
13191319
1320- if (!probes_per_bfd)
1320+ if (probes_per_bfd == NULL)
13211321 {
13221322 int ix;
13231323 const struct probe_ops *probe_ops;
1324+ probes_per_bfd = new std::vector<probe *>;
13241325
13251326 /* Here we try to gather information about all types of probes from the
13261327 objfile. */
13271328 for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops);
13281329 ix++)
1329- probe_ops->get_probes (&probes_per_bfd, objfile);
1330-
1331- if (probes_per_bfd == NULL)
1332- {
1333- VEC_reserve (probe_p, probes_per_bfd, 1);
1334- gdb_assert (probes_per_bfd != NULL);
1335- }
1330+ probe_ops->get_probes (probes_per_bfd, objfile);
13361331
13371332 set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
13381333 }
13391334
1340- return probes_per_bfd;
1335+ return *probes_per_bfd;
13411336 }
13421337
13431338 /* Helper function used to free the space allocated for storing SystemTap
@@ -1346,14 +1341,12 @@ elf_get_probes (struct objfile *objfile)
13461341 static void
13471342 probe_key_free (bfd *abfd, void *d)
13481343 {
1349- int ix;
1350- VEC (probe_p) *probes = (VEC (probe_p) *) d;
1351- struct probe *probe;
1344+ std::vector<probe *> *probes = (std::vector<probe *> *) d;
13521345
1353- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
1346+ for (struct probe *probe : *probes)
13541347 probe->pops->destroy (probe);
13551348
1356- VEC_free (probe_p, probes);
1349+ delete probes;
13571350 }
13581351
13591352
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -58,10 +58,6 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
5858
5959 ALL_PSPACE_OBJFILES (search_pspace, objfile)
6060 {
61- VEC (probe_p) *probes;
62- struct probe *probe;
63- int ix;
64-
6561 if (!objfile->sf || !objfile->sf->sym_probe_fns)
6662 continue;
6763
@@ -71,9 +67,10 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
7167 objfile_namestr) != 0)
7268 continue;
7369
74- probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
70+ const std::vector<probe *> &probes
71+ = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
7572
76- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
73+ for (struct probe *probe : probes)
7774 {
7875 if (probe_ops != &probe_ops_any && probe->pops != probe_ops)
7976 continue;
@@ -211,15 +208,14 @@ VEC (probe_p) *
211208 find_probes_in_objfile (struct objfile *objfile, const char *provider,
212209 const char *name)
213210 {
214- VEC (probe_p) *probes, *result = NULL;
215- int ix;
216- struct probe *probe;
211+ VEC (probe_p) *result = NULL;
217212
218213 if (!objfile->sf || !objfile->sf->sym_probe_fns)
219214 return NULL;
220215
221- probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
222- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
216+ const std::vector<probe *> &probes
217+ = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
218+ for (struct probe *probe : probes)
223219 {
224220 if (strcmp (probe->provider, provider) != 0)
225221 continue;
@@ -246,17 +242,14 @@ find_probe_by_pc (CORE_ADDR pc)
246242
247243 ALL_OBJFILES (objfile)
248244 {
249- VEC (probe_p) *probes;
250- int ix;
251- struct probe *probe;
252-
253245 if (!objfile->sf || !objfile->sf->sym_probe_fns
254246 || objfile->sect_index_text == -1)
255247 continue;
256248
257249 /* If this proves too inefficient, we can replace with a hash. */
258- probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
259- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
250+ const std::vector<probe *> &probes
251+ = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
252+ for (struct probe *probe : probes)
260253 if (get_probe_address (probe, objfile) == pc)
261254 {
262255 result.objfile = objfile;
@@ -297,10 +290,6 @@ collect_probes (const std::string &objname, const std::string &provider,
297290
298291 ALL_OBJFILES (objfile)
299292 {
300- VEC (probe_p) *probes;
301- struct probe *probe;
302- int ix;
303-
304293 if (! objfile->sf || ! objfile->sf->sym_probe_fns)
305294 continue;
306295
@@ -310,9 +299,10 @@ collect_probes (const std::string &objname, const std::string &provider,
310299 continue;
311300 }
312301
313- probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
302+ const std::vector<probe *> &probes
303+ = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
314304
315- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
305+ for (struct probe *probe : probes)
316306 {
317307 struct bound_probe bound;
318308
@@ -901,7 +891,7 @@ probe_any_is_linespec (const char **linespecp)
901891 /* Dummy method used for `probe_ops_any'. */
902892
903893 static void
904-probe_any_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
894+probe_any_get_probes (std::vector<probe *> *probesp, struct objfile *objfile)
905895 {
906896 /* No probes can be provided by this dummy backend. */
907897 }
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -64,7 +64,7 @@ struct probe_ops
6464
6565 /* Function that should fill PROBES with known probes from OBJFILE. */
6666
67- void (*get_probes) (VEC (probe_p) **probes, struct objfile *objfile);
67+ void (*get_probes) (std::vector<probe *> *probes, struct objfile *objfile);
6868
6969 /* Compute the probe's relocated address. OBJFILE is the objfile
7070 in which the probe originated. */
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1472,7 +1472,7 @@ stap_clear_semaphore (struct probe *probe_generic, struct objfile *objfile,
14721472
14731473 static void
14741474 handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
1475- VEC (probe_p) **probesp, CORE_ADDR base)
1475+ std::vector<probe *> *probesp, CORE_ADDR base)
14761476 {
14771477 bfd *abfd = objfile->obfd;
14781478 int size = bfd_get_arch_size (abfd) / 8;
@@ -1543,7 +1543,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
15431543 ret->args_u.text = probe_args;
15441544
15451545 /* Successfully created probe. */
1546- VEC_safe_push (probe_p, *probesp, (struct probe *) ret);
1546+ probesp->push_back ((struct probe *) ret);
15471547 }
15481548
15491549 /* Helper function which tries to find the base address of the SystemTap
@@ -1588,7 +1588,7 @@ get_stap_base_address (bfd *obfd, bfd_vma *base)
15881588 SystemTap probes from OBJFILE. */
15891589
15901590 static void
1591-stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
1591+stap_get_probes (std::vector<probe *> *probesp, struct objfile *objfile)
15921592 {
15931593 /* If we are here, then this is the first time we are parsing the
15941594 SystemTap probe's information. We basically have to count how many
@@ -1597,7 +1597,7 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
15971597 bfd *obfd = objfile->obfd;
15981598 bfd_vma base;
15991599 struct sdt_note *iter;
1600- unsigned save_probesp_len = VEC_length (probe_p, *probesp);
1600+ unsigned save_probesp_len = probesp->size ();
16011601
16021602 if (objfile->separate_debug_objfile_backlink != NULL)
16031603 {
@@ -1628,7 +1628,7 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
16281628 handle_stap_probe (objfile, iter, probesp, base);
16291629 }
16301630
1631- if (save_probesp_len == VEC_length (probe_p, *probesp))
1631+ if (save_probesp_len == probesp->size ())
16321632 {
16331633 /* If we are here, it means we have failed to parse every known
16341634 probe. */
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -384,20 +384,20 @@ static const struct quick_symbol_functions debug_sym_quick_functions =
384384
385385 /* Debugging version of struct sym_probe_fns. */
386386
387-static VEC (probe_p) *
387+static const std::vector<probe *> &
388388 debug_sym_get_probes (struct objfile *objfile)
389389 {
390390 const struct debug_sym_fns_data *debug_data
391391 = ((const struct debug_sym_fns_data *)
392392 objfile_data (objfile, symfile_debug_objfile_data_key));
393- VEC (probe_p) *retval;
394393
395- retval = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
394+ const std::vector<probe *> &retval
395+ = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
396396
397397 fprintf_filtered (gdb_stdlog,
398398 "probes->sym_get_probes (%s) = %s\n",
399399 objfile_debug_name (objfile),
400- host_address_to_string (retval));
400+ host_address_to_string (retval.data ()));
401401
402402 return retval;
403403 }
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -314,11 +314,8 @@ struct quick_symbol_functions
314314
315315 struct sym_probe_fns
316316 {
317- /* If non-NULL, return an array of probe objects.
318-
319- The returned value does not have to be freed and it has lifetime of the
320- OBJFILE. */
321- VEC (probe_p) *(*sym_get_probes) (struct objfile *);
317+ /* If non-NULL, return a reference to vector of probe objects. */
318+ const std::vector<probe *> &(*sym_get_probes) (struct objfile *);
322319 };
323320
324321 /* Structure to keep track of symbol reading functions for various