return s;
}
- public String getAlphaString() {
- return alpha.toStringEscapeNewline();
+ public String getAlphaString( boolean hideSubsetReachability ) {
+ return alpha.toStringEscapeNewline(hideSubsetReachability);
}
public String toString() {
}
Integer n = mapMethodContextToNumUpdates.get(mc);
try {
- og.writeGraph(mc, n, true, true, true, false, false);
+ og.writeGraph(mc, n, true, true, true, false, false, true);
} catch( IOException e ) {}
mapMethodContextToNumUpdates.put(mc, n + 1);
}
// boolean pruneGarbage,
// boolean writeReferencers
// boolean writeParamMappings
+ // boolean hideSubsetReachability
Set entrySet = mapMethodContextToCompleteOwnershipGraph.entrySet();
Iterator itr = entrySet.iterator();
OwnershipGraph og = (OwnershipGraph) me.getValue();
try {
- og.writeGraph(mc, true, true, true, false, false);
+ og.writeGraph(mc, true, true, true, false, false, true);
} catch( IOException e ) {}
}
}
);
}
+ public void writeGraph(MethodContext mc,
+ boolean writeLabels,
+ boolean labelSelect,
+ boolean pruneGarbage,
+ boolean writeReferencers,
+ boolean writeParamMappings,
+ boolean hideSubsetReachability
+ ) throws java.io.IOException {
+
+ writeGraph(mc+"COMPLETE",
+ writeLabels,
+ labelSelect,
+ pruneGarbage,
+ writeReferencers,
+ writeParamMappings,
+ hideSubsetReachability
+ );
+ }
+
public void writeGraph(MethodContext mc,
Integer numUpdate,
boolean writeLabels,
boolean writeParamMappings
) throws java.io.IOException {
+ writeGraph(mc+"COMPLETE"+String.format("%05d", numUpdate),
+ writeLabels,
+ labelSelect,
+ pruneGarbage,
+ writeReferencers,
+ writeParamMappings
+ );
+ }
+ public void writeGraph(MethodContext mc,
+ Integer numUpdate,
+ boolean writeLabels,
+ boolean labelSelect,
+ boolean pruneGarbage,
+ boolean writeReferencers,
+ boolean writeParamMappings,
+ boolean hideSubsetReachability
+ ) throws java.io.IOException {
writeGraph(mc+"COMPLETE"+String.format("%05d", numUpdate),
writeLabels,
labelSelect,
pruneGarbage,
writeReferencers,
- writeParamMappings
+ writeParamMappings,
+ hideSubsetReachability
);
}
boolean writeReferencers,
boolean writeParamMappings
) throws java.io.IOException {
+ writeGraph(graphName,
+ writeLabels,
+ labelSelect,
+ pruneGarbage,
+ writeReferencers,
+ writeParamMappings,
+ false
+ );
+ }
+
+ public void writeGraph(String graphName,
+ boolean writeLabels,
+ boolean labelSelect,
+ boolean pruneGarbage,
+ boolean writeReferencers,
+ boolean writeParamMappings,
+ boolean hideSubsetReachability
+ ) throws java.io.IOException {
// remove all non-word characters from the graph name so
// the filename and identifier in dot don't cause errors
bw,
null,
visited,
- writeReferencers);
+ writeReferencers,
+ hideSubsetReachability);
}
}
}
bw,
null,
visited,
- writeReferencers);
+ writeReferencers,
+ hideSubsetReachability);
}
bw.write(" " + ln.toString() +
" -> " + hrn.toString() +
- "[label=\"" + edge.toGraphEdgeString() +
+ "[label=\"" + edge.toGraphEdgeString(hideSubsetReachability) +
"\",decorate];\n");
}
}
BufferedWriter bw,
TempDescriptor td,
HashSet<HeapRegionNode> visited,
- boolean writeReferencers
+ boolean writeReferencers,
+ boolean hideSubsetReachability
) throws java.io.IOException {
if( visited.contains(hrn) ) {
attributes += hrn.getDescription() +
"\\n" +
- hrn.getAlphaString() +
+ hrn.getAlphaString(hideSubsetReachability) +
"\"]";
bw.write(" " + hrn.toString() + attributes + ";\n");
case VISIT_HRN_WRITE_FULL:
bw.write(" " + hrn.toString() +
" -> " + hrnChild.toString() +
- "[label=\"" + edge.toGraphEdgeString() +
+ "[label=\"" + edge.toGraphEdgeString(hideSubsetReachability) +
"\",decorate];\n");
break;
}
bw,
td,
visited,
- writeReferencers);
+ writeReferencers,
+ hideSubsetReachability);
}
}
return false;
}
+
public boolean containsSuperSet(TokenTupleSet tts) {
+ return containsSuperSet( tts, false );
+ }
+
+ public boolean containsStrictSuperSet(TokenTupleSet tts) {
+ return containsSuperSet( tts, true );
+ }
+
+ public boolean containsSuperSet(TokenTupleSet tts, boolean strict) {
assert tts != null;
- if( possibleReachabilities.contains(tts) ) {
+ if( !strict && possibleReachabilities.contains(tts) ) {
return true;
}
Iterator itr = iterator();
while( itr.hasNext() ) {
TokenTupleSet ttsThis = (TokenTupleSet) itr.next();
- if( tts.isSubset(ttsThis) ) {
- return true;
+ if( strict ) {
+ if( !tts.equals(ttsThis) && tts.isSubset(ttsThis) ) {
+ return true;
+ }
+ } else {
+ if( tts.isSubset(ttsThis) ) {
+ return true;
+ }
}
}
}
- public String toStringEscapeNewline() {
+ public String toStringEscapeNewline( boolean hideSubsetReachability ) {
String s = "[";
- Iterator i = this.iterator();
+ Iterator<TokenTupleSet> i = this.iterator();
while( i.hasNext() ) {
- s += i.next();
+ TokenTupleSet tts = i.next();
+
+ // skip this if there is a superset already
+ if( hideSubsetReachability &&
+ containsStrictSuperSet( tts ) ) {
+ continue;
+ }
+
+ s += tts;
if( i.hasNext() ) {
s += "\\n";
}
s += "]";
return s;
}
+
public String toString() {
+ return toString( false );
+ }
+
+ public String toString( boolean hideSubsetReachability ) {
String s = "[";
- Iterator i = this.iterator();
+ Iterator<TokenTupleSet> i = this.iterator();
while( i.hasNext() ) {
- s += i.next();
+ TokenTupleSet tts = i.next();
+
+ // skip this if there is a superset already
+ if( hideSubsetReachability &&
+ containsStrictSuperSet( tts ) ) {
+ continue;
+ }
+
+ s += tts;
if( i.hasNext() ) {
s += "\n";
}
}
- public String toGraphEdgeString() {
+ public String toGraphEdgeString( boolean hideSubsetReachability ) {
String edgeLabel = "";
if( type != null ) {
edgeLabel+="*taint*="+Integer.toBinaryString(taintIdentifier)+"\\n";
- edgeLabel += beta.toStringEscapeNewline();
+ edgeLabel += beta.toStringEscapeNewline(hideSubsetReachability);
return edgeLabel;
}
+/*
public class SparseGraph {
Node head;
- public SparseGraph() {
- head = null;
+ public SparseGraph( Node n ) {
+ head = n;
}
}
public class DenseGraph {
Node head;
- public DenseGraph() {
- head = null;
+ public DenseGraph( Node n ) {
+ head = n;
}
}
+*/
public class Node {
public int value;
static public void main( String[] args ) {
HashSet sSet = new HashSet();
- HashSet dSet = new HashSet();
+ //HashSet dSet = new HashSet();
for( int i = 0; i < 100; ++i ) {
- SparseGraph sNew = disjoint sparse new SparseGraph();
- DenseGraph dNew = disjoint dense new DenseGraph();
+ /*
+ SparseGraph sNew = disjoint sparse new SparseGraph( new Node( 3*i ) );
+ DenseGraph dNew = disjoint dense new DenseGraph ( new Node( 2*i ) );
sSet.add( sNew );
dSet.add( dNew );
SparseGraph s = (SparseGraph) sSet.iterator().next();
DenseGraph d = (DenseGraph) dSet.iterator().next();
-
+ process( );
+ */
+
+
+ Node sNew = disjoint sparse new Node( 3*i );
+ //Node dNew = disjoint dense new Node( 2*i );
+ sSet.add( sNew );
+ //dSet.add( dNew );
+ Node s = (Node) sSet.iterator().next();
+ //Node d = (Node) dSet.iterator().next();
+ growSparseAndDense( s /*, d*/ );
+ }
+ }
+
+ static public void growSparseAndDense( Node s /*, Node d*/ ) {
+
+ Node sOld = s;
+ for( int j = 0; j < 2; ++j ) {
+ if( !sOld.nodes.isEmpty() ) {
+ sOld = (Node) sOld.nodes.iterator().next();
+ }
+ }
+ Node sNew = new Node( 4/**d.value*/ );
+ sOld.nodes.add( sNew );
+
+
+ /*
+ Node dOld = d;
+ for( int j = 0; j < 2; ++j ) {
+ if( !dOld.nodes.isEmpty() ) {
+ dOld = (Node) dOld.nodes.iterator().next();
+ }
}
+ Node dNew1 = new Node( 5*s.value );
+ Node dNew2 = new Node( 6*s.value );
+ dOld.nodes.add( dNew1 );
+ dOld.nodes.add( dNew2 );
+ */
}
}