Ghidra is a software reverse engineering (SRE) framework
GT-3161 - Function Graph - fixed 3 bugs that caused some edges to get clipped by vertices
dragonmacher99ded59e8472
diff --git a/Ghidra/Features/FunctionGraphDecompilerExtension/src/main/java/ghidra/app/plugin/core/functiongraph/graph/layout/DecompilerNestedLayout.java b/Ghidra/Features/FunctionGraphDecompilerExtension/src/main/java/ghidra/app/plugin/core/functiongraph/graph/layout/DecompilerNestedLayout.javaindex add1a1f4dc..af0c03078d 100644--- a/Ghidra/Features/FunctionGraphDecompilerExtension/src/main/java/ghidra/app/plugin/core/functiongraph/graph/layout/DecompilerNestedLayout.java+++ b/Ghidra/Features/FunctionGraphDecompilerExtension/src/main/java/ghidra/app/plugin/core/functiongraph/graph/layout/DecompilerNestedLayout.java@@ -253,14 +253,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {Vertex2d start = vertex2dFactory.get(startVertex);Vertex2d end = vertex2dFactory.get(endVertex);-- Address startAddress = startVertex.getVertexAddress();- Address endAddress = endVertex.getVertexAddress();- int compareResult = startAddress.compareTo(endAddress);- boolean goingUp = compareResult > 0;+ boolean goingUp = start.rowIndex > end.rowIndex;if (goingUp) {-+ // we paint loops going back up differently than other edges so the user can+ // visually pick out the loops much easierDecompilerBlock block = blockGraphRoot.getBlock(endVertex);DecompilerBlock loop = block.getParentLoop();@@ -383,8 +380,7 @@ public class DecompilerNestedLayout extends AbstractFGLayout {double y2 = y1;articulations.add(new Point2D.Double(x2, y2));- Column column = vertex2dFactory.getColumn(x1);- routeAroundColumnVertices(start, end, column.index, vertex2dFactory, articulations, x2);+ routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);double x3 = x2;double y3 = end.getBottom() - VERTEX_BORDER_THICKNESS;@@ -424,6 +420,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x3);articulations.add(new Point2D.Double(x3, y3));++ double x4 = end.getX();+ double y4 = y3;+ articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex+}private void routeToTheLeft(Vertex2d start, Vertex2d end, FGEdge e,@@ -538,19 +539,28 @@ public class DecompilerNestedLayout extends AbstractFGLayout {y2 = Math.min(y2, endYLimit);articulations.add(new Point2D.Double(x2, y2));- // have not yet seen an example of vertex/edge clipping when routing to the right- // routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);+ routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);- double x3 = end.getX();- double y3 = y2;+ double x3 = x2;+ double y3 = end.getY();articulations.add(new Point2D.Double(x3, y3)); // point is hidden behind the vertex++ double x4 = end.getX();+ double y4 = y3;+ articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex}private void routeAroundColumnVertices(Vertex2d start, Vertex2d end,Vertex2dFactory vertex2dFactory, List<Point2D> articulations, double edgeX) {- int column = end.columnIndex;- routeAroundColumnVertices(start, end, column, vertex2dFactory, articulations, edgeX);+ Column column = vertex2dFactory.getColumn(edgeX);+ int columnIndex = 0;+ if (column != null) {+ // a null column happens with a negative x value that is outside of any column+ columnIndex = column.index;+ }++ routeAroundColumnVertices(start, end, columnIndex, vertex2dFactory, articulations, edgeX);}private void routeAroundColumnVertices(Vertex2d start, Vertex2d end, int column,diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/layout/LayoutLocationMap.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/layout/LayoutLocationMap.javaindex 42b195a976..c3646db268 100644--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/layout/LayoutLocationMap.java+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/layout/LayoutLocationMap.java@@ -103,10 +103,10 @@ public class LayoutLocationMap<V, E> {Column column = null;Collection<Column> values = columnsByIndex.values();for (Column nextColumn : values) {- column = nextColumn;- if (x < column.x) {+ if (x < nextColumn.x) {return column;}+ column = nextColumn;}return column;}