mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-25 18:05:53 +08:00
Merge remote-tracking branch 'origin/GP-0_Dan_fixZ3Tests'
This commit is contained in:
+16
-1
@@ -18,9 +18,11 @@ package ghidra.trace.model.property;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.util.TraceRegisterUtils;
|
||||
|
||||
/**
|
||||
@@ -43,6 +45,19 @@ public interface TracePropertyMapSpace<T> extends TracePropertyMapOperations<T>
|
||||
*/
|
||||
AddressSpace getAddressSpace();
|
||||
|
||||
/**
|
||||
* Set a property on the given register for the given lifespan
|
||||
*
|
||||
* @param platform the platform defining the register
|
||||
* @param lifespan the range of snaps
|
||||
* @param register the register
|
||||
* @param value the value to set
|
||||
*/
|
||||
default void set(TracePlatform platform, Lifespan lifespan, Register register, T value) {
|
||||
AddressRange range = platform.getConventionalRegisterRange(getAddressSpace(), register);
|
||||
set(lifespan, range, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on the given register for the given lifespan
|
||||
*
|
||||
@@ -51,7 +66,7 @@ public interface TracePropertyMapSpace<T> extends TracePropertyMapOperations<T>
|
||||
* @param value the value to set
|
||||
*/
|
||||
default void set(Lifespan lifespan, Register register, T value) {
|
||||
set(lifespan, TraceRegisterUtils.rangeForRegister(register), value);
|
||||
set(getTrace().getPlatformManager().getHostPlatform(), lifespan, register, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,9 @@ dependencies {
|
||||
api ":com.microsoft.z3:"
|
||||
|
||||
// Oof. Apparently, this doesn't work transitively....
|
||||
testImplementation project(path: ':Generic', configuration: 'testArtifacts')
|
||||
testImplementation project(path: ':ProposedUtils', configuration: 'testArtifacts')
|
||||
testImplementation project(path: ':SystemEmulation', configuration: 'testArtifacts')
|
||||
testImplementation project(path: ':Framework-TraceModeling', configuration: 'testArtifacts')
|
||||
testImplementation project(path: ':Debugger', configuration: 'testArtifacts')
|
||||
}
|
||||
|
||||
+17
-3
@@ -35,9 +35,11 @@ import ghidra.pcode.emu.symz3.trace.SymZ3TracePcodeExecutorState;
|
||||
import ghidra.pcode.emu.symz3.trace.SymZ3TracePcodeExecutorStatePiece;
|
||||
import ghidra.program.model.util.StringPropertyMap;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.trace.database.ToyDBTraceBuilder.ToySchemaBuilder;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.property.TracePropertyMap;
|
||||
import ghidra.trace.model.property.TracePropertyMapSpace;
|
||||
import ghidra.trace.model.target.schema.SchemaContext;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.trace.model.time.schedule.*;
|
||||
import ghidra.util.Msg;
|
||||
@@ -61,14 +63,24 @@ public class SymZ3DebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebugger
|
||||
.count());
|
||||
}
|
||||
|
||||
protected SchemaContext buildContext() {
|
||||
return new ToySchemaBuilder()
|
||||
.noRegisterGroups()
|
||||
.useRegistersPerFrame()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFactoryCreate() throws Exception {
|
||||
emuService.setEmulatorFactory(new SymZ3DebuggerPcodeEmulatorFactory());
|
||||
|
||||
createAndOpenTrace();
|
||||
|
||||
TraceThread thread;
|
||||
try (Transaction tid = tb.startTransaction()) {
|
||||
tb.getOrAddThread("Threads[0]", 0);
|
||||
tb.createRootObject(buildContext(), "Target");
|
||||
thread = tb.getOrAddThread("Threads[0]", 0);
|
||||
tb.createObjectsFramesAndRegs(thread, Lifespan.nowOn(0), tb.host, 1);
|
||||
}
|
||||
|
||||
traceManager.activateTrace(tb.trace);
|
||||
@@ -81,7 +93,7 @@ public class SymZ3DebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebugger
|
||||
public TickStep nextSlice(Trace trace) {
|
||||
// Expect decode of uninitialized memory immediately
|
||||
assertEquals(0, calls++);
|
||||
return new TickStep(0, 1);
|
||||
return new TickStep(thread.getKey(), 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -106,10 +118,12 @@ public class SymZ3DebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebugger
|
||||
|
||||
TraceThread thread;
|
||||
try (Transaction tid = tb.startTransaction()) {
|
||||
tb.createRootObject(buildContext(), "Target");
|
||||
mappingService.addMapping(
|
||||
new DefaultTraceLocation(tb.trace, null, Lifespan.nowOn(0), tb.addr(0x55550000)),
|
||||
new ProgramLocation(program, tb.addr(0x00400000)), 0x1000, false);
|
||||
thread = tb.getOrAddThread("Threads[0]", 0);
|
||||
tb.createObjectsFramesAndRegs(thread, Lifespan.nowOn(0), tb.host, 1);
|
||||
tb.exec(0, thread, 0, """
|
||||
RIP = 0x55550000;
|
||||
""");
|
||||
@@ -134,7 +148,7 @@ public class SymZ3DebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebugger
|
||||
"MOV RAX, [0x55550800]"); // was [0x00400800], but fixed address is a problem.
|
||||
}
|
||||
|
||||
TraceSchedule time = TraceSchedule.parse("0:t0-1");
|
||||
TraceSchedule time = TraceSchedule.parse("0:t%d-1".formatted(thread.getKey()));
|
||||
long scratch = emuService.emulate(tb.trace, time, TaskMonitor.DUMMY);
|
||||
|
||||
TracePropertyMap<String> traceSymMap = tb.trace.getAddressPropertyManager()
|
||||
|
||||
Reference in New Issue
Block a user