Go to main content

man pages section 3: Extended Library Functions, Volume 2

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

dtrace_faultstr (3DTRACE)

Name

dtrace_faultstr, dtrace_subrstr - Map DTrace fault and subroutine constants to strings

Synopsis

     cc [ flag... ] file... -ldtrace [ library... ]
     #include <dtrace.h>

     const char *dtrace_faultstr(dtrace_hdl_t *dtp, int fault)

     const char *dtrace_subrstr(dtrace_hdl_t *dtp, int subr)

Description

The dtrace_faultstr() function returns a string associated with a particular DTrace fault number corresponding to the fault argument. If the value passed does not match a known fault, the string, unknown fault is returned.

The dtrace_subrstr() function returns the string corresponding to the subr argument. The string is the name of a DTrace subroutine given the constant associated with that subroutine. If the value passed does not match a known subroutine, the string, unknown is returned.


Note -  When a D script is compiled down into D Intermediate Format (DIF), subroutine is mapped to a constant. The dtrace_subrstr() function is the reverse of this mapping.

Return Values

The dtrace_faultstr() function returns the string corresponding to the fault argument. If the value passed does not match a known fault, the string "unknown fault" is returned.

The dtrace_subrstr() function returns the string corresponding to the subr argument. If the value passed does not match a known subroutine, the string "unknown" is returned.

Errors

None

Examples

Example 1 Using the dtrace_faultstr() Function in an Error Handler

The dtrace_faultstr() function might be used in an error handler as in the following example:

     static int
     errhandler(const dtrace_errdata_t *data, void *arg)
     {
        fprintf(stderr, "Error on enabled probe %d (probe %s:%s:%s:%s): %s\n",
            data->dteda_edesc->dtepd_epid, data->dteda_pdesc->dtpd_provider,
            data->dteda_pdesc->dtpd_mod, data->dteda_pdesc->dtpd_func,
            data->dteda_pdesc->dtpd_name,
            dtrace_faultstr(g_dtp, data->dteda_fault));

        return (DTRACE_HANDLE_OK);
     }

     int
     main()
     {
	[ ... ]

        if (dtrace_handle_err(dtp, errhandler, NULL) == -1)
                fprintf(stderr, "failed to install error handler: %s\n",
		    dtrace_errmsg(dtp, dtrace_errno(dtp)));

	[ ... ]
     }

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Architecture
all
Availability
system/dtrace
Interface Stability
Committed
MT-Level
Safe

See Also

libdtrace(3LIB), dtrace_errno(3DTRACE), dtrace_handle_err(3DTRACE)