gdb/probe.c - gdb

Global variables defined

Data types defined

Functions defined

Source code

  1. /* Generic static probe support for GDB.

  2.    Copyright (C) 2012-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "probe.h"
  16. #include "command.h"
  17. #include "cli/cli-cmds.h"
  18. #include "cli/cli-utils.h"
  19. #include "objfiles.h"
  20. #include "symtab.h"
  21. #include "progspace.h"
  22. #include "filenames.h"
  23. #include "linespec.h"
  24. #include "gdb_regex.h"
  25. #include "frame.h"
  26. #include "arch-utils.h"
  27. #include <ctype.h>

  28. typedef struct bound_probe bound_probe_s;
  29. DEF_VEC_O (bound_probe_s);



  30. /* See definition in probe.h.  */

  31. struct symtabs_and_lines
  32. parse_probes (char **argptr, struct linespec_result *canonical)
  33. {
  34.   char *arg_start, *arg_end, *arg;
  35.   char *objfile_namestr = NULL, *provider = NULL, *name, *p;
  36.   struct cleanup *cleanup;
  37.   struct symtabs_and_lines result;
  38.   struct objfile *objfile;
  39.   struct program_space *pspace;
  40.   const struct probe_ops *probe_ops;
  41.   const char *cs;

  42.   result.sals = NULL;
  43.   result.nelts = 0;

  44.   arg_start = *argptr;

  45.   cs = *argptr;
  46.   probe_ops = probe_linespec_to_ops (&cs);
  47.   if (probe_ops == NULL)
  48.     error (_("'%s' is not a probe linespec"), arg_start);

  49.   arg = (char *) cs;
  50.   arg = skip_spaces (arg);
  51.   if (!*arg)
  52.     error (_("argument to `%s' missing"), arg_start);

  53.   arg_end = skip_to_space (arg);

  54.   /* We make a copy here so we can write over parts with impunity.  */
  55.   arg = savestring (arg, arg_end - arg);
  56.   cleanup = make_cleanup (xfree, arg);

  57.   /* Extract each word from the argument, separated by ":"s.  */
  58.   p = strchr (arg, ':');
  59.   if (p == NULL)
  60.     {
  61.       /* This is `-p name'.  */
  62.       name = arg;
  63.     }
  64.   else
  65.     {
  66.       char *hold = p + 1;

  67.       *p = '\0';
  68.       p = strchr (hold, ':');
  69.       if (p == NULL)
  70.         {
  71.           /* This is `-p provider:name'.  */
  72.           provider = arg;
  73.           name = hold;
  74.         }
  75.       else
  76.         {
  77.           /* This is `-p objfile:provider:name'.  */
  78.           *p = '\0';
  79.           objfile_namestr = arg;
  80.           provider = hold;
  81.           name = p + 1;
  82.         }
  83.     }

  84.   if (*name == '\0')
  85.     error (_("no probe name specified"));
  86.   if (provider && *provider == '\0')
  87.     error (_("invalid provider name"));
  88.   if (objfile_namestr && *objfile_namestr == '\0')
  89.     error (_("invalid objfile name"));

  90.   ALL_PSPACES (pspace)
  91.     ALL_PSPACE_OBJFILES (pspace, objfile)
  92.       {
  93.         VEC (probe_p) *probes;
  94.         struct probe *probe;
  95.         int ix;

  96.         if (!objfile->sf || !objfile->sf->sym_probe_fns)
  97.           continue;

  98.         if (objfile_namestr
  99.             && FILENAME_CMP (objfile_name (objfile), objfile_namestr) != 0
  100.             && FILENAME_CMP (lbasename (objfile_name (objfile)),
  101.                              objfile_namestr) != 0)
  102.           continue;

  103.         probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);

  104.         for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
  105.           {
  106.             struct symtab_and_line *sal;

  107.             if (probe_ops != &probe_ops_any && probe->pops != probe_ops)
  108.               continue;

  109.             if (provider && strcmp (probe->provider, provider) != 0)
  110.               continue;

  111.             if (strcmp (probe->name, name) != 0)
  112.               continue;

  113.             ++result.nelts;
  114.             result.sals = xrealloc (result.sals,
  115.                                     result.nelts
  116.                                     * sizeof (struct symtab_and_line));
  117.             sal = &result.sals[result.nelts - 1];

  118.             init_sal (sal);

  119.             sal->pc = get_probe_address (probe, objfile);
  120.             sal->explicit_pc = 1;
  121.             sal->section = find_pc_overlay (sal->pc);
  122.             sal->pspace = pspace;
  123.             sal->probe = probe;
  124.             sal->objfile = objfile;
  125.           }
  126.       }

  127.   if (result.nelts == 0)
  128.     {
  129.       throw_error (NOT_FOUND_ERROR,
  130.                    _("No probe matching objfile=`%s', provider=`%s', name=`%s'"),
  131.                    objfile_namestr ? objfile_namestr : _("<any>"),
  132.                    provider ? provider : _("<any>"),
  133.                    name);
  134.     }

  135.   if (canonical)
  136.     {
  137.       canonical->special_display = 1;
  138.       canonical->pre_expanded = 1;
  139.       canonical->addr_string = savestring (*argptr, arg_end - *argptr);
  140.     }

  141.   *argptr = arg_end;
  142.   do_cleanups (cleanup);

  143.   return result;
  144. }

  145. /* See definition in probe.h.  */

  146. VEC (probe_p) *
  147. find_probes_in_objfile (struct objfile *objfile, const char *provider,
  148.                         const char *name)
  149. {
  150.   VEC (probe_p) *probes, *result = NULL;
  151.   int ix;
  152.   struct probe *probe;

  153.   if (!objfile->sf || !objfile->sf->sym_probe_fns)
  154.     return NULL;

  155.   probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
  156.   for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
  157.     {
  158.       if (strcmp (probe->provider, provider) != 0)
  159.         continue;

  160.       if (strcmp (probe->name, name) != 0)
  161.         continue;

  162.       VEC_safe_push (probe_p, result, probe);
  163.     }

  164.   return result;
  165. }

  166. /* See definition in probe.h.  */

  167. struct bound_probe
  168. find_probe_by_pc (CORE_ADDR pc)
  169. {
  170.   struct objfile *objfile;
  171.   struct bound_probe result;

  172.   result.objfile = NULL;
  173.   result.probe = NULL;

  174.   ALL_OBJFILES (objfile)
  175.   {
  176.     VEC (probe_p) *probes;
  177.     int ix;
  178.     struct probe *probe;

  179.     if (!objfile->sf || !objfile->sf->sym_probe_fns
  180.         || objfile->sect_index_text == -1)
  181.       continue;

  182.     /* If this proves too inefficient, we can replace with a hash.  */
  183.     probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
  184.     for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
  185.       if (get_probe_address (probe, objfile) == pc)
  186.         {
  187.           result.objfile = objfile;
  188.           result.probe = probe;
  189.           return result;
  190.         }
  191.   }

  192.   return result;
  193. }



  194. /* Make a vector of probes matching OBJNAME, PROVIDER, and PROBE_NAME.
  195.    If POPS is not NULL, only probes of this certain probe_ops will match.
  196.    Each argument is a regexp, or NULL, which matches anything.  */

  197. static VEC (bound_probe_s) *
  198. collect_probes (char *objname, char *provider, char *probe_name,
  199.                 const struct probe_ops *pops)
  200. {
  201.   struct objfile *objfile;
  202.   VEC (bound_probe_s) *result = NULL;
  203.   struct cleanup *cleanup, *cleanup_temps;
  204.   regex_t obj_pat, prov_pat, probe_pat;

  205.   cleanup = make_cleanup (VEC_cleanup (bound_probe_s), &result);

  206.   cleanup_temps = make_cleanup (null_cleanup, NULL);
  207.   if (provider != NULL)
  208.     compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp"));
  209.   if (probe_name != NULL)
  210.     compile_rx_or_error (&probe_pat, probe_name, _("Invalid probe regexp"));
  211.   if (objname != NULL)
  212.     compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp"));

  213.   ALL_OBJFILES (objfile)
  214.     {
  215.       VEC (probe_p) *probes;
  216.       struct probe *probe;
  217.       int ix;

  218.       if (! objfile->sf || ! objfile->sf->sym_probe_fns)
  219.         continue;

  220.       if (objname)
  221.         {
  222.           if (regexec (&obj_pat, objfile_name (objfile), 0, NULL, 0) != 0)
  223.             continue;
  224.         }

  225.       probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);

  226.       for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
  227.         {
  228.           struct bound_probe bound;

  229.           if (pops != NULL && probe->pops != pops)
  230.             continue;

  231.           if (provider
  232.               && regexec (&prov_pat, probe->provider, 0, NULL, 0) != 0)
  233.             continue;

  234.           if (probe_name
  235.               && regexec (&probe_pat, probe->name, 0, NULL, 0) != 0)
  236.             continue;

  237.           bound.objfile = objfile;
  238.           bound.probe = probe;
  239.           VEC_safe_push (bound_probe_s, result, &bound);
  240.         }
  241.     }

  242.   do_cleanups (cleanup_temps);
  243.   discard_cleanups (cleanup);
  244.   return result;
  245. }

  246. /* A qsort comparison function for bound_probe_s objects.  */

  247. static int
  248. compare_probes (const void *a, const void *b)
  249. {
  250.   const struct bound_probe *pa = (const struct bound_probe *) a;
  251.   const struct bound_probe *pb = (const struct bound_probe *) b;
  252.   int v;

  253.   v = strcmp (pa->probe->provider, pb->probe->provider);
  254.   if (v)
  255.     return v;

  256.   v = strcmp (pa->probe->name, pb->probe->name);
  257.   if (v)
  258.     return v;

  259.   if (pa->probe->address < pb->probe->address)
  260.     return -1;
  261.   if (pa->probe->address > pb->probe->address)
  262.     return 1;

  263.   return strcmp (objfile_name (pa->objfile), objfile_name (pb->objfile));
  264. }

  265. /* Helper function that generate entries in the ui_out table being
  266.    crafted by `info_probes_for_ops'.  */

  267. static void
  268. gen_ui_out_table_header_info (VEC (bound_probe_s) *probes,
  269.                               const struct probe_ops *p)
  270. {
  271.   /* `headings' refers to the names of the columns when printing `info
  272.      probes'.  */
  273.   VEC (info_probe_column_s) *headings = NULL;
  274.   struct cleanup *c;
  275.   info_probe_column_s *column;
  276.   size_t headings_size;
  277.   int ix;

  278.   gdb_assert (p != NULL);

  279.   if (p->gen_info_probes_table_header == NULL
  280.       && p->gen_info_probes_table_values == NULL)
  281.     return;

  282.   gdb_assert (p->gen_info_probes_table_header != NULL
  283.               && p->gen_info_probes_table_values != NULL);

  284.   c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings);
  285.   p->gen_info_probes_table_header (&headings);

  286.   headings_size = VEC_length (info_probe_column_s, headings);

  287.   for (ix = 0;
  288.        VEC_iterate (info_probe_column_s, headings, ix, column);
  289.        ++ix)
  290.     {
  291.       struct bound_probe *probe;
  292.       int jx;
  293.       size_t size_max = strlen (column->print_name);

  294.       for (jx = 0; VEC_iterate (bound_probe_s, probes, jx, probe); ++jx)
  295.         {
  296.           /* `probe_fields' refers to the values of each new field that this
  297.              probe will display.  */
  298.           VEC (const_char_ptr) *probe_fields = NULL;
  299.           struct cleanup *c2;
  300.           const char *val;
  301.           int kx;

  302.           if (probe->probe->pops != p)
  303.             continue;

  304.           c2 = make_cleanup (VEC_cleanup (const_char_ptr), &probe_fields);
  305.           p->gen_info_probes_table_values (probe->probe, &probe_fields);

  306.           gdb_assert (VEC_length (const_char_ptr, probe_fields)
  307.                       == headings_size);

  308.           for (kx = 0; VEC_iterate (const_char_ptr, probe_fields, kx, val);
  309.                ++kx)
  310.             {
  311.               /* It is valid to have a NULL value here, which means that the
  312.                  backend does not have something to write and this particular
  313.                  field should be skipped.  */
  314.               if (val == NULL)
  315.                 continue;

  316.               size_max = max (strlen (val), size_max);
  317.             }
  318.           do_cleanups (c2);
  319.         }

  320.       ui_out_table_header (current_uiout, size_max, ui_left,
  321.                            column->field_name, column->print_name);
  322.     }

  323.   do_cleanups (c);
  324. }

  325. /* Helper function to print extra information about a probe and an objfile
  326.    represented by PROBE.  */

  327. static void
  328. print_ui_out_info (struct probe *probe)
  329. {
  330.   int ix;
  331.   int j = 0;
  332.   /* `values' refers to the actual values of each new field in the output
  333.      of `info probe'.  `headings' refers to the names of each new field.  */
  334.   VEC (const_char_ptr) *values = NULL;
  335.   VEC (info_probe_column_s) *headings = NULL;
  336.   info_probe_column_s *column;
  337.   struct cleanup *c;

  338.   gdb_assert (probe != NULL);
  339.   gdb_assert (probe->pops != NULL);

  340.   if (probe->pops->gen_info_probes_table_header == NULL
  341.       && probe->pops->gen_info_probes_table_values == NULL)
  342.     return;

  343.   gdb_assert (probe->pops->gen_info_probes_table_header != NULL
  344.               && probe->pops->gen_info_probes_table_values != NULL);

  345.   c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings);
  346.   make_cleanup (VEC_cleanup (const_char_ptr), &values);

  347.   probe->pops->gen_info_probes_table_header (&headings);
  348.   probe->pops->gen_info_probes_table_values (probe, &values);

  349.   gdb_assert (VEC_length (info_probe_column_s, headings)
  350.               == VEC_length (const_char_ptr, values));

  351.   for (ix = 0;
  352.        VEC_iterate (info_probe_column_s, headings, ix, column);
  353.        ++ix)
  354.     {
  355.       const char *val = VEC_index (const_char_ptr, values, j++);

  356.       if (val == NULL)
  357.         ui_out_field_skip (current_uiout, column->field_name);
  358.       else
  359.         ui_out_field_string (current_uiout, column->field_name, val);
  360.     }

  361.   do_cleanups (c);
  362. }

  363. /* Helper function that returns the number of extra fields which POPS will
  364.    need.  */

  365. static int
  366. get_number_extra_fields (const struct probe_ops *pops)
  367. {
  368.   VEC (info_probe_column_s) *headings = NULL;
  369.   struct cleanup *c;
  370.   int n;

  371.   if (pops->gen_info_probes_table_header == NULL)
  372.     return 0;

  373.   c = make_cleanup (VEC_cleanup (info_probe_column_s), &headings);
  374.   pops->gen_info_probes_table_header (&headings);

  375.   n = VEC_length (info_probe_column_s, headings);

  376.   do_cleanups (c);

  377.   return n;
  378. }

  379. /* See comment in probe.h.  */

  380. void
  381. info_probes_for_ops (const char *arg, int from_tty,
  382.                      const struct probe_ops *pops)
  383. {
  384.   char *provider, *probe_name = NULL, *objname = NULL;
  385.   struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
  386.   VEC (bound_probe_s) *probes;
  387.   int i, any_found;
  388.   int ui_out_extra_fields = 0;
  389.   size_t size_addr;
  390.   size_t size_name = strlen ("Name");
  391.   size_t size_objname = strlen ("Object");
  392.   size_t size_provider = strlen ("Provider");
  393.   struct bound_probe *probe;
  394.   struct gdbarch *gdbarch = get_current_arch ();

  395.   /* Do we have a `provider:probe:objfile' style of linespec?  */
  396.   provider = extract_arg_const (&arg);
  397.   if (provider)
  398.     {
  399.       make_cleanup (xfree, provider);

  400.       probe_name = extract_arg_const (&arg);
  401.       if (probe_name)
  402.         {
  403.           make_cleanup (xfree, probe_name);

  404.           objname = extract_arg_const (&arg);
  405.           if (objname)
  406.             make_cleanup (xfree, objname);
  407.         }
  408.     }

  409.   if (pops == NULL)
  410.     {
  411.       const struct probe_ops *po;
  412.       int ix;

  413.       /* If the probe_ops is NULL, it means the user has requested a "simple"
  414.          `info probes', i.e., she wants to print all information about all
  415.          probes.  For that, we have to identify how many extra fields we will
  416.          need to add in the ui_out table.

  417.          To do that, we iterate over all probe_ops, querying each one about
  418.          its extra fields, and incrementing `ui_out_extra_fields' to reflect
  419.          that number.  */

  420.       for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
  421.         ui_out_extra_fields += get_number_extra_fields (po);
  422.     }
  423.   else
  424.     ui_out_extra_fields = get_number_extra_fields (pops);

  425.   probes = collect_probes (objname, provider, probe_name, pops);
  426.   make_cleanup (VEC_cleanup (probe_p), &probes);
  427.   make_cleanup_ui_out_table_begin_end (current_uiout,
  428.                                        4 + ui_out_extra_fields,
  429.                                        VEC_length (bound_probe_s, probes),
  430.                                        "StaticProbes");

  431.   if (!VEC_empty (bound_probe_s, probes))
  432.     qsort (VEC_address (bound_probe_s, probes),
  433.            VEC_length (bound_probe_s, probes),
  434.            sizeof (bound_probe_s), compare_probes);

  435.   /* What's the size of an address in our architecture?  */
  436.   size_addr = gdbarch_addr_bit (gdbarch) == 64 ? 18 : 10;

  437.   /* Determining the maximum size of each field (`provider', `name' and
  438.      `objname').  */
  439.   for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
  440.     {
  441.       size_name = max (strlen (probe->probe->name), size_name);
  442.       size_provider = max (strlen (probe->probe->provider), size_provider);
  443.       size_objname = max (strlen (objfile_name (probe->objfile)), size_objname);
  444.     }

  445.   ui_out_table_header (current_uiout, size_provider, ui_left, "provider",
  446.                        _("Provider"));
  447.   ui_out_table_header (current_uiout, size_name, ui_left, "name", _("Name"));
  448.   ui_out_table_header (current_uiout, size_addr, ui_left, "addr", _("Where"));

  449.   if (pops == NULL)
  450.     {
  451.       const struct probe_ops *po;
  452.       int ix;

  453.       /* We have to generate the table header for each new probe type that we
  454.          will print.  */
  455.       for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
  456.         gen_ui_out_table_header_info (probes, po);
  457.     }
  458.   else
  459.     gen_ui_out_table_header_info (probes, pops);

  460.   ui_out_table_header (current_uiout, size_objname, ui_left, "object",
  461.                        _("Object"));
  462.   ui_out_table_body (current_uiout);

  463.   for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
  464.     {
  465.       struct cleanup *inner;

  466.       inner = make_cleanup_ui_out_tuple_begin_end (current_uiout, "probe");

  467.       ui_out_field_string (current_uiout, "provider", probe->probe->provider);
  468.       ui_out_field_string (current_uiout, "name", probe->probe->name);
  469.       ui_out_field_core_addr (current_uiout, "addr",
  470.                               probe->probe->arch,
  471.                               get_probe_address (probe->probe, probe->objfile));

  472.       if (pops == NULL)
  473.         {
  474.           const struct probe_ops *po;
  475.           int ix;

  476.           for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po);
  477.                ++ix)
  478.             if (probe->probe->pops == po)
  479.               print_ui_out_info (probe->probe);
  480.         }
  481.       else
  482.         print_ui_out_info (probe->probe);

  483.       ui_out_field_string (current_uiout, "object",
  484.                            objfile_name (probe->objfile));
  485.       ui_out_text (current_uiout, "\n");

  486.       do_cleanups (inner);
  487.     }

  488.   any_found = !VEC_empty (bound_probe_s, probes);
  489.   do_cleanups (cleanup);

  490.   if (!any_found)
  491.     ui_out_message (current_uiout, 0, _("No probes matched.\n"));
  492. }

  493. /* Implementation of the `info probes' command.  */

  494. static void
  495. info_probes_command (char *arg, int from_tty)
  496. {
  497.   info_probes_for_ops (arg, from_tty, NULL);
  498. }

  499. /* See comments in probe.h.  */

  500. CORE_ADDR
  501. get_probe_address (struct probe *probe, struct objfile *objfile)
  502. {
  503.   return probe->pops->get_probe_address (probe, objfile);
  504. }

  505. /* See comments in probe.h.  */

  506. unsigned
  507. get_probe_argument_count (struct probe *probe, struct frame_info *frame)
  508. {
  509.   return probe->pops->get_probe_argument_count (probe, frame);
  510. }

  511. /* See comments in probe.h.  */

  512. int
  513. can_evaluate_probe_arguments (struct probe *probe)
  514. {
  515.   return probe->pops->can_evaluate_probe_arguments (probe);
  516. }

  517. /* See comments in probe.h.  */

  518. struct value *
  519. evaluate_probe_argument (struct probe *probe, unsigned n,
  520.                          struct frame_info *frame)
  521. {
  522.   return probe->pops->evaluate_probe_argument (probe, n, frame);
  523. }

  524. /* See comments in probe.h.  */

  525. struct value *
  526. probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
  527. {
  528.   struct bound_probe probe;
  529.   unsigned n_args;

  530.   probe = find_probe_by_pc (get_frame_pc (frame));
  531.   if (!probe.probe)
  532.     return NULL;

  533.   n_args = get_probe_argument_count (probe.probe, frame);
  534.   if (n >= n_args)
  535.     return NULL;

  536.   return evaluate_probe_argument (probe.probe, n, frame);
  537. }

  538. /* See comment in probe.h.  */

  539. const struct probe_ops *
  540. probe_linespec_to_ops (const char **linespecp)
  541. {
  542.   int ix;
  543.   const struct probe_ops *probe_ops;

  544.   for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops); ix++)
  545.     if (probe_ops->is_linespec (linespecp))
  546.       return probe_ops;

  547.   return NULL;
  548. }

  549. /* See comment in probe.h.  */

  550. int
  551. probe_is_linespec_by_keyword (const char **linespecp, const char *const *keywords)
  552. {
  553.   const char *s = *linespecp;
  554.   const char *const *csp;

  555.   for (csp = keywords; *csp; csp++)
  556.     {
  557.       const char *keyword = *csp;
  558.       size_t len = strlen (keyword);

  559.       if (strncmp (s, keyword, len) == 0 && isspace (s[len]))
  560.         {
  561.           *linespecp += len + 1;
  562.           return 1;
  563.         }
  564.     }

  565.   return 0;
  566. }

  567. /* Implementation of `is_linespec' method for `struct probe_ops'.  */

  568. static int
  569. probe_any_is_linespec (const char **linespecp)
  570. {
  571.   static const char *const keywords[] = { "-p", "-probe", NULL };

  572.   return probe_is_linespec_by_keyword (linespecp, keywords);
  573. }

  574. /* Dummy method used for `probe_ops_any'.  */

  575. static void
  576. probe_any_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
  577. {
  578.   /* No probes can be provided by this dummy backend.  */
  579. }

  580. /* Operations associated with a generic probe.  */

  581. const struct probe_ops probe_ops_any =
  582. {
  583.   probe_any_is_linespec,
  584.   probe_any_get_probes,
  585. };

  586. /* See comments in probe.h.  */

  587. struct cmd_list_element **
  588. info_probes_cmdlist_get (void)
  589. {
  590.   static struct cmd_list_element *info_probes_cmdlist;

  591.   if (info_probes_cmdlist == NULL)
  592.     add_prefix_cmd ("probes", class_info, info_probes_command,
  593.                     _("\
  594. Show available static probes.\n\
  595. Usage: info probes [all|TYPE [ARGS]]\n\
  596. TYPE specifies the type of the probe, and can be one of the following:\n\
  597.   - stap\n\
  598. If you specify TYPE, there may be additional arguments needed by the\n\
  599. subcommand.\n\
  600. If you do not specify any argument, or specify `all', then the command\n\
  601. will show information about all types of probes."),
  602.                     &info_probes_cmdlist, "info probes ",
  603.                     0/*allow-unknown*/, &infolist);

  604.   return &info_probes_cmdlist;
  605. }

  606. VEC (probe_ops_cp) *all_probe_ops;

  607. void _initialize_probe (void);

  608. void
  609. _initialize_probe (void)
  610. {
  611.   VEC_safe_push (probe_ops_cp, all_probe_ops, &probe_ops_any);

  612.   add_cmd ("all", class_info, info_probes_command,
  613.            _("\
  614. Show information about all type of probes."),
  615.            info_probes_cmdlist_get ());
  616. }