User Tools

Site Tools


solaris:dtrace_faultstr.3dtrace

dtrace_faultstr


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:

SEE ALSO

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


solaris/dtrace_faultstr.3dtrace.txt · Last modified: 2023/07/19 08:58 by A User Not Logged in