Get rid of VEC(probe_p)
authorSimon Marchi <simon.marchi@ericsson.com>
Sat, 28 Oct 2017 02:05:42 +0000 (22:05 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Sat, 28 Oct 2017 02:12:01 +0000 (22:12 -0400)
Replace the remaining usages of VEC(probe_p) with std::vector.

Regtested on the buildbot.

gdb/ChangeLog:

* probe.h: Don't include gdb_vecs.h.
(DEF_VEC_P (probe_p)): Remove.
(find_probes_in_objfile): Return an std::vector.
* probe.c (find_probes_in_objfile): Likewise.
* breakpoint.c (breakpoint_objfile_data)
<longjmp_probes>: Change type to std::vector.
<exception_probes>: Likewise.
(free_breakpoint_probes): Don't manually free vectors.
(create_longjmp_master_breakpoint): Adjust.
(create_exception_master_breakpoint): Adjust.
* solib-svr4.c (svr4_create_probe_breakpoints): Change
parameter type, adjust.
(svr4_create_solib_event_breakpoints): Adjust.

gdb/ChangeLog
gdb/breakpoint.c
gdb/probe.c
gdb/probe.h
gdb/solib-svr4.c

index 9b912144d30b1c5024c94c272dd20a59f1edf8ee..9c4e409ef71b49551a36b5460777dbaa631d81a5 100644 (file)
@@ -1,3 +1,19 @@
+2017-10-27  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * probe.h: Don't include gdb_vecs.h.
+       (DEF_VEC_P (probe_p)): Remove.
+       (find_probes_in_objfile): Return an std::vector.
+       * probe.c (find_probes_in_objfile): Likewise.
+       * breakpoint.c (breakpoint_objfile_data)
+       <longjmp_probes>: Change type to std::vector.
+       <exception_probes>: Likewise.
+       (free_breakpoint_probes): Don't manually free vectors.
+       (create_longjmp_master_breakpoint): Adjust.
+       (create_exception_master_breakpoint): Adjust.
+       * solib-svr4.c (svr4_create_probe_breakpoints): Change
+       parameter type, adjust.
+       (svr4_create_solib_event_breakpoints): Adjust.
+
 2017-10-27  Simon Marchi  <simon.marchi@ericsson.com>
 
        * breakpoint.c (breakpoint_objfile_data): Initialize fields.
index 3601e7dec54dbc03c6603c4a3e089ca8c8bee573..aadd6cada25abc08c07920f9e67053df22c20231 100644 (file)
@@ -3191,8 +3191,9 @@ struct breakpoint_objfile_data
   /* True if we have looked for longjmp probes.  */
   int longjmp_searched = 0;
 
-  /* SystemTap probe points for longjmp (if any).  */
-  VEC (probe_p) *longjmp_probes = NULL;
+  /* SystemTap probe points for longjmp (if any).  These are non-owning
+     references.  */
+  std::vector<probe *> longjmp_probes;
 
   /* Minimal symbol for "std::terminate()" (if any).  */
   struct bound_minimal_symbol terminate_msym {};
@@ -3203,8 +3204,9 @@ struct breakpoint_objfile_data
   /* True if we have looked for exception probes.  */
   int exception_searched = 0;
 
-  /* SystemTap probe points for unwinding (if any).  */
-  VEC (probe_p) *exception_probes = NULL;
+  /* SystemTap probe points for unwinding (if any).  These are non-owning
+     references.  */
+  std::vector<probe *> exception_probes;
 };
 
 static const struct objfile_data *breakpoint_objfile_key;
@@ -3244,9 +3246,6 @@ free_breakpoint_objfile_data (struct objfile *obj, void *data)
   struct breakpoint_objfile_data *bp_objfile_data
     = (struct breakpoint_objfile_data *) data;
 
-  VEC_free (probe_p, bp_objfile_data->longjmp_probes);
-  VEC_free (probe_p, bp_objfile_data->exception_probes);
-
   delete bp_objfile_data;
 }
 
@@ -3328,43 +3327,35 @@ create_longjmp_master_breakpoint (void)
 
       if (!bp_objfile_data->longjmp_searched)
        {
-         VEC (probe_p) *ret;
+         std::vector<probe *> ret
+           = find_probes_in_objfile (objfile, "libc", "longjmp");
 
-         ret = find_probes_in_objfile (objfile, "libc", "longjmp");
-         if (ret != NULL)
+         if (!ret.empty ())
            {
              /* We are only interested in checking one element.  */
-             struct probe *p = VEC_index (probe_p, ret, 0);
+             probe *p = ret[0];
 
              if (!can_evaluate_probe_arguments (p))
                {
                  /* We cannot use the probe interface here, because it does
                     not know how to evaluate arguments.  */
-                 VEC_free (probe_p, ret);
-                 ret = NULL;
+                 ret.clear ();
                }
            }
          bp_objfile_data->longjmp_probes = ret;
          bp_objfile_data->longjmp_searched = 1;
        }
 
-      if (bp_objfile_data->longjmp_probes != NULL)
+      if (!bp_objfile_data->longjmp_probes.empty ())
        {
-         int i;
-         struct probe *probe;
          struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
-         for (i = 0;
-              VEC_iterate (probe_p,
-                           bp_objfile_data->longjmp_probes,
-                           i, probe);
-              ++i)
+         for (probe *p : bp_objfile_data->longjmp_probes)
            {
              struct breakpoint *b;
 
              b = create_internal_breakpoint (gdbarch,
-                                             get_probe_address (probe,
-                                                                objfile),
+                                             get_probe_address (p, objfile),
                                              bp_longjmp_master,
                                              &internal_breakpoint_ops);
              b->location = new_probe_location ("-probe-stap libc:longjmp");
@@ -3489,44 +3480,35 @@ create_exception_master_breakpoint (void)
       /* We prefer the SystemTap probe point if it exists.  */
       if (!bp_objfile_data->exception_searched)
        {
-         VEC (probe_p) *ret;
-
-         ret = find_probes_in_objfile (objfile, "libgcc", "unwind");
+         std::vector<probe *> ret
+           = find_probes_in_objfile (objfile, "libgcc", "unwind");
 
-         if (ret != NULL)
+         if (!ret.empty ())
            {
              /* We are only interested in checking one element.  */
-             struct probe *p = VEC_index (probe_p, ret, 0);
+             probe *p = ret[0];
 
              if (!can_evaluate_probe_arguments (p))
                {
                  /* We cannot use the probe interface here, because it does
                     not know how to evaluate arguments.  */
-                 VEC_free (probe_p, ret);
-                 ret = NULL;
+                 ret.clear ();
                }
            }
          bp_objfile_data->exception_probes = ret;
          bp_objfile_data->exception_searched = 1;
        }
 
-      if (bp_objfile_data->exception_probes != NULL)
+      if (!bp_objfile_data->exception_probes.empty ())
        {
          struct gdbarch *gdbarch = get_objfile_arch (objfile);
-         int i;
-         struct probe *probe;
-
-         for (i = 0;
-              VEC_iterate (probe_p,
-                           bp_objfile_data->exception_probes,
-                           i, probe);
-              ++i)
+
+         for (probe *p : bp_objfile_data->exception_probes)
            {
              struct breakpoint *b;
 
              b = create_internal_breakpoint (gdbarch,
-                                             get_probe_address (probe,
-                                                                objfile),
+                                             get_probe_address (p, objfile),
                                              bp_exception_master,
                                              &internal_breakpoint_ops);
              b->location = new_probe_location ("-probe-stap libgcc:unwind");
index ba409591263b3add291c31414836fa01315a04bc..829f6d18d70d5dffff198b853e9a25e30a6cd478 100644 (file)
@@ -193,14 +193,14 @@ parse_probes (const struct event_location *location,
 
 /* See definition in probe.h.  */
 
-VEC (probe_p) *
+std::vector<probe *>
 find_probes_in_objfile (struct objfile *objfile, const char *provider,
                        const char *name)
 {
-  VEC (probe_p) *result = NULL;
+  std::vector<probe *> result;
 
   if (!objfile->sf || !objfile->sf->sym_probe_fns)
-    return NULL;
+    return result;
 
   const std::vector<probe *> &probes
     = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
@@ -212,7 +212,7 @@ find_probes_in_objfile (struct objfile *objfile, const char *provider,
       if (strcmp (p->name, name) != 0)
        continue;
 
-      VEC_safe_push (probe_p, result, p);
+      result.push_back (p);
     }
 
   return result;
index 1b3916602adac7f171e6554180d3fb67ed3311a0..822e5c89a9183135ec6d23cc32df2253dc0bb11f 100644 (file)
 #define PROBE_H 1
 
 struct event_location;
-
-#include "gdb_vecs.h"
-
-/* Definition of a vector of probes.  */
-
-typedef struct probe *probe_p;
-DEF_VEC_P (probe_p);
-
 struct linespec_result;
 
 /* Structure useful for passing the header names in the method
@@ -255,11 +247,11 @@ extern struct bound_probe find_probe_by_pc (CORE_ADDR pc);
 
 /* Search OBJFILE for a probe with the given PROVIDER, NAME.  Return a
    VEC of all probes that were found.  If no matching probe is found,
-   return NULL.  The caller must free the VEC.  */
+   return an empty vector.  */
 
-extern VEC (probe_p) *find_probes_in_objfile (struct objfile *objfile,
-                                             const char *provider,
-                                             const char *name);
+extern std::vector<probe *> find_probes_in_objfile (struct objfile *objfile,
+                                                   const char *provider,
+                                                   const char *name);
 
 /* Generate a `info probes' command output for probe_ops represented by
    POPS.  If POPS is NULL it considers any probes types.  It is a helper
index bf2577a43367a38ccb50050dfa716cc73914cc18..5ec606de436342ae7315b8ebf93c3e557899c31a 100644 (file)
@@ -2075,25 +2075,19 @@ svr4_update_solib_event_breakpoints (void)
 
 static void
 svr4_create_probe_breakpoints (struct gdbarch *gdbarch,
-                              VEC (probe_p) **probes,
+                              const std::vector<probe *> *probes,
                               struct objfile *objfile)
 {
-  int i;
-
-  for (i = 0; i < NUM_PROBES; i++)
+  for (int i = 0; i < NUM_PROBES; i++)
     {
       enum probe_action action = probe_info[i].action;
-      struct probe *probe;
-      int ix;
 
-      for (ix = 0;
-          VEC_iterate (probe_p, probes[i], ix, probe);
-          ++ix)
+      for (probe *p : probes[i])
        {
-         CORE_ADDR address = get_probe_address (probe, objfile);
+         CORE_ADDR address = get_probe_address (p, objfile);
 
          create_solib_event_breakpoint (gdbarch, address);
-         register_solib_event_probe (probe, address, action);
+         register_solib_event_probe (p, address, action);
        }
     }
 
@@ -2125,13 +2119,11 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
 
       for (with_prefix = 0; with_prefix <= 1; with_prefix++)
        {
-         VEC (probe_p) *probes[NUM_PROBES];
+         std::vector<probe *> probes[NUM_PROBES];
          int all_probes_found = 1;
          int checked_can_use_probe_arguments = 0;
-         int i;
 
-         memset (probes, 0, sizeof (probes));
-         for (i = 0; i < NUM_PROBES; i++)
+         for (int i = 0; i < NUM_PROBES; i++)
            {
              const char *name = probe_info[i].name;
              struct probe *p;
@@ -2158,7 +2150,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
              if (strcmp (name, "rtld_map_failed") == 0)
                continue;
 
-             if (VEC_empty (probe_p, probes[i]))
+             if (probes[i].empty ())
                {
                  all_probes_found = 0;
                  break;
@@ -2167,7 +2159,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
              /* Ensure probe arguments can be evaluated.  */
              if (!checked_can_use_probe_arguments)
                {
-                 p = VEC_index (probe_p, probes[i], 0);
+                 p = probes[i][0];
                  if (!can_evaluate_probe_arguments (p))
                    {
                      all_probes_found = 0;
@@ -2180,9 +2172,6 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
          if (all_probes_found)
            svr4_create_probe_breakpoints (gdbarch, probes, os->objfile);
 
-         for (i = 0; i < NUM_PROBES; i++)
-           VEC_free (probe_p, probes[i]);
-
          if (all_probes_found)
            return;
        }
This page took 0.041024 seconds and 4 git commands to generate.