Merge remote-tracking branch 'origin/patch'

This commit is contained in:
ghidra1 2021-12-18 00:12:04 -05:00
commit 35bcf61bac
7 changed files with 73 additions and 15 deletions

View file

@ -56,6 +56,12 @@
<P>The memory window provides a variety of actions, some for managing and configuring windows,
and others for capturing memory from a target.</P>
<H3><A name="new_memory"></A>New Memory View</H3>
<P>This action is always available in the <SPAN class="menu">Window &rarr; Debugger</SPAN>
menu. It creates a new memory window with the same configuration as the primary memory window.
It is equivalent to "snapshotting" the primary memory window.</P>
<H3><A name="follows_thread"></A>Follows Selected Thread</H3>
<P>This action is only available on snapshot memory windows. The primary window always follows

View file

@ -1552,6 +1552,24 @@ public interface DebuggerResources {
}
}
interface NewMemoryAction{
String NAME = "New Memory View";
String DESCRIPTION = "Open a new memory bytes view";
String GROUP = GROUP_TRANSIENT_VIEWS;
Icon ICON = ICON_MEMORY_BYTES;
String HELP_ANCHOR = "new_memory";
static ActionBuilder builder(Plugin owner) {
String ownerName = owner.getName();
return new ActionBuilder(NAME,ownerName)
.description(DESCRIPTION)
.menuGroup(GROUP)
.menuIcon(ICON)
.menuPath("Window", DebuggerPluginPackage.NAME, NAME)
.helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
}
}
abstract class AbstractStepSnapForwardAction extends DockingAction {
public static final String NAME = "Step Trace Snap Forward";
public static final Icon ICON = ICON_SNAP_FORWARD;

View file

@ -1034,7 +1034,11 @@ public class DebuggerListingProvider extends CodeViewerProvider {
public void cloneWindow() {
final DebuggerListingProvider newProvider = plugin.createNewDisconnectedProvider();
final ViewerPosition vp = getListingPanel().getFieldPanel().getViewerPosition();
final SaveState saveState = new SaveState();
writeConfigState(saveState);
Swing.runLater(() -> {
newProvider.readConfigState(saveState);
newProvider.goToCoordinates(current);
newProvider.getListingPanel()
.getFieldPanel()

View file

@ -24,6 +24,7 @@ import java.util.stream.Collectors;
import org.jdom.Element;
import docking.action.DockingAction;
import ghidra.app.events.ProgramLocationPluginEvent;
import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.plugin.PluginCategoryNames;
@ -31,6 +32,7 @@ import ghidra.app.plugin.core.byteviewer.*;
import ghidra.app.plugin.core.debug.DebuggerCoordinates;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.*;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.NewMemoryAction;
import ghidra.app.plugin.core.debug.gui.action.LocationTrackingSpec;
import ghidra.app.plugin.core.debug.gui.action.NoneLocationTrackingSpec;
import ghidra.app.services.*;
@ -71,6 +73,8 @@ public class DebuggerMemoryBytesPlugin
private static final String KEY_DISCONNECTED_COUNT = "disconnectedCount";
private static final String PREFIX_DISCONNECTED_PROVIDER = "disconnectedProvider";
protected DockingAction actionNewMemory;
@AutoServiceConsumed
private ProgramManager programManager;
// NOTE: This plugin doesn't extend AbstractDebuggerPlugin
@ -102,7 +106,10 @@ public class DebuggerMemoryBytesPlugin
}
private void createActions() {
// TODO
actionNewMemory = NewMemoryAction.builder(this)
.enabled(true)
.onAction(c -> createNewDisconnectedProvider())
.buildAndInstall(tool);
}
public DebuggerMemoryBytesProvider createViewerIfMissing(LocationTrackingSpec spec,

View file

@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.ActionContext;
import docking.action.*;
import docking.menu.MultiStateDockingAction;
import docking.widgets.fieldpanel.support.ViewerPosition;
import ghidra.app.plugin.core.byteviewer.*;
import ghidra.app.plugin.core.debug.DebuggerCoordinates;
import ghidra.app.plugin.core.debug.gui.DebuggerLocationLabel;
@ -217,6 +218,11 @@ public class DebuggerMemoryBytesProvider extends ProgramByteViewerComponentProvi
return super.getByteViewerPanel();
}
@Override
protected void addToToolbar() {
// Prevent this from being added to the toolbar
}
/**
* Deal with the fact that initialization order is hard to control
*/
@ -363,6 +369,11 @@ public class DebuggerMemoryBytesProvider extends ProgramByteViewerComponentProvi
return trackingTrait.getSpec();
}
@Override
public boolean isConnected() {
return false;
}
public boolean isMainViewer() {
return isMainViewer;
}
@ -417,13 +428,16 @@ public class DebuggerMemoryBytesProvider extends ProgramByteViewerComponentProvi
@Override
public void cloneWindow() {
final DebuggerMemoryBytesProvider newProvider = myPlugin.createNewDisconnectedProvider();
SaveState saveState = new SaveState();
final ViewerPosition vp = panel.getViewerPosition();
final SaveState saveState = new SaveState();
writeConfigState(saveState);
newProvider.readConfigState(saveState);
Swing.runLater(() -> {
newProvider.readConfigState(saveState);
newProvider.goToCoordinates(current);
newProvider.setLocation(currentLocation);
newProvider.panel.setViewerPosition(panel.getViewerPosition());
newProvider.goToCoordinates(current);
newProvider.setLocation(currentLocation);
newProvider.panel.setViewerPosition(vp);
});
}
@Override