public class BCXPointsToCheckVRuntime implements BuildCodeExtension {
protected BuildCode buildCode;
+ protected TypeUtil typeUtil;
protected HeapAnalysis heapAnalysis;
+ protected ClassDescriptor cdObject;
+
public BCXPointsToCheckVRuntime( BuildCode buildCode,
+ TypeUtil typeUtil,
HeapAnalysis heapAnalysis ) {
this.buildCode = buildCode;
+ this.typeUtil = typeUtil;
this.heapAnalysis = heapAnalysis;
}
protected void
printConditionFailed( PrintWriter output,
- String condition ) {
+ String condition,
+ String pointer ) {
+
+ // don't do this in the constructor of this extension object because
+ // build code hasn't created any types or classes yet!
+ if( cdObject == null ) {
+ cdObject = typeUtil.getClass( typeUtil.ObjectClass );
+ assert cdObject != null;
+ }
+
output.println( "printf(\"[[[ CHECK VS HEAP RESULTS FAILED ]]] Condition for failure( "+
- condition+" ) at %s:%d\\n\", __FILE__, __LINE__ );" );
+ condition+" ) allocsite=%d at %s:%d\\n\", ((struct "+
+ cdObject.getSafeSymbol()+"*)"+
+ pointer+")->allocsite, __FILE__, __LINE__ );" );
}
assert targetsByAnalysis != null;
-
output.println( "" );
output.println( "// checks vs. heap results (DEBUG) for "+x );
return;
}
+ String ptr = buildCode.generateTemp( context, x );
String condition;
if( targetsByAnalysis.isEmpty() ) {
- condition =
- buildCode.generateTemp( context, x )+
- " != NULL";
+ condition = ptr+" != NULL";
} else {
- condition =
- buildCode.generateTemp( context, x )+
- " != NULL &&";
+ condition = ptr+" != NULL &&";
Iterator<Alloc> aItr = targetsByAnalysis.iterator();
while( aItr.hasNext() ) {
Alloc a = aItr.next();
- condition +=
- buildCode.generateTemp( context, x )+
- "->allocsite != "+
- a.getUniqueAllocSiteID();
+ condition += ptr+"->allocsite != "+a.getUniqueAllocSiteID();
if( aItr.hasNext() ) {
condition += " &&";
}
output.println( "if( "+condition+" ) {" );
- printConditionFailed( output, condition );
+ printConditionFailed( output, condition, ptr );
output.println( "}\n" );
}
}
output.println( "if( "+condition+" ) {" );
- printConditionFailed( output, condition );
+ printConditionFailed( output, condition, "objOneHop" );
output.println( "}" );
}
protected TypeUtil typeUtil;
protected HeapAnalysis heapAnalysis;
+ protected ClassDescriptor cdString;
+ protected FieldDescriptor argBytes;
+
public BCXallocsiteObjectField( BuildCode buildCode,
TypeUtil typeUtil,
public void additionalCodeForCommandLineArgs(PrintWriter outmethod, String argsVar) {
- ClassDescriptor cdString = typeUtil.getClass( typeUtil.StringClass );
+ cdString = typeUtil.getClass( typeUtil.StringClass );
assert cdString != null;
- FieldDescriptor argBytes = null;
+ argBytes = null;
Iterator sFieldsItr = cdString.getFields();
while( sFieldsItr.hasNext() ) {
FieldDescriptor fd = (FieldDescriptor) sFieldsItr.next();
}
assert argBytes != null;
+
String argsAccess = "((struct "+cdString.getSafeSymbol()+
" **)(((char *)& "+argsVar+"->___length___)+sizeof(int)))";