FreeBSD/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
/*
 * Reconstruct the type tree from a given buffer of CTF data.  Only the types
 * up to the type associated with the provided label, inclusive, will be
 * reconstructed.  If a NULL label is provided, all types will be reconstructed.
 *
 * This function won't work on files that have been uniquified.
 */
Reconstruct the type tree from a given buffer of CTF data.  Only the types
up to the type associated with the provided label, inclusive, will be
reconstructed.  If a NULL label is provided, all types will be reconstructed.

This function won't work on files that have been uniquified.
Reconstruct the type tree from a given buffer of CTF data . Only the types up to the type associated with the provided label inclusive will be reconstructed . If a NULL label is provided all types will be reconstructed . This function won ' t work on files that have been uniquified .
tdata_t *
ctf_load(char *file, caddr_t buf, size_t bufsz, symit_data_t *si, char *label)
{
	ctf_header_t *h;
	caddr_t ctfdata;
	size_t ctfdatasz;
	tdata_t *td;
	curfile = file;
	if (bufsz < sizeof (ctf_header_t))
		parseterminate("Corrupt CTF - short header");
	void *v = (void *) buf;
	h = v;
	buf += sizeof (ctf_header_t);
	bufsz -= sizeof (ctf_header_t);
	if (h->cth_magic != CTF_MAGIC)
		parseterminate("Corrupt CTF - bad magic 0x%x", h->cth_magic);
	if (h->cth_version != CTF_VERSION)
		parseterminate("Unknown CTF version %d", h->cth_version);
	ctfdatasz = h->cth_stroff + h->cth_strlen;
	if (h->cth_flags & CTF_F_COMPRESS) {
		size_t actual;
		ctfdata = xmalloc(ctfdatasz);
		if ((actual = decompress_ctf(buf, bufsz, ctfdata, ctfdatasz)) !=
		    ctfdatasz) {
			parseterminate("Corrupt CTF - short decompression "
			    "(was %d, expecting %d)", actual, ctfdatasz);
		}
	} else {
		ctfdata = buf;
		ctfdatasz = bufsz;
	}
	td = ctf_parse(h, ctfdata, si, label);
	if (h->cth_flags & CTF_F_COMPRESS)
		free(ctfdata);
	curfile = NULL;
	return (td);
}
tdata_t * ctf_load ( char * file , caddr_t buf , size_t bufsz , symit_data_t * si , char * label ) { ctf_header_t * h ; caddr_t ctfdata ; size_t ctfdatasz ; tdata_t * td ; curfile = file ; if ( bufsz < sizeof ( ctf_header_t ) ) parseterminate ( " " ) ; void * v = ( void * ) buf ; h = v ; buf += sizeof ( ctf_header_t ) ; bufsz -= sizeof ( ctf_header_t ) ; if ( h -> cth_magic != CTF_MAGIC ) parseterminate ( " " , h -> cth_magic ) ; if ( h -> cth_version != CTF_VERSION ) parseterminate ( " " , h -> cth_version ) ; ctfdatasz = h -> cth_stroff + h -> cth_strlen ; if ( h -> cth_flags & CTF_F_COMPRESS ) { size_t actual ; ctfdata = xmalloc ( ctfdatasz ) ; if ( ( actual = decompress_ctf ( buf , bufsz , ctfdata , ctfdatasz ) ) != ctfdatasz ) { parseterminate ( " " " " , actual , ctfdatasz ) ; } } else { ctfdata = buf ; ctfdatasz = bufsz ; } td = ctf_parse ( h , ctfdata , si , label ) ; if ( h -> cth_flags & CTF_F_COMPRESS ) free ( ctfdata ) ; curfile = NULL ; return ( td ) ; }
Reconstruct the type tree from a given buffer of CTF data.
Reconstruct the type tree from a given buffer of CTF data .