FreeBSD/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
/*
 * Create a tdesc from an array node.  Some arrays will come with byte size
 * attributes, and thus can be resolved immediately.  Others don't, and will
 * need to wait until the second pass for resolution.
 */
Create a tdesc from an array node.  Some arrays will come with byte size
attributes, and thus can be resolved immediately.  Others don't, and will
need to wait until the second pass for resolution.
Create a tdesc from an array node . Some arrays will come with byte size attributes and thus can be resolved immediately . Others don ' t and will need to wait until the second pass for resolution .
static void
die_array_create(dwarf_t *dw, Dwarf_Die arr, Dwarf_Off off, tdesc_t *tdp)
{
	tdesc_t *arrtdp = die_lookup_pass1(dw, arr, DW_AT_type);
	Dwarf_Unsigned uval;
	Dwarf_Die dim;
	debug(3, "die %llu <%llx>: creating array\n", off, off);
	if ((dim = die_child(dw, arr)) == NULL ||
	    die_tag(dw, dim) != DW_TAG_subrange_type)
		terminate("die %llu: failed to retrieve array bounds\n", off);
	tdesc_array_create(dw, dim, arrtdp, tdp);
	if (die_unsigned(dw, arr, DW_AT_byte_size, &uval, 0)) {
		tdesc_t *dimtdp;
		int flags;
		if (uval == (unsigned)-1) {
			printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
			    __func__);
			uval = 0;
		}
		tdp->t_size = uval;
		flags = TDESC_F_RESOLVED;
		for (dimtdp = tdp->t_ardef->ad_contents;
		    dimtdp->t_type == ARRAY;
		    dimtdp = dimtdp->t_ardef->ad_contents) {
			if (!(dimtdp->t_flags & TDESC_F_RESOLVED)) {
				flags = 0;
				break;
			}
		}
		tdp->t_flags |= flags;
	}
	debug(3, "die %llu <%llx>: array nelems %u size %u\n", off, off,
	    tdp->t_ardef->ad_nelems, tdp->t_size);
}
static void die_array_create ( dwarf_t * dw , Dwarf_Die arr , Dwarf_Off off , tdesc_t * tdp ) { tdesc_t * arrtdp = die_lookup_pass1 ( dw , arr , DW_AT_type ) ; Dwarf_Unsigned uval ; Dwarf_Die dim ; debug ( 3 , " \n " , off , off ) ; if ( ( dim = die_child ( dw , arr ) ) == NULL || die_tag ( dw , dim ) != DW_TAG_subrange_type ) terminate ( " \n " , off ) ; tdesc_array_create ( dw , dim , arrtdp , tdp ) ; if ( die_unsigned ( dw , arr , DW_AT_byte_size , & uval , 0 ) ) { tdesc_t * dimtdp ; int flags ; if ( uval == ( unsigned ) -1 ) { printf ( " \n " , __func__ ) ; uval = 0 ; } tdp -> t_size = uval ; flags = TDESC_F_RESOLVED ; for ( dimtdp = tdp -> t_ardef -> ad_contents ; dimtdp -> t_type == ARRAY ; dimtdp = dimtdp -> t_ardef -> ad_contents ) { if ( ! ( dimtdp -> t_flags & TDESC_F_RESOLVED ) ) { flags = 0 ; break ; } } tdp -> t_flags |= flags ; } debug ( 3 , " \n " , off , off , tdp -> t_ardef -> ad_nelems , tdp -> t_size ) ; }
Create a tdesc from an array node.
Create a tdesc from an array node .
/* Check for bogus gcc DW_AT_byte_size attribute */ /*
		 * Ensure that sub-dimensions have sizes too before marking
		 * as resolved.
		 */