static value_t * eppic_exepto(ptrto *pto) { value_t *v=eppic_newval(); int n=pto->lev; value_t *ref=NODE_EXE(pto->n); eppic_do_deref(n, v, ref); eppic_freeval(ref); return v; }
static void eppic_prtarray(type_t*t, ull mem, int level, int idx) { int i; int j, size=1; for(j=idx+1; t->idxlst[j]; j++) size *= t->idxlst[j]; size *= t->type==V_REF ? eppic_defbsize() : t->size; /* start printing */ eppic_msg("{"); eppic_msg("\n"); eppic_indent(level+1, 1); for(i=0; i<t->idxlst[idx]; i++, mem += size) { if(t->idxlst[idx+1]) { eppic_msg("[%d] = ", i); eppic_prtarray(t, mem, level+1, idx+1); } else { /* time to deref and print final type */ value_t *v=eppic_newval(), *vr=eppic_newval(); int *pi=t->idxlst; t->idxlst=0; eppic_duptype(&vr->type, t); eppic_pushref(&vr->type, 1); if(eppic_defbsize()==8) vr->v.ull=mem; else vr->v.ul=(ul)mem; eppic_do_deref(1, v, vr); if(is_ctype(v->type.type) || !(i%NBUNDLE)) eppic_msg("[%2d] ", i); eppic_ptype2(&v->type, v, level+1, 0, 0, 0, 1); eppic_msg(", "); /* anything else then struct/unions, print in buddles */ if(!is_ctype(v->type.type) && !((i+1)%NBUNDLE)) { eppic_msg("\n"); eppic_indent(level+1, 1); } eppic_freeval(v); eppic_freeval(vr); t->idxlst=pi; } } eppic_msg("\n"); eppic_indent(level, 1); eppic_msg("}"); }
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; }
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; }