mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-29 07:18:16 +08:00
GP-0: Fix tests
This commit is contained in:
+16
@@ -392,6 +392,22 @@ public class DebuggerCoordinates {
|
|||||||
return time(TraceSchedule.snap(snap));
|
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) {
|
public DebuggerCoordinates time(TraceSchedule newTime) {
|
||||||
if (trace == null) {
|
if (trace == null) {
|
||||||
return NOWHERE;
|
return NOWHERE;
|
||||||
|
|||||||
+7
@@ -36,6 +36,7 @@ import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
|
|||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressRange;
|
import ghidra.program.model.address.AddressRange;
|
||||||
import ghidra.program.util.ProgramSelection;
|
import ghidra.program.util.ProgramSelection;
|
||||||
|
import ghidra.trace.model.Trace;
|
||||||
import ghidra.trace.model.target.TraceObject;
|
import ghidra.trace.model.target.TraceObject;
|
||||||
import ghidra.trace.model.target.TraceObjectInterface;
|
import ghidra.trace.model.target.TraceObjectInterface;
|
||||||
|
|
||||||
@@ -89,6 +90,12 @@ public abstract class AbstractObjectsTableBasedPanel<U extends TraceObjectInterf
|
|||||||
|
|
||||||
public void coordinatesActivated(DebuggerCoordinates coordinates) {
|
public void coordinatesActivated(DebuggerCoordinates coordinates) {
|
||||||
TraceObject object = coordinates.getObject();
|
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));
|
setQuery(object == null ? ModelQuery.EMPTY : computeQuery(object));
|
||||||
goToCoordinates(coordinates);
|
goToCoordinates(coordinates);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -641,7 +641,7 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
|
|||||||
DebuggerCoordinates inactive = null;
|
DebuggerCoordinates inactive = null;
|
||||||
synchronized (listenersByTrace) {
|
synchronized (listenersByTrace) {
|
||||||
DebuggerCoordinates curForTrace = getCurrentFor(trace);
|
DebuggerCoordinates curForTrace = getCurrentFor(trace);
|
||||||
inactive = curForTrace.snap(snap);
|
inactive = curForTrace.snapNoResolve(snap);
|
||||||
lastCoordsByTrace.put(trace, inactive);
|
lastCoordsByTrace.put(trace, inactive);
|
||||||
}
|
}
|
||||||
trace.getProgramView().setSnap(snap);
|
trace.getProgramView().setSnap(snap);
|
||||||
|
|||||||
+36
-36
@@ -138,42 +138,42 @@ public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUI
|
|||||||
|
|
||||||
public void activateObjectsMode() throws Exception {
|
public void activateObjectsMode() throws Exception {
|
||||||
// NOTE the use of index='1' allowing object-based managers to ID unique path
|
// NOTE the use of index='1' allowing object-based managers to ID unique path
|
||||||
ctx = XmlSchemaContext.deserialize("" + //
|
ctx = XmlSchemaContext.deserialize("""
|
||||||
"<context>" + //
|
<context>
|
||||||
" <schema name='Session' elementResync='NEVER' attributeResync='ONCE'>" + //
|
<schema name='Session' elementResync='NEVER' attributeResync='ONCE'>
|
||||||
" <attribute name='Processes' schema='ProcessContainer' />" + //
|
<attribute name='Processes' schema='ProcessContainer' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='ProcessContainer' canonical='yes' elementResync='NEVER' " + //
|
<schema name='ProcessContainer' canonical='yes' elementResync='NEVER'
|
||||||
" attributeResync='ONCE'>" + //
|
attributeResync='ONCE'>
|
||||||
" <element index='1' schema='Process' />" + // <---- NOTE HERE
|
<element index='1' schema='Process' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='Process' elementResync='NEVER' attributeResync='ONCE'>" + //
|
<schema name='Process' elementResync='NEVER' attributeResync='ONCE'>
|
||||||
" <attribute name='Modules' schema='ModuleContainer' />" + //
|
<attribute name='Modules' schema='ModuleContainer' />
|
||||||
" <attribute name='Memory' schema='RegionContainer' />" + //
|
<attribute name='Memory' schema='RegionContainer' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='RegionContainer' canonical='yes' elementResync='NEVER' " + //
|
<schema name='RegionContainer' canonical='yes' elementResync='NEVER'
|
||||||
" attributeResync='ONCE'>" + //
|
attributeResync='ONCE'>
|
||||||
" <element schema='Region' />" + //
|
<element schema='Region' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='Region' elementResync='NEVER' attributeResync='NEVER'>" + //
|
<schema name='Region' elementResync='NEVER' attributeResync='NEVER'>
|
||||||
" <interface name='MemoryRegion' />" + //
|
<interface name='MemoryRegion' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='ModuleContainer' canonical='yes' elementResync='NEVER' " + //
|
<schema name='ModuleContainer' canonical='yes' elementResync='NEVER'
|
||||||
" attributeResync='ONCE'>" + //
|
attributeResync='ONCE'>
|
||||||
" <element schema='Module' />" + //
|
<element schema='Module' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='Module' elementResync='NEVER' attributeResync='NEVER'>" + //
|
<schema name='Module' elementResync='NEVER' attributeResync='NEVER'>
|
||||||
" <interface name='Module' />" + //
|
<interface name='Module' />
|
||||||
" <attribute name='Sections' schema='SectionContainer' />" + //
|
<attribute name='Sections' schema='SectionContainer' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='SectionContainer' canonical='yes' elementResync='NEVER' " + //
|
<schema name='SectionContainer' canonical='yes' elementResync='NEVER'
|
||||||
" attributeResync='ONCE'>" + //
|
attributeResync='ONCE'>
|
||||||
" <element schema='Section' />" + //
|
<element schema='Section' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
" <schema name='Section' elementResync='NEVER' attributeResync='NEVER'>" + //
|
<schema name='Section' elementResync='NEVER' attributeResync='NEVER'>
|
||||||
" <interface name='Section' />" + //
|
<interface name='Section' />
|
||||||
" </schema>" + //
|
</schema>
|
||||||
"</context>");
|
</context>""");
|
||||||
|
|
||||||
try (UndoableTransaction tid = tb.startTransaction()) {
|
try (UndoableTransaction tid = tb.startTransaction()) {
|
||||||
tb.trace.getObjectManager().createRootObject(ctx.getSchema(new SchemaName("Session")));
|
tb.trace.getObjectManager().createRootObject(ctx.getSchema(new SchemaName("Session")));
|
||||||
|
|||||||
+10
-2
@@ -28,7 +28,8 @@ import ghidra.dbg.target.schema.TargetObjectSchema;
|
|||||||
import ghidra.program.model.address.AddressSpace;
|
import ghidra.program.model.address.AddressSpace;
|
||||||
|
|
||||||
public class TestTargetSession extends DefaultTargetModelRoot
|
public class TestTargetSession extends DefaultTargetModelRoot
|
||||||
implements TestTargetObject, TargetFocusScope, TargetEventScope, TargetLauncher {
|
implements TestTargetObject, TargetActiveScope, TargetFocusScope, TargetEventScope,
|
||||||
|
TargetLauncher {
|
||||||
|
|
||||||
public final TestTargetEnvironment environment;
|
public final TestTargetEnvironment environment;
|
||||||
public final TestTargetProcessContainer processes;
|
public final TestTargetProcessContainer processes;
|
||||||
@@ -65,6 +66,14 @@ public class TestTargetSession extends DefaultTargetModelRoot
|
|||||||
return (TestDebuggerObjectModel) super.getModel();
|
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
|
@Override
|
||||||
public CompletableFuture<Void> requestFocus(TargetObject obj) {
|
public CompletableFuture<Void> requestFocus(TargetObject obj) {
|
||||||
return model.gateFuture(getModel().future(null).thenAccept(__ -> {
|
return model.gateFuture(getModel().future(null).thenAccept(__ -> {
|
||||||
@@ -82,7 +91,6 @@ public class TestTargetSession extends DefaultTargetModelRoot
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> launch(Map<String, ?> args) {
|
public CompletableFuture<Void> launch(Map<String, ?> args) {
|
||||||
// TODO: Record the request and allow tests to complete it?
|
|
||||||
return AsyncUtils.NIL;
|
return AsyncUtils.NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<schema name="Test" elementResync="NEVER" attributeResync="ONCE">
|
<schema name="Test" elementResync="NEVER" attributeResync="ONCE">
|
||||||
<interface name="EventScope" />
|
<interface name="EventScope" />
|
||||||
<interface name="Launcher" />
|
<interface name="Launcher" />
|
||||||
|
<interface name="ActiveScope" />
|
||||||
<interface name="FocusScope" />
|
<interface name="FocusScope" />
|
||||||
<interface name="Aggregate" />
|
<interface name="Aggregate" />
|
||||||
<element schema="VOID" />
|
<element schema="VOID" />
|
||||||
|
|||||||
Reference in New Issue
Block a user