Print this page
4471 DTrace count() with histogram
4472 DTrace full width distribution histograms
4473 DTrace frequency trails
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdtrace/common/dtrace.h
+++ new/usr/src/lib/libdtrace/common/dtrace.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright (c) 2013 by Delphix. All rights reserved.
29 29 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
30 30 */
31 31
32 32 #ifndef _DTRACE_H
33 33 #define _DTRACE_H
34 34
35 35 #include <sys/dtrace.h>
36 36 #include <stdarg.h>
37 37 #include <stdio.h>
38 38 #include <gelf.h>
39 39
40 40 #ifdef __cplusplus
41 41 extern "C" {
42 42 #endif
43 43
44 44 /*
45 45 * DTrace Dynamic Tracing Software: Library Interfaces
46 46 *
47 47 * Note: The contents of this file are private to the implementation of the
48 48 * Solaris system and DTrace subsystem and are subject to change at any time
49 49 * without notice. Applications and drivers using these interfaces will fail
50 50 * to run on future releases. These interfaces should not be used for any
51 51 * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
52 52 * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
53 53 */
54 54
55 55 #define DTRACE_VERSION 3 /* library ABI interface version */
56 56
57 57 struct ps_prochandle;
58 58 typedef struct dtrace_hdl dtrace_hdl_t;
59 59 typedef struct dtrace_prog dtrace_prog_t;
60 60 typedef struct dtrace_vector dtrace_vector_t;
61 61 typedef struct dtrace_aggdata dtrace_aggdata_t;
62 62
63 63 #define DTRACE_O_NODEV 0x01 /* do not open dtrace(7D) device */
64 64 #define DTRACE_O_NOSYS 0x02 /* do not load /system/object modules */
65 65 #define DTRACE_O_LP64 0x04 /* force D compiler to be LP64 */
66 66 #define DTRACE_O_ILP32 0x08 /* force D compiler to be ILP32 */
67 67 #define DTRACE_O_MASK 0x0f /* mask of valid flags to dtrace_open */
68 68
69 69 extern dtrace_hdl_t *dtrace_open(int, int, int *);
70 70 extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
71 71 const dtrace_vector_t *, void *);
72 72
73 73 extern int dtrace_go(dtrace_hdl_t *);
74 74 extern int dtrace_stop(dtrace_hdl_t *);
75 75 extern void dtrace_sleep(dtrace_hdl_t *);
76 76 extern void dtrace_close(dtrace_hdl_t *);
77 77
78 78 extern int dtrace_errno(dtrace_hdl_t *);
79 79 extern const char *dtrace_errmsg(dtrace_hdl_t *, int);
80 80 extern const char *dtrace_faultstr(dtrace_hdl_t *, int);
81 81 extern const char *dtrace_subrstr(dtrace_hdl_t *, int);
82 82
83 83 extern int dtrace_setopt(dtrace_hdl_t *, const char *, const char *);
84 84 extern int dtrace_getopt(dtrace_hdl_t *, const char *, dtrace_optval_t *);
85 85
86 86 extern void dtrace_update(dtrace_hdl_t *);
87 87 extern int dtrace_ctlfd(dtrace_hdl_t *);
88 88
89 89 /*
90 90 * DTrace Program Interface
91 91 *
92 92 * DTrace programs can be created by compiling ASCII text files containing
93 93 * D programs or by compiling in-memory C strings that specify a D program.
94 94 * Once created, callers can examine the list of program statements and
95 95 * enable the probes and actions described by these statements.
96 96 */
97 97
98 98 typedef struct dtrace_proginfo {
99 99 dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */
100 100 dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */
101 101 uint_t dpi_aggregates; /* number of aggregates specified in program */
102 102 uint_t dpi_recgens; /* number of record generating probes in prog */
103 103 uint_t dpi_matches; /* number of probes matched by program */
104 104 uint_t dpi_speculations; /* number of speculations specified in prog */
105 105 } dtrace_proginfo_t;
106 106
107 107 #define DTRACE_C_DIFV 0x0001 /* DIF verbose mode: show each compiled DIFO */
108 108 #define DTRACE_C_EMPTY 0x0002 /* Permit compilation of empty D source files */
109 109 #define DTRACE_C_ZDEFS 0x0004 /* Permit probe defs that match zero probes */
110 110 #define DTRACE_C_EATTR 0x0008 /* Error if program attributes less than min */
111 111 #define DTRACE_C_CPP 0x0010 /* Preprocess input file with cpp(1) utility */
112 112 #define DTRACE_C_KNODEF 0x0020 /* Permit unresolved kernel symbols in DIFO */
113 113 #define DTRACE_C_UNODEF 0x0040 /* Permit unresolved user symbols in DIFO */
114 114 #define DTRACE_C_PSPEC 0x0080 /* Intepret ambiguous specifiers as probes */
115 115 #define DTRACE_C_ETAGS 0x0100 /* Prefix error messages with error tags */
116 116 #define DTRACE_C_ARGREF 0x0200 /* Do not require all macro args to be used */
117 117 #define DTRACE_C_DEFARG 0x0800 /* Use 0/"" as value for unspecified args */
118 118 #define DTRACE_C_NOLIBS 0x1000 /* Do not process D system libraries */
119 119 #define DTRACE_C_CTL 0x2000 /* Only process control directives */
120 120 #define DTRACE_C_MASK 0x3bff /* mask of all valid flags to dtrace_*compile */
121 121
122 122 extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
123 123 const char *, dtrace_probespec_t, uint_t, int, char *const []);
124 124
125 125 extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *,
126 126 FILE *, uint_t, int, char *const []);
127 127
128 128 extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *,
129 129 dtrace_proginfo_t *);
130 130 extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *,
131 131 dtrace_proginfo_t *);
132 132
133 133 #define DTRACE_D_STRIP 0x01 /* strip non-loadable sections from program */
134 134 #define DTRACE_D_PROBES 0x02 /* include provider and probe definitions */
135 135 #define DTRACE_D_MASK 0x03 /* mask of valid flags to dtrace_dof_create */
136 136
137 137 extern int dtrace_program_link(dtrace_hdl_t *, dtrace_prog_t *,
138 138 uint_t, const char *, int, char *const []);
139 139
140 140 extern int dtrace_program_header(dtrace_hdl_t *, FILE *, const char *);
141 141
142 142 extern void *dtrace_dof_create(dtrace_hdl_t *, dtrace_prog_t *, uint_t);
143 143 extern void dtrace_dof_destroy(dtrace_hdl_t *, void *);
144 144
145 145 extern void *dtrace_getopt_dof(dtrace_hdl_t *);
146 146 extern void *dtrace_geterr_dof(dtrace_hdl_t *);
147 147
148 148 typedef struct dtrace_stmtdesc {
149 149 dtrace_ecbdesc_t *dtsd_ecbdesc; /* ECB description */
150 150 dtrace_actdesc_t *dtsd_action; /* action list */
151 151 dtrace_actdesc_t *dtsd_action_last; /* last action in action list */
152 152 void *dtsd_aggdata; /* aggregation data */
153 153 void *dtsd_fmtdata; /* type-specific output data */
154 154 void *dtsd_strdata; /* type-specific string data */
155 155 void (*dtsd_callback)(); /* callback function for EPID */
156 156 void *dtsd_data; /* callback data pointer */
157 157 dtrace_attribute_t dtsd_descattr; /* probedesc attributes */
158 158 dtrace_attribute_t dtsd_stmtattr; /* statement attributes */
159 159 } dtrace_stmtdesc_t;
160 160
161 161 typedef int dtrace_stmt_f(dtrace_hdl_t *, dtrace_prog_t *,
162 162 dtrace_stmtdesc_t *, void *);
163 163
164 164 extern dtrace_stmtdesc_t *dtrace_stmt_create(dtrace_hdl_t *,
165 165 dtrace_ecbdesc_t *);
166 166 extern dtrace_actdesc_t *dtrace_stmt_action(dtrace_hdl_t *,
167 167 dtrace_stmtdesc_t *);
168 168 extern int dtrace_stmt_add(dtrace_hdl_t *, dtrace_prog_t *,
169 169 dtrace_stmtdesc_t *);
170 170 extern int dtrace_stmt_iter(dtrace_hdl_t *, dtrace_prog_t *,
171 171 dtrace_stmt_f *, void *);
172 172 extern void dtrace_stmt_destroy(dtrace_hdl_t *, dtrace_stmtdesc_t *);
173 173
174 174 /*
175 175 * DTrace Data Consumption Interface
176 176 */
177 177 typedef enum {
178 178 DTRACEFLOW_ENTRY,
179 179 DTRACEFLOW_RETURN,
180 180 DTRACEFLOW_NONE
181 181 } dtrace_flowkind_t;
182 182
183 183 #define DTRACE_CONSUME_ERROR -1 /* error while processing */
184 184 #define DTRACE_CONSUME_THIS 0 /* consume this probe/record */
185 185 #define DTRACE_CONSUME_NEXT 1 /* advance to next probe/rec */
186 186 #define DTRACE_CONSUME_ABORT 2 /* abort consumption */
187 187
188 188 typedef struct dtrace_probedata {
189 189 dtrace_hdl_t *dtpda_handle; /* handle to DTrace library */
190 190 dtrace_eprobedesc_t *dtpda_edesc; /* enabled probe description */
191 191 dtrace_probedesc_t *dtpda_pdesc; /* probe description */
192 192 processorid_t dtpda_cpu; /* CPU for data */
193 193 caddr_t dtpda_data; /* pointer to raw data */
194 194 dtrace_flowkind_t dtpda_flow; /* flow kind */
195 195 const char *dtpda_prefix; /* recommended flow prefix */
196 196 int dtpda_indent; /* recommended flow indent */
197 197 } dtrace_probedata_t;
198 198
199 199 typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *);
200 200 typedef int dtrace_consume_rec_f(const dtrace_probedata_t *,
201 201 const dtrace_recdesc_t *, void *);
202 202
203 203 extern int dtrace_consume(dtrace_hdl_t *, FILE *,
204 204 dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
205 205
206 206 #define DTRACE_STATUS_NONE 0 /* no status; not yet time */
207 207 #define DTRACE_STATUS_OKAY 1 /* status okay */
208 208 #define DTRACE_STATUS_EXITED 2 /* exit() was called; tracing stopped */
209 209 #define DTRACE_STATUS_FILLED 3 /* fill buffer filled; tracing stoped */
210 210 #define DTRACE_STATUS_STOPPED 4 /* tracing already stopped */
211 211
212 212 extern int dtrace_status(dtrace_hdl_t *);
213 213
214 214 /*
215 215 * DTrace Formatted Output Interfaces
216 216 *
217 217 * To format output associated with a given dtrace_stmtdesc, the caller can
218 218 * invoke one of the following functions, passing the opaque dtsd_fmtdata and a
219 219 * list of record descriptions. These functions return either -1 to indicate
220 220 * an error, or a positive integer indicating the number of records consumed.
221 221 * For anonymous enablings, the consumer can use the dtrd_format member of
222 222 * the record description to obtain a format description. The dtfd_string
223 223 * member of the format description may be passed to dtrace_print{fa}_create()
224 224 * to create the opaque format data.
225 225 */
226 226 extern void *dtrace_printf_create(dtrace_hdl_t *, const char *);
227 227 extern void *dtrace_printa_create(dtrace_hdl_t *, const char *);
228 228 extern size_t dtrace_printf_format(dtrace_hdl_t *, void *, char *, size_t);
229 229
230 230 extern int dtrace_fprintf(dtrace_hdl_t *, FILE *, void *,
231 231 const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
232 232 const void *, size_t);
233 233
234 234 extern int dtrace_fprinta(dtrace_hdl_t *, FILE *, void *,
235 235 const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
236 236 const void *, size_t);
237 237
238 238 extern int dtrace_system(dtrace_hdl_t *, FILE *, void *,
239 239 const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
240 240 const void *, size_t);
241 241
242 242 extern int dtrace_freopen(dtrace_hdl_t *, FILE *, void *,
243 243 const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
244 244 const void *, size_t);
245 245
246 246 /*
247 247 * Type-specific output printing
248 248 *
249 249 * The print() action will associate a string data record that is actually the
250 250 * fully-qualified type name of the data traced by the DIFEXPR action. This is
251 251 * stored in the same 'format' record from the kernel, but we know by virtue of
252 252 * the fact that the action is still DIFEXPR that it is actually a reference to
253 253 * plain string data.
254 254 */
255 255 extern int dtrace_print(dtrace_hdl_t *, FILE *, const char *,
256 256 caddr_t, size_t);
257 257
258 258 /*
259 259 * DTrace Work Interface
260 260 */
261 261 typedef enum {
262 262 DTRACE_WORKSTATUS_ERROR = -1,
263 263 DTRACE_WORKSTATUS_OKAY,
264 264 DTRACE_WORKSTATUS_DONE
265 265 } dtrace_workstatus_t;
266 266
267 267 extern dtrace_workstatus_t dtrace_work(dtrace_hdl_t *, FILE *,
268 268 dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
269 269
270 270 /*
271 271 * DTrace Handler Interface
272 272 */
273 273 #define DTRACE_HANDLE_ABORT -1 /* abort current operation */
274 274 #define DTRACE_HANDLE_OK 0 /* handled okay; continue */
275 275
276 276 typedef struct dtrace_errdata {
277 277 dtrace_hdl_t *dteda_handle; /* handle to DTrace library */
278 278 dtrace_eprobedesc_t *dteda_edesc; /* enabled probe inducing err */
279 279 dtrace_probedesc_t *dteda_pdesc; /* probe inducing error */
280 280 processorid_t dteda_cpu; /* CPU of error */
281 281 int dteda_action; /* action inducing error */
282 282 int dteda_offset; /* offset in DIFO of error */
283 283 int dteda_fault; /* specific fault */
284 284 uint64_t dteda_addr; /* address of fault, if any */
285 285 const char *dteda_msg; /* preconstructed message */
286 286 } dtrace_errdata_t;
287 287
288 288 typedef int dtrace_handle_err_f(const dtrace_errdata_t *, void *);
289 289 extern int dtrace_handle_err(dtrace_hdl_t *, dtrace_handle_err_f *, void *);
290 290
291 291 typedef enum {
292 292 DTRACEDROP_PRINCIPAL, /* drop to principal buffer */
293 293 DTRACEDROP_AGGREGATION, /* drop to aggregation buffer */
294 294 DTRACEDROP_DYNAMIC, /* dynamic drop */
295 295 DTRACEDROP_DYNRINSE, /* dyn drop due to rinsing */
296 296 DTRACEDROP_DYNDIRTY, /* dyn drop due to dirty */
297 297 DTRACEDROP_SPEC, /* speculative drop */
298 298 DTRACEDROP_SPECBUSY, /* spec drop due to busy */
299 299 DTRACEDROP_SPECUNAVAIL, /* spec drop due to unavail */
300 300 DTRACEDROP_STKSTROVERFLOW, /* stack string tab overflow */
301 301 DTRACEDROP_DBLERROR /* error in ERROR probe */
302 302 } dtrace_dropkind_t;
303 303
304 304 typedef struct dtrace_dropdata {
305 305 dtrace_hdl_t *dtdda_handle; /* handle to DTrace library */
306 306 processorid_t dtdda_cpu; /* CPU, if any */
307 307 dtrace_dropkind_t dtdda_kind; /* kind of drop */
308 308 uint64_t dtdda_drops; /* number of drops */
309 309 uint64_t dtdda_total; /* total drops */
310 310 const char *dtdda_msg; /* preconstructed message */
311 311 } dtrace_dropdata_t;
312 312
313 313 typedef int dtrace_handle_drop_f(const dtrace_dropdata_t *, void *);
314 314 extern int dtrace_handle_drop(dtrace_hdl_t *, dtrace_handle_drop_f *, void *);
315 315
316 316 typedef void dtrace_handle_proc_f(struct ps_prochandle *, const char *, void *);
317 317 extern int dtrace_handle_proc(dtrace_hdl_t *, dtrace_handle_proc_f *, void *);
318 318
319 319 #define DTRACE_BUFDATA_AGGKEY 0x0001 /* aggregation key */
320 320 #define DTRACE_BUFDATA_AGGVAL 0x0002 /* aggregation value */
321 321 #define DTRACE_BUFDATA_AGGFORMAT 0x0004 /* aggregation format data */
322 322 #define DTRACE_BUFDATA_AGGLAST 0x0008 /* last for this key/val */
323 323
324 324 typedef struct dtrace_bufdata {
325 325 dtrace_hdl_t *dtbda_handle; /* handle to DTrace library */
326 326 const char *dtbda_buffered; /* buffered output */
327 327 dtrace_probedata_t *dtbda_probe; /* probe data */
328 328 const dtrace_recdesc_t *dtbda_recdesc; /* record description */
329 329 const dtrace_aggdata_t *dtbda_aggdata; /* aggregation data, if agg. */
330 330 uint32_t dtbda_flags; /* flags; see above */
331 331 } dtrace_bufdata_t;
332 332
333 333 typedef int dtrace_handle_buffered_f(const dtrace_bufdata_t *, void *);
334 334 extern int dtrace_handle_buffered(dtrace_hdl_t *,
335 335 dtrace_handle_buffered_f *, void *);
336 336
337 337 typedef struct dtrace_setoptdata {
338 338 dtrace_hdl_t *dtsda_handle; /* handle to DTrace library */
339 339 const dtrace_probedata_t *dtsda_probe; /* probe data */
340 340 const char *dtsda_option; /* option that was set */
341 341 dtrace_optval_t dtsda_oldval; /* old value */
342 342 dtrace_optval_t dtsda_newval; /* new value */
343 343 } dtrace_setoptdata_t;
344 344
345 345 typedef int dtrace_handle_setopt_f(const dtrace_setoptdata_t *, void *);
↓ open down ↓ |
345 lines elided |
↑ open up ↑ |
346 346 extern int dtrace_handle_setopt(dtrace_hdl_t *,
347 347 dtrace_handle_setopt_f *, void *);
348 348
349 349 /*
350 350 * DTrace Aggregate Interface
351 351 */
352 352
353 353 #define DTRACE_A_PERCPU 0x0001
354 354 #define DTRACE_A_KEEPDELTA 0x0002
355 355 #define DTRACE_A_ANONYMOUS 0x0004
356 +#define DTRACE_A_TOTAL 0x0008
357 +#define DTRACE_A_MINMAXBIN 0x0010
358 +#define DTRACE_A_HASNEGATIVES 0x0020
359 +#define DTRACE_A_HASPOSITIVES 0x0040
360 +
361 +#define DTRACE_AGGZOOM_MAX 0.95 /* height of max bar */
356 362
357 363 #define DTRACE_AGGWALK_ERROR -1 /* error while processing */
358 364 #define DTRACE_AGGWALK_NEXT 0 /* proceed to next element */
359 365 #define DTRACE_AGGWALK_ABORT 1 /* abort aggregation walk */
360 366 #define DTRACE_AGGWALK_CLEAR 2 /* clear this element */
361 367 #define DTRACE_AGGWALK_NORMALIZE 3 /* normalize this element */
362 368 #define DTRACE_AGGWALK_DENORMALIZE 4 /* denormalize this element */
363 369 #define DTRACE_AGGWALK_REMOVE 5 /* remove this element */
364 370
365 371 struct dtrace_aggdata {
366 372 dtrace_hdl_t *dtada_handle; /* handle to DTrace library */
367 373 dtrace_aggdesc_t *dtada_desc; /* aggregation description */
368 374 dtrace_eprobedesc_t *dtada_edesc; /* enabled probe description */
369 375 dtrace_probedesc_t *dtada_pdesc; /* probe description */
370 376 caddr_t dtada_data; /* pointer to raw data */
371 377 uint64_t dtada_normal; /* the normal -- 1 for denorm */
372 378 size_t dtada_size; /* total size of the data */
373 379 caddr_t dtada_delta; /* delta data, if available */
374 380 caddr_t *dtada_percpu; /* per CPU data, if avail */
375 381 caddr_t *dtada_percpu_delta; /* per CPU delta, if avail */
382 + int64_t dtada_total; /* per agg total, if avail */
383 + uint16_t dtada_minbin; /* minimum bin, if avail */
384 + uint16_t dtada_maxbin; /* maximum bin, if avail */
385 + uint32_t dtada_flags; /* flags */
376 386 };
377 387
378 388 typedef int dtrace_aggregate_f(const dtrace_aggdata_t *, void *);
379 389 typedef int dtrace_aggregate_walk_f(dtrace_hdl_t *,
380 390 dtrace_aggregate_f *, void *);
381 391 typedef int dtrace_aggregate_walk_joined_f(const dtrace_aggdata_t **,
382 392 const int, void *);
383 393
384 394 extern void dtrace_aggregate_clear(dtrace_hdl_t *);
385 395 extern int dtrace_aggregate_snap(dtrace_hdl_t *);
386 396 extern int dtrace_aggregate_print(dtrace_hdl_t *, FILE *,
387 397 dtrace_aggregate_walk_f *);
388 398
389 399 extern int dtrace_aggregate_walk(dtrace_hdl_t *, dtrace_aggregate_f *, void *);
390 400
391 401 extern int dtrace_aggregate_walk_joined(dtrace_hdl_t *,
392 402 dtrace_aggvarid_t *, int, dtrace_aggregate_walk_joined_f *, void *);
393 403
394 404 extern int dtrace_aggregate_walk_sorted(dtrace_hdl_t *,
395 405 dtrace_aggregate_f *, void *);
396 406
397 407 extern int dtrace_aggregate_walk_keysorted(dtrace_hdl_t *,
398 408 dtrace_aggregate_f *, void *);
399 409
400 410 extern int dtrace_aggregate_walk_valsorted(dtrace_hdl_t *,
401 411 dtrace_aggregate_f *, void *);
402 412
403 413 extern int dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *,
404 414 dtrace_aggregate_f *, void *);
405 415
406 416 extern int dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *,
407 417 dtrace_aggregate_f *, void *);
408 418
409 419 extern int dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *,
410 420 dtrace_aggregate_f *, void *);
411 421
412 422 extern int dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *,
413 423 dtrace_aggregate_f *, void *);
414 424
415 425 extern int dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *,
416 426 dtrace_aggregate_f *, void *);
417 427
418 428 extern int dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *,
419 429 dtrace_aggregate_f *, void *);
420 430
421 431 #define DTRACE_AGD_PRINTED 0x1 /* aggregation printed in program */
422 432
423 433 /*
424 434 * DTrace Process Control Interface
425 435 *
426 436 * Library clients who wish to have libdtrace create or grab processes for
427 437 * monitoring of their symbol table changes may use these interfaces to
428 438 * request that libdtrace obtain control of the process using libproc.
429 439 */
430 440
431 441 extern struct ps_prochandle *dtrace_proc_create(dtrace_hdl_t *,
432 442 const char *, char *const *);
433 443
434 444 extern struct ps_prochandle *dtrace_proc_grab(dtrace_hdl_t *, pid_t, int);
435 445 extern void dtrace_proc_release(dtrace_hdl_t *, struct ps_prochandle *);
436 446 extern void dtrace_proc_continue(dtrace_hdl_t *, struct ps_prochandle *);
437 447
438 448 /*
439 449 * DTrace Object, Symbol, and Type Interfaces
440 450 *
441 451 * Library clients can use libdtrace to perform symbol and C type information
442 452 * lookups by symbol name, symbol address, or C type name, or to lookup meta-
443 453 * information cached for each of the program objects in use by DTrace. The
444 454 * resulting struct contain pointers to arbitrary-length strings, including
445 455 * object, symbol, and type names, that are persistent until the next call to
446 456 * dtrace_update(). Once dtrace_update() is called, any cached values must
447 457 * be flushed and not used subsequently by the client program.
448 458 */
449 459
450 460 #define DTRACE_OBJ_EXEC ((const char *)0L) /* primary executable file */
451 461 #define DTRACE_OBJ_RTLD ((const char *)1L) /* run-time link-editor */
452 462 #define DTRACE_OBJ_CDEFS ((const char *)2L) /* C include definitions */
453 463 #define DTRACE_OBJ_DDEFS ((const char *)3L) /* D program definitions */
454 464 #define DTRACE_OBJ_EVERY ((const char *)-1L) /* all known objects */
455 465 #define DTRACE_OBJ_KMODS ((const char *)-2L) /* all kernel objects */
456 466 #define DTRACE_OBJ_UMODS ((const char *)-3L) /* all user objects */
457 467
458 468 typedef struct dtrace_objinfo {
459 469 const char *dto_name; /* object file scope name */
460 470 const char *dto_file; /* object file path (if any) */
461 471 int dto_id; /* object file id (if any) */
462 472 uint_t dto_flags; /* object flags (see below) */
463 473 GElf_Addr dto_text_va; /* address of text section */
464 474 GElf_Xword dto_text_size; /* size of text section */
465 475 GElf_Addr dto_data_va; /* address of data section */
466 476 GElf_Xword dto_data_size; /* size of data section */
467 477 GElf_Addr dto_bss_va; /* address of BSS */
468 478 GElf_Xword dto_bss_size; /* size of BSS */
469 479 } dtrace_objinfo_t;
470 480
471 481 #define DTRACE_OBJ_F_KERNEL 0x1 /* object is a kernel module */
472 482 #define DTRACE_OBJ_F_PRIMARY 0x2 /* object is a primary module */
473 483
474 484 typedef int dtrace_obj_f(dtrace_hdl_t *, const dtrace_objinfo_t *, void *);
475 485
476 486 extern int dtrace_object_iter(dtrace_hdl_t *, dtrace_obj_f *, void *);
477 487 extern int dtrace_object_info(dtrace_hdl_t *, const char *, dtrace_objinfo_t *);
478 488
479 489 typedef struct dtrace_syminfo {
480 490 const char *dts_object; /* object name */
481 491 const char *dts_name; /* symbol name */
482 492 ulong_t dts_id; /* symbol id */
483 493 } dtrace_syminfo_t;
484 494
485 495 extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *,
486 496 GElf_Sym *, dtrace_syminfo_t *);
487 497
488 498 extern int dtrace_lookup_by_addr(dtrace_hdl_t *, GElf_Addr addr,
489 499 GElf_Sym *, dtrace_syminfo_t *);
490 500
491 501 typedef struct dtrace_typeinfo {
492 502 const char *dtt_object; /* object containing type */
493 503 ctf_file_t *dtt_ctfp; /* CTF container handle */
494 504 ctf_id_t dtt_type; /* CTF type identifier */
495 505 uint_t dtt_flags; /* Misc. flags */
496 506 } dtrace_typeinfo_t;
497 507
498 508 #define DTT_FL_USER 0x1 /* user type */
499 509
500 510 extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
501 511 dtrace_typeinfo_t *);
502 512
503 513 extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *,
504 514 const dtrace_syminfo_t *, dtrace_typeinfo_t *);
505 515
506 516 extern int dtrace_type_strcompile(dtrace_hdl_t *,
507 517 const char *, dtrace_typeinfo_t *);
508 518
509 519 extern int dtrace_type_fcompile(dtrace_hdl_t *,
510 520 FILE *, dtrace_typeinfo_t *);
511 521
512 522 /*
513 523 * DTrace Probe Interface
514 524 *
515 525 * Library clients can use these functions to iterate over the set of available
516 526 * probe definitions and inquire as to their attributes. The probe iteration
517 527 * interfaces report probes that are declared as well as those from dtrace(7D).
518 528 */
519 529 typedef struct dtrace_probeinfo {
520 530 dtrace_attribute_t dtp_attr; /* name attributes */
521 531 dtrace_attribute_t dtp_arga; /* arg attributes */
522 532 const dtrace_typeinfo_t *dtp_argv; /* arg types */
523 533 int dtp_argc; /* arg count */
524 534 } dtrace_probeinfo_t;
525 535
526 536 typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *);
527 537
528 538 extern int dtrace_probe_iter(dtrace_hdl_t *,
529 539 const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *);
530 540
531 541 extern int dtrace_probe_info(dtrace_hdl_t *,
532 542 const dtrace_probedesc_t *, dtrace_probeinfo_t *);
533 543
534 544 /*
535 545 * DTrace Vector Interface
536 546 *
537 547 * The DTrace library normally speaks directly to dtrace(7D). However,
538 548 * this communication may be vectored elsewhere. Consumers who wish to
539 549 * perform a vectored open must fill in the vector, and use the dtrace_vopen()
540 550 * entry point to obtain a library handle.
541 551 */
542 552 struct dtrace_vector {
543 553 int (*dtv_ioctl)(void *, int, void *);
544 554 int (*dtv_lookup_by_addr)(void *, GElf_Addr, GElf_Sym *,
545 555 dtrace_syminfo_t *);
546 556 int (*dtv_status)(void *, processorid_t);
547 557 long (*dtv_sysconf)(void *, int);
548 558 };
549 559
550 560 /*
551 561 * DTrace Utility Functions
552 562 *
553 563 * Library clients can use these functions to convert addresses strings, to
554 564 * convert between string and integer probe descriptions and the
555 565 * dtrace_probedesc_t representation, and to perform similar conversions on
556 566 * stability attributes.
557 567 */
558 568 extern int dtrace_addr2str(dtrace_hdl_t *, uint64_t, char *, int);
559 569 extern int dtrace_uaddr2str(dtrace_hdl_t *, pid_t, uint64_t, char *, int);
560 570
561 571 extern int dtrace_xstr2desc(dtrace_hdl_t *, dtrace_probespec_t,
562 572 const char *, int, char *const [], dtrace_probedesc_t *);
563 573
564 574 extern int dtrace_str2desc(dtrace_hdl_t *, dtrace_probespec_t,
565 575 const char *, dtrace_probedesc_t *);
566 576
567 577 extern int dtrace_id2desc(dtrace_hdl_t *, dtrace_id_t, dtrace_probedesc_t *);
568 578
569 579 #define DTRACE_DESC2STR_MAX 1024 /* min buf size for dtrace_desc2str() */
570 580
571 581 extern char *dtrace_desc2str(const dtrace_probedesc_t *, char *, size_t);
572 582
573 583 #define DTRACE_ATTR2STR_MAX 64 /* min buf size for dtrace_attr2str() */
574 584
575 585 extern char *dtrace_attr2str(dtrace_attribute_t, char *, size_t);
576 586 extern int dtrace_str2attr(const char *, dtrace_attribute_t *);
577 587
578 588 extern const char *dtrace_stability_name(dtrace_stability_t);
579 589 extern const char *dtrace_class_name(dtrace_class_t);
580 590
581 591 extern int dtrace_provider_modules(dtrace_hdl_t *, const char **, int);
582 592
583 593 extern const char *const _dtrace_version;
584 594 extern int _dtrace_debug;
585 595
586 596 #ifdef __cplusplus
587 597 }
588 598 #endif
589 599
590 600 #endif /* _DTRACE_H */
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX