Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Fix tests.

Dan3f34adb79325
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingActionContext.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingActionContext.java
index e91688d37f..29e5d4fb6d 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingActionContext.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingActionContext.java
@@ -15,24 +15,35 @@
*/
package ghidra.app.plugin.core.debug.gui.listing;
-import ghidra.app.plugin.core.codebrowser.CodeViewerActionContext;
-import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
+import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.core.debug.gui.action.DebuggerProgramLocationActionContext;
import ghidra.program.util.ProgramLocation;
+import ghidra.program.util.ProgramSelection;
import ghidra.trace.model.program.TraceProgramView;
-public class DebuggerListingActionContext extends CodeViewerActionContext
+public class DebuggerListingActionContext extends ListingActionContext
implements DebuggerProgramLocationActionContext {
- public DebuggerListingActionContext(CodeViewerProvider provider) {
- super(provider);
+ public DebuggerListingActionContext(DebuggerListingProvider provider) {
+ super(provider, provider);
}
- public DebuggerListingActionContext(CodeViewerProvider provider, ProgramLocation location) {
- super(provider, location);
+ public DebuggerListingActionContext(DebuggerListingProvider provider,
+ ProgramLocation location) {
+ super(provider, provider, location);
+ }
+
+ public DebuggerListingActionContext(DebuggerListingProvider provider, ProgramLocation location,
+ ProgramSelection selection, ProgramSelection highlight) {
+ super(provider, provider, location.getProgram(), location, selection, highlight);
}
@Override
public TraceProgramView getProgram() {
return (TraceProgramView) super.getProgram();
}
+
+ @Override
+ public DebuggerListingProvider getComponentProvider() {
+ return (DebuggerListingProvider) super.getComponentProvider();
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
index 0cd5c4a259..9d0ee81eba 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
@@ -42,8 +42,10 @@ import docking.menu.MultiStateDockingAction;
import docking.widgets.EventTrigger;
import docking.widgets.fieldpanel.support.ViewerPosition;
import generic.theme.GThemeDefaults.Colors;
+import ghidra.app.context.ListingActionContext;
import ghidra.app.nav.ListingPanelContainer;
-import ghidra.app.plugin.core.codebrowser.*;
+import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
+import ghidra.app.plugin.core.codebrowser.MarkerServiceBackgroundColorModel;
import ghidra.app.plugin.core.debug.DebuggerCoordinates;
import ghidra.app.plugin.core.debug.gui.DebuggerLocationLabel;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
@@ -668,7 +670,7 @@ public class DebuggerListingProvider extends CodeViewerProvider {
}
@Override
- protected CodeViewerActionContext newCodeViewerActionContext() {
+ protected ListingActionContext newListingActionContext() {
return new DebuggerListingActionContext(this);
}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
index 5381948541..9f698111c2 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
@@ -33,8 +33,7 @@ import generic.Unique;
import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.core.assembler.AssemblerPluginTestHelper;
import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
-import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
-import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
+import ghidra.app.plugin.core.debug.gui.listing.*;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.plugin.core.debug.service.platform.DebuggerPlatformServicePlugin;
import ghidra.app.plugin.core.debug.service.workflow.DebuggerWorkflowServiceProxyPlugin;
@@ -55,13 +54,13 @@ import ghidra.trace.database.listing.DBTraceInstruction;
import ghidra.trace.database.listing.DBTraceInstructionsMemoryView;
import ghidra.trace.database.memory.DBTraceMemoryManager;
import ghidra.trace.database.memory.DBTraceMemorySpace;
-import ghidra.trace.database.program.DBTraceVariableSnapProgramView;
import ghidra.trace.database.target.DBTraceObject;
import ghidra.trace.database.target.DBTraceObjectManager;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.guest.TraceGuestPlatform;
import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.memory.TraceObjectMemoryRegion;
+import ghidra.trace.model.program.TraceProgramView;
import ghidra.trace.model.stack.TraceObjectStackFrame;
import ghidra.trace.model.target.TraceObject.ConflictResolution;
import ghidra.trace.model.target.TraceObjectKeyPath;
@@ -145,6 +144,13 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
workflowService.enableBots(disBot);
}
+ protected DebuggerListingActionContext createActionContext(Address start, int len) {
+ TraceProgramView view = tb.trace.getProgramView();
+ ProgramSelection sel = new ProgramSelection(start, start.addWrap(len - 1));
+ return new DebuggerListingActionContext(listingProvider, new ProgramLocation(view, start),
+ sel, null);
+ }
+
protected TraceObjectThread createPolyglotTrace(String arch, long offset,
Supplier<ByteBuffer> byteSupplier) throws IOException {
createAndOpenTrace("DATA:BE:64:default");
@@ -236,10 +242,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
// Ensure the mapper is added to the trace
assertNotNull(platformService.getMapper(tb.trace, null, 0));
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(3)), null);
+ ListingActionContext actionContext = createActionContext(start, 4);
performAction(disassemblerPlugin.actionDisassemble, actionContext, true);
waitForTasks();
@@ -271,10 +274,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
// Ensure the mapper is added to the trace
assertNotNull(platformService.getMapper(tb.trace, null, 0));
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(3)), null);
+ ListingActionContext actionContext = createActionContext(start, 4);
performAction(disassemblerPlugin.actionDisassemble, actionContext, true);
waitForTasks();
@@ -297,10 +297,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
// Ensure the mapper is added to the trace
assertNotNull(platformService.getMapper(tb.trace, thread.getObject(), 0));
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(3)), null);
+ ListingActionContext actionContext = createActionContext(start, 4);
performAction(disassemblerPlugin.actionDisassemble, actionContext, true);
waitForTasks();
@@ -324,10 +321,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
// Ensure the mapper is added to the trace
assertNotNull(platformService.getMapper(tb.trace, thread.getObject(), 0));
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(3)), null);
+ ListingActionContext actionContext = createActionContext(start, 4);
performAction(disassemblerPlugin.actionDisassemble, actionContext, true);
waitForTasks();
@@ -339,10 +333,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
protected void performFixedDisassembleAction(Address start,
Predicate<DockingActionIf> actionPred) {
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(3)), null);
+ ListingActionContext actionContext = createActionContext(start, 4);
DockingActionIf action =
runSwing(() -> Unique.assertOne(disassemblerPlugin.getPopupActions(tool, actionContext)
.stream()
@@ -419,11 +410,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
}
waitForDomainObject(tb.trace);
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(1)), null);
-
+ ListingActionContext actionContext = createActionContext(start, 2);
assertTrue(disassemblerPlugin.actionPatchInstruction.isEnabledForContext(actionContext));
DebuggerDisassemblerPluginTestHelper helper = new DebuggerDisassemblerPluginTestHelper(
disassemblerPlugin, listingProvider, tb.trace.getProgramView());
@@ -455,11 +442,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
}
waitForDomainObject(tb.trace);
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(1)), null);
-
+ ListingActionContext actionContext = createActionContext(start, 2);
assertTrue(disassemblerPlugin.actionPatchInstruction.isEnabledForContext(actionContext));
DebuggerDisassemblerPluginTestHelper helper = new DebuggerDisassemblerPluginTestHelper(
disassemblerPlugin, listingProvider, tb.trace.getProgramView());
@@ -489,11 +472,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
}
waitForDomainObject(tb.trace);
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(1)), null);
-
+ ListingActionContext actionContext = createActionContext(start, 2);
assertTrue(disassemblerPlugin.actionPatchInstruction.isEnabledForContext(actionContext));
DebuggerDisassemblerPluginTestHelper helper = new DebuggerDisassemblerPluginTestHelper(
disassemblerPlugin, listingProvider, tb.trace.getProgramView());
@@ -528,11 +507,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
}
waitForDomainObject(tb.trace);
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(1)), null);
-
+ ListingActionContext actionContext = createActionContext(start, 2);
assertTrue(disassemblerPlugin.actionPatchInstruction.isEnabledForContext(actionContext));
DebuggerDisassemblerPluginTestHelper helper = new DebuggerDisassemblerPluginTestHelper(
disassemblerPlugin, listingProvider, tb.trace.getProgramView());
@@ -544,10 +519,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
protected Instruction performFixedAssembleAction(Address start,
Predicate<FixedPlatformTracePatchInstructionAction> actionPred, String assembly) {
- DBTraceVariableSnapProgramView view = tb.trace.getProgramView();
- ListingActionContext actionContext = new ListingActionContext(listingProvider,
- listingProvider, view, new ProgramLocation(view, start),
- new ProgramSelection(start, start.addWrap(1)), null);
+ ListingActionContext actionContext = createActionContext(start, 2);
FixedPlatformTracePatchInstructionAction action =
runSwing(() -> Unique.assertOne(disassemblerPlugin.getPopupActions(tool, actionContext)
.stream()
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
index eccd6d4b6e..b14c7ec1ae 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
@@ -38,6 +38,7 @@ import docking.widgets.fieldpanel.HoverHandler;
import docking.widgets.fieldpanel.internal.FieldPanelCoordinator;
import docking.widgets.fieldpanel.support.*;
import generic.theme.GIcon;
+import ghidra.app.context.ListingActionContext;
import ghidra.app.nav.*;
import ghidra.app.plugin.core.clipboard.CodeBrowserClipboardProvider;
import ghidra.app.plugin.core.codebrowser.actions.*;
@@ -266,7 +267,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
return decorationPanel;
}
- protected CodeViewerActionContext newCodeViewerActionContext() {
+ protected ListingActionContext newListingActionContext() {
return new CodeViewerActionContext(this);
}
@@ -277,7 +278,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
}
if (event == null) {
- return newCodeViewerActionContext();
+ return newListingActionContext();
}
Object source = event.getSource();
@@ -287,7 +288,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
if (programLocation == null) {
return null;
}
- return newCodeViewerActionContext();
+ return newListingActionContext();
}
FieldHeader headerPanel = listingPanel.getFieldHeader();