Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Fix tests

Dan127ebf9fe756
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/DebuggerCoordinates.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/DebuggerCoordinates.java
index 01fd9f49d1..0ea96f1350 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/DebuggerCoordinates.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/DebuggerCoordinates.java
@@ -392,6 +392,22 @@ public class DebuggerCoordinates {
return time(TraceSchedule.snap(snap));
}
+ /**
+ * Get these same coordinates with time replace by the given snap-only schedule, and DO NOT
+ * resolve or adjust anything else
+ *
+ * @param snap the new snap
+ * @return exactly these same coordinates with the snap/time changed
+ */
+ public DebuggerCoordinates snapNoResolve(long snap) {
+ if (time.isSnapOnly() && time.getSnap() == snap) {
+ return this;
+ }
+ TraceSchedule newTime = TraceSchedule.snap(snap);
+ return new DebuggerCoordinates(trace, platform, recorder, thread, view, newTime, frame,
+ object);
+ }
+
public DebuggerCoordinates time(TraceSchedule newTime) {
if (trace == null) {
return NOWHERE;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
index 1462651628..d8373a9821 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
@@ -36,6 +36,7 @@ import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange;
import ghidra.program.util.ProgramSelection;
+import ghidra.trace.model.Trace;
import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.target.TraceObjectInterface;
@@ -89,6 +90,12 @@ public abstract class AbstractObjectsTableBasedPanel<U extends TraceObjectInterf
public void coordinatesActivated(DebuggerCoordinates coordinates) {
TraceObject object = coordinates.getObject();
+ if (object == null) {
+ Trace trace = coordinates.getTrace();
+ if (trace != null) {
+ object = trace.getObjectManager().getRootObject();
+ }
+ }
setQuery(object == null ? ModelQuery.EMPTY : computeQuery(object));
goToCoordinates(coordinates);
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
index 357a44f639..f28e5ae62e 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
@@ -641,7 +641,7 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
DebuggerCoordinates inactive = null;
synchronized (listenersByTrace) {
DebuggerCoordinates curForTrace = getCurrentFor(trace);
- inactive = curForTrace.snap(snap);
+ inactive = curForTrace.snapNoResolve(snap);
lastCoordsByTrace.put(trace, inactive);
}
trace.getProgramView().setSnap(snap);
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
index c4208acac6..b0c0515e4a 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
@@ -138,42 +138,42 @@ public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUI
public void activateObjectsMode() throws Exception {
// NOTE the use of index='1' allowing object-based managers to ID unique path
- ctx = XmlSchemaContext.deserialize("" + //
- "<context>" + //
- " <schema name='Session' elementResync='NEVER' attributeResync='ONCE'>" + //
- " <attribute name='Processes' schema='ProcessContainer' />" + //
- " </schema>" + //
- " <schema name='ProcessContainer' canonical='yes' elementResync='NEVER' " + //
- " attributeResync='ONCE'>" + //
- " <element index='1' schema='Process' />" + // <---- NOTE HERE
- " </schema>" + //
- " <schema name='Process' elementResync='NEVER' attributeResync='ONCE'>" + //
- " <attribute name='Modules' schema='ModuleContainer' />" + //
- " <attribute name='Memory' schema='RegionContainer' />" + //
- " </schema>" + //
- " <schema name='RegionContainer' canonical='yes' elementResync='NEVER' " + //
- " attributeResync='ONCE'>" + //
- " <element schema='Region' />" + //
- " </schema>" + //
- " <schema name='Region' elementResync='NEVER' attributeResync='NEVER'>" + //
- " <interface name='MemoryRegion' />" + //
- " </schema>" + //
- " <schema name='ModuleContainer' canonical='yes' elementResync='NEVER' " + //
- " attributeResync='ONCE'>" + //
- " <element schema='Module' />" + //
- " </schema>" + //
- " <schema name='Module' elementResync='NEVER' attributeResync='NEVER'>" + //
- " <interface name='Module' />" + //
- " <attribute name='Sections' schema='SectionContainer' />" + //
- " </schema>" + //
- " <schema name='SectionContainer' canonical='yes' elementResync='NEVER' " + //
- " attributeResync='ONCE'>" + //
- " <element schema='Section' />" + //
- " </schema>" + //
- " <schema name='Section' elementResync='NEVER' attributeResync='NEVER'>" + //
- " <interface name='Section' />" + //
- " </schema>" + //
- "</context>");
+ ctx = XmlSchemaContext.deserialize("""
+ <context>
+ <schema name='Session' elementResync='NEVER' attributeResync='ONCE'>
+ <attribute name='Processes' schema='ProcessContainer' />
+ </schema>
+ <schema name='ProcessContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element index='1' schema='Process' />
+ </schema>
+ <schema name='Process' elementResync='NEVER' attributeResync='ONCE'>
+ <attribute name='Modules' schema='ModuleContainer' />
+ <attribute name='Memory' schema='RegionContainer' />
+ </schema>
+ <schema name='RegionContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element schema='Region' />
+ </schema>
+ <schema name='Region' elementResync='NEVER' attributeResync='NEVER'>
+ <interface name='MemoryRegion' />
+ </schema>
+ <schema name='ModuleContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element schema='Module' />
+ </schema>
+ <schema name='Module' elementResync='NEVER' attributeResync='NEVER'>
+ <interface name='Module' />
+ <attribute name='Sections' schema='SectionContainer' />
+ </schema>
+ <schema name='SectionContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element schema='Section' />
+ </schema>
+ <schema name='Section' elementResync='NEVER' attributeResync='NEVER'>
+ <interface name='Section' />
+ </schema>
+ </context>""");
try (UndoableTransaction tid = tb.startTransaction()) {
tb.trace.getObjectManager().createRootObject(ctx.getSchema(new SchemaName("Session")));
diff --git a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/model/TestTargetSession.java b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/model/TestTargetSession.java
index 2cc280a9da..2cd0bd279d 100644
--- a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/model/TestTargetSession.java
+++ b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/model/TestTargetSession.java
@@ -28,7 +28,8 @@ import ghidra.dbg.target.schema.TargetObjectSchema;
import ghidra.program.model.address.AddressSpace;
public class TestTargetSession extends DefaultTargetModelRoot
- implements TestTargetObject, TargetFocusScope, TargetEventScope, TargetLauncher {
+ implements TestTargetObject, TargetActiveScope, TargetFocusScope, TargetEventScope,
+ TargetLauncher {
public final TestTargetEnvironment environment;
public final TestTargetProcessContainer processes;
@@ -65,6 +66,14 @@ public class TestTargetSession extends DefaultTargetModelRoot
return (TestDebuggerObjectModel) super.getModel();
}
+ @Override
+ public CompletableFuture<Void> requestActivation(TargetObject obj) {
+ return model.gateFuture(getModel().future(null).thenAccept(__ -> {
+ changeAttributes(List.of(), List.of(), Map.of(FOCUS_ATTRIBUTE_NAME, obj),
+ "Activation requested");
+ }));
+ }
+
@Override
public CompletableFuture<Void> requestFocus(TargetObject obj) {
return model.gateFuture(getModel().future(null).thenAccept(__ -> {
@@ -82,7 +91,6 @@ public class TestTargetSession extends DefaultTargetModelRoot
@Override
public CompletableFuture<Void> launch(Map<String, ?> args) {
- // TODO: Record the request and allow tests to complete it?
return AsyncUtils.NIL;
}
}
diff --git a/Ghidra/Debug/Framework-Debugging/src/test/resources/ghidra/dbg/model/test_schema.xml b/Ghidra/Debug/Framework-Debugging/src/test/resources/ghidra/dbg/model/test_schema.xml
index 8109d9390e..cd3f019e05 100644
--- a/Ghidra/Debug/Framework-Debugging/src/test/resources/ghidra/dbg/model/test_schema.xml
+++ b/Ghidra/Debug/Framework-Debugging/src/test/resources/ghidra/dbg/model/test_schema.xml
@@ -3,6 +3,7 @@
<schema name="Test" elementResync="NEVER" attributeResync="ONCE">
<interface name="EventScope" />
<interface name="Launcher" />
+ <interface name="ActiveScope" />
<interface name="FocusScope" />
<interface name="Aggregate" />
<element schema="VOID" />