Merge remote-tracking branch 'origin/GP-1450_Dan_fixSelectAddressesButtons--SQUASHED'

This commit is contained in:
Ryan Kurtz
2021-11-09 14:25:44 -05:00
3 changed files with 73 additions and 41 deletions

View File

@@ -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?

View File

@@ -220,38 +220,54 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
}
}
protected static Set<TraceModule> getSelectedModulesFromModuleContext(
DebuggerModuleActionContext context) {
return context.getSelectedModules()
.stream()
.map(r -> r.getModule())
.collect(Collectors.toSet());
}
protected static Set<TraceModule> getSelectedModulesFromSectionContext(
DebuggerSectionActionContext context) {
return context.getSelectedSections()
.stream()
.map(r -> r.getModule())
.collect(Collectors.toSet());
}
protected static Set<TraceSection> getSelectedSectionsFromModuleContext(
DebuggerModuleActionContext context) {
return context.getSelectedModules()
.stream()
.flatMap(r -> r.getModule().getSections().stream())
.collect(Collectors.toSet());
}
protected static Set<TraceSection> getSelectedSectionsFromSectionContext(
DebuggerSectionActionContext context) {
return context.getSelectedSections()
.stream()
.map(r -> r.getSection())
.collect(Collectors.toSet());
}
protected static Set<TraceModule> 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<TraceSection> 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<TraceSection> 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);
}

View File

@@ -37,15 +37,13 @@ import ghidra.util.Msg;
import ghidra.util.bean.opteditor.OptionsVetoException;
/**
* <CODE>NavigationHistoryPlugin</CODE> 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.
* <CODE>NavigationHistoryPlugin</CODE> 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) {