gdb/probe.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Generic SDT 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. #if !defined (PROBE_H)
  15. #define PROBE_H 1

  16. #include "gdb_vecs.h"

  17. /* Definition of a vector of probes.  */

  18. typedef struct probe *probe_p;
  19. DEF_VEC_P (probe_p);

  20. struct linespec_result;

  21. /* Structure useful for passing the header names in the method
  22.    `gen_ui_out_table_header'.  */

  23. struct info_probe_column
  24.   {
  25.     /* The internal name of the field.  This string cannot be capitalized nor
  26.        localized, e.g., "extra_field".  */

  27.     const char *field_name;

  28.     /* The field name to be printed in the `info probes' command.  This
  29.        string can be capitalized and localized, e.g., _("Extra Field").  */
  30.     const char *print_name;
  31.   };

  32. typedef struct info_probe_column info_probe_column_s;
  33. DEF_VEC_O (info_probe_column_s);

  34. /* Operations associated with a probe.  */

  35. struct probe_ops
  36.   {
  37.     /* Method responsible for verifying if LINESPECP is a valid linespec for
  38.        a probe breakpoint.  It should return 1 if it is, or zero if it is not.
  39.        It also should update LINESPECP in order to discard the breakpoint
  40.        option associated with this linespec.  For example, if the option is
  41.        `-probe', and the LINESPECP is `-probe abc', the function should
  42.        return 1 and set LINESPECP to `abc'.  */

  43.     int (*is_linespec) (const char **linespecp);

  44.     /* Function that should fill PROBES with known probes from OBJFILE.  */

  45.     void (*get_probes) (VEC (probe_p) **probes, struct objfile *objfile);

  46.     /* Compute the probe's relocated address.  OBJFILE is the objfile
  47.        in which the probe originated.  */

  48.     CORE_ADDR (*get_probe_address) (struct probe *probe,
  49.                                     struct objfile *objfile);

  50.     /* Return the number of arguments of PROBE.  */

  51.     unsigned (*get_probe_argument_count) (struct probe *probe,
  52.                                           struct frame_info *frame);

  53.     /* Return 1 if the probe interface can evaluate the arguments of probe
  54.        PROBE, zero otherwise.  See the comments on
  55.        sym_probe_fns:can_evaluate_probe_arguments for more details.  */

  56.     int (*can_evaluate_probe_arguments) (struct probe *probe);

  57.     /* Evaluate the Nth argument from the PROBE, returning a value
  58.        corresponding to it.  The argument number is represented N.  */

  59.     struct value *(*evaluate_probe_argument) (struct probe *probe,
  60.                                               unsigned n,
  61.                                               struct frame_info *frame);

  62.     /* Compile the Nth argument of the PROBE to an agent expression.
  63.        The argument number is represented by N.  */

  64.     void (*compile_to_ax) (struct probe *probe, struct agent_expr *aexpr,
  65.                            struct axs_value *axs_value, unsigned n);

  66.     /* Set the semaphore associated with the PROBE.  This function only makes
  67.        sense if the probe has a concept of semaphore associated to a
  68.        probe, otherwise it can be set to NULL.  */

  69.     void (*set_semaphore) (struct probe *probe, struct objfile *objfile,
  70.                            struct gdbarch *gdbarch);

  71.     /* Clear the semaphore associated with the PROBE.  This function only
  72.        makes sense if the probe has a concept of semaphore associated to
  73.        a probe, otherwise it can be set to NULL.  */

  74.     void (*clear_semaphore) (struct probe *probe, struct objfile *objfile,
  75.                              struct gdbarch *gdbarch);

  76.     /* Function called to destroy PROBE's specific data.  This function
  77.        shall not free PROBE itself.  */

  78.     void (*destroy) (struct probe *probe);

  79.     /* Function responsible for providing the extra fields that will be
  80.        printed in the `info probes' command.  It should fill HEADS
  81.        with whatever extra fields it needs.  If the backend doesn't need
  82.        to print extra fields, it can set this method to NULL.  */

  83.     void (*gen_info_probes_table_header) (VEC (info_probe_column_s) **heads);

  84.     /* Function that will fill VALUES with the values of the extra fields
  85.        to be printed for PROBE.  If the backend implements the
  86.        `gen_ui_out_table_header' method, then it should implement
  87.        this method as well.  The backend should also guarantee that the
  88.        order and the number of values in the vector is exactly the same
  89.        as the order of the extra fields provided in the method
  90.        `gen_ui_out_table_header'.  If a certain field is to be skipped
  91.        when printing the information, you can push a NULL value in that
  92.        position in the vector.  */

  93.     void (*gen_info_probes_table_values) (struct probe *probe,
  94.                                           VEC (const_char_ptr) **values);
  95.   };

  96. /* Definition of a vector of probe_ops.  */

  97. typedef const struct probe_ops *probe_ops_cp;
  98. DEF_VEC_P (probe_ops_cp);
  99. extern VEC (probe_ops_cp) *all_probe_ops;

  100. /* The probe_ops associated with the generic probe.  */

  101. extern const struct probe_ops probe_ops_any;

  102. /* Helper function that, given KEYWORDS, iterate over it trying to match
  103.    each keyword with LINESPECP.  If it succeeds, it updates the LINESPECP
  104.    pointer and returns 1.  Otherwise, nothing is done to LINESPECP and zero
  105.    is returned.  */

  106. extern int probe_is_linespec_by_keyword (const char **linespecp,
  107.                                          const char *const *keywords);

  108. /* Return specific PROBE_OPS * matching *LINESPECP and possibly updating
  109.    *LINESPECP to skip its "-probe-type " prefix.  Return &probe_ops_any if
  110.    *LINESPECP matches "-probe ", that is any unspecific probe.  Return NULL if
  111.    *LINESPECP is not identified as any known probe type, *LINESPECP is not
  112.    modified in such case.  */

  113. extern const struct probe_ops *probe_linespec_to_ops (const char **linespecp);

  114. /* The probe itself.  The struct contains generic information about the
  115.    probe, and then some specific information which should be stored in
  116.    the `probe_info' field.  */

  117. struct probe
  118.   {
  119.     /* The operations associated with this probe.  */
  120.     const struct probe_ops *pops;

  121.     /* The probe's architecture.  */
  122.     struct gdbarch *arch;

  123.     /* The name of the probe.  */
  124.     const char *name;

  125.     /* The provider of the probe.  It generally defaults to the name of
  126.        the objfile which contains the probe.  */
  127.     const char *provider;

  128.     /* The address where the probe is inserted, relative to
  129.        SECT_OFF_TEXT.  */
  130.     CORE_ADDR address;
  131.   };

  132. /* A bound probe holds a pointer to a probe and a pointer to the
  133.    probe's defining objfile.  This is needed because probes are
  134.    independent of the program space and thus require relocation at
  135.    their point of use.  */

  136. struct bound_probe
  137.   {
  138.     /* The probe.  */

  139.     struct probe *probe;

  140.     /* The objfile in which the probe originated.  */

  141.     struct objfile *objfile;
  142.   };

  143. /* A helper for linespec that decodes a probe specification.  It returns a
  144.    symtabs_and_lines object and updates *ARGPTR or throws an error.  */

  145. extern struct symtabs_and_lines parse_probes (char **argptr,
  146.                                               struct linespec_result *canon);

  147. /* Helper function to register the proper probe_ops to a newly created probe.
  148.    This function is mainly called from `sym_get_probes'.  */

  149. extern void register_probe_ops (struct probe *probe);

  150. /* Given a PC, find an associated probe.  If a probe is found, return
  151.    it.  If no probe is found, return a bound probe whose fields are
  152.    both NULL.  */

  153. extern struct bound_probe find_probe_by_pc (CORE_ADDR pc);

  154. /* Search OBJFILE for a probe with the given PROVIDER, NAME.  Return a
  155.    VEC of all probes that were found.  If no matching probe is found,
  156.    return NULL.  The caller must free the VEC.  */

  157. extern VEC (probe_p) *find_probes_in_objfile (struct objfile *objfile,
  158.                                               const char *provider,
  159.                                               const char *name);

  160. /* Generate a `info probes' command output for probe_ops represented by
  161.    POPS.  If POPS is NULL it considers any probes types.  It is a helper
  162.    function that can be used by the probe backends to print their
  163.    `info probe TYPE'.  */

  164. extern void info_probes_for_ops (const char *arg, int from_tty,
  165.                                  const struct probe_ops *pops);

  166. /* Return the `cmd_list_element' associated with the `info probes' command,
  167.    or create a new one if it doesn't exist.  Helper function that serves the
  168.    purpose of avoiding the case of a backend using the `cmd_list_element'
  169.    associated with `info probes', without having it registered yet.  */

  170. extern struct cmd_list_element **info_probes_cmdlist_get (void);

  171. /* Compute the probe's relocated address.  OBJFILE is the objfile in
  172.    which the probe originated.  */

  173. extern CORE_ADDR get_probe_address (struct probe *probe,
  174.                                     struct objfile *objfile);

  175. /* Return the argument count of the specified probe.  */

  176. extern unsigned get_probe_argument_count (struct probe *probe,
  177.                                           struct frame_info *frame);

  178. /* Return 1 if the probe interface associated with PROBE can evaluate
  179.    arguments, zero otherwise.  See the comments on the definition of
  180.    sym_probe_fns:can_evaluate_probe_arguments for more details.  */

  181. extern int can_evaluate_probe_arguments (struct probe *probe);

  182. /* Evaluate argument N of the specified probeN must be between 0
  183.    inclusive and get_probe_argument_count exclusive.  */

  184. extern struct value *evaluate_probe_argument (struct probe *probe,
  185.                                               unsigned n,
  186.                                               struct frame_info *frame);

  187. /* A convenience function that finds a probe at the PC in FRAME and
  188.    evaluates argument N, with 0 <= N < number_of_args.  If there is no
  189.    probe at that location, or if the probe does not have enough arguments,
  190.    this returns NULL.  */

  191. extern struct value *probe_safe_evaluate_at_pc (struct frame_info *frame,
  192.                                                 unsigned n);

  193. #endif /* !defined (PROBE_H) */