palashborhanuddin / RefactoringMatcher

0 stars 0 forks source link

Verify CFG/PDG generation #1

Open palashborhanuddin opened 3 years ago

palashborhanuddin commented 3 years ago

verify and confirm the CFG generation step towards GROUM generation

palashborhanuddin commented 3 years ago

Findings for the incomplete CFG/PDG generation:

palashborhanuddin commented 3 years ago

Integrating JarAnalyzer fluent API to get the Binding information.

palashborhanuddin commented 3 years ago

Running JarAnalyzer taking >5GB memory so could not run locally (System with 8GB memory support)! Currently, it loads all the jar information in heap memory! Need to overcome/workaround this to make it work locally.

java.lang.OutOfMemoryError: Java heap space

at java.base/java.util.HashMap.resize(HashMap.java:699)
at java.base/java.util.HashMap.putVal(HashMap.java:624)
at java.base/java.util.HashMap.put(HashMap.java:607)
at java.base/java.util.HashSet.add(HashSet.java:220)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerHelper.addInEdge(TinkerHelper.java:90)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerHelper.addEdge(TinkerHelper.java:68)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex.addEdge(TinkerVertex.java:125)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader.lambda$null$2(GryoReader.java:110)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader$$Lambda$152/0x00000008012f0840.accept(Unknown Source)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader.lambda$readGraph$3(GryoReader.java:100)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader$$Lambda$151/0x00000008012cb040.accept(Unknown Source)
at java.base/java.util.HashMap$EntrySet.forEach(HashMap.java:1039)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader.readGraph(GryoReader.java:100)
at org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep.read(IoStep.java:132)
at org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep.processNextStart(IoStep.java:110)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)
at org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep.processNextStart(FilterStep.java:37)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.iterate(Traversal.java:206)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.iterate(GraphTraversal.java:2931)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal$Admin.iterate(GraphTraversal.java:189)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.iterate(DefaultGraphTraversal.java:48)
at ca.concordia.jaranalyzer.TypeInferenceAPI.loadClassStructureGraph(TypeInferenceAPI.java:567)
at ca.concordia.jaranalyzer.TypeInferenceAPI.<clinit>(TypeInferenceAPI.java:68)
at ca.concordia.jaranalyzer.JFreeChartTests.loadPreviousJFreeChartJar(JFreeChartTests.java:416)
at ca.concordia.jaranalyzer.JFreeChartTests.loadExternalLibrary(JFreeChartTests.java:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[EDIT UPDATE Sat, 27] Above mentioned issue has been resolved by new commits in JarAnalyzer

palashborhanuddin commented 3 years ago

2 has the output of soot to compare with.

palashborhanuddin commented 3 years ago

PDG and CFG for the example method from the paper:

CFG: CFG{nodes=[1 StringBuffer strbuf=new StringBuffer(); , 2 BufferedReader in=new BufferedReader(new FileReader("")); , 3 String str; , 4 while((str=in.readLine()) != null) , 5 strbuf.append(str + "\n"); , 6 if(strbuf.length() > 0) , 7 outputMessage(strbuf.toString()); , 8 in.close(); ], edges=[1 StringBuffer strbuf=new StringBuffer(); --> 2 BufferedReader in=new BufferedReader(new FileReader(""));

, 2 BufferedReader in=new BufferedReader(new FileReader("")); --> 3 String str;

, 3 String str; --> 4 while((str=in.readLine()) != null)

, 4 while((str=in.readLine()) != null) -->T 5 strbuf.append(str + "\n");

, 5 strbuf.append(str + "\n"); -->LB 4 while((str=in.readLine()) != null)

, 4 while((str=in.readLine()) != null) -->F 6 if(strbuf.length() > 0)

, 6 if(strbuf.length() > 0) -->T 7 outputMessage(strbuf.toString());

, 7 outputMessage(strbuf.toString()); --> 8 in.close();

, 6 if(strbuf.length() > 0) -->F 8 in.close();

]}

PDG: [0-->1 StringBuffer strbuf=new StringBuffer(); T , 0-->2 BufferedReader in=new BufferedReader(new FileReader("")); T , 0-->3 String str; T , 0-->4 while((str=in.readLine()) != null) T , 4 while((str=in.readLine()) != null) -->5 strbuf.append(str + "\n"); T , 0-->6 if(strbuf.length() > 0) T , 6 if(strbuf.length() > 0) -->7 outputMessage(strbuf.toString()); T , 0-->8 in.close(); T , SRC:1 StringBuffer strbuf=new StringBuffer(); -->DST:5 strbuf.append(str + "\n");

StringBuffer strbuf , SRC:1 StringBuffer strbuf=new StringBuffer(); -->DST:6 if(strbuf.length() > 0) StringBuffer strbuf , SRC:1 StringBuffer strbuf=new StringBuffer(); -->DST:7 outputMessage(strbuf.toString()); StringBuffer strbuf , SRC:2 BufferedReader in=new BufferedReader(new FileReader("")); -->DST:4 while((str=in.readLine()) != null) BufferedReader in , SRC:2 BufferedReader in=new BufferedReader(new FileReader("")); -->DST:4 while((str=in.readLine()) != null) BufferedReader in (through loop 4) , SRC:2 BufferedReader in=new BufferedReader(new FileReader("")); -->DST:8 in.close(); BufferedReader in , SRC:3 String str; -->DST:4 while((str=in.readLine()) != null) String str , SRC:3 String str; -->DST:4 while((str=in.readLine()) != null) String str , SRC:4 while((str=in.readLine()) != null) -->DST:5 strbuf.append(str + "\n"); String str , SRC:4 while((str=in.readLine()) != null) -->DST:4 while((str=in.readLine()) != null) String str (through loop 4) , SRC:5 strbuf.append(str + "\n"); -->DST:4 while((str=in.readLine()) != null) String str (through loop 4) ]
palashborhanuddin commented 3 years ago

Source code for the example PDG:

private static void groumTestMethod() throws IOException {
        StringBuffer strbuf = new StringBuffer();
        BufferedReader in = new BufferedReader(new FileReader(""));

        String str;

        while((str = in.readLine()) != null ) {
            strbuf.append(str + "\n");
        }

        if(strbuf.length() > 0) {
            outputMessage(strbuf.toString());
        }
        in.close();
    }
palashborhanuddin commented 3 years ago
1   StringBuffer strbuf=new StringBuffer();
, 2 BufferedReader in=new BufferedReader(new FileReader(""));
, 3 String str;
, 4 while((str=in.readLine()) != null)
, 5 strbuf.append(str + "\n");
, 6 if(strbuf.length() > 0)
, 7 outputMessage(strbuf.toString());
, 8 in.close();
], edges=[0 groumTestMethod-->T
1   StringBuffer strbuf=new StringBuffer();
, 0 groumTestMethod-->T
2   BufferedReader in=new BufferedReader(new FileReader(""));
, 0 groumTestMethod-->T
3   String str;
, 0 groumTestMethod-->T
4   while((str=in.readLine()) != null)
, 4 while((str=in.readLine()) != null)
-->T
5   strbuf.append(str + "\n");
, 0 groumTestMethod-->T
6   if(strbuf.length() > 0)
, 6 if(strbuf.length() > 0)
-->T
7   outputMessage(strbuf.toString());
, 0 groumTestMethod-->T
8   in.close();
, 1 StringBuffer strbuf=new StringBuffer();
-->StringBuffer strbuf <data>
5   strbuf.append(str + "\n");
, 1 StringBuffer strbuf=new StringBuffer();
-->StringBuffer strbuf <data>
6   if(strbuf.length() > 0)
, 1 StringBuffer strbuf=new StringBuffer();
-->StringBuffer strbuf <data>
7   outputMessage(strbuf.toString());
, 2 BufferedReader in=new BufferedReader(new FileReader(""));
-->BufferedReader in <data>
4   while((str=in.readLine()) != null)
, 2 BufferedReader in=new BufferedReader(new FileReader(""));
-->BufferedReader in <data> through loop 4
4   while((str=in.readLine()) != null)
, 2 BufferedReader in=new BufferedReader(new FileReader(""));
-->BufferedReader in <data>
8   in.close();
, 3 String str;
-->String str <def_order>
4   while((str=in.readLine()) != null)
, 3 String str;
-->String str <output>
4   while((str=in.readLine()) != null)
, 4 while((str=in.readLine()) != null)
-->String str <data>
5   strbuf.append(str + "\n");
, 4 while((str=in.readLine()) != null)
-->String str <output> through loop 4
4   while((str=in.readLine()) != null)
, 5 strbuf.append(str + "\n");
-->String str <anti> through loop 4
4   while((str=in.readLine()) != null)