Add constructor to stap_static_probe_ops
[deliverable/binutils-gdb.git] / gdb / stap-probe.c
index 75fa4a69bf31a998e6d1b4d3432fb058355ca3be..39da2900e7af30d0c24702019c8b835038b0b646 100644 (file)
@@ -1,6 +1,6 @@
 /* SystemTap probe support for GDB.
 
-   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,7 +20,6 @@
 #include "defs.h"
 #include "stap-probe.h"
 #include "probe.h"
-#include "vec.h"
 #include "ui-out.h"
 #include "objfiles.h"
 #include "arch-utils.h"
 
 #define STAP_BASE_SECTION_NAME ".stapsdt.base"
 
-/* Forward declaration. */
-
-extern const struct probe_ops stap_probe_ops;
-
 /* Should we display debug information for the probe's argument expression
    parsing?  */
 
@@ -85,6 +80,12 @@ enum stap_arg_bitness
 
 struct stap_probe_arg
 {
+  /* Constructor for stap_probe_arg.  */
+  stap_probe_arg (enum stap_arg_bitness bitness_, struct type *atype_,
+                 expression_up &&aexpr_)
+  : bitness (bitness_), atype (atype_), aexpr (std::move (aexpr_))
+  {}
+
   /* The bitness of this argument.  */
   enum stap_arg_bitness bitness;
 
@@ -92,35 +93,140 @@ struct stap_probe_arg
   struct type *atype;
 
   /* The argument converted to an internal GDB expression.  */
-  struct expression *aexpr;
+  expression_up aexpr;
 };
 
-typedef struct stap_probe_arg stap_probe_arg_s;
-DEF_VEC_O (stap_probe_arg_s);
+/* Class that implements the static probe methods for "stap" probes.  */
 
-struct stap_probe
+class stap_static_probe_ops : public static_probe_ops
 {
-  /* Generic information about the probe.  This shall be the first element
-     of this struct, in order to maintain binary compatibility with the
-     `struct probe' and be able to fully abstract it.  */
-  struct probe p;
+public:
+  /* We need a user-provided constructor to placate some compilers.
+     See PR build/24937.  */
+  stap_static_probe_ops ()
+  {
+  }
+
+  /* See probe.h.  */
+  bool is_linespec (const char **linespecp) const override;
+
+  /* See probe.h.  */
+  void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
+                  struct objfile *objfile) const override;
+
+  /* See probe.h.  */
+  const char *type_name () const override;
+
+  /* See probe.h.  */
+  std::vector<struct info_probe_column> gen_info_probes_table_header
+    () const override;
+};
+
+/* SystemTap static_probe_ops.  */
+
+const stap_static_probe_ops stap_static_probe_ops {};
+
+class stap_probe : public probe
+{
+public:
+  /* Constructor for stap_probe.  */
+  stap_probe (std::string &&name_, std::string &&provider_, CORE_ADDR address_,
+             struct gdbarch *arch_, CORE_ADDR sem_addr, const char *args_text)
+    : probe (std::move (name_), std::move (provider_), address_, arch_),
+      m_sem_addr (sem_addr),
+      m_have_parsed_args (false), m_unparsed_args_text (args_text)
+  {}
+
+  /* See probe.h.  */
+  CORE_ADDR get_relocated_address (struct objfile *objfile) override;
+
+  /* See probe.h.  */
+  unsigned get_argument_count (struct gdbarch *gdbarch) override;
+
+  /* See probe.h.  */
+  bool can_evaluate_arguments () const override;
+
+  /* See probe.h.  */
+  struct value *evaluate_argument (unsigned n,
+                                  struct frame_info *frame) override;
+
+  /* See probe.h.  */
+  void compile_to_ax (struct agent_expr *aexpr,
+                     struct axs_value *axs_value,
+                     unsigned n) override;
+
+  /* See probe.h.  */
+  void set_semaphore (struct objfile *objfile,
+                     struct gdbarch *gdbarch) override;
+
+  /* See probe.h.  */
+  void clear_semaphore (struct objfile *objfile,
+                       struct gdbarch *gdbarch) override;
+
+  /* See probe.h.  */
+  const static_probe_ops *get_static_ops () const override;
+
+  /* See probe.h.  */
+  std::vector<const char *> gen_info_probes_table_values () const override;
+
+  /* Return argument N of probe.
+
+     If the probe's arguments have not been parsed yet, parse them.  If
+     there are no arguments, throw an exception (error).  Otherwise,
+     return the requested argument.  */
+  struct stap_probe_arg *get_arg_by_number (unsigned n,
+                                           struct gdbarch *gdbarch)
+  {
+    if (!m_have_parsed_args)
+      this->parse_arguments (gdbarch);
+
+    gdb_assert (m_have_parsed_args);
+    if (m_parsed_args.empty ())
+      internal_error (__FILE__, __LINE__,
+                     _("Probe '%s' apparently does not have arguments, but \n"
+                       "GDB is requesting its argument number %u anyway.  "
+                       "This should not happen.  Please report this bug."),
+                     this->get_name ().c_str (), n);
 
+    if (n > m_parsed_args.size ())
+      internal_error (__FILE__, __LINE__,
+                     _("Probe '%s' has %d arguments, but GDB is requesting\n"
+                       "argument %u.  This should not happen.  Please\n"
+                       "report this bug."),
+                     this->get_name ().c_str (),
+                     (int) m_parsed_args.size (), n);
+
+    return &m_parsed_args[n];
+  }
+
+  /* Function which parses an argument string from the probe,
+     correctly splitting the arguments and storing their information
+     in properly ways.
+
+     Consider the following argument string (x86 syntax):
+
+     `4@%eax 4@$10'
+
+     We have two arguments, `%eax' and `$10', both with 32-bit
+     unsigned bitness.  This function basically handles them, properly
+     filling some structures with this information.  */
+  void parse_arguments (struct gdbarch *gdbarch);
+
+private:
   /* If the probe has a semaphore associated, then this is the value of
      it, relative to SECT_OFF_DATA.  */
-  CORE_ADDR sem_addr;
+  CORE_ADDR m_sem_addr;
 
-  /* One if the arguments have been parsed.  */
-  unsigned int args_parsed : 1;
+  /* True if the arguments have been parsed.  */
+  bool m_have_parsed_args;
 
-  union
-    {
-      const char *text;
+  /* The text version of the probe's arguments, unparsed.  */
+  const char *m_unparsed_args_text;
 
-      /* Information about each argument.  This is an array of `stap_probe_arg',
-        with each entry representing one argument.  */
-      VEC (stap_probe_arg_s) *vec;
-    }
-  args_u;
+  /* Information about each argument.  This is an array of `stap_probe_arg',
+     with each entry representing one argument.  This is only valid if
+     M_ARGS_PARSED is true.  */
+  std::vector<struct stap_probe_arg> m_parsed_args;
 };
 
 /* When parsing the arguments, we have to establish different precedences
@@ -156,14 +262,14 @@ enum stap_operand_prec
   STAP_OPERAND_PREC_MUL
 };
 
-static void stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
+static void stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
                                   enum stap_operand_prec prec);
 
 static void stap_parse_argument_conditionally (struct stap_parse_info *p);
 
-/* Returns 1 if *S is an operator, zero otherwise.  */
+/* Returns true if *S is an operator, false otherwise.  */
 
-static int stap_is_operator (const char *op);
+static bool stap_is_operator (const char *op);
 
 static void
 show_stapexpressiondebug (struct ui_file *file, int from_tty,
@@ -215,8 +321,9 @@ stap_get_operator_prec (enum exp_opcode op)
     }
 }
 
-/* Given S, read the operator in it and fills the OP pointer with its code.
-   Return 1 on success, zero if the operator was not recognized.  */
+/* Given S, read the operator in it.  Return the EXP_OPCODE which
+   represents the operator detected, or throw an error if no operator
+   was found.  */
 
 static enum exp_opcode
 stap_get_opcode (const char **s)
@@ -313,20 +420,21 @@ stap_get_opcode (const char **s)
       break;
 
     default:
-      internal_error (__FILE__, __LINE__,
-                     _("Invalid opcode in expression `%s' for SystemTap"
-                       "probe"), *s);
+      error (_("Invalid opcode in expression `%s' for SystemTap"
+              "probe"), *s);
     }
 
   return op;
 }
 
 /* Given the bitness of the argument, represented by B, return the
-   corresponding `struct type *'.  */
+   corresponding `struct type *', or throw an error if B is
+   unknown.  */
 
 static struct type *
 stap_get_expected_argument_type (struct gdbarch *gdbarch,
-                                enum stap_arg_bitness b)
+                                enum stap_arg_bitness b,
+                                const char *probe_name)
 {
   switch (b)
     {
@@ -361,8 +469,7 @@ stap_get_expected_argument_type (struct gdbarch *gdbarch,
       return builtin_type (gdbarch)->builtin_uint64;
 
     default:
-      internal_error (__FILE__, __LINE__,
-                     _("Undefined bitness for probe."));
+      error (_("Undefined bitness for probe '%s'."), probe_name);
       break;
     }
 }
@@ -374,9 +481,9 @@ stap_get_expected_argument_type (struct gdbarch *gdbarch,
 
    This function does a case-insensitive match.
 
-   Return 1 if any prefix has been found, zero otherwise.  */
+   Return true if any prefix has been found, false otherwise.  */
 
-static int
+static bool
 stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
                        const char **r, const char *const *prefixes)
 {
@@ -387,7 +494,7 @@ stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
       if (r != NULL)
        *r = "";
 
-      return 1;
+      return true;
     }
 
   for (p = prefixes; *p != NULL; ++p)
@@ -396,16 +503,16 @@ stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
        if (r != NULL)
          *r = *p;
 
-       return 1;
+       return true;
       }
 
-  return 0;
+  return false;
 }
 
-/* Return 1 if S points to a register prefix, zero otherwise.  For a
-   description of the arguments, look at stap_is_generic_prefix.  */
+/* Return true if S points to a register prefix, false otherwise.  For
+   description of the arguments, look at stap_is_generic_prefix.  */
 
-static int
+static bool
 stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
                         const char **r)
 {
@@ -414,11 +521,11 @@ stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
   return stap_is_generic_prefix (gdbarch, s, r, t);
 }
 
-/* Return 1 if S points to a register indirection prefix, zero
+/* Return true if S points to a register indirection prefix, false
    otherwise.  For a description of the arguments, look at
    stap_is_generic_prefix.  */
 
-static int
+static bool
 stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
                                     const char **r)
 {
@@ -427,15 +534,15 @@ stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
   return stap_is_generic_prefix (gdbarch, s, r, t);
 }
 
-/* Return 1 if S points to an integer prefix, zero otherwise.  For a
-   description of the arguments, look at stap_is_generic_prefix.
+/* Return true if S points to an integer prefix, false otherwise.  For
+   description of the arguments, look at stap_is_generic_prefix.
 
    This function takes care of analyzing whether we are dealing with
    an expected integer prefix, or, if there is no integer prefix to be
    expected, whether we are dealing with a digit.  It does a
    case-insensitive match.  */
 
-static int
+static bool
 stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
                        const char **r)
 {
@@ -449,7 +556,7 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
       if (r != NULL)
        *r = "";
 
-      return isdigit (*s);
+      return isdigit (*s) > 0;
     }
 
   for (p = t; *p != NULL; ++p)
@@ -467,35 +574,35 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
          if (r != NULL)
            *r = *p;
 
-         return 1;
+         return true;
        }
     }
 
-  return 0;
+  return false;
 }
 
 /* Helper function to check for a generic list of suffixes.  If we are
    not expecting any suffixes, then it just returns 1.  If we are
-   expecting at least one suffix, then it returns 1 if a suffix has
-   been found, zero otherwise.  GDBARCH is the current gdbarch being
+   expecting at least one suffix, then it returns true if a suffix has
+   been found, false otherwise.  GDBARCH is the current gdbarch being
    used.  S is the expression being analyzed.  If R is not NULL, it
    will be used to return the found suffix.  SUFFIXES is the list of
    expected suffixes.  This function does a case-insensitive
    match.  */
 
-static int
+static bool
 stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
                           const char **r, const char *const *suffixes)
 {
   const char *const *p;
-  int found = 0;
+  bool found = false;
 
   if (suffixes == NULL)
     {
       if (r != NULL)
        *r = "";
 
-      return 1;
+      return true;
     }
 
   for (p = suffixes; *p != NULL; ++p)
@@ -504,18 +611,18 @@ stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
        if (r != NULL)
          *r = *p;
 
-       found = 1;
+       found = true;
        break;
       }
 
   return found;
 }
 
-/* Return 1 if S points to an integer suffix, zero otherwise.  For a
-   description of the arguments, look at
+/* Return true if S points to an integer suffix, false otherwise.  For
+   description of the arguments, look at
    stap_generic_check_suffix.  */
 
-static int
+static bool
 stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
                           const char **r)
 {
@@ -524,11 +631,11 @@ stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
   return stap_generic_check_suffix (gdbarch, s, r, p);
 }
 
-/* Return 1 if S points to a register suffix, zero otherwise.  For a
-   description of the arguments, look at
+/* Return true if S points to a register suffix, false otherwise.  For
+   description of the arguments, look at
    stap_generic_check_suffix.  */
 
-static int
+static bool
 stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
                            const char **r)
 {
@@ -537,11 +644,11 @@ stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
   return stap_generic_check_suffix (gdbarch, s, r, p);
 }
 
-/* Return 1 if S points to a register indirection suffix, zero
+/* Return true if S points to a register indirection suffix, false
    otherwise.  For a description of the arguments, look at
    stap_generic_check_suffix.  */
 
-static int
+static bool
 stap_check_register_indirection_suffix (struct gdbarch *gdbarch, const char *s,
                                        const char **r)
 {
@@ -574,22 +681,19 @@ stap_parse_register_operand (struct stap_parse_info *p)
 {
   /* Simple flag to indicate whether we have seen a minus signal before
      certain number.  */
-  int got_minus = 0;
+  bool got_minus = false;
   /* Flags to indicate whether this register access is being displaced and/or
      indirected.  */
-  int disp_p = 0, indirect_p = 0;
+  bool disp_p = false;
+  bool indirect_p = false;
   struct gdbarch *gdbarch = p->gdbarch;
   /* Needed to generate the register name as a part of an expression.  */
   struct stoken str;
   /* Variables used to extract the register name from the probe's
      argument.  */
   const char *start;
-  char *regname;
-  int len;
   const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
-  int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
   const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
-  int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 0;
   const char *reg_prefix;
   const char *reg_ind_prefix;
   const char *reg_suffix;
@@ -602,10 +706,9 @@ stap_parse_register_operand (struct stap_parse_info *p)
         pointer.  */
       ++p->arg;
     }
-
-  if (*p->arg == '-')
+  else if (*p->arg == '-')
     {
-      got_minus = 1;
+      got_minus = true;
       ++p->arg;
     }
 
@@ -615,7 +718,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
       long displacement;
       char *endp;
 
-      disp_p = 1;
+      disp_p = true;
       displacement = strtol (p->arg, &endp, 10);
       p->arg = endp;
 
@@ -631,7 +734,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
   /* Getting rid of register indirection prefix.  */
   if (stap_is_register_indirection_prefix (gdbarch, p->arg, &reg_ind_prefix))
     {
-      indirect_p = 1;
+      indirect_p = true;
       p->arg += strlen (reg_ind_prefix);
     }
 
@@ -651,37 +754,55 @@ stap_parse_register_operand (struct stap_parse_info *p)
   while (isalnum (*p->arg))
     ++p->arg;
 
-  len = p->arg - start;
-
-  regname = alloca (len + gdb_reg_prefix_len + gdb_reg_suffix_len + 1);
-  regname[0] = '\0';
+  std::string regname (start, p->arg - start);
 
   /* We only add the GDB's register prefix/suffix if we are dealing with
      a numeric register.  */
-  if (gdb_reg_prefix && isdigit (*start))
+  if (isdigit (*start))
     {
-      strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
-      strncpy (regname + gdb_reg_prefix_len, start, len);
-
-      if (gdb_reg_suffix)
-       strncpy (regname + gdb_reg_prefix_len + len,
-                gdb_reg_suffix, gdb_reg_suffix_len);
+      if (gdb_reg_prefix != NULL)
+       regname = gdb_reg_prefix + regname;
 
-      len += gdb_reg_prefix_len + gdb_reg_suffix_len;
+      if (gdb_reg_suffix != NULL)
+       regname += gdb_reg_suffix;
     }
-  else
-    strncpy (regname, start, len);
 
-  regname[len] = '\0';
+  int regnum = user_reg_map_name_to_regnum (gdbarch, regname.c_str (),
+                                           regname.size ());
 
   /* Is this a valid register name?  */
-  if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
+  if (regnum == -1)
     error (_("Invalid register name `%s' on expression `%s'."),
-          regname, p->saved_arg);
+          regname.c_str (), p->saved_arg);
+
+  /* Check if there's any special treatment that the arch-specific
+     code would like to perform on the register name.  */
+  if (gdbarch_stap_adjust_register_p (gdbarch))
+    {
+      std::string newregname
+       = gdbarch_stap_adjust_register (gdbarch, p, regname, regnum);
+
+      if (regname != newregname)
+       {
+         /* This is just a check we perform to make sure that the
+            arch-dependent code has provided us with a valid
+            register name.  */
+         regnum = user_reg_map_name_to_regnum (gdbarch, newregname.c_str (),
+                                               newregname.size ());
+
+         if (regnum == -1)
+           internal_error (__FILE__, __LINE__,
+                           _("Invalid register name '%s' after replacing it"
+                             " (previous name was '%s')"),
+                           newregname.c_str (), regname.c_str ());
+
+         regname = newregname;
+       }
+    }
 
   write_exp_elt_opcode (&p->pstate, OP_REGISTER);
-  str.ptr = regname;
-  str.length = len;
+  str.ptr = regname.c_str ();
+  str.length = regname.size ();
   write_exp_string (&p->pstate, str);
   write_exp_elt_opcode (&p->pstate, OP_REGISTER);
 
@@ -739,22 +860,22 @@ stap_parse_single_operand (struct stap_parse_info *p)
   const char *int_prefix = NULL;
 
   /* We first try to parse this token as a "special token".  */
-  if (gdbarch_stap_parse_special_token_p (gdbarch))
-    if (gdbarch_stap_parse_special_token (gdbarch, p) != 0)
-      {
-       /* If the return value of the above function is not zero,
-          it means it successfully parsed the special token.
+  if (gdbarch_stap_parse_special_token_p (gdbarch)
+      && (gdbarch_stap_parse_special_token (gdbarch, p) != 0))
+    {
+      /* If the return value of the above function is not zero,
+        it means it successfully parsed the special token.
 
-          If it is NULL, we try to parse it using our method.  */
-       return;
-      }
+        If it is NULL, we try to parse it using our method.  */
+      return;
+    }
 
   if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+')
     {
       char c = *p->arg;
       /* We use this variable to do a lookahead.  */
       const char *tmp = p->arg;
-      int has_digit = 0;
+      bool has_digit = false;
 
       /* Skipping signal.  */
       ++tmp;
@@ -769,7 +890,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
         We handle the register displacement here, and the other cases
         recursively.  */
       if (p->inside_paren_p)
-       tmp = skip_spaces_const (tmp);
+       tmp = skip_spaces (tmp);
 
       while (isdigit (*tmp))
        {
@@ -779,7 +900,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
             called below ('stap_parse_argument_conditionally' or
             'stap_parse_register_operand').  */
          ++tmp;
-         has_digit = 1;
+         has_digit = true;
        }
 
       if (has_digit && stap_is_register_indirection_prefix (gdbarch, tmp,
@@ -787,7 +908,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
        {
          /* If we are here, it means it is a displacement.  The only
             operations allowed here are `-' and `+'.  */
-         if (c == '~')
+         if (c != '-' && c != '+')
            error (_("Invalid operator `%c' for register displacement "
                     "on expression `%s'."), c, p->saved_arg);
 
@@ -818,7 +939,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
       tmp = endp;
 
       if (p->inside_paren_p)
-       tmp = skip_spaces_const (tmp);
+       tmp = skip_spaces (tmp);
 
       /* If "stap_is_integer_prefix" returns true, it means we can
         accept integers without a prefix here.  But we also need to
@@ -901,7 +1022,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p)
         have to parse it as it was a separate expression, without
         left-side or precedence.  */
       ++p->arg;
-      p->arg = skip_spaces_const (p->arg);
+      p->arg = skip_spaces (p->arg);
       ++p->inside_paren_p;
 
       stap_parse_argument_1 (p, 0, STAP_OPERAND_PREC_NONE);
@@ -913,7 +1034,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p)
 
       ++p->arg;
       if (p->inside_paren_p)
-       p->arg = skip_spaces_const (p->arg);
+       p->arg = skip_spaces (p->arg);
     }
   else
     error (_("Cannot parse expression `%s'."), p->saved_arg);
@@ -923,7 +1044,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p)
    better understand what this function does.  */
 
 static void
-stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
+stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
                       enum stap_operand_prec prec)
 {
   /* This is an operator-precedence parser.
@@ -935,7 +1056,7 @@ stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
   gdb_assert (p->arg != NULL);
 
   if (p->inside_paren_p)
-    p->arg = skip_spaces_const (p->arg);
+    p->arg = skip_spaces (p->arg);
 
   if (!has_lhs)
     {
@@ -981,7 +1102,7 @@ stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
 
       p->arg = tmp_exp_buf;
       if (p->inside_paren_p)
-       p->arg = skip_spaces_const (p->arg);
+       p->arg = skip_spaces (p->arg);
 
       /* Parse the right-side of the expression.  */
       stap_parse_argument_conditionally (p);
@@ -1039,32 +1160,21 @@ stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
    - If we find an operator, we skip it.
 
    This function can also call a special function that will try to match
-   unknown tokens.  It will return 1 if the argument has been parsed
-   successfully, or zero otherwise.  */
+   unknown tokens.  It will return the expression_up generated from
+   parsing the argument.  */
 
-static struct expression *
+static expression_up
 stap_parse_argument (const char **arg, struct type *atype,
                     struct gdbarch *gdbarch)
 {
-  struct stap_parse_info p;
-  struct cleanup *back_to;
-
   /* We need to initialize the expression buffer, in order to begin
      our parsing efforts.  We use language_c here because we may need
      to do pointer arithmetics.  */
-  initialize_expout (&p.pstate, 10, language_def (language_c), gdbarch);
-  back_to = make_cleanup (free_current_contents, &p.pstate.expout);
-
-  p.saved_arg = *arg;
-  p.arg = *arg;
-  p.arg_type = atype;
-  p.gdbarch = gdbarch;
-  p.inside_paren_p = 0;
+  struct stap_parse_info p (*arg, atype, language_def (language_c),
+                           gdbarch);
 
   stap_parse_argument_1 (&p, 0, STAP_OPERAND_PREC_NONE);
 
-  discard_cleanups (back_to);
-
   gdb_assert (p.inside_paren_p == 0);
 
   /* Casting the final expression to the appropriate type.  */
@@ -1072,47 +1182,30 @@ stap_parse_argument (const char **arg, struct type *atype,
   write_exp_elt_type (&p.pstate, atype);
   write_exp_elt_opcode (&p.pstate, UNOP_CAST);
 
-  reallocate_expout (&p.pstate);
-
-  p.arg = skip_spaces_const (p.arg);
+  p.arg = skip_spaces (p.arg);
   *arg = p.arg;
 
-  /* We can safely return EXPOUT here.  */
-  return p.pstate.expout;
+  return p.pstate.release ();
 }
 
-/* Function which parses an argument string from PROBE, correctly splitting
-   the arguments and storing their information in properly ways.
-
-   Consider the following argument string (x86 syntax):
-
-   `4@%eax 4@$10'
+/* Implementation of 'parse_arguments' method.  */
 
-   We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness.
-   This function basically handles them, properly filling some structures with
-   this information.  */
-
-static void
-stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
+void
+stap_probe::parse_arguments (struct gdbarch *gdbarch)
 {
   const char *cur;
 
-  gdb_assert (!probe->args_parsed);
-  cur = probe->args_u.text;
-  probe->args_parsed = 1;
-  probe->args_u.vec = NULL;
+  gdb_assert (!m_have_parsed_args);
+  cur = m_unparsed_args_text;
+  m_have_parsed_args = true;
 
   if (cur == NULL || *cur == '\0' || *cur == ':')
     return;
 
   while (*cur != '\0')
     {
-      struct stap_probe_arg arg;
-      enum stap_arg_bitness b;
-      int got_minus = 0;
-      struct expression *expr;
-
-      memset (&arg, 0, sizeof (arg));
+      enum stap_arg_bitness bitness;
+      bool got_minus = false;
 
       /* We expect to find something like:
 
@@ -1128,30 +1221,30 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
            {
              /* Discard the `-'.  */
              ++cur;
-             got_minus = 1;
+             got_minus = true;
            }
 
          /* Defining the bitness.  */
          switch (*cur)
            {
            case '1':
-             b = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
-                  : STAP_ARG_BITNESS_8BIT_UNSIGNED);
+             bitness = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
+                        : STAP_ARG_BITNESS_8BIT_UNSIGNED);
              break;
 
            case '2':
-             b = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
-                  : STAP_ARG_BITNESS_16BIT_UNSIGNED);
+             bitness = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
+                        : STAP_ARG_BITNESS_16BIT_UNSIGNED);
              break;
 
            case '4':
-             b = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
-                  : STAP_ARG_BITNESS_32BIT_UNSIGNED);
+             bitness = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
+                        : STAP_ARG_BITNESS_32BIT_UNSIGNED);
              break;
 
            case '8':
-             b = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
-                  : STAP_ARG_BITNESS_64BIT_UNSIGNED);
+             bitness = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
+                        : STAP_ARG_BITNESS_64BIT_UNSIGNED);
              break;
 
            default:
@@ -1159,69 +1252,69 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
                /* We have an error, because we don't expect anything
                   except 1, 2, 4 and 8.  */
                warning (_("unrecognized bitness %s%c' for probe `%s'"),
-                        got_minus ? "`-" : "`", *cur, probe->p.name);
+                        got_minus ? "`-" : "`", *cur,
+                        this->get_name ().c_str ());
                return;
              }
            }
-
-         arg.bitness = b;
-
          /* Discard the number and the `@' sign.  */
          cur += 2;
        }
       else
-       arg.bitness = STAP_ARG_BITNESS_UNDEFINED;
+       bitness = STAP_ARG_BITNESS_UNDEFINED;
 
-      arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness);
+      struct type *atype
+       = stap_get_expected_argument_type (gdbarch, bitness,
+                                          this->get_name ().c_str ());
 
-      expr = stap_parse_argument (&cur, arg.atype, gdbarch);
+      expression_up expr = stap_parse_argument (&cur, atype, gdbarch);
 
       if (stap_expression_debug)
-       dump_raw_expression (expr, gdb_stdlog,
+       dump_raw_expression (expr.get (), gdb_stdlog,
                             "before conversion to prefix form");
 
-      prefixify_expression (expr);
+      prefixify_expression (expr.get ());
 
       if (stap_expression_debug)
-       dump_prefix_expression (expr, gdb_stdlog);
+       dump_prefix_expression (expr.get (), gdb_stdlog);
 
-      arg.aexpr = expr;
+      m_parsed_args.emplace_back (bitness, atype, std::move (expr));
 
       /* Start it over again.  */
-      cur = skip_spaces_const (cur);
-
-      VEC_safe_push (stap_probe_arg_s, probe->args_u.vec, &arg);
+      cur = skip_spaces (cur);
     }
 }
 
-/* Implementation of the get_probe_address method.  */
+/* Helper function to relocate an address.  */
 
 static CORE_ADDR
-stap_get_probe_address (struct probe *probe, struct objfile *objfile)
+relocate_address (CORE_ADDR address, struct objfile *objfile)
 {
-  return probe->address + ANOFFSET (objfile->section_offsets,
-                                   SECT_OFF_DATA (objfile));
+  return address + ANOFFSET (objfile->section_offsets,
+                            SECT_OFF_DATA (objfile));
 }
 
-/* Given PROBE, returns the number of arguments present in that probe's
-   argument string.  */
+/* Implementation of the get_relocated_address method.  */
 
-static unsigned
-stap_get_probe_argument_count (struct probe *probe_generic,
-                              struct frame_info *frame)
+CORE_ADDR
+stap_probe::get_relocated_address (struct objfile *objfile)
 {
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-  struct gdbarch *gdbarch = get_frame_arch (frame);
+  return relocate_address (this->get_address (), objfile);
+}
 
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
+/* Given PROBE, returns the number of arguments present in that probe's
+   argument string.  */
 
-  if (!probe->args_parsed)
+unsigned
+stap_probe::get_argument_count (struct gdbarch *gdbarch)
+{
+  if (!m_have_parsed_args)
     {
-      if (can_evaluate_probe_arguments (probe_generic))
-       stap_parse_probe_arguments (probe, gdbarch);
+      if (this->can_evaluate_arguments ())
+       this->parse_arguments (gdbarch);
       else
        {
-         static int have_warned_stap_incomplete = 0;
+         static bool have_warned_stap_incomplete = false;
 
          if (!have_warned_stap_incomplete)
            {
@@ -1229,26 +1322,25 @@ stap_get_probe_argument_count (struct probe *probe_generic,
 "The SystemTap SDT probe support is not fully implemented on this target;\n"
 "you will not be able to inspect the arguments of the probes.\n"
 "Please report a bug against GDB requesting a port to this target."));
-             have_warned_stap_incomplete = 1;
+             have_warned_stap_incomplete = true;
            }
 
          /* Marking the arguments as "already parsed".  */
-         probe->args_u.vec = NULL;
-         probe->args_parsed = 1;
+         m_have_parsed_args = true;
        }
     }
 
-  gdb_assert (probe->args_parsed);
-  return VEC_length (stap_probe_arg_s, probe->args_u.vec);
+  gdb_assert (m_have_parsed_args);
+  return m_parsed_args.size ();
 }
 
-/* Return 1 if OP is a valid operator inside a probe argument, or zero
-   otherwise.  */
+/* Return true if OP is a valid operator inside a probe argument, or
+   false otherwise.  */
 
-static int
+static bool
 stap_is_operator (const char *op)
 {
-  int ret = 1;
+  bool ret = true;
 
   switch (*op)
     {
@@ -1267,33 +1359,23 @@ stap_is_operator (const char *op)
 
     case '=':
       if (op[1] != '=')
-       ret = 0;
+       ret = false;
       break;
 
     default:
       /* We didn't find any operator.  */
-      ret = 0;
+      ret = false;
     }
 
   return ret;
 }
 
-static struct stap_probe_arg *
-stap_get_arg (struct stap_probe *probe, unsigned n, struct gdbarch *gdbarch)
-{
-  if (!probe->args_parsed)
-    stap_parse_probe_arguments (probe, gdbarch);
-
-  return VEC_index (stap_probe_arg_s, probe->args_u.vec, n);
-}
-
-/* Implement the `can_evaluate_probe_arguments' method of probe_ops.  */
+/* Implement the `can_evaluate_arguments' method.  */
 
-static int
-stap_can_evaluate_probe_arguments (struct probe *probe_generic)
+bool
+stap_probe::can_evaluate_arguments () const
 {
-  struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
-  struct gdbarch *gdbarch = stap_probe->p.arch;
+  struct gdbarch *gdbarch = this->get_gdbarch ();
 
   /* For SystemTap probes, we have to guarantee that the method
      stap_is_single_operand is defined on gdbarch.  If it is not, then it
@@ -1304,71 +1386,42 @@ stap_can_evaluate_probe_arguments (struct probe *probe_generic)
 /* Evaluate the probe's argument N (indexed from 0), returning a value
    corresponding to it.  Assertion is thrown if N does not exist.  */
 
-static struct value *
-stap_evaluate_probe_argument (struct probe *probe_generic, unsigned n,
-                             struct frame_info *frame)
+struct value *
+stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
 {
-  struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
-  struct gdbarch *gdbarch = get_frame_arch (frame);
   struct stap_probe_arg *arg;
   int pos = 0;
+  struct gdbarch *gdbarch = get_frame_arch (frame);
 
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
-
-  arg = stap_get_arg (stap_probe, n, gdbarch);
-  return evaluate_subexp_standard (arg->atype, arg->aexpr, &pos, EVAL_NORMAL);
+  arg = this->get_arg_by_number (n, gdbarch);
+  return evaluate_subexp_standard (arg->atype, arg->aexpr.get (), &pos,
+                                  EVAL_NORMAL);
 }
 
 /* Compile the probe's argument N (indexed from 0) to agent expression.
    Assertion is thrown if N does not exist.  */
 
-static void
-stap_compile_to_ax (struct probe *probe_generic, struct agent_expr *expr,
-                   struct axs_value *value, unsigned n)
+void
+stap_probe::compile_to_ax (struct agent_expr *expr, struct axs_value *value,
+                          unsigned n)
 {
-  struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
   struct stap_probe_arg *arg;
   union exp_element *pc;
 
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
-
-  arg = stap_get_arg (stap_probe, n, expr->gdbarch);
+  arg = this->get_arg_by_number (n, expr->gdbarch);
 
   pc = arg->aexpr->elts;
-  gen_expr (arg->aexpr, &pc, expr, value);
+  gen_expr (arg->aexpr.get (), &pc, expr, value);
 
   require_rvalue (expr, value);
   value->type = arg->atype;
 }
-
-/* Destroy (free) the data related to PROBE.  PROBE memory itself is not feed
-   as it is allocated on an obstack.  */
-
-static void
-stap_probe_destroy (struct probe *probe_generic)
-{
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
-
-  if (probe->args_parsed)
-    {
-      struct stap_probe_arg *arg;
-      int ix;
-
-      for (ix = 0; VEC_iterate (stap_probe_arg_s, probe->args_u.vec, ix, arg);
-          ++ix)
-       xfree (arg->aexpr);
-      VEC_free (stap_probe_arg_s, probe->args_u.vec);
-    }
-}
-
 \f
 
 /* Set or clear a SystemTap semaphore.  ADDRESS is the semaphore's
-   address.  SET is zero if the semaphore should be cleared, or one
-   if it should be set.  This is a helper function for `stap_semaphore_down'
-   and `stap_semaphore_up'.  */
+   address.  SET is zero if the semaphore should be cleared, or one if
+   it should be set.  This is a helper function for
+   'stap_probe::set_semaphore' and 'stap_probe::clear_semaphore'.  */
 
 static void
 stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
@@ -1388,8 +1441,8 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
       return;
     }
 
-  value = extract_unsigned_integer (bytes, TYPE_LENGTH (type),
-                                   gdbarch_byte_order (gdbarch));
+  enum bfd_endian byte_order = type_byte_order (type);
+  value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order);
   /* Note that we explicitly don't worry about overflow or
      underflow.  */
   if (set)
@@ -1397,48 +1450,53 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
   else
     --value;
 
-  store_unsigned_integer (bytes, TYPE_LENGTH (type),
-                         gdbarch_byte_order (gdbarch), value);
+  store_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order, value);
 
   if (target_write_memory (address, bytes, TYPE_LENGTH (type)) != 0)
     warning (_("Could not write the value of a SystemTap semaphore."));
 }
 
-/* Set a SystemTap semaphore.  SEM is the semaphore's address.  Semaphores
-   act as reference counters, so calls to this function must be paired with
-   calls to `stap_semaphore_down'.
+/* Implementation of the 'set_semaphore' method.
 
-   This function and `stap_semaphore_down' race with another tool changing
-   the probes, but that is too rare to care.  */
+   SystemTap semaphores act as reference counters, so calls to this
+   function must be paired with calls to 'clear_semaphore'.
 
-static void
-stap_set_semaphore (struct probe *probe_generic, struct objfile *objfile,
-                   struct gdbarch *gdbarch)
+   This function and 'clear_semaphore' race with another tool
+   changing the probes, but that is too rare to care.  */
+
+void
+stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
+{
+  stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 1, gdbarch);
+}
+
+/* Implementation of the 'clear_semaphore' method.  */
+
+void
+stap_probe::clear_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
 {
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-  CORE_ADDR addr;
+  stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 0, gdbarch);
+}
 
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
+/* Implementation of the 'get_static_ops' method.  */
 
-  addr = (probe->sem_addr
-         + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)));
-  stap_modify_semaphore (addr, 1, gdbarch);
+const static_probe_ops *
+stap_probe::get_static_ops () const
+{
+  return &stap_static_probe_ops;
 }
 
-/* Clear a SystemTap semaphore.  SEM is the semaphore's address.  */
+/* Implementation of the 'gen_info_probes_table_values' method.  */
 
-static void
-stap_clear_semaphore (struct probe *probe_generic, struct objfile *objfile,
-                     struct gdbarch *gdbarch)
+std::vector<const char *>
+stap_probe::gen_info_probes_table_values () const
 {
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-  CORE_ADDR addr;
+  const char *val = NULL;
 
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
+  if (m_sem_addr != 0)
+    val = print_core_address (this->get_gdbarch (), m_sem_addr);
 
-  addr = (probe->sem_addr
-         + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)));
-  stap_modify_semaphore (addr, 0, gdbarch);
+  return std::vector<const char *> { val };
 }
 
 /* Helper function that parses the information contained in a
@@ -1450,83 +1508,74 @@ stap_clear_semaphore (struct probe *probe_generic, struct objfile *objfile,
      probe doesn't have an associated semaphore;
    - Probe's provider name;
    - Probe's name;
-   - Probe's argument format
-   
-   This function returns 1 if the handling was successful, and zero
-   otherwise.  */
+   - Probe's argument format.  */
 
 static void
 handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
-                  VEC (probe_p) **probesp, CORE_ADDR base)
+                  std::vector<std::unique_ptr<probe>> *probesp,
+                  CORE_ADDR base)
 {
   bfd *abfd = objfile->obfd;
   int size = bfd_get_arch_size (abfd) / 8;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-  CORE_ADDR base_ref;
-  const char *probe_args = NULL;
-  struct stap_probe *ret;
-
-  ret = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
-  ret->p.pops = &stap_probe_ops;
-  ret->p.arch = gdbarch;
 
   /* Provider and the name of the probe.  */
-  ret->p.provider = (char *) &el->data[3 * size];
-  ret->p.name = memchr (ret->p.provider, '\0',
-                       (char *) el->data + el->size - ret->p.provider);
+  const char *provider = (const char *) &el->data[3 * size];
+  const char *name = ((const char *)
+                     memchr (provider, '\0',
+                             (char *) el->data + el->size - provider));
   /* Making sure there is a name.  */
-  if (ret->p.name == NULL)
+  if (name == NULL)
     {
-      complaint (&symfile_complaints, _("corrupt probe name when "
-                                       "reading `%s'"),
+      complaint (_("corrupt probe name when reading `%s'"),
                 objfile_name (objfile));
 
       /* There is no way to use a probe without a name or a provider, so
-        returning zero here makes sense.  */
+        returning here makes sense.  */
       return;
     }
   else
-    ++ret->p.name;
+    ++name;
 
   /* Retrieving the probe's address.  */
-  ret->p.address = extract_typed_address (&el->data[0], ptr_type);
+  CORE_ADDR address = extract_typed_address (&el->data[0], ptr_type);
 
   /* Link-time sh_addr of `.stapsdt.base' section.  */
-  base_ref = extract_typed_address (&el->data[size], ptr_type);
+  CORE_ADDR base_ref = extract_typed_address (&el->data[size], ptr_type);
 
   /* Semaphore address.  */
-  ret->sem_addr = extract_typed_address (&el->data[2 * size], ptr_type);
+  CORE_ADDR sem_addr = extract_typed_address (&el->data[2 * size], ptr_type);
 
-  ret->p.address += base - base_ref;
-  if (ret->sem_addr != 0)
-    ret->sem_addr += base - base_ref;
+  address += base - base_ref;
+  if (sem_addr != 0)
+    sem_addr += base - base_ref;
 
   /* Arguments.  We can only extract the argument format if there is a valid
      name for this probe.  */
-  probe_args = memchr (ret->p.name, '\0',
-                      (char *) el->data + el->size - ret->p.name);
+  const char *probe_args = ((const char*)
+                           memchr (name, '\0',
+                                   (char *) el->data + el->size - name));
 
   if (probe_args != NULL)
     ++probe_args;
 
   if (probe_args == NULL
-      || (memchr (probe_args, '\0', (char *) el->data + el->size - ret->p.name)
+      || (memchr (probe_args, '\0', (char *) el->data + el->size - name)
          != el->data + el->size - 1))
     {
-      complaint (&symfile_complaints, _("corrupt probe argument when "
-                                       "reading `%s'"),
+      complaint (_("corrupt probe argument when reading `%s'"),
                 objfile_name (objfile));
       /* If the argument string is NULL, it means some problem happened with
-        it.  So we return 0.  */
+        it.  So we return.  */
       return;
     }
 
-  ret->args_parsed = 0;
-  ret->args_u.text = (void *) probe_args;
+  stap_probe *ret = new stap_probe (std::string (name), std::string (provider),
+                                   address, gdbarch, sem_addr, probe_args);
 
   /* Successfully created probe.  */
-  VEC_safe_push (probe_p, *probesp, (struct probe *) ret);
+  probesp->emplace_back (ret);
 }
 
 /* Helper function which tries to find the base address of the SystemTap
@@ -1535,7 +1584,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
 static void
 get_stap_base_address_1 (bfd *abfd, asection *sect, void *obj)
 {
-  asection **ret = obj;
+  asection **ret = (asection **) obj;
 
   if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
       && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
@@ -1555,7 +1604,7 @@ get_stap_base_address (bfd *obfd, bfd_vma *base)
 
   if (ret == NULL)
     {
-      complaint (&symfile_complaints, _("could not obtain base address for "
+      complaint (_("could not obtain base address for "
                                        "SystemTap section on objfile `%s'."),
                 obfd->filename);
       return 0;
@@ -1567,11 +1616,22 @@ get_stap_base_address (bfd *obfd, bfd_vma *base)
   return 1;
 }
 
-/* Helper function for `elf_get_probes', which gathers information about all
-   SystemTap probes from OBJFILE.  */
+/* Implementation of the 'is_linespec' method.  */
 
-static void
-stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
+bool
+stap_static_probe_ops::is_linespec (const char **linespecp) const
+{
+  static const char *const keywords[] = { "-pstap", "-probe-stap", NULL };
+
+  return probe_is_linespec_by_keyword (linespecp, keywords);
+}
+
+/* Implementation of the 'get_probes' method.  */
+
+void
+stap_static_probe_ops::get_probes
+  (std::vector<std::unique_ptr<probe>> *probesp,
+   struct objfile *objfile) const
 {
   /* If we are here, then this is the first time we are parsing the
      SystemTap probe's information.  We basically have to count how many
@@ -1580,7 +1640,7 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
   bfd *obfd = objfile->obfd;
   bfd_vma base;
   struct sdt_note *iter;
-  unsigned save_probesp_len = VEC_length (probe_p, *probesp);
+  unsigned save_probesp_len = probesp->size ();
 
   if (objfile->separate_debug_objfile_backlink != NULL)
     {
@@ -1611,95 +1671,48 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
       handle_stap_probe (objfile, iter, probesp, base);
     }
 
-  if (save_probesp_len == VEC_length (probe_p, *probesp))
+  if (save_probesp_len == probesp->size ())
     {
       /* If we are here, it means we have failed to parse every known
         probe.  */
-      complaint (&symfile_complaints, _("could not parse SystemTap probe(s) "
-                                       "from inferior"));
+      complaint (_("could not parse SystemTap probe(s) from inferior"));
       return;
     }
 }
 
 /* Implementation of the type_name method.  */
 
-static const char *
-stap_type_name (struct probe *probe)
+const char *
+stap_static_probe_ops::type_name () const
 {
-  gdb_assert (probe->pops == &stap_probe_ops);
   return "stap";
 }
 
-static int
-stap_probe_is_linespec (const char **linespecp)
-{
-  static const char *const keywords[] = { "-pstap", "-probe-stap", NULL };
-
-  return probe_is_linespec_by_keyword (linespecp, keywords);
-}
+/* Implementation of the 'gen_info_probes_table_header' method.  */
 
-static void
-stap_gen_info_probes_table_header (VEC (info_probe_column_s) **heads)
+std::vector<struct info_probe_column>
+stap_static_probe_ops::gen_info_probes_table_header () const
 {
-  info_probe_column_s stap_probe_column;
+  struct info_probe_column stap_probe_column;
 
   stap_probe_column.field_name = "semaphore";
   stap_probe_column.print_name = _("Semaphore");
 
-  VEC_safe_push (info_probe_column_s, *heads, &stap_probe_column);
-}
-
-static void
-stap_gen_info_probes_table_values (struct probe *probe_generic,
-                                  VEC (const_char_ptr) **ret)
-{
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-  struct gdbarch *gdbarch;
-  const char *val = NULL;
-
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
-
-  gdbarch = probe->p.arch;
-
-  if (probe->sem_addr != 0)
-    val = print_core_address (gdbarch, probe->sem_addr);
-
-  VEC_safe_push (const_char_ptr, *ret, val);
+  return std::vector<struct info_probe_column> { stap_probe_column };
 }
 
-/* SystemTap probe_ops.  */
-
-const struct probe_ops stap_probe_ops =
-{
-  stap_probe_is_linespec,
-  stap_get_probes,
-  stap_get_probe_address,
-  stap_get_probe_argument_count,
-  stap_can_evaluate_probe_arguments,
-  stap_evaluate_probe_argument,
-  stap_compile_to_ax,
-  stap_set_semaphore,
-  stap_clear_semaphore,
-  stap_probe_destroy,
-  stap_type_name,
-  stap_gen_info_probes_table_header,
-  stap_gen_info_probes_table_values,
-};
-
 /* Implementation of the `info probes stap' command.  */
 
 static void
-info_probes_stap_command (char *arg, int from_tty)
+info_probes_stap_command (const char *arg, int from_tty)
 {
-  info_probes_for_ops (arg, from_tty, &stap_probe_ops);
+  info_probes_for_spops (arg, from_tty, &stap_static_probe_ops);
 }
 
-void _initialize_stap_probe (void);
-
 void
 _initialize_stap_probe (void)
 {
-  VEC_safe_push (probe_ops_cp, all_probe_ops, &stap_probe_ops);
+  all_static_probe_ops.push_back (&stap_static_probe_ops);
 
   add_setshow_zuinteger_cmd ("stap-expression", class_maintenance,
                             &stap_expression_debug,
This page took 0.042021 seconds and 4 git commands to generate.