FreeBSD/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
/*
 * Most enums (those with members) will be resolved during this first pass.
 * Others - those without members (see the file comment) - won't be, and will
 * need to wait until the second pass when they can be matched with their full
 * definitions.
 */
Most enums (those with members) will be resolved during this first pass.
Others - those without members  - won't be, and will
need to wait until the second pass when they can be matched with their full
definitions.
Most enums ( those with members ) will be resolved during this first pass . Others - those without members - won ' t be and will need to wait until the second pass when they can be matched with their full definitions .
static void
die_enum_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
{
	Dwarf_Die mem;
	Dwarf_Unsigned uval;
	Dwarf_Signed sval;
	debug(3, "die %llu: creating enum\n", off);
	tdp->t_type = ENUM;
	(void) die_unsigned(dw, die, DW_AT_byte_size, &uval, DW_ATTR_REQ);
	if (uval == (unsigned)-1) {
		printf("dwarf.c:%s() working around bogus -1 DW_AT_byte_size\n",
		    __func__); 
		uval = 0;
	}
	tdp->t_size = uval;
	if ((mem = die_child(dw, die)) != NULL) {
		elist_t **elastp = &tdp->t_emem;
		do {
			elist_t *el;
			if (die_tag(dw, mem) != DW_TAG_enumerator) {
				die_create_one(dw, mem);
				continue;
			}
			el = xcalloc(sizeof (elist_t));
			el->el_name = die_name(dw, mem);
			if (die_signed(dw, mem, DW_AT_const_value, &sval, 0)) {
				el->el_number = sval;
			} else if (die_unsigned(dw, mem, DW_AT_const_value,
			    &uval, 0)) {
				el->el_number = uval;
			} else {
				terminate("die %llu: enum %llu: member without "
				    "value\n", off, die_off(dw, mem));
			}
			debug(3, "die %llu: enum %llu: created %s = %d\n", off,
			    die_off(dw, mem), el->el_name, el->el_number);
			*elastp = el;
			elastp = &el->el_next;
		} while ((mem = die_sibling(dw, mem)) != NULL);
		hash_add(dw->dw_enumhash, tdp);
		tdp->t_flags |= TDESC_F_RESOLVED;
		if (tdp->t_name != NULL) {
			iidesc_t *ii = xcalloc(sizeof (iidesc_t));
			ii->ii_type = II_SOU;
			ii->ii_name = xstrdup(tdp->t_name);
			ii->ii_dtype = tdp;
			iidesc_add(dw->dw_td->td_iihash, ii);
		}
	}
}
static void die_enum_create ( dwarf_t * dw , Dwarf_Die die , Dwarf_Off off , tdesc_t * tdp ) { Dwarf_Die mem ; Dwarf_Unsigned uval ; Dwarf_Signed sval ; debug ( 3 , " \n " , off ) ; tdp -> t_type = ENUM ; ( void ) die_unsigned ( dw , die , DW_AT_byte_size , & uval , DW_ATTR_REQ ) ; if ( uval == ( unsigned ) -1 ) { printf ( " \n " , __func__ ) ; uval = 0 ; } tdp -> t_size = uval ; if ( ( mem = die_child ( dw , die ) ) != NULL ) { elist_t * * elastp = & tdp -> t_emem ; do { elist_t * el ; if ( die_tag ( dw , mem ) != DW_TAG_enumerator ) { die_create_one ( dw , mem ) ; continue ; } el = xcalloc ( sizeof ( elist_t ) ) ; el -> el_name = die_name ( dw , mem ) ; if ( die_signed ( dw , mem , DW_AT_const_value , & sval , 0 ) ) { el -> el_number = sval ; } else if ( die_unsigned ( dw , mem , DW_AT_const_value , & uval , 0 ) ) { el -> el_number = uval ; } else { terminate ( " " " \n " , off , die_off ( dw , mem ) ) ; } debug ( 3 , " \n " , off , die_off ( dw , mem ) , el -> el_name , el -> el_number ) ; * elastp = el ; elastp = & el -> el_next ; } while ( ( mem = die_sibling ( dw , mem ) ) != NULL ) ; hash_add ( dw -> dw_enumhash , tdp ) ; tdp -> t_flags |= TDESC_F_RESOLVED ; if ( tdp -> t_name != NULL ) { iidesc_t * ii = xcalloc ( sizeof ( iidesc_t ) ) ; ii -> ii_type = II_SOU ; ii -> ii_name = xstrdup ( tdp -> t_name ) ; ii -> ii_dtype = tdp ; iidesc_add ( dw -> dw_td -> td_iihash , ii ) ; } } }
Most enums (those with members) will be resolved during this first pass.
Most enums ( those with members ) will be resolved during this first pass .
/* Check for bogus gcc DW_AT_byte_size attribute */ /* Nested type declaration */