Ejemplo n.º 1
0
static void dump_sue(dump *ctx, type *ty)
{
	struct_union_enum_st *sue = type_is_s_or_u_or_e(ty);
	sue_member **mi;

	if(!sue)
		return;

	dump_inc(ctx);

	for(mi = sue->members; mi && *mi; mi++){
		if(sue->primitive == type_enum){
			enum_member *emem = (*mi)->enum_member;

			dump_desc(ctx, emem->spel, emem, &emem->where);

			if(emem->val && emem->val != (expr *)-1){
				dump_inc(ctx);
				dump_expr(emem->val, ctx);
				dump_dec(ctx);
			}

			dump_attributes(emem->attr, ctx);

		}else{
			decl *d = (*mi)->struct_member;

			dump_decl(d, ctx, "member");

			dump_sue(ctx, d->ref);
		}
	}

	dump_dec(ctx);
}
Ejemplo n.º 2
0
static void process_file(FILE *in, FILE *out)
{
	static unsigned char attributes[NUM_KEYSYMS];
	init_keysyms(attributes);
	read_file(in, attributes);
	dump_attributes(out, attributes);
}
Ejemplo n.º 3
0
struct wprobe_iface *
wprobe_get_dev(const char *ifname)
{
    struct wprobe_iface *dev;

    if (wprobe_init() != 0)
        return NULL;

    dev = malloc(sizeof(struct wprobe_iface));
    if (!dev)
        return NULL;

    memset(dev, 0, sizeof(struct wprobe_iface));
    dev->ifname = strdup(ifname);
    if (!dev->ifname)
        goto error;

    dev->interval = -1;
    dev->scale_min = -1;
    dev->scale_max = -1;
    dev->scale_m = -1;
    dev->scale_d = -1;

    INIT_LIST_HEAD(&dev->global_attr);
    INIT_LIST_HEAD(&dev->link_attr);
    INIT_LIST_HEAD(&dev->links);

    dump_attributes(ifname, false, &dev->global_attr, NULL);
    dump_attributes(ifname, true, &dev->link_attr, NULL);

    return dev;

error:
    free(dev);
    return NULL;
}
Ejemplo n.º 4
0
void dump_decl(decl *d, dump *ctx, const char *desc)
{
	const int is_func = !!type_is(d->ref, type_func);
	type *ty;

	if(!desc){
		if(d->spel){
			desc = is_func ? "function" : "variable";
		}else{
			desc = "type";
		}
	}

	dump_desc_colour_newline(ctx, desc, d, &d->where,
			maybe_colour(ctx->fout, col_desc_decl), 0);

	if(d->proto)
		dump_printf_indent(ctx, 0, " prev %p", (void *)d->proto);

	if(d->spel)
		dump_printf_indent(ctx, 0, " %s", d->spel);

	dump_type(ctx, d->ref);

	if(d->store)
		dump_printf_indent(ctx, 0, " %s", decl_store_to_str(d->store));

	dump_printf_indent(ctx, 0, "\n");

	if(!is_func){
		type *tof = type_skip_non_tdefs(d->ref);
		if(tof->type == type_tdef && !tof->bits.tdef.decl){
			/* show typeof expr */
			dump_inc(ctx);
			dump_expr(tof->bits.tdef.type_of, ctx);
			dump_dec(ctx);
		}

		if(d->bits.var.field_width){
			dump_inc(ctx);
			dump_expr(d->bits.var.field_width, ctx);
			dump_dec(ctx);
		}

		if(!d->spel){
			dump_sue(ctx, d->ref);
		}else if(d->bits.var.init.dinit){
			dump_inc(ctx);
			dump_init(ctx, d->bits.var.init.dinit);
			dump_dec(ctx);
		}
	}

	dump_inc(ctx);
	dump_attributes(d->attr, ctx);
	ty = type_skip_non_attr(d->ref);
	if(ty && ty->type == type_attr)
		dump_attributes(ty->bits.attr, ctx);
	dump_dec(ctx);

	if(is_func && d->bits.func.code){
		funcargs *fa = type_funcargs(d->ref);

		dump_inc(ctx);
		dump_args(fa, ctx);
		dump_stmt(d->bits.func.code, ctx);
		dump_dec(ctx);
	}
}
Ejemplo n.º 5
0
Archivo: break.c Proyecto: easemob/otp
void
loaded(int to, void *to_arg)
{
    int i;
    int old = 0;
    int cur = 0;
    BeamInstr* code;
    Module* modp;
    ErtsCodeIndex code_ix;

    code_ix = erts_active_code_ix();
    erts_rlock_old_code(code_ix);

    /*
     * Calculate and print totals.
     */
    for (i = 0; i < module_code_size(code_ix); i++) {
	if ((modp = module_code(i, code_ix)) != NULL &&
	    ((modp->curr.code_length != 0) ||
	     (modp->old.code_length != 0))) {
	    cur += modp->curr.code_length;
	    if (modp->old.code_length != 0) {
		old += modp->old.code_length;
	    }
	}
    }
    erts_print(to, to_arg, "Current code: %d\n", cur);
    erts_print(to, to_arg, "Old code: %d\n", old);
    
    /*
     * Print one line per module.
     */

    for (i = 0; i < module_code_size(code_ix); i++) {
	modp = module_code(i, code_ix);
	if (!ERTS_IS_CRASH_DUMPING) {
	    /*
	     * Interactive dump; keep it brief.
	     */
	    if (modp != NULL &&
	    ((modp->curr.code_length != 0) ||
	     (modp->old.code_length != 0))) {
		erts_print(to, to_arg, "%T", make_atom(modp->module));
		cur += modp->curr.code_length;
		erts_print(to, to_arg, " %d", modp->curr.code_length );
		if (modp->old.code_length != 0) {
		    erts_print(to, to_arg, " (%d old)",
			       modp->old.code_length );
		    old += modp->old.code_length;
		}
		erts_print(to, to_arg, "\n");
	    }
	} else {
	    /*
	     * To crash dump; make it parseable.
	     */
	    if (modp != NULL &&
		((modp->curr.code_length != 0) ||
		 (modp->old.code_length != 0))) {
		erts_print(to, to_arg, "=mod:");
		erts_print(to, to_arg, "%T", make_atom(modp->module));
		erts_print(to, to_arg, "\n");
		erts_print(to, to_arg, "Current size: %d\n",
			   modp->curr.code_length);
		code = modp->curr.code;
		if (code != NULL && code[MI_ATTR_PTR]) {
		    erts_print(to, to_arg, "Current attributes: ");
		    dump_attributes(to, to_arg, (byte *) code[MI_ATTR_PTR],
				    code[MI_ATTR_SIZE]);
		}
		if (code != NULL && code[MI_COMPILE_PTR]) {
		    erts_print(to, to_arg, "Current compilation info: ");
		    dump_attributes(to, to_arg, (byte *) code[MI_COMPILE_PTR],
				    code[MI_COMPILE_SIZE]);
		}

		if (modp->old.code_length != 0) {
		    erts_print(to, to_arg, "Old size: %d\n", modp->old.code_length);
		    code = modp->old.code;
		    if (code[MI_ATTR_PTR]) {
			erts_print(to, to_arg, "Old attributes: ");
			dump_attributes(to, to_arg, (byte *) code[MI_ATTR_PTR],
					code[MI_ATTR_SIZE]);
		    }
		    if (code[MI_COMPILE_PTR]) {
			erts_print(to, to_arg, "Old compilation info: ");
			dump_attributes(to, to_arg, (byte *) code[MI_COMPILE_PTR],
					code[MI_COMPILE_SIZE]);
		    }
		}
	    }
	}
    }
    erts_runlock_old_code(code_ix);
}