Skip to content

Commit

Permalink
added c toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
benjholla committed Aug 29, 2016
1 parent d224fe8 commit 4846e07
Show file tree
Hide file tree
Showing 21 changed files with 1,049 additions and 11 deletions.
14 changes: 3 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/
.DS_Store
Thumbs.db

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*.class
Empty file.
217 changes: 217 additions & 0 deletions com.ensoftcorp.open.c.commons/.cache

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions com.ensoftcorp.open.c.commons/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions com.ensoftcorp.open.c.commons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
28 changes: 28 additions & 0 deletions com.ensoftcorp.open.c.commons/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ensoftcorp.open.c.commons</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
21 changes: 21 additions & 0 deletions com.ensoftcorp.open.c.commons/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014-2015

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
16 changes: 16 additions & 0 deletions com.ensoftcorp.open.c.commons/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.ensoftcorp.open.c.commons;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
com.ensoftcorp.atlas.c.core;bundle-version="3.0.10",
com.ensoftcorp.atlas.java.core;bundle-version="3.0.10",
com.ensoftcorp.atlas.java.ui;bundle-version="3.0.10",
com.ensoftcorp.atlas.core;bundle-version="3.0.10",
com.ensoftcorp.atlas.ui.shell;bundle-version="3.0.10",
com.ensoftcorp.atlas.ui;bundle-version="3.0.10",
com.ensoftcorp.atlas.scala-lang;bundle-version="3.0.10"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: atlas.c.smartview,
atlas.c.xinu
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions com.ensoftcorp.open.c.commons/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
src/
19 changes: 19 additions & 0 deletions com.ensoftcorp.open.c.commons/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="com.ensoftcorp.atlas.ui.smartViewScript">
<script
class="atlas.c.smartview.ControlFlowWithinFunction">
</script>
<script
class="atlas.c.smartview.DataFlowWithinFunction">
</script>
<script
class="atlas.c.smartview.MatchingPairSearchModel">
</script>
<script
class="atlas.c.smartview.Typeof">
</script>
</extension>
</plugin>
4 changes: 4 additions & 0 deletions com.ensoftcorp.open.c.commons/selectionScripts.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
atlas.c.smartview.ControlFlowWithinFunction
atlas.c.smartview.DataFlowWithinFunction
atlas.c.smartview.Typeof
atlas.c.smartview.MatchingPairSearchModel
21 changes: 21 additions & 0 deletions com.ensoftcorp.open.c.commons/shellInit.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This is an initialization file for the Atlas Shell view. Each time a Shell linked
* with this project is opened or restarted, the code in this file will be run as scala code. Below
* is included the default initialization code for the shell. As long as this file exists only
* the code in this file will be run on shell startup; this default code will not be run if you
* remove it from this file.
*
* You do not need to put initialization code in a scala object or class.
*/
import com.ensoftcorp.atlas.core.query.Q
import com.ensoftcorp.atlas.core.xcsg.XCSG
import com.ensoftcorp.atlas.core.xcsg.XCSG._
import com.ensoftcorp.atlas.core.script.Common
import com.ensoftcorp.atlas.core.script.Common._
import com.ensoftcorp.atlas.ui.shell.lib.ShellCommon._
import com.ensoftcorp.atlas.core.db.Accuracy._
import com.ensoftcorp.atlas.core.db.graph.Graph
import com.ensoftcorp.atlas.core.highlight.Highlighter
import com.ensoftcorp.atlas.core.highlight.H

import atlas.c.xinu.Queries._
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package atlas.c.smartview;

import static com.ensoftcorp.atlas.core.script.Common.edges;

import java.awt.Color;

import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.atlas.core.highlight.Highlighter;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.script.StyledResult;
import com.ensoftcorp.atlas.ui.scripts.selections.FilteringAtlasSmartViewScript;
import com.ensoftcorp.atlas.ui.selection.event.IAtlasSelectionEvent;

/**
* For a selected function, displays the control flow graph.
* The edge back to the start of the loop is highlighted in blue.
*/
public class ControlFlowWithinFunction extends FilteringAtlasSmartViewScript {
@Override
public String[] getSupportedNodeTags() {
return new String[]{XCSG.Function};
}

@Override
public String[] getSupportedEdgeTags() {
return FilteringAtlasSmartViewScript.NOTHING;
}

@Override
public StyledResult selectionChanged(IAtlasSelectionEvent input, Q filteredSelection) {
Q functions = filteredSelection;

Q body = functions.contained();

Q res = body.nodesTaggedWithAny(XCSG.ControlFlow_Node).induce(edges(XCSG.ControlFlow_Edge));


Highlighter h = new Highlighter();
h.highlightEdges(Common.edges(XCSG.ControlFlowBackEdge), Color.BLUE);

return new StyledResult(res, h);
}

@Override
public String getTitle() {
return "Control Flow within a function";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package atlas.c.smartview;

import static com.ensoftcorp.atlas.core.script.Common.edges;

import java.awt.Color;

import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.atlas.core.highlight.Highlighter;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.script.Common;
import com.ensoftcorp.atlas.core.script.StyledResult;
import com.ensoftcorp.atlas.ui.scripts.selections.FilteringAtlasSmartViewScript;
import com.ensoftcorp.atlas.ui.selection.event.IAtlasSelectionEvent;

/**
* For a selected function, displays the data flow graph embedded
* in the control flow graph.
* The control flow edge back to the start of the loop is highlighted in blue.
*/
public class DataFlowWithinFunction extends FilteringAtlasSmartViewScript {
@Override
public String[] getSupportedNodeTags() {
return new String[]{XCSG.Function};
}

@Override
public String[] getSupportedEdgeTags() {
return FilteringAtlasSmartViewScript.NOTHING;
}

@Override
public StyledResult selectionChanged(IAtlasSelectionEvent input, Q filteredSelection) {
Q functions = filteredSelection;

Q body = functions.contained();

Q res = body.nodesTaggedWithAny(XCSG.ControlFlow_Node, XCSG.DataFlow_Node, XCSG.Variable).induce(edges(XCSG.ControlFlow_Edge, XCSG.DataFlow_Edge));


Highlighter h = new Highlighter();
h.highlightEdges(Common.edges(XCSG.ControlFlowBackEdge), Color.BLUE);

return new StyledResult(res, h);
}

@Override
public String getTitle() {
return "Data Flow within a function";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package atlas.c.smartview;

import java.awt.Color;

import atlas.c.xinu.Queries;

import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.atlas.core.highlight.Highlighter;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.script.StyledResult;
import com.ensoftcorp.atlas.ui.scripts.selections.FilteringAtlasSmartViewScript;
import com.ensoftcorp.atlas.ui.selection.event.IAtlasSelectionEvent;
/**
* For a selected node, displays the immediate type and the basis of that type.
*
*/
public class MatchingPairSearchModel extends FilteringAtlasSmartViewScript {

@Override
public String[] getSupportedNodeTags() {
return new String[]{XCSG.DataFlow_Node,
XCSG.Variable,
XCSG.Type,
XCSG.TypeAlias};
}

@Override
public String[] getSupportedEdgeTags() {
return FilteringAtlasSmartViewScript.NOTHING;
}

@Override
public StyledResult selectionChanged(IAtlasSelectionEvent input, Q filteredSelection) {

Q res = Queries.typeOf(filteredSelection);
Q selectedType = res.leaves();
Q a1 = Queries.functions("getbuf");
Q a2 = Queries.functions("freebuf");
Q leaves = a1.union(a2);
Q refSelectedType = Queries.ref(selectedType);
Q roots = refSelectedType.roots();
Q searchModel = Queries.graph(roots, leaves);
return new StyledResult(searchModel);
}

@Override
public String getTitle() {
return "Matching Pair Search Model";
}
}
47 changes: 47 additions & 0 deletions com.ensoftcorp.open.c.commons/src/atlas/c/smartview/Typeof.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package atlas.c.smartview;

import java.awt.Color;

import atlas.c.xinu.Queries;

import com.ensoftcorp.atlas.core.xcsg.XCSG;
import com.ensoftcorp.atlas.core.highlight.Highlighter;
import com.ensoftcorp.atlas.core.query.Q;
import com.ensoftcorp.atlas.core.script.StyledResult;
import com.ensoftcorp.atlas.ui.scripts.selections.FilteringAtlasSmartViewScript;
import com.ensoftcorp.atlas.ui.selection.event.IAtlasSelectionEvent;
/**
* For a selected node, displays the immediate type and the basis of that type.
*
*/
public class Typeof extends FilteringAtlasSmartViewScript {

@Override
public String[] getSupportedNodeTags() {
return new String[]{XCSG.DataFlow_Node,
XCSG.Variable,
XCSG.Type,
XCSG.TypeAlias};
}

@Override
public String[] getSupportedEdgeTags() {
return FilteringAtlasSmartViewScript.NOTHING;
}

@Override
public StyledResult selectionChanged(IAtlasSelectionEvent input, Q filteredSelection) {

Q res = Queries.typeOf(filteredSelection);

Highlighter h = new Highlighter();
h.highlightEdges(Queries.typeEdges(), Color.BLUE);

return new StyledResult(res, h);
}

@Override
public String getTitle() {
return "TypeOf";
}
}
Loading

0 comments on commit 4846e07

Please sign in to comment.