mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-0: Fix tests. Add "requireCanonical" parameter
This commit is contained in:
parent
c198419b7e
commit
ab97c34205
13 changed files with 43 additions and 33 deletions
|
@ -470,7 +470,7 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
public Set<TargetThread> getLiveTargetThreads() {
|
||||
return trace.getObjectManager()
|
||||
.getRootObject()
|
||||
.querySuccessorsInterface(Lifespan.at(getSnap()), TraceObjectThread.class)
|
||||
.querySuccessorsInterface(Lifespan.at(getSnap()), TraceObjectThread.class, true)
|
||||
.map(t -> objectRecorder.getTargetInterface(t.getObject(), TargetThread.class))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -673,9 +673,10 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
public List<TargetBreakpointSpecContainer> collectBreakpointContainers(TargetThread thread) {
|
||||
if (thread == null) {
|
||||
return objectRecorder.collectTargetSuccessors(target,
|
||||
TargetBreakpointSpecContainer.class);
|
||||
TargetBreakpointSpecContainer.class, false);
|
||||
}
|
||||
return objectRecorder.collectTargetSuccessors(thread, TargetBreakpointSpecContainer.class);
|
||||
return objectRecorder.collectTargetSuccessors(thread, TargetBreakpointSpecContainer.class,
|
||||
false);
|
||||
}
|
||||
|
||||
private class BreakpointConvention {
|
||||
|
@ -711,7 +712,8 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
@Override
|
||||
public List<TargetBreakpointLocation> collectBreakpoints(TargetThread thread) {
|
||||
if (thread == null) {
|
||||
return objectRecorder.collectTargetSuccessors(target, TargetBreakpointLocation.class);
|
||||
return objectRecorder.collectTargetSuccessors(target, TargetBreakpointLocation.class,
|
||||
true);
|
||||
}
|
||||
BreakpointConvention convention = new BreakpointConvention(
|
||||
objectRecorder.getTraceInterface(thread, TraceObjectThread.class));
|
||||
|
@ -725,7 +727,8 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
|
||||
@Override
|
||||
public Set<TraceBreakpointKind> getSupportedBreakpointKinds() {
|
||||
return objectRecorder.collectTargetSuccessors(target, TargetBreakpointSpecContainer.class)
|
||||
return objectRecorder
|
||||
.collectTargetSuccessors(target, TargetBreakpointSpecContainer.class, false)
|
||||
.stream()
|
||||
.flatMap(c -> c.getSupportedBreakpointKinds().stream())
|
||||
.map(k -> TraceRecorder.targetToTraceBreakpointKind(k))
|
||||
|
@ -750,7 +753,7 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
@Override
|
||||
public CompletableFuture<Boolean> requestFocus(TargetObject focus) {
|
||||
for (TargetFocusScope scope : objectRecorder.collectTargetSuccessors(target,
|
||||
TargetFocusScope.class)) {
|
||||
TargetFocusScope.class, false)) {
|
||||
if (PathUtils.isAncestor(scope.getPath(), focus.getPath())) {
|
||||
return scope.requestFocus(focus).thenApply(__ -> true).exceptionally(ex -> {
|
||||
ex = AsyncUtils.unwrapThrowable(ex);
|
||||
|
@ -772,7 +775,7 @@ public class ObjectBasedTraceRecorder implements TraceRecorder {
|
|||
@Override
|
||||
public CompletableFuture<Boolean> requestActivation(TargetObject active) {
|
||||
for (TargetActiveScope scope : objectRecorder.collectTargetSuccessors(target,
|
||||
TargetActiveScope.class)) {
|
||||
TargetActiveScope.class, false)) {
|
||||
if (PathUtils.isAncestor(scope.getPath(), active.getPath())) {
|
||||
return scope.requestActivation(active).thenApply(__ -> true).exceptionally(ex -> {
|
||||
ex = AsyncUtils.unwrapThrowable(ex);
|
||||
|
|
|
@ -314,13 +314,14 @@ class ObjectRecorder {
|
|||
}
|
||||
|
||||
protected <T extends TargetObject> List<T> collectTargetSuccessors(TargetObject targetSeed,
|
||||
Class<T> targetIf) {
|
||||
Class<T> targetIf, boolean requireCanonical) {
|
||||
// TODO: Should this really go through the database?
|
||||
TraceObject seed = toTrace(targetSeed);
|
||||
if (seed == null) {
|
||||
return List.of();
|
||||
}
|
||||
return seed.querySuccessorsTargetInterface(Lifespan.at(recorder.getSnap()), targetIf)
|
||||
return seed.querySuccessorsTargetInterface(Lifespan.at(recorder.getSnap()), targetIf,
|
||||
requireCanonical)
|
||||
.map(p -> toTarget(p.getDestination(seed)).as(targetIf))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -47,10 +47,9 @@ import ghidra.framework.plugintool.annotation.AutoConfigStateField;
|
|||
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
|
||||
import ghidra.framework.plugintool.util.PluginStatus;
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.Trace.TraceObjectChangeType;
|
||||
import ghidra.trace.model.Trace.TraceThreadChangeType;
|
||||
import ghidra.trace.model.TraceDomainObjectListener;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.program.TraceProgramView;
|
||||
import ghidra.trace.model.program.TraceVariableSnapProgramView;
|
||||
|
@ -641,7 +640,13 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
|
|||
inactive = curForTrace.snapNoResolve(snap);
|
||||
lastCoordsByTrace.put(trace, inactive);
|
||||
}
|
||||
trace.getProgramView().setSnap(snap);
|
||||
try {
|
||||
trace.getProgramView().setSnap(snap);
|
||||
}
|
||||
catch (TraceClosedException e) {
|
||||
// Whatever. Presumably, a closed event is already queued....
|
||||
Msg.warn(this, "Ignoring snapshot advance for closed trace: " + e);
|
||||
}
|
||||
firePluginEvent(new TraceInactiveCoordinatesPluginEvent(getName(), inactive));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -186,13 +186,13 @@ public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUI
|
|||
try (UndoableTransaction tid = tb.startTransaction()) {
|
||||
TraceObject root = om.getRootObject();
|
||||
for (TraceObject module : (Iterable<TraceObject>) () -> root
|
||||
.querySuccessorsTargetInterface(Lifespan.at(0), TargetModule.class)
|
||||
.querySuccessorsTargetInterface(Lifespan.at(0), TargetModule.class, true)
|
||||
.map(p -> p.getDestination(root))
|
||||
.iterator()) {
|
||||
String moduleName = module.getCanonicalPath().index();
|
||||
Lifespan span = module.getLife().bound();
|
||||
for (TraceObject section : (Iterable<TraceObject>) () -> module
|
||||
.querySuccessorsTargetInterface(Lifespan.at(0), TargetSection.class)
|
||||
.querySuccessorsTargetInterface(Lifespan.at(0), TargetSection.class, true)
|
||||
.map(p -> p.getDestination(root))
|
||||
.iterator()) {
|
||||
String sectionName = section.getCanonicalPath().index();
|
||||
|
|
|
@ -517,7 +517,7 @@ public class ObjectBasedTraceRecorderTest extends AbstractGhidraHeadedDebuggerGU
|
|||
|
||||
TraceObject traceBank = thread.getObject()
|
||||
.querySuccessorsTargetInterface(Lifespan.at(recorder.getSnap()),
|
||||
TargetRegisterBank.class)
|
||||
TargetRegisterBank.class, false)
|
||||
.map(p -> p.getDestination(thread.getObject()))
|
||||
.findAny()
|
||||
.orElseThrow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue