diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java index 22403c4e13..4c2f68e243 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java @@ -153,7 +153,7 @@ public interface DebuggerResources { ImageIcon ICON_MAP_SECTIONS = ICON_MAP_MODULES; // TODO ImageIcon ICON_BLOCK = ICON_MAP_SECTIONS; // TODO // TODO: Draw an icon - ImageIcon ICON_SELECT_ADDRESSES = ResourceManager.loadImage("images/NextSelectionBlock16.gif"); + ImageIcon ICON_SELECT_ADDRESSES = ResourceManager.loadImage("images/text_align_justify.png"); // TODO: Draw an icon? ImageIcon ICON_DATA_TYPES = ResourceManager.loadImage("images/dataTypes.png"); // TODO: Draw an icon? diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java index 1fe24fe85f..351f71c2c9 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java @@ -220,38 +220,54 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter { } } + protected static Set getSelectedModulesFromModuleContext( + DebuggerModuleActionContext context) { + return context.getSelectedModules() + .stream() + .map(r -> r.getModule()) + .collect(Collectors.toSet()); + } + + protected static Set getSelectedModulesFromSectionContext( + DebuggerSectionActionContext context) { + return context.getSelectedSections() + .stream() + .map(r -> r.getModule()) + .collect(Collectors.toSet()); + } + + protected static Set getSelectedSectionsFromModuleContext( + DebuggerModuleActionContext context) { + return context.getSelectedModules() + .stream() + .flatMap(r -> r.getModule().getSections().stream()) + .collect(Collectors.toSet()); + } + + protected static Set getSelectedSectionsFromSectionContext( + DebuggerSectionActionContext context) { + return context.getSelectedSections() + .stream() + .map(r -> r.getSection()) + .collect(Collectors.toSet()); + } + protected static Set getSelectedModules(ActionContext context) { if (context instanceof DebuggerModuleActionContext) { - DebuggerModuleActionContext ctx = (DebuggerModuleActionContext) context; - return ctx.getSelectedModules() - .stream() - .map(r -> r.getModule()) - .collect(Collectors.toSet()); + return getSelectedModulesFromModuleContext((DebuggerModuleActionContext) context); } if (context instanceof DebuggerSectionActionContext) { - DebuggerSectionActionContext ctx = (DebuggerSectionActionContext) context; - return ctx.getSelectedSections() - .stream() - .map(r -> r.getModule()) - .collect(Collectors.toSet()); + return getSelectedModulesFromSectionContext((DebuggerSectionActionContext) context); } return null; } protected static Set getSelectedSections(ActionContext context) { if (context instanceof DebuggerModuleActionContext) { - DebuggerModuleActionContext ctx = (DebuggerModuleActionContext) context; - return ctx.getSelectedModules() - .stream() - .flatMap(r -> r.getModule().getSections().stream()) - .collect(Collectors.toSet()); + return getSelectedSectionsFromModuleContext((DebuggerModuleActionContext) context); } if (context instanceof DebuggerSectionActionContext) { - DebuggerSectionActionContext ctx = (DebuggerSectionActionContext) context; - return ctx.getSelectedSections() - .stream() - .map(r -> r.getSection()) - .collect(Collectors.toSet()); + return getSelectedSectionsFromSectionContext((DebuggerSectionActionContext) context); } return null; } @@ -345,14 +361,24 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter { if (listingService == null) { return; } - Set sections = getSelectedSections(myActionContext); - if (sections == null) { - return; - } + AddressSet sel = new AddressSet(); - for (TraceSection s : sections) { - sel.add(s.getRange()); + if (myActionContext instanceof DebuggerModuleActionContext) { + DebuggerModuleActionContext mCtx = + (DebuggerModuleActionContext) myActionContext; + for (TraceModule module : getSelectedModulesFromModuleContext(mCtx)) { + sel.add(module.getRange()); + } } + else if (myActionContext instanceof DebuggerSectionActionContext) { + DebuggerSectionActionContext sCtx = + (DebuggerSectionActionContext) myActionContext; + for (TraceSection section : getSelectedSectionsFromSectionContext(sCtx)) { + sel.add(section.getRange()); + } + } + + sel = sel.intersect(traceManager.getCurrentView().getMemory()); ProgramSelection ps = new ProgramSelection(sel); listingService.setCurrentSelection(ps); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NavigationHistoryPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NavigationHistoryPlugin.java index 4283dcbdbc..ce10f964a6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NavigationHistoryPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NavigationHistoryPlugin.java @@ -37,15 +37,13 @@ import ghidra.util.Msg; import ghidra.util.bean.opteditor.OptionsVetoException; /** - * NavigationHistoryPlugin is used in conjunction with other - * plugins to cause program viewer plugins to change their focus to a certain - * address. As viewer plugins are directed to one or more addresses it maintains - * information about where the viewers have been to support ability for the - * viewers to go back to a previous "focus" point. + * NavigationHistoryPlugin is used in conjunction with other plugins to cause program + * viewer plugins to change their focus to a certain address. As viewer plugins are directed to one + * or more addresses it maintains information about where the viewers have been to support ability + * for the viewers to go back to a previous "focus" point. * - * Services Provided: NavigationHistoryService - * Events Consumed: ProgramLocationPluginEvent, ProgramPluginEvent - * Event Produced: HistoryChangePluginEvent Actions: None. + * Services Provided: NavigationHistoryService Events Consumed: ProgramLocationPluginEvent, + * ProgramPluginEvent Event Produced: HistoryChangePluginEvent Actions: None. */ //@formatter:off @PluginInfo( @@ -367,7 +365,15 @@ public class NavigationHistoryPlugin extends Plugin } private void notifyHistoryChange() { - tool.contextChanged(null); + /* + * During tool disposal, Plugins having providers that extend + * NavigatableComponentProviderAdapter may get disposed after we do. Those providers remove + * themselves from us via NavigatableRemovalListener, which eventually calls into here. If + * that is the case, our tool will already be set to null, so we'll just ignore the event. + */ + if (tool != null) { + tool.contextChanged(null); + } } @Override @@ -543,12 +549,12 @@ public class NavigationHistoryPlugin extends Plugin } /** - * Find the next history LocationMemento that contains a different function. If no such + * Find the next history LocationMemento that contains a different function. If no such * LocationMemento is found, null is returned. * * @param navigatable the navigatable being navigated - * @param moveTo true means after finding, get current location to it. false to just find - * and do nothing + * @param moveTo true means after finding, get current location to it. false to just find + * and do nothing * @return next LocationMemento, or null if no next function */ private LocationMemento nextFunction(Navigatable navigatable, boolean moveTo) { @@ -591,8 +597,8 @@ public class NavigationHistoryPlugin extends Plugin * LocationMemento is found, null is returned. * * @param navigatable the navigatable being navigated - * @param moveTo true means after finding, get current location to it. false to just find - * and do nothing + * @param moveTo true means after finding, get current location to it. false to just find + * and do nothing * @return previous LocationMemento, or null if no previous function found */ private LocationMemento previousFunction(Navigatable navigatable, boolean moveTo) {