FreeBSD/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c
/*
 * Print an integer type.  Before dumping the contents via dt_print_hex(), we
 * first check the encoding to see if it's part of a bitfield or a character.
 */
Print an integer type.  Before dumping the contents via dt_print_hex(), we
first check the encoding to see if it's part of a bitfield or a character.
Print an integer type . Before dumping the contents via dt_print_hex () we first check the encoding to see if it ' s part of a bitfield or a character .
static void
dt_print_int(ctf_id_t base, ulong_t off, dt_printarg_t *pap)
{
	FILE *fp = pap->pa_file;
	ctf_file_t *ctfp = pap->pa_ctfp;
	ctf_encoding_t e;
	size_t size;
	caddr_t addr = pap->pa_addr + off / NBBY;
	if (ctf_type_encoding(ctfp, base, &e) == CTF_ERR) {
		(void) fprintf(fp, "<unknown encoding>");
		return;
	}
	if (e.cte_format & CTF_INT_VARARGS) {
		(void) fprintf(fp, "...");
		return;
	}
	size = e.cte_bits / NBBY;
	if (size > 8 || (e.cte_bits % NBBY) != 0 || (size & (size - 1)) != 0) {
		print_bitfield(pap, off, &e);
		return;
	}
	if (CTF_IS_CHAR(e)) {
		char c = *(char *)addr;
		if (isprint(c))
			(void) fprintf(fp, "'%c'", c);
		else if (c == 0)
			(void) fprintf(fp, "'\\0'");
		else
			(void) fprintf(fp, "'\\%03o'", c);
		return;
	}
	dt_print_hex(fp, addr, size);
}
static void dt_print_int ( ctf_id_t base , ulong_t off , dt_printarg_t * pap ) { FILE * fp = pap -> pa_file ; ctf_file_t * ctfp = pap -> pa_ctfp ; ctf_encoding_t e ; size_t size ; caddr_t addr = pap -> pa_addr + off / NBBY ; if ( ctf_type_encoding ( ctfp , base , & e ) == CTF_ERR ) { ( void ) fprintf ( fp , " " ) ; return ; } if ( e . cte_format & CTF_INT_VARARGS ) { ( void ) fprintf ( fp , " " ) ; return ; } size = e . cte_bits / NBBY ; if ( size > 8 || ( e . cte_bits % NBBY ) != 0 || ( size & ( size - 1 ) ) != 0 ) { print_bitfield ( pap , off , & e ) ; return ; } if ( CTF_IS_CHAR ( e ) ) { char c = * ( char * ) addr ; if ( isprint ( c ) ) ( void ) fprintf ( fp , " " , c ) ; else if ( c == 0 ) ( void ) fprintf ( fp , " \\ " ) ; else ( void ) fprintf ( fp , " \\ " , c ) ; return ; } dt_print_hex ( fp , addr , size ) ; }
Print an integer type.
Print an integer type .
/*
	 * This comes from MDB - it's not clear under what circumstances this
	 * would be found.
	 */ /*
	 * We print this as a bitfield if the bit encoding indicates it's not
	 * an even power of two byte size, or is larger than 8 bytes.
	 */ /*
	 * If this is a character, print it out as such.
	 */