Authors: Carolyn Oates
- $Id: parseXTA.c 1927 2005-02-10 10:50:55Z twisti $
+ $Id: parseXTA.c 1959 2005-02-19 11:46:27Z carolyn $
*/
+/*--------------------------------------
+XTA so far
+static
+fields
+virtual
+interfaces - started
+clinit / final
+general initialization
+----
+interfaces
++ hand coded calls for system
+2nd interation (want to try it in inlining)
+
+Testing
+
+?? PARTUSED???
+----------------------------------*/
+
/***************
- Rapid Type Static Analysis of Java program
+ XTA Type Static Analysis of Java program
used -xta option is turned on either explicitly
or automatically with inlining of virtuals.
+ XTA is called for reachable methods and keeps sets for each Method and Field used as follows:
+1. Work list of reachable methods is initialized to main + JVM called methods
+ + missed methods
+2. For virtual method call from M of e.m then
+ a. Add all static lookup of m in the cone of e = ce.mi to reachable worklist
+ JAVA_INVOKESTATIC/ JAVA_INVOKESPECIAL - addXTAcallededges
+ JAVA_INVOKEVIRTUAL - xtaMarkSubs
+ JAVA_INVOKEINTERFACES
+ b. Add mi's parameters class + subtypes that are used by M to mi used classes
+ When XTA parsed follow the calls list (beg. parseXTA)
+ c. Add mi's return type + subtypes used by mi to M's used classes
+ When XTA parsed follow the calledBy list (end parseXTA)
+ d. Add ce of mi to mi's used classes
+ static/special - addXTAcalledges
+
+3. new C (new, <init>, & similiar) then add C to M's used classes
+ JAVA_NEW, INVOKE_SPECIAL <init>, JAVA_CHECKCAST / JAVA_INSTANCEOF - classinit
+4. read Field X.f: add X to M's used classes
+ JAVA_GETSTATIC
+5. write Field X.f: add X+subtypes that are used by M to X's classes
+ JAVA_PUTSTATIC
+
+
+ If M calls
USAGE:
Methods called by NATIVE methods and classes loaded dynamically
cannot be found by parsing. The following files supply missing methods:
bool XTA_DEBUGr = false;
bool XTA_DEBUGopcodes = false;
+/*********************************************************************/
+/*********************************************************************/
+/*-------------------------------------------------------------------------------*/
-/*********************************************************************/
+xtafldinfo * xtafldinfoInit (fieldinfo *f)
+{
+ if (f->xta != NULL)
+ return f->xta;
-void addToXtaWorkList(methodinfo *meth, char *info) {
- xtaNode *xta;
+ f->xta = NEW(xtafldinfo);
-if (meth->methodUsed == USED) return;
+ f->xta->fieldChecked = false;
+ f->xta->fldClassType = NULL;
+ f->xta->XTAclassSet = NULL;
-if (!(meth->flags & ACC_ABSTRACT)) {
- count_methods_marked_used++;
- METHINFOt(meth,info,XTA_DEBUGopcodes)
- if (meth->class->super != NULL) {
- CLASSNAME(meth->class->super,"\tsuper=",XTA_DEBUGr)
- }
- else {
- if (XTA_DEBUGr) printf("\tsuper=NULL\n");}
- fflush(stdout);
- meth ->methodUsed = USED;
+ return f->xta;
+}
+
+/*-------------------------------------------------------------------------------*/
+
+xtainfo *xtainfoInit(methodinfo *m)
+{
+ if (m->xta != NULL)
+ return m->xta; /* already initialized */
+
+ count_methods_marked_used++;
+
+ m ->xta = (xtainfo *) NEW(xtainfo);
+ m ->xta-> XTAmethodUsed = NOTUSED;
+
+ /* xta sets for a method */
+ m->xta->fldsUsed = NULL;
+ m ->xta-> XTAclassSet = NULL;
+ /* Methods's have access to the class they are a part of */
+ m ->xta-> XTAclassSet = add2ClassSet ( m ->xta-> XTAclassSet, m->class);
+ /* cone set of methods parameters */
+ /* what if no param?? is it NULL then, too? */
+ m->xta->paramClassSet = descriptor2typesL(m);
+
+ /* Edges */
+ m->xta->calls = NULL;
+ m->xta->calledBy = NULL;
+
+ m ->xta->markedBy = NULL;
+ m->xta->chgdSinceLastParse = false;
+ return m->xta;
+
+ /* thought needed at some earlier point */
+ /*m->xta->marked = NULL; * comment out*/
+ /*m ->xta->interfaceCalls = NULL*/
+}
+
+/*-------------------------------------------------------------------------------*/
+void xtaAddCallEdges(methodinfo *mCalls, methodinfo *mCalled, s4 monoPoly, char *info) {
+ xtaNode *xta;
+
+/* First call to this method initializations */
+if (mCalled->methodUsed != USED) {
+ if (!(mCalled->flags & ACC_ABSTRACT)) {
+ mCalled->xta = xtainfoInit(mCalled);
+ mCalled ->methodUsed = USED; /* used to see if method in the work list of methods */
xta = NEW(xtaNode);
- xta->method = meth ;
+ xta->method = mCalled ;
list_addlast(xtaWorkList,xta);
-if (meth->class->classUsed == NOTUSED) {
- METHINFOx(meth)
- printf("\nADDED method in class not used at all!\n");
- fflush(stdout);
- }
}
-/***
-else {
- printf("Method not added to work list!!!<%i> : ",
- meth->methodUsed); fflush(stdout);
- METHINFO(meth,true)
- }
-***/
+ else return; /* abstract */
+ }
+
+if ((mCalls == NULL) && (monoPoly == SYSCALL)) return;
+/* Add call edges */
+mCalls->xta->calls = add2MethSet(mCalls->xta->calls, mCalled);
+ /* mono if static, private, final else virtual so poly */
+mCalls->xta->calls->tail->monoPoly = monoPoly;
+
+mCalled->xta->calledBy = add2MethSet(mCalled->xta->calledBy, mCalls);
+
+/* IS THIS REALLY NEEDED???? */
+if (mCalled->xta->calledBy == NULL) panic("mCalled->xta->calledBy is NULL!!!");
+if (mCalls->xta->calls == NULL) panic("mCalls->xta->calls is NULL!!!");
+
}
-/**************************************************************************/
-void xtaMarkSubs(classinfo *class, methodinfo *topmethod);
-/*------------------------------------------------------------------------*/
-void xtaAddUsedInterfaceMethods(classinfo *ci) {
- int jj,mm;
+/*-------------------------------------------------------------------------------*/
+bool xtaPassParams (methodinfo *Called, methodinfo *Calls, methSetNode *lastptrInto)
+{
+ classSetNode *p;
+ classSetNode *c;
+ classSetNode *c1;
+ classSetNode *cprev;
+ bool chgd = false;
+
+ if (lastptrInto->lastptrIntoClassSet2 == NULL) {
+ if (Calls->xta->XTAclassSet != NULL)
+ c1 = Calls->xta->XTAclassSet->head;
+ /*else already c1 = NULL; */
+ }
+ else {
+ /* start with type where left off */
+ c1 = lastptrInto->lastptrIntoClassSet2;
+ c1 = c1 -> nextClass; /* even if NULL */
+ }
+ if (c1 == NULL) return false;
- /* add used interfaces methods to callgraph */
- for (jj=0; jj < ci -> interfacescount; jj++) {
- classinfo *ici = ci -> interfaces [jj];
-
- if (XTA_DEBUGinf) {
- printf("BInterface used: ");fflush(stdout);
- utf_display(ici->name);
- printf("<%i>\t",ici -> classUsed ); fflush(stdout);
- if (ici -> classUsed == NOTUSED) printf("\t classUsed=NOTUSED\n" );
- if (ici -> classUsed == USED) printf("\t classUsed=USED\n");
- if (ici -> classUsed == PARTUSED) printf("\t classUsed=PARTUSED\n");
- fflush(stdout);
- }
- /* add class to interfaces list of classes that implement it */
- ici -> impldBy = addElement(ici -> impldBy, ci);
+ cprev = NULL;
+ /* for each Param Class */
+ for ( p=Called->xta->paramClassSet; p != NULL; p = p->nextClass) {
- /* if interface class is used */
- if (ici -> classUsed != NOTUSED) {
+ /* for each SmCalls class */
+ for (c=c1; c != NULL; c = c->nextClass) {
+ vftbl_t *p_cl_vt = p->classType->vftbl;
+ vftbl_t *c_cl_vt = c->classType->vftbl;
- /* for each interface method implementation that has already been used */
- for (mm=0; mm< ici->methodscount; mm++) {
- methodinfo *imi = &(ici->methods[mm]);
- if (XTA_DEBUGinf) {
- if (imi->methodUsed != USED) {
- if (imi->methodUsed == NOTUSED) printf("Interface Method notused: ");
- if (imi->methodUsed == MARKED) printf("Interface Method marked: ");
- utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
- }
- }
- if (imi->methodUsed == USED) {
- if (XTA_DEBUGinf) {
- printf("Interface Method used: "); utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+ /* if SmCalls class is in the Params Class range */
+ if ( (p_cl_vt->baseval <= c_cl_vt->baseval)
+ && (c_cl_vt->baseval <= (p_cl_vt->baseval+p_cl_vt->diffval)) ) {
+
+ /* add Calls class to CalledBy Class set */
+ Called->xta->XTAclassSet = Called->xta->XTAclassSet = add2ClassSet(Called->xta->XTAclassSet, c->classType);
+ chgd = true;
+ }
+ cprev = c;
+ }
+ }
+ lastptrInto->lastptrIntoClassSet2 = cprev;
+ return chgd;
+}
- /* Mark this method used in the (used) implementing class and its subclasses */
- printf("rMAY ADD methods that was used by an interface\n");
- }
- if ((utf_new_char("<clinit>") != imi->name) &&
- (utf_new_char("<init>") != imi->name))
- xtaMarkSubs(ci,imi);
- }
- }
- }
- }
+/*-------------------------------------------------------------------------------*/
+void xtaPassAllCalledByParams (methodinfo *m) {
+ methSetNode *SmCalled;
+ if (m->xta->calledBy == NULL)
+ return;
+ for (SmCalled = m->xta->calledBy->head;
+ SmCalled != NULL;
+ SmCalled = SmCalled->nextmethRef) {
+ m->xta->chgdSinceLastParse = false; /* re'init flag */
+ xtaPassParams(m, SmCalled->methRef,SmCalled); /* chg flag output ignored for 1st regular parse */
+ }
}
-/**************************************************************************/
-/* Add Marked methods for input class ci */
-/* Add methods with the same name and descriptor as implemented interfaces*/
-/* with the same method name */
-/* */
-/*------------------------------------------------------------------------*/
-void xtaAddMarkedMethods(classinfo *ci) {
-int ii,jj,mm;
+/*-------------------------------------------------------------------------------*/
+void xtaPassFldPUT(methodinfo *m, fldSetNode *fN)
+{
+ /* Field type is a class */
+ classSetNode *c;
+ classSetNode *c1 = NULL;
+ classSetNode *cp = NULL;
+ classSetNode *cprev= NULL;
+
+ fieldinfo *fi;
+ if (fN != NULL)
+ fi = fN->fldRef;
+ else
+ return;
+
+/* Use lastptr so don't check whole XTA class set each time */
+ cp = fN->lastptrPUT;
+ if (cp != NULL) {
+ if (cp->nextClass != NULL)
+ c1 = cp -> nextClass;
+ }
+ else {
+ if (m->xta->XTAclassSet != NULL)
+ c1 = m->xta->XTAclassSet->head;
+ }
-/* add marked methods to callgraph */
-for (ii=0; ii<ci->methodscount; ii++) {
- methodinfo *mi = &(ci->methods[ii]);
+ /*--- PUTSTATIC specific ---*/
+ /* Sx = intersection of type+subtypes(field x) */
+ /* and Sm (where putstatic code is) */
+ for (c=c1; c != NULL; c=c->nextClass) {
+ vftbl_t *f_cl_vt = fi->xta->fldClassType->vftbl;
+ vftbl_t *c_cl_vt = c-> classType->vftbl;
- if (mi->methodUsed == MARKED) {
- addToXtaWorkList(mi,
- "addTo was MARKED:");
+ if ((f_cl_vt->baseval <= c_cl_vt->baseval)
+ && (c_cl_vt->baseval <= (f_cl_vt->baseval+f_cl_vt->diffval)) ) {
+ fi->xta->XTAclassSet = add2ClassSet(fi->xta->XTAclassSet,c->classType);
}
+ cprev = c;
+ }
+ fN->lastptrPUT = cprev;
+}
+/*-------------------------------------------------------------------------------*/
+void xtaPassFldGET(methodinfo *m, fldSetNode *fN)
+{
+ /* Field type is a class */
+ classSetNode *c;
+ classSetNode *c1 = NULL;
+ classSetNode *cp = NULL;
+ classSetNode *cprev= NULL;
+
+ fieldinfo *fi;
+ if (fN != NULL)
+ fi = fN->fldRef;
+ else
+ return;
+
+/* Use lastptr so don't check whole XTA class set each time */
+ cp = fN->lastptrGET;
+ if (cp != NULL) {
+ if (cp->nextClass != NULL)
+ c1 = cp -> nextClass;
+ }
else {
- for (jj=0; jj < ci -> interfacescount; jj++) {
- classinfo *ici = ci -> interfaces [jj];
- /* use resolve method....!!!! */
- if (ici -> classUsed != NOTUSED) {
- for (mm=0; mm< ici->methodscount; mm++) {
- methodinfo *imi = &(ici->methods[mm]);
- METHINFOt(imi,"NEW IMPD INTERFACE:",XTA_DEBUGinf)
- /*if interface method=method is used*/
- if ( (imi->methodUsed == USED)
- && ( (imi->name == mi->name)
- && (imi->descriptor == mi->descriptor))) {
- addToXtaWorkList(mi,
- "addTo was interfaced used/MARKED:");
- }
- } /*end for */
- }
+ if (fi->xta->XTAclassSet != NULL)
+ c1 = fi->xta->XTAclassSet->head;
+ }
+
+ /*--- GETSTATIC specific ---*/
+ /* Sm = union of Sm and Sx */
+ for (c=c1; c != NULL; c=c->nextClass) {
+ bool addFlg = false;
+ if (m->xta->XTAclassSet ==NULL)
+ addFlg = true;
+ else {
+ if (!(inSet (m->xta->XTAclassSet->head, c->classType) ))
+ addFlg = true;
}
+ if (addFlg) {
+ m->xta->XTAclassSet
+ = add2ClassSet(m->xta->XTAclassSet,c->classType);
}
+ cprev = c;
}
-}
-#define CLINITS_T true
-#define FINALIZE_T true
-#define ADDMARKED_T true
+ fN->lastptrGET = cprev;
+}
-#define CLINITS_F false
-#define FINALIZE_F false
-#define ADDMARKED_F false
-/*********************************************************************/
-void XTAaddClassInit(classinfo *ci, bool clinits, bool finalizes, bool addmark)
-{
- methodinfo *mi;
- if (addmark)
- ci->classUsed = USED;
+/*-------------------------------------------------------------------------------*/
+void xtaAllFldsUsed (methodinfo *m) {
+ fldSetNode *f;
+ fldSetNode *f1=NULL;
+ /* bool chgd = false */
+
+ if (m->xta->fldsUsed == NULL) return;
+
+ /* for each field that this method uses */
+ f1 = m->xta->fldsUsed->head;
+
+ for (f=f1; f != NULL; f = f->nextfldRef) {
+
+ if (f->writePUT)
+ xtaPassFldPUT(m,f);
+ if (f->readGET)
+ xtaPassFldGET(m,f);
+ }
+}
+
+/*-------------------------------------------------------------------------------*/
+bool xtaPassReturnType(methodinfo *Called, methodinfo *Calls) {
+
+ classSetNode* cs;
+ classSetNode* cs1;
+ bool fchgd = false;
+
+ /* Get Called return class is null */
+ if ((Called->returnclass == NULL) && (Called->xta->paramClassSet == NULL)) {
+ Called->xta->paramClassSet = descriptor2typesL(Called); /* old comment - in new xta struc init */
+ }
+
+ if (Called->returnclass == NULL) {
+ return fchgd;
+ }
- if (clinits) { /* No <clinit> available - ignore */
- mi = class_findmethod(ci,
- utf_new_char("<clinit>"),
- utf_new_char("()V"));
- if (mi) {
- if (ci->classUsed != USED)
- ci->classUsed = PARTUSED;
- mi->monoPoly = MONO;
- addToXtaWorkList(mi,"addTo CLINIT added:");
- }
- }
+ if (Called->xta->XTAclassSet == NULL)
+ cs1 = NULL;
+ else
+ cs1 = Called->xta->XTAclassSet->head;
+
+ for (cs =cs1; cs != NULL; cs = cs->nextClass) {
+ classinfo *c = cs->classType;
+ vftbl_t *r_cl_vt = Called->returnclass->vftbl;
+ vftbl_t *c_cl_vt = c->vftbl;
+
+ /* if class is a subtype of the return type, then add to Calls class set (ie.interscection)*/
+ if ( (r_cl_vt->baseval <= r_cl_vt->baseval)
+ && (c_cl_vt->baseval <= (r_cl_vt->baseval+r_cl_vt->diffval)) ) {
+ Calls->xta->XTAclassSet = add2ClassSet(Calls->xta->XTAclassSet, c);
+ fchgd = true;
+ }
+ }
- /*Special Case for System class init:
- add java/lang/initializeSystemClass to callgraph */
- if (ci->name == utf_new_char("initializeSystemClass")) {
- /* ?? what is name of method ?? */
- }
+ return fchgd;
+}
- if (finalizes) {
- mi = class_findmethod(ci,
- utf_new_char("finalize"),
- utf_new_char("()V"));
- if (mi) {
- if (ci->classUsed != USED)
- ci->classUsed = PARTUSED;
- mi->monoPoly = MONO;
- addToXtaWorkList(mi,"addTo FINALIZE added:");
- }
- }
- if (addmark) {
- xtaAddMarkedMethods(ci);
- }
- xtaAddUsedInterfaceMethods(ci);
+/*-------------------------------------------------------------------------------*/
+void xtaMethodCalls_and_sendReturnType(methodinfo *m)
+{
+ methSetNode *SmCalled; /* for return type */
+ methSetNode *SmCalls; /* for calls param types */
+ methSetNode *s1=NULL;
+ bool chgd = false;
+ xtaAllFldsUsed (m);
+
+ /* for each method that this method calls */
+ if (m->xta->calls == NULL)
+ s1 = NULL;
+ else
+ s1 = SmCalls=m->xta->calls->head;
+
+ for (SmCalls=s1; SmCalls != NULL; SmCalls = SmCalls->nextmethRef) {
+ /* pass param types */
+ bool chgd = false;
+ chgd = xtaPassParams (SmCalls->methRef, m, SmCalls);
+ /* if true chgd after its own parse */
+ if (!(SmCalls->methRef->xta->chgdSinceLastParse)) {
+ SmCalls->methRef->xta->chgdSinceLastParse = true;
+ }
+ }
+ /* for each calledBy method */
+ /* send return type */
+ if (m->xta->calledBy == NULL)
+ s1 = NULL;
+ else
+ s1 = m->xta->calledBy->head;
+ for (SmCalled=s1; SmCalled != NULL; SmCalled = SmCalled->nextmethRef) {
+
+ chgd = xtaPassReturnType(m, SmCalled->methRef);
+ if (!(SmCalled->methRef->xta->chgdSinceLastParse)) {
+ SmCalled->methRef->xta->chgdSinceLastParse = chgd;
+ }
+ }
}
+/*-------------------------------------------------------------------------------*/
+bool xtaAddFldClassTypeInfo(fieldinfo *fi) {
+
+ bool is_classtype = false; /* return value */
+
+ if (fi->xta->fieldChecked) {
+ if (fi->xta->fldClassType != NULL)
+ return true; /* field has a class type */
+ else
+ return false;
+ }
+ fi->xta->fieldChecked = true;
+
+ if (fi->type == TYPE_ADDRESS) {
+ char *utf_ptr = fi->descriptor->text; /* current position in utf text */
+
+ if (*utf_ptr != 'L') {
+ while (*utf_ptr++ =='[') ;
+ }
+
+ if (*utf_ptr =='L') {
+ is_classtype = true;
+ if (fi->xta->fldClassType== NULL) {
+ char *desc;
+ char *cname;
+ classinfo * class;
+
+ desc = MNEW(char, 256);
+ strcpy(desc,++utf_ptr);
+ cname = strtok(desc,";");
+ class = class_get(utf_new_char(cname));
+ fi->xta->fldClassType= class; /* save field's type class ptr */
+ }
+ }
+ }
+ return is_classtype;
+}
/*--------------------------------------------------------------*/
/* Mark the method with same name /descriptor in topmethod */
/* in class */
/* */
/* Class marked USED and method defined in this class -> */
-/* -> mark method as USED */
+/* -> add call edges = USED */
/* Class not marked USED and method defined in this class -> */
/* -> if Method NOTUSED mark method as MARKED */
/* */
/* Class USED, but method not defined in this class -> */
/* -> 1) search up the heirarchy and mark method where defined */
/* 2) if class where method is defined is not USED -> */
-/* -> mark class with defined method as PARTUSED */
+/* -> ????mark class with defined method as PARTUSED */
/*--------------------------------------------------------------*/
-void xtaMarkMethod(classinfo *class, methodinfo *topmethod) {
+
+void xtaMarkMethod(classinfo *class, methodinfo *mCalls, methodinfo *topmethod, classSetNode *subtypesUsedSet) {
utf *name = topmethod->name;
utf *descriptor = topmethod->descriptor;
printf("parse XTA: Method not found in class hierarchy");fflush(stdout);
panic("parse XTA: Method not found in class hierarchy");
}
-if (submeth->methodUsed == USED) return;
-
+
+/* if submeth called previously from this method then return */
+if (mCalls->xta->calls != NULL) {
+ if (inMethSet(mCalls->xta->calls->head,submeth)) return;
+ }
+
#undef CTA
#ifdef CTA
/* Class Type Analysis if class.method in virt cone marks it used */
/* very inexact, too many extra methods */
- XTAaddClassInit( submeth->class,
+ XTAaddClassInit(submeth, submeth->class,
CLINITS_T,FINALIZE_T,ADDMARKED_T);
- submeth->monoPoly = POLY;
- addToXtaWorkList(submeth,
- "addTo XTA VIRT CONE:");
+ if (inSet(subtypesUsedSet,submeth->class)) {
+ submeth->monoPoly = POLY;
+ xtaAddCallEdges(mCalls, submeth, submeth->monoPoly,
+ "addTo XTA VIRT CONE:");
+ }
return;
#endif
if (submeth->class == class) {
/*--- Method defined in class -----------------------------*/
- if ( submeth->class->classUsed == USED) {
+ if (inSet(subtypesUsedSet,submeth->class)) {
/* method defined in this class -> */
/* Class IS marked USED */
/* -> mark method as USED */
submeth->monoPoly = POLY;
- addToXtaWorkList(submeth,
+ xtaAddCallEdges(mCalls, submeth, submeth->monoPoly,
"addTo VIRT CONE 1:");
}
else {
METHINFOt(submeth,
"\tmarked VIRT CONE 2:",XTA_DEBUGr);
submeth->monoPoly = POLY;
- submeth->methodUsed = MARKED;
+ submeth->xta->markedBy = add2MethSet(submeth->xta->markedBy,mCalls);
/* Note: if class NOTUSED and subclass is used handled */
/* by subsequent calls to xtaMarkMethods for cone */
}
else {
/*--- Method NOT defined in class ---------------*/
/* first mark classes if needed */
- if (submeth->class->classUsed == NOTUSED) {
- submeth->class->classUsed = PARTUSED;
- if (class->classUsed != USED) {
+ if (!(inSet(subtypesUsedSet,submeth->class))) {
+ submeth->class->classUsed = PARTUSED; /**** ???? equivalant for xta ???? */
+ if (!(inSet(subtypesUsedSet,class))) {
submeth->monoPoly = POLY;
- submeth->methodUsed = MARKED;
+ submeth->xta->markedBy = add2MethSet(submeth->xta->markedBy,mCalls);
METHINFOt(submeth,"JUST MARKED :",XTA_DEBUGr);
}
}
/* add method to xta work list if conditions met */
/*??if ( (submeth->class->classUsed == USED) || */
- if (class->classUsed == USED) {
+ if (inSet(subtypesUsedSet,class)) {
submeth->monoPoly = POLY;
- addToXtaWorkList(submeth,
+ xtaAddCallEdges(mCalls, submeth, submeth->monoPoly,
"addTo VIRT CONE 3:");
}
} /* end NOT defined in class */
/* and any subclass where the method is defined and/or class is used */
/* */
/*----------------------------------------------------------------------*/
-void xtaMarkSubs(classinfo *class, methodinfo *topmethod) {
- /* Mark method in class */
- CLASSNAME1(class," MARKSUBS ",XTA_DEBUGr);
- METHINFOt(topmethod," TOP ",XTA_DEBUGr);
- xtaMarkMethod(class, topmethod);
+void xtaMarkSubs(methodinfo *mCalls, classinfo *class, methodinfo *topmethod, classSetNode *subtypesUsedSet) {
+ /* xtaPRINTmarkSubs1*/
+ xtaMarkMethod(class, mCalls, topmethod, subtypesUsedSet); /* Mark method in class where it was found */
+ if (class->sub != NULL) {
+ classinfo *subs;
- /* Mark method in subclasses */
- if (class->sub != NULL) {
- classinfo *subs;
+ if (!(topmethod->flags & ACC_FINAL )) {
+ for (subs = class->sub; subs != NULL; subs = subs->nextsub) {
+ /* xtaPRINTmarkSubs1 */
+ xtaMarkSubs(mCalls, subs, topmethod, subtypesUsedSet);
+ }
+ }
+ }
+}
+
+
+/**************************************************************************/
+/* Add Marked methods for input class ci */
+/* Add methods with the same name and descriptor as implemented interfaces*/
+/* with the same method name */
+/* ??? not XTA checked */
+/*------------------------------------------------------------------------*/
+void xtaAddMarkedMethods(methodinfo *mCalls, classinfo *ci) {
+int ii,jj,mm;
+
+/* add marked methods to callgraph */
+for (ii=0; ii<ci->methodscount; ii++) {
+ methodinfo *mi = &(ci->methods[ii]);
+
+ if (mi->methodUsed == MARKED) {
+ xtaAddCallEdges(mCalls, mi, MONO, /* SHOULD this really be MONO ?????? */
+ "addTo was MARKED:");
+ }
+ else {
+ for (jj=0; jj < ci -> interfacescount; jj++) {
+ classinfo *ici = ci -> interfaces [jj];
+ /* use resolve method....!!!! */
+ if (ici -> classUsed != NOTUSED) {
+ for (mm=0; mm< ici->methodscount; mm++) {
+ methodinfo *imi = &(ici->methods[mm]);
+ METHINFOt(imi,"NEW IMPD INTERFACE:",XTA_DEBUGinf)
+ /*if interface method=method is used*/
+ if ( (imi->methodUsed == USED)
+ && ( (imi->name == mi->name)
+ && (imi->descriptor == mi->descriptor))) {
+ xtaAddCallEdges(mCalls, mi, mi->monoPoly,
+ "addTo was interfaced used/MARKED:");
+ }
+ } /*end for */
+ }
+ }
+ }
+ }
+}
+void xtaAddUsedInterfaceMethods(methodinfo *m, classinfo *ci); /* prototype until check code for xta */
+
+/*----------------------------------------------------------------------*/
+
+#define CLINITS_T true
+#define FINALIZE_T true
+#define ADDMARKED_T true
+
+#define CLINITS_F false
+#define FINALIZE_F false
+#define ADDMARKED_F false
+/*-----------------------*/
+
+void XTAaddClassInit(methodinfo *mCalls, classinfo *ci, bool clinits, bool finalizes, bool addmark)
+{
+ methodinfo *mi;
+
+ if (addmark)
+ ci->classUsed = USED;
- if (!(topmethod->flags & ACC_FINAL )) {
- for (subs = class->sub;subs != NULL;subs = subs->nextsub) {
- CLASSNAME1(subs," SUBS ",XTA_DEBUGr);
- xtaMarkSubs(subs, topmethod);
- }
+ if (clinits) { /* No <clinit> available - ignore */
+ mi = class_findmethod(ci, utf_clinit, utf_void__void);
+ if (mi) {
+ if (ci->classUsed != USED)
+ ci->classUsed = PARTUSED;
+ mi->monoPoly = MONO;
+ xtaAddCallEdges(mCalls, mi, mi->monoPoly,
+ "addTo CLINIT added:");
+ }
+ }
+
+ /*Special Case for System class init:
+ add java/lang/initializeSystemClass to callgraph */
+ if (ci->name == utf_new_char("initializeSystemClass")) {
+ /* ?? what is name of method ?? */
+ }
+
+ if (finalizes) {
+ mi = class_findmethod(ci, utf_finalize, utf_void__void);
+ if (mi) {
+ if (ci->classUsed != USED)
+ ci->classUsed = PARTUSED;
+ mi->monoPoly = MONO;
+ xtaAddCallEdges(mCalls, mi, mi->monoPoly,
+ "addTo FINALIZE added:");
+ }
+ }
+
+ if (addmark) {
+ xtaAddMarkedMethods(mCalls, ci);
+ }
+ xtaAddUsedInterfaceMethods(mi,ci);
+
+}
+
+/*-------------------------------------------------------------------------------*/
+
+/*********************************************************************/
+/*********************************************************************/
+
+/**************************************************************************/
+
+/*------------------------------------------------------------------------*/
+void xtaAddUsedInterfaceMethods(methodinfo *m, classinfo *ci) {
+ int jj,mm;
+
+ /* add used interfaces methods to callgraph */
+ for (jj=0; jj < ci -> interfacescount; jj++) {
+ classinfo *ici = ci -> interfaces [jj];
+
+ if (XTA_DEBUGinf) {
+ printf("BInterface used: ");fflush(stdout);
+ utf_display(ici->name);
+ printf("<%i>\t",ici -> classUsed ); fflush(stdout);
+ if (ici -> classUsed == NOTUSED) printf("\t classUsed=NOTUSED\n" );
+ if (ici -> classUsed == USED) printf("\t classUsed=USED\n");
+ if (ici -> classUsed == PARTUSED) printf("\t classUsed=PARTUSED\n");
+ fflush(stdout);
+ }
+ /* add class to interfaces list of classes that implement it */
+ ici -> impldBy = addElement(ici -> impldBy, ci);
+
+ /* if interface class is used */
+ if (ici -> classUsed != NOTUSED) {
+
+ /* for each interface method implementation that has already been used */
+ for (mm=0; mm< ici->methodscount; mm++) {
+ methodinfo *imi = &(ici->methods[mm]);
+ if (XTA_DEBUGinf) {
+ if (imi->methodUsed != USED) {
+ if (imi->methodUsed == NOTUSED) printf("Interface Method notused: ");
+ if (imi->methodUsed == MARKED) printf("Interface Method marked: ");
+ utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+ }
+ }
+ if (imi->methodUsed == USED) {
+ if (XTA_DEBUGinf) {
+ printf("Interface Method used: "); utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+
+ /* Mark this method used in the (used) implementing class and its subclasses */
+ printf("rMAY ADD methods that was used by an interface\n");
+ }
+ if ((utf_clinit != imi->name) &&
+ (utf_init != imi->name))
+ {
+ classSetNode *subtypesUsedSet = NULL;
+ xtaMarkSubs(m, ci, imi, subtypesUsedSet); /*** CODE not finished for set */
+ }
+ }
+ }
+ }
}
- }
- return;
+
}
/*********************************************************************/
-void xtaMarkInterfaceSubs(methodinfo *mi) {
+void xtaMarkInterfaceSubs(methodinfo *m, methodinfo *mi) {
classSetNode *subs;
if (mi->class->classUsed == NOTUSED) {
mi->class->classUsed = USED;
fflush(stdout);
}
while (subs != NULL) {
- classinfo * isubs = subs->classType;
methodinfo *submeth;
if (XTA_DEBUGinf) {
- printf("\t");utf_display(isubs->name);fflush(stdout);
- printf(" <%i>\n",isubs->classUsed);fflush(stdout);
+ printf("\t");utf_display(subs->classType->name);fflush(stdout);
+ printf(" <%i>\n",subs->classType->classUsed);fflush(stdout);
}
/*Mark method (mark/used) in classes that implement method*/
- submeth = class_findmethod(isubs,mi->name, mi->descriptor);
- if (submeth != NULL)
+ submeth = class_findmethod(subs->classType, mi->name, mi->descriptor);
+ if (submeth != NULL) {
+ classSetNode *subtypesUsedSet = NULL;
submeth->monoPoly = POLY; /* poly even if nosubs */
- xtaMarkSubs(isubs, mi);
+ mi->xta->XTAmethodUsed = USED;
+ if (m->xta->XTAclassSet != NULL) {
+ subtypesUsedSet =
+ intersectSubtypesWithSet
+ (subs->classType, m->xta->XTAclassSet->head);
+
+ subtypesUsedSet =
+ intersectSubtypesWithSet(mi->class, m->xta->XTAclassSet->head);
+ }
+ else
+ subtypesUsedSet = addElement(subtypesUsedSet, m->class);
+ xtaMarkSubs(m, subs->classType, mi, subtypesUsedSet);
+ }
subs = subs->nextClass;
} /* end while */
-
+
/*********************************************************************/
METHINFOt(m,"\n----XTA PARSING:",XTA_DEBUGopcodes);
if ((XTA_DEBUGr)||(XTA_DEBUGopcodes)) printf("\n");
+ if (m->xta == NULL) {
+ xtainfoInit (m);
+ }
+ else {
+ xtaPassAllCalledByParams (m);
+ }
/* scan all java instructions */
for (p = 0; p < m->jcodelength; p = nextp) {
break;
}
/*********************/
- case JAVA_PUTSTATIC:
- case JAVA_GETSTATIC:
+
+ case JAVA_PUTSTATIC: /* write */
i = code_get_u2(p + 1,m);
{
if (!fi)
return 0; /* was NULL */
- CLASSNAME(fi->class,"\tPUT/GETSTATIC: ",XTA_DEBUGr);
- if (!fi->class->initialized) {
- m->isleafmethod = false;
- }
- XTAaddClassInit( fi->class,
+ fi->xta = xtafldinfoInit(fi);
+ XTAaddClassInit(m, fi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_F);
+ if (xtaAddFldClassTypeInfo(fi)) {
+ m->xta->fldsUsed = add2FldSet(m->xta->fldsUsed, fi, true,false);
+ }
+ }
+ break;
+
+
+ case JAVA_GETSTATIC: /* read */
+
+ i = code_get_u2(p + 1,m);
+ {
+ constant_FMIref *fr;
+ fieldinfo *fi;
+
+ fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
+ LAZYLOADING(fr->class)
+
+ fi = class_resolvefield(fr->class,
+ fr->name,
+ fr->descriptor,
+ m->class,
+ true);
+
+ if (!fi)
+ return 0; /* was NULL */
+
+ fi->xta = xtafldinfoInit(fi);
+ XTAaddClassInit(m, fi->class,
+ CLINITS_T,FINALIZE_T,ADDMARKED_F);
+ if (xtaAddFldClassTypeInfo(fi)) {
+ m->xta->fldsUsed = add2FldSet(m->xta->fldsUsed, fi, false, true);
+ }
+
}
break;
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
mr = class_getconstant(m->class, i, CONSTANT_Methodref);
LAZYLOADING(mr->class)
mi = class_resolveclassmethod( mr->class,
METHINFOt(mi,"INVOKESTAT/SPEC:: ",XTA_DEBUGopcodes)
mi->monoPoly = MONO;
- /*---- Handle "leaf" = static, private, final calls----------------------------*/
+ /*---- Handle "leaf" = static, private, final calls-------------*/
if ((opcode == JAVA_INVOKESTATIC)
|| (mi->flags & ACC_STATIC)
|| (mi->flags & ACC_PRIVATE)
|| (mi->flags & ACC_FINAL) )
{
- if (mi->class->classUsed == PARTUSED){
- XTAaddClassInit(mi->class,
+ if (mi->class->classUsed != USED) { /* = NOTUSED or PARTUSED */
+ XTAaddClassInit(m, mi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_T);
- }
- else {
- if (mi->class->classUsed == NOTUSED){
- XTAaddClassInit(mi->class,
- CLINITS_T,FINALIZE_T,ADDMARKED_T);
- if (mi->class->classUsed == NOTUSED){
- /* Leaf methods are used whether class is or not */
- /* so mark class as PARTlyUSED */
- mi->class->classUsed = PARTUSED;
- }
- }
- }
- /* Add to XTA working list/set of reachable methods */
- if (opcode == JAVA_INVOKESTATIC) /* if stmt just for debug tracing */
- addToXtaWorkList(mi,
- "addTo INVOKESTATIC ");
- else
- addToXtaWorkList(mi,
- "addTo INVOKESPECIAL ");
+ /* Leaf methods are used whether class is or not */
+ /* so mark class as PARTlyUSED */
+ mi->class->classUsed = PARTUSED;
}
+ /* Add to XTA working list/set of reachable methods */
+ if (opcode == JAVA_INVOKESTATIC) /* if stmt just for debug tracing */
+ /* calls , called */
+ xtaAddCallEdges(m, mi, MONO,
+ "addTo INVOKESTATIC ");
+ else
+ xtaAddCallEdges(m, mi, MONO,
+ "addTo INVOKESPECIAL ");
+ } /* end STATIC, PRIVATE, FINAL */
- else {
+ else {
/*---- Handle special <init> calls ---------------------------------------------*/
- if (mi->class->classUsed != USED) {
- /* XTA special case:
- call of super's <init> then
- methods of super class not all used */
+ if (mi->class->classUsed != USED) {
+ /* XTA special case:
+ call of super's <init> then
+ methods of super class not all used */
- /*--- <init> ()V is equivalent to "new"
- indicating a class is used = instaniated ---- */
- if (utf_new_char("<init>")==mi->name) {
- if ((m->class->super == mi->class)
- && (m->descriptor == utf_new_char("()V")) )
- {
- METHINFOt(mi,"SUPER INIT:",XTA_DEBUGopcodes);
- /* super init so class may be only used because of its sub-class */
- XTAaddClassInit(mi->class,
+ /*--- <init> ()V is equivalent to "new"
+ indicating a class is used = instaniated ---- */
+ if (utf_init==mi->name) {
+ if ((m->class->super == mi->class)
+ && (m->descriptor == utf_void__void) )
+ {
+ METHINFOt(mi,"SUPER INIT:",XTA_DEBUGopcodes);
+ /* super init so class may be only used because of its sub-class */
+ XTAaddClassInit(m,mi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_F);
- if (mi->class->classUsed == NOTUSED) mi->class->classUsed = PARTUSED;
- }
+ if (mi->class->classUsed == NOTUSED) mi->class->classUsed = PARTUSED;
+ }
else {
/* since <init> indicates classes is used, then add marked methods, too */
METHINFOt(mi,"NORMAL INIT:",XTA_DEBUGopcodes);
- XTAaddClassInit(mi->class,
+ XTAaddClassInit(m, mi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_T);
}
- addToXtaWorkList(mi,
+ xtaAddCallEdges(m, mi, MONO,
"addTo INIT ");
- } /* end just for <init> ()V */
+ } /* end just for <init> ()V */
- /* <clinit> for class inits do not add marked methods; class not yet instaniated */
- if (utf_new_char("<clinit>")==mi->name)
- XTAaddClassInit( mi->class,
+ /* <clinit> for class inits do not add marked methods;
+ class not yet instaniated */
+ if (utf_clinit==mi->name)
+ XTAaddClassInit(m, mi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_F);
- if (!((utf_new_char("<init>")==mi->name))
- || (utf_new_char("<clinit>")==mi->name)) {
- METHINFOt(mi,"SPECIAL not init:",XTA_DEBUGopcodes)
- if (mi->class->classUsed !=USED)
- mi->class->classUsed = PARTUSED;
- addToXtaWorkList(mi,
- "addTo SPEC notINIT ");
- }
+ if (!((utf_init==mi->name))
+ || (utf_clinit==mi->name)) {
+ METHINFOt(mi,"SPECIAL not init:",XTA_DEBUGopcodes)
+ if (mi->class->classUsed !=USED)
+ mi->class->classUsed = PARTUSED;
+ xtaAddCallEdges(m, mi, MONO,
+ "addTo SPEC notINIT ");
+ }
- } /* end init'd class not used = class init process was needed */
+ } /* end init'd class not used = class init process was needed */
- /* add method to XTA list = set of reachable methods */
- addToXtaWorkList(mi,
- "addTo SPEC whymissed ");
- } /* end inits */
- }
+ /* add method to XTA list = set of reachable methods */
+ xtaAddCallEdges(m, mi, MONO,
+ "addTo SPEC whymissed ");
+ } /* end inits */
+ }
/*** assume if method can't be resolved won't actually be called or
there is a real error in classpath and in normal parse an exception
will be thrown. Following debug print can verify this
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
mr = m->class->cpinfos[i];
/*mr = class_getconstant(m->class, i, CONSTANT_Methodref)*/
LAZYLOADING(mr->class)
if ((mi->flags & ACC_STATIC)
|| (mi->flags & ACC_PRIVATE)
|| (mi->flags & ACC_FINAL) )
- {
+ { /*** DOES THIS EVER OCCUR ??? */
if (mi->class->classUsed == NOTUSED){
- XTAaddClassInit(mi->class,
+ XTAaddClassInit(m, mi->class,
CLINITS_T,FINALIZE_T,ADDMARKED_T);
}
mi->monoPoly = MONO;
- addToXtaWorkList(mi,
+ xtaAddCallEdges(m, mi, MONO,
"addTo INVOKEVIRTUAL ");
}
- else {
- mi->monoPoly = POLY;
- xtaMarkSubs(mi->class,mi);
- }
+ else { /* normal virtual */
+ classSetNode *subtypesUsedSet = NULL;
+ if (m->xta->XTAclassSet != NULL)
+ subtypesUsedSet =
+ intersectSubtypesWithSet(mi->class, m->xta->XTAclassSet->head);
+ else
+ subtypesUsedSet = addElement(subtypesUsedSet, m->class);
+ mi->monoPoly = POLY;
+ xtaMarkSubs(m, mi->class, mi, subtypesUsedSet);
+ }
}
else {
CLASSNAME1(mr->class,"CouldNOT Resolve virt meth:",XTA_DEBUGr);printf(".");fflush(stdout);
constant_FMIref *mr;
methodinfo *mi;
- m->isleafmethod = false;
-
mr = class_getconstant(m->class, i, CONSTANT_InterfaceMethodref);
LAZYLOADING(mr->class)
if (mi)
{
METHINFOt(mi,"\tINVOKEINTERFACE: ",XTA_DEBUGopcodes)
- xtaMarkInterfaceSubs(mi);
+ xtaMarkInterfaceSubs(m,mi);
}
/* see INVOKESTATIC for explanation about */
/* case when Interface is not resolved */
{
classinfo *ci;
ci = class_getconstant(m->class, i, CONSTANT_Class);
- m->isleafmethod = false; /* why for new ? */
/*** s_count++; look for s_counts for VTA */
- /***ci->classUsed=USED; */
/* add marked methods */
CLASSNAME(ci,"NEW : do nothing",XTA_DEBUGr);
- XTAaddClassInit(ci, CLINITS_T, FINALIZE_T,ADDMARKED_T);
+ XTAaddClassInit(m, ci, CLINITS_T, FINALIZE_T,ADDMARKED_T);
+ m->xta->XTAclassSet = add2ClassSet(m->xta->XTAclassSet,ci );
}
break;
LAZYLOADING(cls)
CLASSNAMEop(cls,XTA_DEBUGr);
if (cls->classUsed == NOTUSED){
- XTAaddClassInit(cls,
+ XTAaddClassInit(m, cls,
CLINITS_T,FINALIZE_T,ADDMARKED_T);
+ m->xta->XTAclassSet = add2ClassSet(m->xta->XTAclassSet,cls );
}
}
break;
} /* end switch */
} /* end for */
+ xtaMethodCalls_and_sendReturnType(m);
return rc;
}
/* Initialize XTA Work list ***********************************************/
/*-- Get meth ptr for class.meth desc and add to XTA worklist --*/
-#define SYSADD(cls,meth,desc,txt) \
- c = class_new(utf_new_char(cls)); \
- LAZYLOADING(c) \
- callmeth = class_resolveclassmethod(c, \
- utf_new_char(meth), \
- utf_new_char(desc), \
- c, \
- false); \
- if (callmeth->class->classUsed != USED) { \
- c->classUsed = PARTUSED; \
- XTAaddClassInit(callmeth->class, \
- CLINITS_T,FINALIZE_T,ADDMARKED_T);\
- } \
- callmeth->monoPoly = POLY; \
- addToXtaWorkList(callmeth,txt);
-
-
-/*--
+#define SYSADD(cls,meth,desc, is_mono_poly, txt) \
+ c = class_new(utf_new_char(cls)); \
+ LAZYLOADING(c) \
+ callmeth = class_resolveclassmethod(c, \
+ utf_new_char(meth), \
+ utf_new_char(desc), \
+ c, \
+ false); \
+ if (callmeth->class->classUsed != USED) { \
+ c->classUsed = PARTUSED; \
+ XTAaddClassInit(callmeth, callmeth->class, \
+ CLINITS_T,FINALIZE_T,ADDMARKED_T);\
+ } \
+ callmeth->monoPoly = is_mono_poly; \
+ xtaAddCallEdges(NULL, callmeth, is_mono_poly, txt);
+
+/*-- ----------------------------------------------------------------------------
Initialize XTA work list with methods/classes from:
System calls
and
xtaMissedIn list (missed becaused called from NATIVE &/or dynamic calls
---*/
+-------------------------------------------------------------------------------*/
methodinfo *initializeXTAworklist(methodinfo *m) {
classinfo *c;
methodinfo* callmeth;
/* Add first method to call list */
m->class->classUsed = USED;
- addToXtaWorkList(m,systxt);
+ xtaAddCallEdges(NULL, m, SYSCALL, systxt);
/* Add system called methods */
-/*** SYSADD(mainstring, "main","([Ljava/lang/String;)V",systxt) ***/
- SYSADD(MAINCLASS, MAINMETH, MAINDESC,systxt)
+/*** SYSADD(mainstring, "main","([Ljava/lang/String;)V", SYSCALL, systxt) ***/
+ SYSADD(MAINCLASS, MAINMETH, MAINDESC, SYSCALL, systxt)
rm = callmeth;
-/*** SYSADD("java/lang/System","exit","(I)V",systxt) ***/
- SYSADD(EXITCLASS, EXITMETH, EXITDESC, systxt)
+/*** SYSADD("java/lang/System","exit","(I)V",SYSCALL, systxt) ***/
+ SYSADD(EXITCLASS, EXITMETH, EXITDESC, SYSCALL, systxt)
/*----- xtaMissedIn 0 */
if ( (xtaMissedIn = fopen("xtaMissedIn0", "r")) == NULL) {
/*if (opt_verbose) */
class = strtok(line, " \n");
meth = strtok(NULL, " \n");
desc = strtok(NULL, " \n");
- SYSADD(class,meth,desc,missedtxt)
+ SYSADD(class,meth,desc, POLY, missedtxt)
+ /* ??? Need to hand / hard code who calls it ??? */
}
fclose(xtaMissedIn);
/*- end initializeXTAworklist-------- */
-
+/*-------------------------------------------------------------------------------*/
methodinfo *missedXTAworklist()
{
FILE *xtaMissedIn; /* Methods missed during previous XTA parse */
char filenameIn[256] = "xtaIn/";
char line[256];
char* class, *meth, *desc;
+ char* calls_class, *calls_meth, *calls_desc;
char missedtxt[] = "xtaIn/ missed Call :";
classinfo *c;
methodinfo* callmeth;
#if defined(USE_THREADS)
- SYSADD(THREADCLASS, THREADMETH, THREADDESC, "systxt2")
- SYSADD(THREADGROUPCLASS, THREADGROUPMETH, THREADGROUPDESC, "systxt2")
+ SYSADD(THREADCLASS, THREADMETH, THREADDESC, SYSCALL, "systxt2")
+ SYSADD(THREADGROUPCLASS, THREADGROUPMETH, THREADGROUPDESC, SYSCALL, "systxt2")
#endif
/*----- xtaMissedIn pgm specific */
strcat(filenameIn, (const char *)mainstring);
return rm;
}
while (XTAgetline(line,256,xtaMissedIn)) {
- class = strtok(line, " \n");
+ calls_class = strtok(line, " \n");
+ calls_meth = strtok(NULL, " \n");
+ calls_desc = strtok(NULL, " \n");
+
+ class = strtok(NULL, " \n");
meth = strtok(NULL, " \n");
desc = strtok(NULL, " \n");
- if ((class == NULL) || (meth == NULL) || (desc == NULL)) {
- fprintf(stderr,"Error in xtaMissedIn file for: %s.%s %s\n",class, meth, desc);
- fflush(stderr);
- panic ("Error in xtaMissedIn file for: class.meth, desc\n");
- }
- SYSADD(class,meth,desc,missedtxt)
+
+ if ((calls_class == NULL) || (calls_meth == NULL) || (calls_desc == NULL)
+ || (class == NULL) || (meth == NULL) || (desc == NULL))
+ panic (
+ "Error in xtaMissedIn file: Missing a part of calls_class.calls_meth calls calls_desc class.meth desc \n");
+ SYSADD(class,meth,desc, POLY, missedtxt)
}
fclose(xtaMissedIn);
/* Should only be called once */
if (firstCall) {
- /*----- XTA initializations --------*/
- if (opt_verbose)
+ /*----- XTA initializations --------*/
+ if (opt_verbose)
log_text("XTA static analysis started.\n");
- mainmeth = initializeXTAworklist(m);
- firstCall = false; /* turn flag off */
+ mainmeth = initializeXTAworklist(m);
+ firstCall = false; /* turn flag off */
if ( (xtaMissed = fopen("xtaMissed", "w")) == NULL) {
printf("CACAO - xtaMissed file: cant open file to write\n");