fixed a few minor issues with AST graphs

This commit is contained in:
ghidravore 2021-08-10 14:37:18 -04:00
parent fe6006c300
commit 269ca50d33
3 changed files with 10 additions and 10 deletions

View file

@ -43,8 +43,8 @@ public class GraphAST extends GhidraScript {
protected static final String ADDRESS_TIED = "Address Tied"; protected static final String ADDRESS_TIED = "Address Tied";
protected static final String OP = "Op"; protected static final String OP = "Op";
protected static final String TYPE_OUTPUT = "Output"; protected static final String WITHIN_BLOCK = "Within Block";
protected static final String TYPE_INPUT = "Input"; protected static final String BETWEEN_BLOCK = "Between Block";
private Function func; private Function func;
private AttributedGraph graph; private AttributedGraph graph;
protected HighFunction high; protected HighFunction high;
@ -80,8 +80,8 @@ public class GraphAST extends GhidraScript {
.vertexType(ADDRESS_TIED) .vertexType(ADDRESS_TIED)
.vertexType(OP) .vertexType(OP)
.edgeType(DEFAULT) .edgeType(DEFAULT)
.edgeType(TYPE_OUTPUT) .edgeType(WITHIN_BLOCK)
.edgeType(TYPE_INPUT) .edgeType(BETWEEN_BLOCK)
.build(); .build();
GraphDisplayOptions displayOptions = new GraphDisplayOptionsBuilder(graphType) GraphDisplayOptions displayOptions = new GraphDisplayOptionsBuilder(graphType)
@ -92,6 +92,7 @@ public class GraphAST extends GhidraScript {
.defaultVertexShape(VertexShape.ELLIPSE) .defaultVertexShape(VertexShape.ELLIPSE)
.defaultLayoutAlgorithm("Hierarchical MinCross Coffman Graham") .defaultLayoutAlgorithm("Hierarchical MinCross Coffman Graham")
.useIcons(false) .useIcons(false)
.arrowLength(15)
.labelPosition(GraphLabelPosition.SOUTH) .labelPosition(GraphLabelPosition.SOUTH)
.shapeOverrideAttribute(SHAPE_ATTRIBUTE) .shapeOverrideAttribute(SHAPE_ATTRIBUTE)
.vertex(DEFAULT, VertexShape.ELLIPSE, WebColors.RED) .vertex(DEFAULT, VertexShape.ELLIPSE, WebColors.RED)
@ -102,8 +103,8 @@ public class GraphAST extends GhidraScript {
.vertex(ADDRESS_TIED, VertexShape.ELLIPSE, WebColors.ORANGE) .vertex(ADDRESS_TIED, VertexShape.ELLIPSE, WebColors.ORANGE)
.vertex(OP, VertexShape.RECTANGLE, WebColors.RED) .vertex(OP, VertexShape.RECTANGLE, WebColors.RED)
.edge(DEFAULT, WebColors.BLUE) .edge(DEFAULT, WebColors.BLUE)
.edge(TYPE_OUTPUT, WebColors.BLACK) .edge(WITHIN_BLOCK, WebColors.BLACK)
.edge(TYPE_INPUT, WebColors.RED) .edge(BETWEEN_BLOCK, WebColors.RED)
.build(); .build();
graph = new AttributedGraph("AST Graph", graphType); graph = new AttributedGraph("AST Graph", graphType);

View file

@ -77,7 +77,7 @@ public class GraphASTAndFlow extends GraphAST {
} }
if (prev != null && map.containsKey(prev) && map.containsKey(next)) { if (prev != null && map.containsKey(prev) && map.containsKey(next)) {
AttributedEdge edge = createEdge(map.get(prev), map.get(next)); AttributedEdge edge = createEdge(map.get(prev), map.get(next));
edge.setEdgeType(TYPE_OUTPUT); edge.setEdgeType(WITHIN_BLOCK);
} }
prev = next; prev = next;
} }
@ -92,7 +92,7 @@ public class GraphASTAndFlow extends GraphAST {
PcodeBlock in = block.getIn(i); PcodeBlock in = block.getIn(i);
if (last.containsKey(in)) { if (last.containsKey(in)) {
AttributedEdge edge = createEdge(last.get(in), first.get(block)); AttributedEdge edge = createEdge(last.get(in), first.get(block));
edge.setEdgeType(TYPE_INPUT); edge.setEdgeType(BETWEEN_BLOCK);
} }
} }
} }

View file

@ -37,7 +37,6 @@ public abstract class VertexShape {
public static VertexShape HEXAGON = new HexagonVertexShape(SIZE); public static VertexShape HEXAGON = new HexagonVertexShape(SIZE);
public static VertexShape OCTAGON = new OctagonVertexShape(SIZE); public static VertexShape OCTAGON = new OctagonVertexShape(SIZE);
private Shape cachedShape; private Shape cachedShape;
private String name; private String name;
private int size; private int size;
@ -169,7 +168,7 @@ public abstract class VertexShape {
} }
protected Shape createShape() { protected Shape createShape() {
return new Ellipse2D.Double(-1.0, 1.0, 2.0, 2.0); return new Ellipse2D.Double(-1.0, -1.0, 2.0, 2.0);
} }
@Override @Override