From 63eee10d565b41fe74e79b52754345c637d3481f Mon Sep 17 00:00:00 2001 From: benjholla Date: Sun, 7 Oct 2018 13:38:49 -0500 Subject: [PATCH] updates for upstream changes, modernized Atlas API usage --- .../feature.xml | 2 +- .../META-INF/MANIFEST.MF | 17 +++++++++-------- .../c/commons/analysis/CallSiteAnalysis.java | 5 +++-- .../open/c/commons/analysis/CommonQueries.java | 11 ++++++----- .../c/commons/analysis/GotoLoopDetection.java | 10 +++++++--- .../smart/MatchingPairSearchModelSmartView.java | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/com.ensoftcorp.open.c.commons.feature/feature.xml b/com.ensoftcorp.open.c.commons.feature/feature.xml index 1d807a3..989b942 100644 --- a/com.ensoftcorp.open.c.commons.feature/feature.xml +++ b/com.ensoftcorp.open.c.commons.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF b/com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF index f7c0f0d..7b99b15 100644 --- a/com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF +++ b/com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF @@ -1,16 +1,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: com.ensoftcorp.open.c.commons;singleton:=true -Bundle-Version: 3.3.0.qualifier +Bundle-Version: 3.3.7.qualifier Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, - com.ensoftcorp.atlas.c.core;bundle-version="3.3.0";visibility:=reexport, - com.ensoftcorp.atlas.c.ui;bundle-version="3.3.0";visibility:=reexport, - com.ensoftcorp.atlas.core;bundle-version="3.3.0", - com.ensoftcorp.atlas.ui.shell;bundle-version="3.3.0", - com.ensoftcorp.atlas.ui;bundle-version="3.3.0", - com.ensoftcorp.atlas.scala-lang;bundle-version="3.3.0", - com.ensoftcorp.open.commons;bundle-version="3.3.0" + com.ensoftcorp.atlas.c.core;bundle-version="3.3.7";visibility:=reexport, + com.ensoftcorp.atlas.c.ui;bundle-version="3.3.7";visibility:=reexport, + com.ensoftcorp.atlas.core;bundle-version="3.3.7", + com.ensoftcorp.atlas.ui.shell;bundle-version="3.3.7", + com.ensoftcorp.atlas.ui;bundle-version="3.3.7", + com.ensoftcorp.atlas.scala-lang;bundle-version="3.3.7", + com.ensoftcorp.open.commons;bundle-version="3.3.7", + com.ensoftcorp.open.commons.ui;bundle-version="3.3.7" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.ensoftcorp.open.c.commons, com.ensoftcorp.open.c.commons.analysis, diff --git a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CallSiteAnalysis.java b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CallSiteAnalysis.java index eb03336..560edc5 100644 --- a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CallSiteAnalysis.java +++ b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CallSiteAnalysis.java @@ -7,6 +7,7 @@ import com.ensoftcorp.atlas.core.db.set.AtlasHashSet; import com.ensoftcorp.atlas.core.db.set.AtlasSet; import com.ensoftcorp.atlas.core.query.Q; +import com.ensoftcorp.atlas.core.query.Query; import com.ensoftcorp.atlas.core.script.Common; import com.ensoftcorp.atlas.core.xcsg.XCSG; import com.ensoftcorp.open.commons.analysis.CallSiteAnalysis.LanguageSpecificCallSiteAnalysis; @@ -44,7 +45,7 @@ public static AtlasSet getInvokedFunction(AtlasSet callsites) { * @return */ public static AtlasSet getInvokedFunction(Node callsite) { - return Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction).successors(Common.toQ(callsite)).eval().nodes(); + return Query.universe().edges(XCSG.InvokedFunction).successors(Common.toQ(callsite)).eval().nodes(); } /** @@ -75,7 +76,7 @@ public static AtlasSet getFunctionInvocations(AtlasSet functions) { * @return */ public static AtlasSet getFunctionInvocations(Node function) { - return Common.universe().edgesTaggedWithAny(XCSG.InvokedFunction).predecessors(Common.toQ(function)).eval().nodes(); + return Query.universe().edges(XCSG.InvokedFunction).predecessors(Common.toQ(function)).eval().nodes(); } @Override diff --git a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CommonQueries.java b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CommonQueries.java index 02b4da1..049596a 100644 --- a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CommonQueries.java +++ b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/CommonQueries.java @@ -19,6 +19,7 @@ import com.ensoftcorp.atlas.core.db.set.IntersectionSet; import com.ensoftcorp.atlas.core.index.common.SourceCorrespondence; import com.ensoftcorp.atlas.core.query.Q; +import com.ensoftcorp.atlas.core.query.Query; import com.ensoftcorp.atlas.core.script.Common; import com.ensoftcorp.atlas.core.script.CommonQueries.TraversalDirection; import com.ensoftcorp.atlas.core.xcsg.XCSG; @@ -1092,7 +1093,7 @@ public static Q mpg(Q e1Functions, Q e2Functions, Q object){ * @return intra-procedural data-flow graph */ public static Q projectDFG(Q dfg, Q func){ - Q functionBody = func.contained().induce(Common.universe()); + Q functionBody = func.contained().induce(Query.universe()); return functionBody.intersection(dfg); } @@ -1191,12 +1192,12 @@ public static Q file(String path) { private static Q findByName(String functionName, String tag) { if(functionName.indexOf("*") >= 0){ - Q nodes = Common.universe().nodes(tag); + Q nodes = Query.universe().nodes(tag); Q result = getMatches(functionName, nodes); return result; } // Atlas has an index over literal attribute values, so it's faster to query directly - return Common.universe().nodes(tag).selectNode(XCSG.name, functionName); + return Query.universe().nodes(tag).selectNode(XCSG.name, functionName); } /** @@ -1325,7 +1326,7 @@ public static Graph reverseDF(AtlasSet origin) { } public static Graph reverseDF(AtlasSet origin, AtlasSet stop) { - Graph context = Common.universe().edgesTaggedWithAny(XCSG.DataFlow_Edge).eval(); + Graph context = Query.universe().edges(XCSG.DataFlow_Edge).eval(); return traverse(context, TraversalDirection.REVERSE, origin, stop); } @@ -1335,7 +1336,7 @@ public static Graph forwardDF(AtlasSet origin) { } public static Graph forwardDF(AtlasSet origin, AtlasSet stop) { - Graph context = Common.universe().edgesTaggedWithAny(XCSG.DataFlow_Edge).eval(); + Graph context = Query.universe().edges(XCSG.DataFlow_Edge).eval(); return traverse(context, TraversalDirection.FORWARD, origin, stop); } diff --git a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/GotoLoopDetection.java b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/GotoLoopDetection.java index 4585311..edadc47 100644 --- a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/GotoLoopDetection.java +++ b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/analysis/GotoLoopDetection.java @@ -7,13 +7,14 @@ import com.ensoftcorp.atlas.core.db.set.AtlasHashSet; import com.ensoftcorp.atlas.core.db.set.AtlasSet; import com.ensoftcorp.atlas.core.query.Q; +import com.ensoftcorp.atlas.core.query.Query; import com.ensoftcorp.atlas.core.script.Common; import com.ensoftcorp.atlas.core.script.CommonQueries; import com.ensoftcorp.atlas.core.xcsg.XCSG; +import com.ensoftcorp.open.c.commons.log.Log; import com.ensoftcorp.open.commons.algorithms.UniqueEntryExitControlFlowGraph; import com.ensoftcorp.open.commons.algorithms.UniqueEntryExitGraph; import com.ensoftcorp.open.commons.algorithms.dominance.DominatorTree; -import com.ensoftcorp.open.commons.log.Log; import com.ensoftcorp.open.commons.preferences.CommonsPreferences; /** @@ -24,9 +25,12 @@ */ public class GotoLoopDetection { public static String recoverGotoLoops() { - return recoverGotoLoops(Common.universe()); + return recoverGotoLoops(Query.universe()); } + // TODO: Where does this constant come from?? XCSG?? I can't find it... ~BH + private static final String IS_LABEL = "isLabel"; + public static String recoverGotoLoops(Q app) { String message = "Total number of Goto Loops = "; long totalLoops = 0l; @@ -35,7 +39,7 @@ public static String recoverGotoLoops(Q app) { AtlasSet allEdges = new AtlasHashSet(); Q cfg = CommonQueries.cfg(Common.toQ(function)); allEdges.addAll(cfg.eval().edges()); - Q labelNodesQ = cfg.contained().nodesTaggedWithAny("isLabel"); + Q labelNodesQ = cfg.contained().nodes(IS_LABEL); AtlasSet labelNodes = labelNodesQ.eval().nodes(); if (!CommonQueries.isEmpty(labelNodesQ)) { diff --git a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/ui/smart/MatchingPairSearchModelSmartView.java b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/ui/smart/MatchingPairSearchModelSmartView.java index a2d7e0e..81bc33e 100644 --- a/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/ui/smart/MatchingPairSearchModelSmartView.java +++ b/com.ensoftcorp.open.c.commons/src/com/ensoftcorp/open/c/commons/ui/smart/MatchingPairSearchModelSmartView.java @@ -35,7 +35,7 @@ public static Q getAllowedLeafNodes() { * @param f1 */ public static void setAllowedLeafNodes(Q leaves) { - MatchingPairSearchModelSmartView.leaves = leaves.nodesTaggedWithAny(XCSG.Function); + MatchingPairSearchModelSmartView.leaves = leaves.nodes(XCSG.Function); } @Override