FreeBSD/sys/cddl/contrib/opensolaris/uts/common/os/fm.c
/*
 * Convert a getpcstack() trace to symbolic name+offset, and add the resulting
 * string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK.
 */
Convert a getpcstack() trace to symbolic name+offset, and add the resulting
string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK.
Convert a getpcstack () trace to symbolic name + offset and add the resulting string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK .
void
fm_payload_stack_add(nvlist_t *payload, const pc_t *stack, int depth)
{
	int i;
	char *sym;
	ulong_t off;
	char *stkpp[FM_STK_DEPTH];
	char buf[FM_STK_DEPTH * FM_SYM_SZ];
	char *stkp = buf;
	for (i = 0; i < depth && i != FM_STK_DEPTH; i++, stkp += FM_SYM_SZ) {
		if ((sym = kobj_getsymname(stack[i], &off)) != NULL)
			(void) snprintf(stkp, FM_SYM_SZ, "%s+%lx", sym, off);
		else
			(void) snprintf(stkp, FM_SYM_SZ, "%lx", (long)stack[i]);
		stkpp[i] = stkp;
	}
	fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_STACK,
	    DATA_TYPE_STRING_ARRAY, depth, stkpp, NULL);
}
void fm_payload_stack_add ( nvlist_t * payload , const pc_t * stack , int depth ) { int i ; char * sym ; ulong_t off ; char * stkpp [ FM_STK_DEPTH ] ; char buf [ FM_STK_DEPTH * FM_SYM_SZ ] ; char * stkp = buf ; for ( i = 0 ; i < depth && i != FM_STK_DEPTH ; i ++ , stkp += FM_SYM_SZ ) { if ( ( sym = kobj_getsymname ( stack [ i ] , & off ) ) != NULL ) ( void ) snprintf ( stkp , FM_SYM_SZ , " " , sym , off ) ; else ( void ) snprintf ( stkp , FM_SYM_SZ , " " , ( long ) stack [ i ] ) ; stkpp [ i ] = stkp ; } fm_payload_set ( payload , FM_EREPORT_PAYLOAD_NAME_STACK , DATA_TYPE_STRING_ARRAY , depth , stkpp , NULL ) ; }
Convert a getpcstack() trace to symbolic name+offset, and add the resulting
 string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK.
Convert a getpcstack () trace to symbolic name + offset and add the resulting string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK .