GP-2295 - fixes and debug code for a history actions stack trace

This commit is contained in:
dragonmacher 2022-07-14 11:31:27 -04:00
parent b8425e804d
commit c8e15f0fe2
6 changed files with 133 additions and 95 deletions

View file

@ -135,7 +135,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
@Override
public boolean isSnapshot() {
// we are a snapshot when we are 'disconnected'
// we are a snapshot when we are 'disconnected'
return !isConnected();
}
@ -241,7 +241,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
/**
* Gives to the clipboard of this provider the given string. This will prime the clipboard
* such that a copy action will copy the given string.
*
*
* @param string the string to set
*/
public void setClipboardStringContent(String string) {
@ -351,7 +351,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
/**
* Called to signal to this provider that it should update its state due to a new function
* being graphed. The UI is updated by the controller without this provider's knowledge.
* being graphed. The UI is updated by the controller without this provider's knowledge.
* This call here is to signal that the provider needs to update its metadata.
*/
public void functionGraphDataChanged() {
@ -413,15 +413,15 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
/**
* Called from within the FunctionGraph when locations are changed (e.g., if a user clicks
* inside of a vertex)
*
* @param newLocation the new location
*
* @param newLocation the new location
*/
public void graphLocationChanged(ProgramLocation newLocation) {
storeLocation(newLocation);
if (isFocusedProvider()) {
// Note: this is the easy way to avoid odd event bouncing--only send events out if
// Note: this is the easy way to avoid odd event bouncing--only send events out if
// we are focused, as this implies the user is driving the events. A better
// metaphor for handling external and internal program locations is needed to
// simplify the logic of when to broadcast location changes.
@ -434,8 +434,8 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
/**
* Called from within the FunctionGraph when selections are changed (e.g., if a user clicks
* inside of a vertex)
*
* @param selection the new selection
*
* @param selection the new selection
*/
public void graphSelectionChanged(ProgramSelection selection) {
storeSelection(selection);
@ -476,10 +476,10 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
/**
* Called when for location changes that are <b>external</b> to the function graph (e.g.,
* Called when for location changes that are <b>external</b> to the function graph (e.g.,
* when the user clicks in Ghidra's Listing window)
*
* @param newLocation the new location
*
* @param newLocation the new location
*/
void setLocation(ProgramLocation newLocation) {
pendingLocation = newLocation;
@ -497,6 +497,13 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return;
}
Program program = newLocation.getProgram();
if (program.isClosed()) {
// this method is called from an update manager, which means that the callback may
// happen after the notification that the program was closed
return;
}
setLocationNow(newLocation);
}
@ -522,7 +529,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
/**
* Tells this provider to refresh, which means to rebuild the graph and relayout the
* Tells this provider to refresh, which means to rebuild the graph and relayout the
* vertices.
*/
private void refresh(boolean keepPerspective) {
@ -537,7 +544,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
Address address = function.getEntryPoint();
Address currentAddress = currentLocation.getAddress();
if (function.getBody().contains(currentAddress)) {
// prefer the current address if it is within the current function (i.e., the
// prefer the current address if it is within the current function (i.e., the
// location hasn't changed out from under the graph due to threading issues)
address = currentAddress;
}
@ -568,7 +575,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
/**
* Tells the graph that some display data may have changed, but the changes are not worth
* Tells the graph that some display data may have changed, but the changes are not worth
* performing a full rebuild
*/
public void refreshDisplayWithoutRebuilding() {
@ -597,7 +604,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
//
// Note: since we are not looping and we are using 'else if's, order is important!
//
//
if (ev.containsEvent(DomainObject.DO_OBJECT_RESTORED) ||
ev.containsEvent(ChangeManager.DOCR_FUNCTION_BODY_CHANGED)) {
@ -716,7 +723,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
private void handleReferenceRemoved(DomainObjectChangeRecord record) {
//
//
// Get the affected vertex (if any). Determine if we have to combine the vertex with
// the vertex below it (adding a reference creates a new basic block, which creates a new
// vertex--we may need to reverse that process)
@ -730,7 +737,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return; // this particular removal doesn't affect our graph
}
//
//
// How do we know if we can combine this vertex with its parent? Well, we have some
// tests that must hold true:
// -There must be only a fallthrough edge to the affected vertex
@ -774,7 +781,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
private void handleReferenceAdded(DomainObjectChangeRecord record) {
//
//
// Get the affected vertex (if any). Determine if we have to split the vertex.
//
FGData functionGraphData = controller.getFunctionGraphData();
@ -786,10 +793,10 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return; // this particular removal doesn't affect our graph
}
//
//
// How do we know if we need to split this vertex? Well, we have some
// tests that must hold true:
// -The 'to' address for the reference must not be to the minimum address for that vertex
// -The 'to' address for the reference must not be to the minimum address for that vertex
//
AddressSetView addresses = destinationVertex.getAddresses();
Address minAddress = addresses.getMinAddress();
@ -824,7 +831,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
private void handleSymbolRemoved(DomainObjectChangeRecord record) {
//
//
// Get the affected vertex (if any). Determine if we have to combine the vertex with
// the vertex below it (adding a symbol creates a new basic block, which creates a new
// vertex--we may need to reverse that process)
@ -837,13 +844,13 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return; // this particular removal doesn't affect our graph
}
//
//
// How do we know if we can combine this vertex with its parent? Well, we have some
// tests that must hold true:
// -There must be only a fallthrough edge to the affected vertex
// -The parent vertex must have only one flow--FallThrough
// -There must not be any other references to the entry of the vertex
// -There must not be any non-dynamic labels on the vertex
// -There must not be any non-dynamic labels on the vertex
//
Graph<FGVertex, FGEdge> graph = functionGraph;
Collection<FGEdge> inEdgesForDestination = graph.getInEdges(destinationVertex);
@ -895,7 +902,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
private void handleSymbolAdded(DomainObjectChangeRecord record) {
//
//
// Get the affected vertex (if any). Determine if we have to split the vertex.
//
FGData functionGraphData = controller.getFunctionGraphData();
@ -906,10 +913,10 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return; // this particular removal doesn't affect our graph
}
//
//
// How do we know if we need to split this vertex? Well, we have some
// tests that must hold true:
// -The address for the symbol must not be to the minimum address for that vertex
// -The address for the symbol must not be to the minimum address for that vertex
//
AddressSetView addresses = destinationVertex.getAddresses();
Address minAddress = addresses.getMinAddress();
@ -1155,7 +1162,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return null;
}
// we want to limit the selections we return here to that which is inside of our
// we want to limit the selections we return here to that which is inside of our
// graph (the current selection of this provider is that for the entire program)
Function function = currentData.getFunction();
AddressSetView functionBody = function.getBody();
@ -1174,7 +1181,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
return null;
}
// we want to limit the selections we return here to that which is inside of our
// we want to limit the selections we return here to that which is inside of our
// graph (the current selection of this provider is that for the entire program)
Function function = currentData.getFunction();
AddressSetView functionBody = function.getBody();