GP-385: Prevent re-goto-PC on memory bytes change

This commit is contained in:
Dan 2022-06-13 13:49:59 -04:00
parent 592edd3843
commit 6bbacbc3f9

View file

@ -295,6 +295,8 @@ public class DebuggerListingProvider extends CodeViewerProvider {
protected final boolean isMainListing; protected final boolean isMainListing;
private long countAddressesInIndex;
public DebuggerListingProvider(DebuggerListingPlugin plugin, FormatManager formatManager, public DebuggerListingProvider(DebuggerListingPlugin plugin, FormatManager formatManager,
boolean isConnected) { boolean isConnected) {
super(plugin, formatManager, isConnected); super(plugin, formatManager, isConnected);
@ -722,6 +724,19 @@ public class DebuggerListingProvider extends CodeViewerProvider {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
super.stateChanged(e); super.stateChanged(e);
/*
* It seems this method gets called a bit spuriously. A change in bytes, which does not
* imply a change in layout, will also land us here. Thus, we do some simple test here to
* verify that the layout has actually changed. A good proxy is if the number of addresses
* in the listing has changed. To detect that, we have to record what we've seen each
* change.
*/
long newCountAddressesInIndex =
getListingPanel().getAddressIndexMap().getIndexedAddressSet().getNumAddresses();
if (this.countAddressesInIndex == newCountAddressesInIndex) {
return;
}
this.countAddressesInIndex = newCountAddressesInIndex;
ProgramLocation trackedLocation = trackingTrait.getTrackedLocation(); ProgramLocation trackedLocation = trackingTrait.getTrackedLocation();
if (trackedLocation != null && !isEffectivelyDifferent(getLocation(), trackedLocation)) { if (trackedLocation != null && !isEffectivelyDifferent(getLocation(), trackedLocation)) {
cbGoTo.invoke(() -> getListingPanel().goTo(trackedLocation, true)); cbGoTo.invoke(() -> getListingPanel().goTo(trackedLocation, true));