• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
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

修订版0782db848b52ecaf29e13d9f12a2c7cfabec2bdb (tree)
时间2017-09-12 21:15:23
作者Simon Marchi <simon.marchi@eric...>
CommiterSimon Marchi

Log Message

probe: Replace VEC(probe_ops_cp) with std::vector

This patch replaces the usage of VEC to store pointers to probe_ops with
an std::vector. The sole usage of that vector type is one global
variable that holds the ops for the various kinds of probes, so this is
pretty straightforward (no allocation/deallocation issues).

gdb/ChangeLog:

* probe.h (probe_ops_cp): Remove typedef.
(DEF_VEC_P (probe_ops_cp)): Remove.
(all_probe_ops): Change type to std::vector.
* probe.c (info_probes_for_ops): Adjust to vector change.
(probe_linespec_to_ops): Likewise.
(all_probe_ops): Change type to std::vector.
(_initialize_probe): Adjust to vector change.
* dtrace-probe.c (_initialize_dtrace_probe): Likewise.
* elfread.c (elf_get_probes): Likewise.
* stap-probe.c (_initialize_stap_probe): Likewise.

更改概述

差异

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
11 2017-09-12 Simon Marchi <simon.marchi@ericsson.com>
22
3+ * probe.h (probe_ops_cp): Remove typedef.
4+ (DEF_VEC_P (probe_ops_cp)): Remove.
5+ (all_probe_ops): Change type to std::vector.
6+ * probe.c (info_probes_for_ops): Adjust to vector change.
7+ (probe_linespec_to_ops): Likewise.
8+ (all_probe_ops): Change type to std::vector.
9+ (_initialize_probe): Adjust to vector change.
10+ * dtrace-probe.c (_initialize_dtrace_probe): Likewise.
11+ * elfread.c (elf_get_probes): Likewise.
12+ * stap-probe.c (_initialize_stap_probe): Likewise.
13+
14+2017-09-12 Simon Marchi <simon.marchi@ericsson.com>
15+
316 * probe.h (struct bound_probe): Define constructors.
417 * probe.c (bound_probe_s): Remove typedef.
518 (DEF_VEC_O (bound_probe_s)): Remove VEC.
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -912,7 +912,7 @@ info_probes_dtrace_command (char *arg, int from_tty)
912912 void
913913 _initialize_dtrace_probe (void)
914914 {
915- VEC_safe_push (probe_ops_cp, all_probe_ops, &dtrace_probe_ops);
915+ all_probe_ops.push_back (&dtrace_probe_ops);
916916
917917 add_cmd ("dtrace", class_info, info_probes_dtrace_command,
918918 _("\
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1319,15 +1319,12 @@ elf_get_probes (struct objfile *objfile)
13191319
13201320 if (probes_per_bfd == NULL)
13211321 {
1322- int ix;
1323- const struct probe_ops *probe_ops;
13241322 probes_per_bfd = new std::vector<probe *>;
13251323
13261324 /* Here we try to gather information about all types of probes from the
13271325 objfile. */
1328- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops);
1329- ix++)
1330- probe_ops->get_probes (probes_per_bfd, objfile);
1326+ for (const probe_ops *ops : all_probe_ops)
1327+ ops->get_probes (probes_per_bfd, objfile);
13311328
13321329 set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
13331330 }
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -565,9 +565,6 @@ info_probes_for_ops (const char *arg, int from_tty,
565565
566566 if (pops == NULL)
567567 {
568- const struct probe_ops *po;
569- int ix;
570-
571568 /* If the probe_ops is NULL, it means the user has requested a "simple"
572569 `info probes', i.e., she wants to print all information about all
573570 probes. For that, we have to identify how many extra fields we will
@@ -578,7 +575,7 @@ info_probes_for_ops (const char *arg, int from_tty,
578575 that number. But note that we ignore the probe_ops for which no probes
579576 are defined with the given search criteria. */
580577
581- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
578+ for (const probe_ops *po : all_probe_ops)
582579 if (exists_probe_with_pops (probes, po))
583580 ui_out_extra_fields += get_number_extra_fields (po);
584581 }
@@ -616,13 +613,10 @@ info_probes_for_ops (const char *arg, int from_tty,
616613
617614 if (pops == NULL)
618615 {
619- const struct probe_ops *po;
620- int ix;
621-
622616 /* We have to generate the table header for each new probe type
623617 that we will print. Note that this excludes probe types not
624618 having any defined probe with the search criteria. */
625- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
619+ for (const probe_ops *po : all_probe_ops)
626620 if (exists_probe_with_pops (probes, po))
627621 gen_ui_out_table_header_info (probes, po);
628622 }
@@ -647,11 +641,7 @@ info_probes_for_ops (const char *arg, int from_tty,
647641
648642 if (pops == NULL)
649643 {
650- const struct probe_ops *po;
651- int ix;
652-
653- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po);
654- ++ix)
644+ for (const probe_ops *po : all_probe_ops)
655645 if (probe.probe->pops == po)
656646 print_ui_out_info (probe.probe);
657647 else if (exists_probe_with_pops (probes, po))
@@ -816,12 +806,9 @@ probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
816806 const struct probe_ops *
817807 probe_linespec_to_ops (const char **linespecp)
818808 {
819- int ix;
820- const struct probe_ops *probe_ops;
821-
822- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops); ix++)
823- if (probe_ops->is_linespec (linespecp))
824- return probe_ops;
809+ for (const probe_ops *ops : all_probe_ops)
810+ if (ops->is_linespec (linespecp))
811+ return ops;
825812
826813 return NULL;
827814 }
@@ -980,12 +967,12 @@ static const struct internalvar_funcs probe_funcs =
980967 };
981968
982969
983-VEC (probe_ops_cp) *all_probe_ops;
970+std::vector<const probe_ops *> all_probe_ops;
984971
985972 void
986973 _initialize_probe (void)
987974 {
988- VEC_safe_push (probe_ops_cp, all_probe_ops, &probe_ops_any);
975+ all_probe_ops.push_back (&probe_ops_any);
989976
990977 create_internalvar_type_lazy ("_probe_argc", &probe_funcs,
991978 (void *) (uintptr_t) -1);
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -160,9 +160,7 @@ struct probe_ops
160160
161161 /* Definition of a vector of probe_ops. */
162162
163-typedef const struct probe_ops *probe_ops_cp;
164-DEF_VEC_P (probe_ops_cp);
165-extern VEC (probe_ops_cp) *all_probe_ops;
163+extern std::vector<const probe_ops *> all_probe_ops;
166164
167165 /* The probe_ops associated with the generic probe. */
168166
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1716,7 +1716,7 @@ info_probes_stap_command (char *arg, int from_tty)
17161716 void
17171717 _initialize_stap_probe (void)
17181718 {
1719- VEC_safe_push (probe_ops_cp, all_probe_ops, &stap_probe_ops);
1719+ all_probe_ops.push_back (&stap_probe_ops);
17201720
17211721 add_setshow_zuinteger_cmd ("stap-expression", class_maintenance,
17221722 &stap_expression_debug,