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