mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
Merge remote-tracking branch 'origin/GP-0_Dan_testFixes-2022-02-21-1'
This commit is contained in:
@@ -94,6 +94,11 @@ public enum ControlMode {
|
|||||||
public boolean isSelectable(DebuggerCoordinates coordinates) {
|
public boolean isSelectable(DebuggerCoordinates coordinates) {
|
||||||
return coordinates.isAlive();
|
return coordinates.isAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControlMode getAlternative(DebuggerCoordinates coordinates) {
|
||||||
|
return RW_EMULATOR;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Control actions, breakpoint commands, and state edits are all directed to the target.
|
* Control actions, breakpoint commands, and state edits are all directed to the target.
|
||||||
@@ -150,6 +155,11 @@ public enum ControlMode {
|
|||||||
public boolean isSelectable(DebuggerCoordinates coordinates) {
|
public boolean isSelectable(DebuggerCoordinates coordinates) {
|
||||||
return coordinates.isAlive();
|
return coordinates.isAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControlMode getAlternative(DebuggerCoordinates coordinates) {
|
||||||
|
return RW_EMULATOR;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Control actions activate trace snapshots, breakpoint commands are directed to the emulator,
|
* Control actions activate trace snapshots, breakpoint commands are directed to the emulator,
|
||||||
@@ -393,8 +403,9 @@ public enum ControlMode {
|
|||||||
"Cannot navigate time in %s mode. Switch to Trace or Emulate mode first."
|
"Cannot navigate time in %s mode. Switch to Trace or Emulate mode first."
|
||||||
.formatted(name),
|
.formatted(name),
|
||||||
true);
|
true);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return coordinates.snap(target.getSnap());
|
return coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -450,6 +461,37 @@ public enum ControlMode {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the mode can no longer be selected for new coordinates, get the new mode
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* For example, if a target terminates while the mode is {@link #RO_TARGET}, this specifies the
|
||||||
|
* new mode.
|
||||||
|
*
|
||||||
|
* @param coordinates the new coordinates
|
||||||
|
* @return the new mode
|
||||||
|
*/
|
||||||
|
public ControlMode getAlternative(DebuggerCoordinates coordinates) {
|
||||||
|
throw new AssertionError("INTERNAL: Non-selectable mode must provide alternative");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the new mode (or same) mode when activating the given coordinates
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The default is implemented using {@link #isSelectable(DebuggerCoordinates)} followed by
|
||||||
|
* {@link #getAlternative(DebuggerCoordinates)}.
|
||||||
|
*
|
||||||
|
* @param coordinates the new coordinates
|
||||||
|
* @return the mode
|
||||||
|
*/
|
||||||
|
public ControlMode modeOnChange(DebuggerCoordinates coordinates) {
|
||||||
|
if (isSelectable(coordinates)) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return getAlternative(coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this mode controls the target
|
* Indicates whether this mode controls the target
|
||||||
*
|
*
|
||||||
|
|||||||
+2
@@ -398,6 +398,8 @@ public class TraceRmiConnectionManagerProviderTest extends AbstractGhidraHeadedD
|
|||||||
waitForPass(
|
waitForPass(
|
||||||
() -> assertEquals(node, Unique.assertOne(provider.tree.getSelectedNodes())));
|
() -> assertEquals(node, Unique.assertOne(provider.tree.getSelectedNodes())));
|
||||||
|
|
||||||
|
controlService.setCurrentMode(target.getTrace(), ControlMode.RO_TRACE);
|
||||||
|
waitForSwing();
|
||||||
traceManager.activateSnap(0);
|
traceManager.activateSnap(0);
|
||||||
waitForPass(() -> {
|
waitForPass(() -> {
|
||||||
assertEquals(0, traceManager.getCurrentSnap());
|
assertEquals(0, traceManager.getCurrentSnap());
|
||||||
|
|||||||
+29
-2
@@ -22,9 +22,9 @@ import java.util.concurrent.*;
|
|||||||
import ghidra.app.plugin.PluginCategoryNames;
|
import ghidra.app.plugin.PluginCategoryNames;
|
||||||
import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
|
import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
|
||||||
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
|
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
|
||||||
import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
|
import ghidra.app.plugin.core.debug.event.*;
|
||||||
import ghidra.app.plugin.core.debug.event.TraceOpenedPluginEvent;
|
|
||||||
import ghidra.app.services.*;
|
import ghidra.app.services.*;
|
||||||
|
import ghidra.app.services.DebuggerTraceManagerService.ActivationCause;
|
||||||
import ghidra.debug.api.control.ControlMode;
|
import ghidra.debug.api.control.ControlMode;
|
||||||
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
|
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
|
||||||
import ghidra.framework.plugintool.*;
|
import ghidra.framework.plugintool.*;
|
||||||
@@ -46,6 +46,7 @@ import ghidra.util.datastruct.ListenerSet;
|
|||||||
status = PluginStatus.RELEASED,
|
status = PluginStatus.RELEASED,
|
||||||
eventsConsumed = {
|
eventsConsumed = {
|
||||||
TraceOpenedPluginEvent.class,
|
TraceOpenedPluginEvent.class,
|
||||||
|
TraceActivatedPluginEvent.class,
|
||||||
TraceClosedPluginEvent.class,
|
TraceClosedPluginEvent.class,
|
||||||
},
|
},
|
||||||
servicesRequired = {
|
servicesRequired = {
|
||||||
@@ -262,6 +263,29 @@ public class DebuggerControlServicePlugin extends AbstractDebuggerPlugin
|
|||||||
return new FollowsViewStateEditor(view);
|
return new FollowsViewStateEditor(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void coordinatesActivated(DebuggerCoordinates coordinates, ActivationCause cause) {
|
||||||
|
if (cause != ActivationCause.USER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Trace trace = coordinates.getTrace();
|
||||||
|
if (trace == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ControlMode oldMode;
|
||||||
|
ControlMode newMode;
|
||||||
|
synchronized (currentModes) {
|
||||||
|
oldMode = currentModes.getOrDefault(trace, ControlMode.DEFAULT);
|
||||||
|
newMode = oldMode.modeOnChange(coordinates);
|
||||||
|
if (newMode != oldMode) {
|
||||||
|
currentModes.put(trace, newMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newMode != oldMode) {
|
||||||
|
listeners.invoke().modeChanged(trace, newMode);
|
||||||
|
tool.contextChanged(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void installMemoryEditor(TraceProgramView view) {
|
protected void installMemoryEditor(TraceProgramView view) {
|
||||||
TraceProgramViewMemory memory = view.getMemory();
|
TraceProgramViewMemory memory = view.getMemory();
|
||||||
if (memory.getLiveMemoryHandler() != null) {
|
if (memory.getLiveMemoryHandler() != null) {
|
||||||
@@ -322,6 +346,9 @@ public class DebuggerControlServicePlugin extends AbstractDebuggerPlugin
|
|||||||
if (event instanceof TraceOpenedPluginEvent ev) {
|
if (event instanceof TraceOpenedPluginEvent ev) {
|
||||||
installAllMemoryEditors(ev.getTrace());
|
installAllMemoryEditors(ev.getTrace());
|
||||||
}
|
}
|
||||||
|
else if (event instanceof TraceActivatedPluginEvent ev) {
|
||||||
|
coordinatesActivated(ev.getActiveCoordinates(), ev.getCause());
|
||||||
|
}
|
||||||
else if (event instanceof TraceClosedPluginEvent ev) {
|
else if (event instanceof TraceClosedPluginEvent ev) {
|
||||||
uninstallAllMemoryEditors(ev.getTrace());
|
uninstallAllMemoryEditors(ev.getTrace());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -568,7 +568,7 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
newCurrent = validateCoordiantes(newCurrent, cause);
|
newCurrent = validateCoordiantes(newCurrent, cause);
|
||||||
if (!doSetCurrent(newCurrent)) {
|
if (newCurrent == null || !doSetCurrent(newCurrent)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return newCurrent;
|
return newCurrent;
|
||||||
|
|||||||
+11
-4
@@ -25,8 +25,8 @@ import org.jdom.JDOMException;
|
|||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import db.Transaction;
|
import db.Transaction;
|
||||||
import docking.widgets.table.DynamicTableColumn;
|
import docking.widgets.table.*;
|
||||||
import docking.widgets.table.GDynamicColumnTableModel;
|
import docking.widgets.table.ColumnSortState.SortDirection;
|
||||||
import docking.widgets.tree.GTree;
|
import docking.widgets.tree.GTree;
|
||||||
import docking.widgets.tree.GTreeNode;
|
import docking.widgets.tree.GTreeNode;
|
||||||
import docking.widgets.tree.support.GTreeSelectionEvent.EventOrigin;
|
import docking.widgets.tree.support.GTreeSelectionEvent.EventOrigin;
|
||||||
@@ -36,8 +36,7 @@ import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.PrimitiveRow;
|
|||||||
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.ValueRow;
|
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.ValueRow;
|
||||||
import ghidra.app.plugin.core.debug.gui.model.ObjectTreeModel.AbstractNode;
|
import ghidra.app.plugin.core.debug.gui.model.ObjectTreeModel.AbstractNode;
|
||||||
import ghidra.app.plugin.core.debug.gui.model.PathTableModel.PathRow;
|
import ghidra.app.plugin.core.debug.gui.model.PathTableModel.PathRow;
|
||||||
import ghidra.app.plugin.core.debug.gui.model.columns.TraceValueLifePlotColumn;
|
import ghidra.app.plugin.core.debug.gui.model.columns.*;
|
||||||
import ghidra.app.plugin.core.debug.gui.model.columns.TraceValueValColumn;
|
|
||||||
import ghidra.dbg.target.TargetEventScope;
|
import ghidra.dbg.target.TargetEventScope;
|
||||||
import ghidra.dbg.target.TargetObject;
|
import ghidra.dbg.target.TargetObject;
|
||||||
import ghidra.dbg.target.schema.SchemaContext;
|
import ghidra.dbg.target.schema.SchemaContext;
|
||||||
@@ -365,10 +364,18 @@ public class DebuggerModelProviderTest extends AbstractGhidraHeadedDebuggerTest
|
|||||||
modelProvider.setPath(TraceObjectKeyPath.parse("Processes[0].Handles"));
|
modelProvider.setPath(TraceObjectKeyPath.parse("Processes[0].Handles"));
|
||||||
waitForTasks();
|
waitForTasks();
|
||||||
|
|
||||||
|
int keyColIndex =
|
||||||
|
waitForValue(() -> findColumnOfClass(modelProvider.elementsTablePanel.tableModel,
|
||||||
|
TraceValueKeyColumn.class));
|
||||||
int valColIndex =
|
int valColIndex =
|
||||||
waitForValue(() -> findColumnOfClass(modelProvider.elementsTablePanel.tableModel,
|
waitForValue(() -> findColumnOfClass(modelProvider.elementsTablePanel.tableModel,
|
||||||
TraceValueValColumn.class));
|
TraceValueValColumn.class));
|
||||||
|
|
||||||
|
TableSortStateEditor sortEditor = new TableSortStateEditor();
|
||||||
|
sortEditor.addSortedColumn(keyColIndex, SortDirection.ASCENDING);
|
||||||
|
modelProvider.elementsTablePanel.tableModel
|
||||||
|
.setTableSortState(sortEditor.createTableSortState());
|
||||||
|
|
||||||
waitForPass(() -> {
|
waitForPass(() -> {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Object obj = modelProvider.elementsTablePanel.tableModel.getValueAt(i, valColIndex);
|
Object obj = modelProvider.elementsTablePanel.tableModel.getValueAt(i, valColIndex);
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ import ghidra.app.plugin.core.debug.gui.register.*;
|
|||||||
import ghidra.app.plugin.core.debug.gui.watch.DebuggerWatchesProvider.WatchDataSettingsDialog;
|
import ghidra.app.plugin.core.debug.gui.watch.DebuggerWatchesProvider.WatchDataSettingsDialog;
|
||||||
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
|
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
|
||||||
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
|
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
|
||||||
import ghidra.app.services.*;
|
import ghidra.app.services.DebuggerControlService;
|
||||||
import ghidra.dbg.model.TestTargetRegisterBankInThread;
|
import ghidra.dbg.model.TestTargetRegisterBankInThread;
|
||||||
import ghidra.debug.api.action.ActionSource;
|
import ghidra.debug.api.action.ActionSource;
|
||||||
import ghidra.debug.api.control.ControlMode;
|
import ghidra.debug.api.control.ControlMode;
|
||||||
|
|||||||
+9
@@ -467,6 +467,15 @@ public class DebuggerControlServiceTest extends AbstractGhidraHeadedDebuggerTest
|
|||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertEquals(recorder.getSnap(), traceManager.getCurrentSnap());
|
assertEquals(recorder.getSnap(), traceManager.getCurrentSnap());
|
||||||
|
|
||||||
|
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
||||||
|
waitForSwing();
|
||||||
|
assertEquals(
|
||||||
|
"Cannot navigate time in Control Target mode. Switch to Trace or Emulate mode first.",
|
||||||
|
tool.getStatusInfo());
|
||||||
|
assertEquals(recorder.getSnap(), traceManager.getCurrentSnap());
|
||||||
|
|
||||||
|
controlService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
|
||||||
|
waitForSwing();
|
||||||
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
traceManager.activateSnap(traceManager.getCurrentSnap() - 1);
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertEquals(ControlMode.RW_EMULATOR, controlService.getCurrentMode(tb.trace));
|
assertEquals(ControlMode.RW_EMULATOR, controlService.getCurrentMode(tb.trace));
|
||||||
|
|||||||
Reference in New Issue
Block a user