Пример #1
0
/* Extensions to built-in functions */
VALUE_S *
eppic_memset(VALUE_S *vaddr, VALUE_S *vch, VALUE_S *vlen)
{
	ull addr = eppic_getval(vaddr);
	int len = eppic_getval(vlen);
	int ch = eppic_getval(vch);

	/*
	 * Set the value at address from iaddr till iaddr + nbytes
	 * to the value specified in variable ch
	 */
	UPDATE_FILTER_INFO_RAW(addr, ch, len);
	return eppic_makebtype(1);
}
Пример #2
0
int
apigetval(char *name, ull *val, VALUE_S *value)
{
	ull ptr = 0;

	ptr = GET_SYMBOL_ADDR_ALL(name);

	if (!ptr)
		return 0;

	*val = ptr;

	if (!value)
		return 1;

	/* Support for fully typed symbol access */
	ull type;
	TYPE_S *stype;

	type = GET_DIE_OFFSET(name);
	stype = eppic_gettype(value);

	apigetrtype(type, stype);

	eppic_pushref(stype, 1);
	eppic_setmemaddr(value, *val);
	eppic_do_deref(1, value, value);

	*val = eppic_getval(value);

	if (!eppic_typeislocal(stype) && eppic_type_getidx(stype) > 100) {
		char *tname = GET_DIE_NAME(eppic_type_getidx(stype));
		if (tname) {
			eppic_chktype(stype, tname);
			/* Free the memory allocated by makedumpfile. */
			free(tname);
		}
	}
	return 1;
}
Пример #3
0
/*
    Print a type.
    Typical output of the 'whatis' command.
*/
static
void eppic_ptype2(type_t*t, value_t*v, int level, int indent, char *name, int ref, int justv)
{
int type=t->type;

    eppic_indent(level, indent);
    switch(type) {

        case V_STRUCT: case V_UNION:

            /* make sure we have all the member info */
            eppic_print_ctype(t, v, level, 0, name, ref, justv);
        break;


        case V_TYPEDEF:
            /* no typedef should get here */
            eppic_warning("Typedef in print!");
        break;

        case V_ENUM:
            /* no enum should get here */
            eppic_warning("ENUM in print!");
        break;

        case V_REF:
        {
        int refi=t->ref, ref=refi;

            /* decrement ref if this was declared as a array */
            if(t->idxlst) ref--;

            /* print the referenced type */
            eppic_popref(t, t->ref);
            eppic_ptype2(t, 0, level, 0, 0, 1, justv);
            eppic_pushref(t, refi);

            if(!justv) {

                char buf[100], buf2[100];
                int pos=0, len=sizeof(buf);

                buf[0]='\0';
                if(t->fct) buf[pos++]='(';
                if(pos < len)
                    pos += snprintf(buf+pos, len-pos, "%s%s", eppic_getref(ref), name?name:"");
                if(pos < len)
                    pos += snprintf(buf+pos, len-pos, "%s", eppic_getidx(t, buf2, sizeof(buf2)));
                if(pos < len && t->fct)
                    pos += snprintf(buf+pos, len-pos, "%s", ")()");

                eppic_msg("%*s ", NAMESPACE, buf);
            }

            /* arrays are ref with boundaries... */
            if(t->idxlst && v) {

                if(t->idxlst[1] || t->rtype!=V_BASE || t->size!=1 || !eppic_prtstr(v, justv)) 
                {
                    if(!justv) eppic_msg("= ");
                    eppic_popref(t, 1);
                    eppic_prtarray(t, v->mem, level, 0);
                    eppic_pushref(t, 1);
                }

            } else if(v) {

                if(!justv) eppic_msg("= ");
                if(!eppic_getval(v)) eppic_msg("(nil)");
                else {
                    if(eppic_defbsize()==8) eppic_msg("0x%016llx", eppic_getval(v));
                    else eppic_msg("0x%08x", eppic_getval(v));
                }
                if(t->ref==1 && t->rtype==V_BASE && t->size==1) {

                    (void)eppic_prtstr(v, justv);
                }
            }
        }
        break;

        case V_BASE:
        {
            if(eppic_isenum(t->typattr)) {

                stinfo_t *st=eppic_getstbyindex(t->rtype, V_ENUM);
                if(!justv) {
                    char buf[200];
                    snprintf(buf, sizeof(buf), "enum %s", st->name?st->name:"");
                    eppic_msg("%-*s ", SPACER, buf);
                    eppic_msg("%*s ", NAMESPACE, (name&&v)?name:"");
                }
                if(v) {

                    enum_t *e=st->enums;

                    eppic_msg("= ");
                    eppic_prbval(v);
                    while(e) {

                        if(e->value==eppic_getval(v)) {
                            eppic_msg(" [%s]", e->name);
                            break;
                        }
                        e=e->next;
                    }
                    if(!e) eppic_msg(" [???]");

                }else{

                    enum_t *e=st->enums;
                    int count=0;

                    eppic_msg(" {");
                    while(e) {

                        if(!(count%4)) {
                            eppic_msg("\n");
                            eppic_indent(level+1, 1);
                        }
                        count ++;
                        eppic_msg("%s = %d, ", e->name, e->value);
                        e=e->next;

                    }
                    eppic_msg("\n");
                    eppic_indent(level, 1);
                    eppic_msg("%-*s ", SPACER, "}");
                    if(ref) return;
                    eppic_msg("%*s ", NAMESPACE, name?name:"");
                }

            } else {

                if(!justv) {
                    eppic_msg("%-*s " , SPACER , eppic_getbtypename(t->typattr));
                    if(ref) return;
                    eppic_msg("%s%*s ", eppic_getref(t->ref), NAMESPACE, name?name:"");
                }
                if(v) { 

                    if(!justv) eppic_msg("= ");
                    eppic_prbval(v);
                }
            }
        }
        break;
        case V_STRING:
            if(!justv) {
                eppic_msg("%-*s " , SPACER , "string");
                eppic_msg("%*s ", NAMESPACE, name?name:"");
            }
            if(v) {

                if(!justv) eppic_msg("= ");
                eppic_msg("\"%s\"", v->v.data);
            }
        break;
    }
    if(indent) eppic_msg("\n");
}
Пример #4
0
static value_t *
eppic_exeindex(index_t  *i)
{
value_t *var;
value_t *vi=NODE_EXE(i->index);
value_t *v;
srcpos_t p;

    eppic_curpos(&i->pos, &p);

    /* we need to make believe it's been initiazed */
    eppic_setini(i->var);
    var=NODE_EXE(i->var);

    /* check the type of the variable */
    /* if it's a pointer then index through the image */
    if(var->type.type==V_REF) {

        int size;
        int n=eppic_getval(vi);
        value_t *ref;

        /* if this is an array and we're not at the rightmost index */
        if(var->type.idxlst && var->type.idxlst[1]) {

            int i, size=var->type.size;

            v=eppic_cloneval(var);

            v->type.idxlst[0]=0;
            for(i=1; var->type.idxlst[i]; i++) {

                size *= var->type.idxlst[i];
                v->type.idxlst[i]=var->type.idxlst[i+1];
            }

            if(eppic_defbsize()==4) {

                v->v.ul+=size*n;
                v->mem=v->v.ul;

            } else {

                v->v.ull+=size*n;
                v->mem=v->v.ull;
            }
            

        } else {

            v=eppic_newval();
            ref=eppic_cloneval(var);

            if(var->type.ref==1) size=var->type.size;
            else size=eppic_defbsize();

            if(eppic_defbsize()==4) {

                ref->v.ul+=size*n;
                ref->mem=ref->v.ul;

            } else {

                ref->v.ull+=size*n;
                ref->mem=ref->v.ull;
            }
            eppic_do_deref(1, v, ref);
            eppic_freeval(ref);
        }

    } else {

        v=eppic_newval();

        /* use dynamic indexing aka awk indexing */
        eppic_valindex(var, vi, v);
    }

    /* discard expression results */
    eppic_freeval(var);
    eppic_freeval(vi);
    eppic_curpos(&p, 0);

    return v;
}
Пример #5
0
static void
eppic_prbval(value_t *v)
{
    if(eppic_issigned(v->type.typattr)) eppic_msg("%8lld", eppic_getval(v));
    else eppic_msg("%8llu", eppic_getval(v));
}