Handler APIs

int dtrace_handle_err(dtrace_hdl_t *dtp, dtrace_handle_err_f *hdlr, void *arg)

Registers an error handler for a DTrace consumer. The error handler is called when an error occurs in a running D program such as accessing an invalid address or dividing by zero. Information about the error is stored in the dtrace_errdata_t argument. The error handler can return a DTRACE_HANDLE_OK value to continue processing or DTRACE_HANDLE_ABORT to abort. An error handler has the following signature:

int dtrace_handle_err_f(const dtrace_errdata_t *, void *);

See dtrace_handle_err(3DTRACE).

int dtrace_handle_drop(dtrace_hdl_t *dtp, dtrace_handle_drop_f *hdlr, void *arg)

Registers a drop handler for a DTrace consumer. The drop handler is called when the data is dropped by the running D program. Information about the drop (including the drop type) is stored in the dtrace_dropdata_t argument. The drop handler can return a value to continue processing DTRACE_HANDLE_OK or DTRACE_HANDLE_ABORT to abort. A drop handler has the following signature:

int dtrace_handle_drop_f(const dtrace_dropdata_t *, void *);

See dtrace_handle_drop(3DTRACE).

int dtrace_handle_proc(dtrace_hdl_t *dtp, dtrace_handle_proc_f *hdlr, void *arg)

Registers a process handler for a DTrace consumer. The process handler is called when certain events occur for a process under DTrace control, such as dynamic linker activity or the process exiting. The process handler is called whenever certain events occur for a process under DTrace control, such as dynamic linker activity or the process exiting. A libproc handle to the process is passed as the first argument, and a predefined message is passed as the second argument. A proc handler has the following signature:

void dtrace_handle_proc_f(struct ps_prochandle *, const char *, void *);

See dtrace_handle_proc(3DTRACE).

int dtrace_handle_buffered(dtrace_hdl_t *dtp, dtrace_handle_buffered_f *hdlr, void *arg)

Registers a buffered I/O handler for a DTrace consumer. A buffered I/O handler allows the consumer to perform its own buffered I/O. If a NULL pointer is passed to dtrace_work(), dtrace_consume(), or dtrace_aggregate_print(), libdtrace() will make use of the buffered I/O handler. Output goes into the dtbda_buffered member of the dtrace_bufdata_t data structure. A simple buffered I/O handler can just print that output. Information about the probe and the record or aggregation data being processed is also included. The buffered I/O handler can return a DTRACE_HANDLE_OK value to continue processing or DTRACE_HANDLE_ABORT to abort. See dtrace_handle_buffered(3DTRACE).

int dtrace_handle_setopt(dtrace_hdl_t *dtp, dtrace_handle_setopt_f *hdlr, void *arg)

Registers a setopt handler for a DTrace consumer. The setopt handler is called when a DTrace option is set from within a D program by using the setopt() action. Information about the option being set and the old and new values of the option are passed in the dtrace_setoptdata_t argument. The setopt handler can return a DTRACE_HANDLE_OK value to continue processing or DTRACE_HANDLE_ABORT to abort. See dtrace_handle_setopt(3DTRACE).