Print this page
7085 add support for "if" and "else" statements in dtrace


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2013 by Delphix. All rights reserved.
  29  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  30  */
  31 
  32 #ifndef _DTRACE_H
  33 #define _DTRACE_H
  34 
  35 #include <sys/dtrace.h>
  36 #include <stdarg.h>
  37 #include <stdio.h>
  38 #include <gelf.h>
  39 
  40 #ifdef  __cplusplus
  41 extern "C" {
  42 #endif
  43 
  44 /*
  45  * DTrace Dynamic Tracing Software: Library Interfaces
  46  *
  47  * Note: The contents of this file are private to the implementation of the
  48  * Solaris system and DTrace subsystem and are subject to change at any time
  49  * without notice.  Applications and drivers using these interfaces will fail
  50  * to run on future releases.  These interfaces should not be used for any
  51  * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
  52  * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
  53  */
  54 
  55 #define DTRACE_VERSION  3               /* library ABI interface version */
  56 
  57 struct ps_prochandle;

  58 typedef struct dtrace_hdl dtrace_hdl_t;
  59 typedef struct dtrace_prog dtrace_prog_t;
  60 typedef struct dtrace_vector dtrace_vector_t;
  61 typedef struct dtrace_aggdata dtrace_aggdata_t;
  62 
  63 #define DTRACE_O_NODEV          0x01    /* do not open dtrace(7D) device */
  64 #define DTRACE_O_NOSYS          0x02    /* do not load /system/object modules */
  65 #define DTRACE_O_LP64           0x04    /* force D compiler to be LP64 */
  66 #define DTRACE_O_ILP32          0x08    /* force D compiler to be ILP32 */
  67 #define DTRACE_O_MASK           0x0f    /* mask of valid flags to dtrace_open */
  68 
  69 extern dtrace_hdl_t *dtrace_open(int, int, int *);
  70 extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
  71     const dtrace_vector_t *, void *);
  72 
  73 extern int dtrace_go(dtrace_hdl_t *);
  74 extern int dtrace_stop(dtrace_hdl_t *);
  75 extern void dtrace_sleep(dtrace_hdl_t *);
  76 extern void dtrace_close(dtrace_hdl_t *);
  77 


  94  * Once created, callers can examine the list of program statements and
  95  * enable the probes and actions described by these statements.
  96  */
  97 
  98 typedef struct dtrace_proginfo {
  99         dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */
 100         dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */
 101         uint_t dpi_aggregates;  /* number of aggregates specified in program */
 102         uint_t dpi_recgens;     /* number of record generating probes in prog */
 103         uint_t dpi_matches;     /* number of probes matched by program */
 104         uint_t dpi_speculations; /* number of speculations specified in prog */
 105 } dtrace_proginfo_t;
 106 
 107 #define DTRACE_C_DIFV   0x0001  /* DIF verbose mode: show each compiled DIFO */
 108 #define DTRACE_C_EMPTY  0x0002  /* Permit compilation of empty D source files */
 109 #define DTRACE_C_ZDEFS  0x0004  /* Permit probe defs that match zero probes */
 110 #define DTRACE_C_EATTR  0x0008  /* Error if program attributes less than min */
 111 #define DTRACE_C_CPP    0x0010  /* Preprocess input file with cpp(1) utility */
 112 #define DTRACE_C_KNODEF 0x0020  /* Permit unresolved kernel symbols in DIFO */
 113 #define DTRACE_C_UNODEF 0x0040  /* Permit unresolved user symbols in DIFO */
 114 #define DTRACE_C_PSPEC  0x0080  /* Intepret ambiguous specifiers as probes */
 115 #define DTRACE_C_ETAGS  0x0100  /* Prefix error messages with error tags */
 116 #define DTRACE_C_ARGREF 0x0200  /* Do not require all macro args to be used */
 117 #define DTRACE_C_DEFARG 0x0800  /* Use 0/"" as value for unspecified args */
 118 #define DTRACE_C_NOLIBS 0x1000  /* Do not process D system libraries */
 119 #define DTRACE_C_CTL    0x2000  /* Only process control directives */
 120 #define DTRACE_C_MASK   0x3bff  /* mask of all valid flags to dtrace_*compile */
 121 
 122 extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
 123     const char *, dtrace_probespec_t, uint_t, int, char *const []);
 124 
 125 extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *,
 126     FILE *, uint_t, int, char *const []);
 127 
 128 extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *,
 129     dtrace_proginfo_t *);
 130 extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *,
 131     dtrace_proginfo_t *);
 132 
 133 #define DTRACE_D_STRIP  0x01    /* strip non-loadable sections from program */
 134 #define DTRACE_D_PROBES 0x02    /* include provider and probe definitions */


 502         const char *dtt_object;                 /* object containing type */
 503         ctf_file_t *dtt_ctfp;                   /* CTF container handle */
 504         ctf_id_t dtt_type;                      /* CTF type identifier */
 505         uint_t dtt_flags;                       /* Misc. flags */
 506 } dtrace_typeinfo_t;
 507 
 508 #define DTT_FL_USER     0x1                     /* user type */
 509 
 510 extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
 511     dtrace_typeinfo_t *);
 512 
 513 extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *,
 514     const dtrace_syminfo_t *, dtrace_typeinfo_t *);
 515 
 516 extern int dtrace_type_strcompile(dtrace_hdl_t *,
 517     const char *, dtrace_typeinfo_t *);
 518 
 519 extern int dtrace_type_fcompile(dtrace_hdl_t *,
 520     FILE *, dtrace_typeinfo_t *);
 521 




 522 /*
 523  * DTrace Probe Interface
 524  *
 525  * Library clients can use these functions to iterate over the set of available
 526  * probe definitions and inquire as to their attributes.  The probe iteration
 527  * interfaces report probes that are declared as well as those from dtrace(7D).
 528  */
 529 typedef struct dtrace_probeinfo {
 530         dtrace_attribute_t dtp_attr;            /* name attributes */
 531         dtrace_attribute_t dtp_arga;            /* arg attributes */
 532         const dtrace_typeinfo_t *dtp_argv;      /* arg types */
 533         int dtp_argc;                           /* arg count */
 534 } dtrace_probeinfo_t;
 535 
 536 typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *);
 537 
 538 extern int dtrace_probe_iter(dtrace_hdl_t *,
 539     const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *);
 540 
 541 extern int dtrace_probe_info(dtrace_hdl_t *,




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2014 by Delphix. All rights reserved.
  29  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  30  */
  31 
  32 #ifndef _DTRACE_H
  33 #define _DTRACE_H
  34 
  35 #include <sys/dtrace.h>
  36 #include <stdarg.h>
  37 #include <stdio.h>
  38 #include <gelf.h>
  39 
  40 #ifdef  __cplusplus
  41 extern "C" {
  42 #endif
  43 
  44 /*
  45  * DTrace Dynamic Tracing Software: Library Interfaces
  46  *
  47  * Note: The contents of this file are private to the implementation of the
  48  * Solaris system and DTrace subsystem and are subject to change at any time
  49  * without notice.  Applications and drivers using these interfaces will fail
  50  * to run on future releases.  These interfaces should not be used for any
  51  * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
  52  * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
  53  */
  54 
  55 #define DTRACE_VERSION  3               /* library ABI interface version */
  56 
  57 struct ps_prochandle;
  58 struct dt_node;
  59 typedef struct dtrace_hdl dtrace_hdl_t;
  60 typedef struct dtrace_prog dtrace_prog_t;
  61 typedef struct dtrace_vector dtrace_vector_t;
  62 typedef struct dtrace_aggdata dtrace_aggdata_t;
  63 
  64 #define DTRACE_O_NODEV          0x01    /* do not open dtrace(7D) device */
  65 #define DTRACE_O_NOSYS          0x02    /* do not load /system/object modules */
  66 #define DTRACE_O_LP64           0x04    /* force D compiler to be LP64 */
  67 #define DTRACE_O_ILP32          0x08    /* force D compiler to be ILP32 */
  68 #define DTRACE_O_MASK           0x0f    /* mask of valid flags to dtrace_open */
  69 
  70 extern dtrace_hdl_t *dtrace_open(int, int, int *);
  71 extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
  72     const dtrace_vector_t *, void *);
  73 
  74 extern int dtrace_go(dtrace_hdl_t *);
  75 extern int dtrace_stop(dtrace_hdl_t *);
  76 extern void dtrace_sleep(dtrace_hdl_t *);
  77 extern void dtrace_close(dtrace_hdl_t *);
  78 


  95  * Once created, callers can examine the list of program statements and
  96  * enable the probes and actions described by these statements.
  97  */
  98 
  99 typedef struct dtrace_proginfo {
 100         dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */
 101         dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */
 102         uint_t dpi_aggregates;  /* number of aggregates specified in program */
 103         uint_t dpi_recgens;     /* number of record generating probes in prog */
 104         uint_t dpi_matches;     /* number of probes matched by program */
 105         uint_t dpi_speculations; /* number of speculations specified in prog */
 106 } dtrace_proginfo_t;
 107 
 108 #define DTRACE_C_DIFV   0x0001  /* DIF verbose mode: show each compiled DIFO */
 109 #define DTRACE_C_EMPTY  0x0002  /* Permit compilation of empty D source files */
 110 #define DTRACE_C_ZDEFS  0x0004  /* Permit probe defs that match zero probes */
 111 #define DTRACE_C_EATTR  0x0008  /* Error if program attributes less than min */
 112 #define DTRACE_C_CPP    0x0010  /* Preprocess input file with cpp(1) utility */
 113 #define DTRACE_C_KNODEF 0x0020  /* Permit unresolved kernel symbols in DIFO */
 114 #define DTRACE_C_UNODEF 0x0040  /* Permit unresolved user symbols in DIFO */
 115 #define DTRACE_C_PSPEC  0x0080  /* Interpret ambiguous specifiers as probes */
 116 #define DTRACE_C_ETAGS  0x0100  /* Prefix error messages with error tags */
 117 #define DTRACE_C_ARGREF 0x0200  /* Do not require all macro args to be used */
 118 #define DTRACE_C_DEFARG 0x0800  /* Use 0/"" as value for unspecified args */
 119 #define DTRACE_C_NOLIBS 0x1000  /* Do not process D system libraries */
 120 #define DTRACE_C_CTL    0x2000  /* Only process control directives */
 121 #define DTRACE_C_MASK   0x3bff  /* mask of all valid flags to dtrace_*compile */
 122 
 123 extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
 124     const char *, dtrace_probespec_t, uint_t, int, char *const []);
 125 
 126 extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *,
 127     FILE *, uint_t, int, char *const []);
 128 
 129 extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *,
 130     dtrace_proginfo_t *);
 131 extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *,
 132     dtrace_proginfo_t *);
 133 
 134 #define DTRACE_D_STRIP  0x01    /* strip non-loadable sections from program */
 135 #define DTRACE_D_PROBES 0x02    /* include provider and probe definitions */


 503         const char *dtt_object;                 /* object containing type */
 504         ctf_file_t *dtt_ctfp;                   /* CTF container handle */
 505         ctf_id_t dtt_type;                      /* CTF type identifier */
 506         uint_t dtt_flags;                       /* Misc. flags */
 507 } dtrace_typeinfo_t;
 508 
 509 #define DTT_FL_USER     0x1                     /* user type */
 510 
 511 extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
 512     dtrace_typeinfo_t *);
 513 
 514 extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *,
 515     const dtrace_syminfo_t *, dtrace_typeinfo_t *);
 516 
 517 extern int dtrace_type_strcompile(dtrace_hdl_t *,
 518     const char *, dtrace_typeinfo_t *);
 519 
 520 extern int dtrace_type_fcompile(dtrace_hdl_t *,
 521     FILE *, dtrace_typeinfo_t *);
 522 
 523 extern struct dt_node *dt_compile_sugar(dtrace_hdl_t *,
 524     struct dt_node *);
 525 
 526 
 527 /*
 528  * DTrace Probe Interface
 529  *
 530  * Library clients can use these functions to iterate over the set of available
 531  * probe definitions and inquire as to their attributes.  The probe iteration
 532  * interfaces report probes that are declared as well as those from dtrace(7D).
 533  */
 534 typedef struct dtrace_probeinfo {
 535         dtrace_attribute_t dtp_attr;            /* name attributes */
 536         dtrace_attribute_t dtp_arga;            /* arg attributes */
 537         const dtrace_typeinfo_t *dtp_argv;      /* arg types */
 538         int dtp_argc;                           /* arg count */
 539 } dtrace_probeinfo_t;
 540 
 541 typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *);
 542 
 543 extern int dtrace_probe_iter(dtrace_hdl_t *,
 544     const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *);
 545 
 546 extern int dtrace_probe_info(dtrace_hdl_t *,