mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-0: Fix tests
This commit is contained in:
parent
d8a144eeee
commit
127ebf9fe7
6 changed files with 71 additions and 39 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue