GNU Binutils with patches for OS216
修订版 | 0782db848b52ecaf29e13d9f12a2c7cfabec2bdb (tree) |
---|---|
时间 | 2017-09-12 21:15:23 |
作者 | Simon Marchi <simon.marchi@eric...> |
Commiter | Simon Marchi |
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.
@@ -1,5 +1,18 @@ | ||
1 | 1 | 2017-09-12 Simon Marchi <simon.marchi@ericsson.com> |
2 | 2 | |
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 | + | |
3 | 16 | * probe.h (struct bound_probe): Define constructors. |
4 | 17 | * probe.c (bound_probe_s): Remove typedef. |
5 | 18 | (DEF_VEC_O (bound_probe_s)): Remove VEC. |
@@ -912,7 +912,7 @@ info_probes_dtrace_command (char *arg, int from_tty) | ||
912 | 912 | void |
913 | 913 | _initialize_dtrace_probe (void) |
914 | 914 | { |
915 | - VEC_safe_push (probe_ops_cp, all_probe_ops, &dtrace_probe_ops); | |
915 | + all_probe_ops.push_back (&dtrace_probe_ops); | |
916 | 916 | |
917 | 917 | add_cmd ("dtrace", class_info, info_probes_dtrace_command, |
918 | 918 | _("\ |
@@ -1319,15 +1319,12 @@ elf_get_probes (struct objfile *objfile) | ||
1319 | 1319 | |
1320 | 1320 | if (probes_per_bfd == NULL) |
1321 | 1321 | { |
1322 | - int ix; | |
1323 | - const struct probe_ops *probe_ops; | |
1324 | 1322 | probes_per_bfd = new std::vector<probe *>; |
1325 | 1323 | |
1326 | 1324 | /* Here we try to gather information about all types of probes from the |
1327 | 1325 | 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); | |
1331 | 1328 | |
1332 | 1329 | set_bfd_data (objfile->obfd, probe_key, probes_per_bfd); |
1333 | 1330 | } |
@@ -565,9 +565,6 @@ info_probes_for_ops (const char *arg, int from_tty, | ||
565 | 565 | |
566 | 566 | if (pops == NULL) |
567 | 567 | { |
568 | - const struct probe_ops *po; | |
569 | - int ix; | |
570 | - | |
571 | 568 | /* If the probe_ops is NULL, it means the user has requested a "simple" |
572 | 569 | `info probes', i.e., she wants to print all information about all |
573 | 570 | 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, | ||
578 | 575 | that number. But note that we ignore the probe_ops for which no probes |
579 | 576 | are defined with the given search criteria. */ |
580 | 577 | |
581 | - for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix) | |
578 | + for (const probe_ops *po : all_probe_ops) | |
582 | 579 | if (exists_probe_with_pops (probes, po)) |
583 | 580 | ui_out_extra_fields += get_number_extra_fields (po); |
584 | 581 | } |
@@ -616,13 +613,10 @@ info_probes_for_ops (const char *arg, int from_tty, | ||
616 | 613 | |
617 | 614 | if (pops == NULL) |
618 | 615 | { |
619 | - const struct probe_ops *po; | |
620 | - int ix; | |
621 | - | |
622 | 616 | /* We have to generate the table header for each new probe type |
623 | 617 | that we will print. Note that this excludes probe types not |
624 | 618 | 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) | |
626 | 620 | if (exists_probe_with_pops (probes, po)) |
627 | 621 | gen_ui_out_table_header_info (probes, po); |
628 | 622 | } |
@@ -647,11 +641,7 @@ info_probes_for_ops (const char *arg, int from_tty, | ||
647 | 641 | |
648 | 642 | if (pops == NULL) |
649 | 643 | { |
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) | |
655 | 645 | if (probe.probe->pops == po) |
656 | 646 | print_ui_out_info (probe.probe); |
657 | 647 | else if (exists_probe_with_pops (probes, po)) |
@@ -816,12 +806,9 @@ probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n) | ||
816 | 806 | const struct probe_ops * |
817 | 807 | probe_linespec_to_ops (const char **linespecp) |
818 | 808 | { |
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; | |
825 | 812 | |
826 | 813 | return NULL; |
827 | 814 | } |
@@ -980,12 +967,12 @@ static const struct internalvar_funcs probe_funcs = | ||
980 | 967 | }; |
981 | 968 | |
982 | 969 | |
983 | -VEC (probe_ops_cp) *all_probe_ops; | |
970 | +std::vector<const probe_ops *> all_probe_ops; | |
984 | 971 | |
985 | 972 | void |
986 | 973 | _initialize_probe (void) |
987 | 974 | { |
988 | - VEC_safe_push (probe_ops_cp, all_probe_ops, &probe_ops_any); | |
975 | + all_probe_ops.push_back (&probe_ops_any); | |
989 | 976 | |
990 | 977 | create_internalvar_type_lazy ("_probe_argc", &probe_funcs, |
991 | 978 | (void *) (uintptr_t) -1); |
@@ -160,9 +160,7 @@ struct probe_ops | ||
160 | 160 | |
161 | 161 | /* Definition of a vector of probe_ops. */ |
162 | 162 | |
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; | |
166 | 164 | |
167 | 165 | /* The probe_ops associated with the generic probe. */ |
168 | 166 |
@@ -1716,7 +1716,7 @@ info_probes_stap_command (char *arg, int from_tty) | ||
1716 | 1716 | void |
1717 | 1717 | _initialize_stap_probe (void) |
1718 | 1718 | { |
1719 | - VEC_safe_push (probe_ops_cp, all_probe_ops, &stap_probe_ops); | |
1719 | + all_probe_ops.push_back (&stap_probe_ops); | |
1720 | 1720 | |
1721 | 1721 | add_setshow_zuinteger_cmd ("stap-expression", class_maintenance, |
1722 | 1722 | &stap_expression_debug, |