mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-6369: Convert remaining uses of EmulatorHelper to PcodeEmulator.
This commit is contained in:
@@ -230,7 +230,7 @@ public enum TraceEmulationIntegration {
|
||||
* @param set the uninitialized portion required
|
||||
* @return the addresses in {@code set} that remain uninitialized
|
||||
* @see PcodeEmulationCallbacks#readUninitialized(PcodeThread, PcodeExecutorStatePiece,
|
||||
* AddressSetView)
|
||||
* AddressSetView, Reason)
|
||||
*/
|
||||
AddressSetView readUninitialized(PcodeTraceDataAccess acc, PcodeThread<?> thread,
|
||||
PcodeExecutorStatePiece<A, T> piece, AddressSetView set);
|
||||
@@ -246,12 +246,14 @@ public enum TraceEmulationIntegration {
|
||||
* @param space the address space
|
||||
* @param offset the offset at the start of the uninitialized portion
|
||||
* @param length the size in bytes of the uninitialized portion
|
||||
* @param reason the reason for reading
|
||||
* @return the number of bytes just initialized, typically 0 or {@code length}
|
||||
* @see PcodeEmulationCallbacks#readUninitialized(PcodeThread, PcodeExecutorStatePiece,
|
||||
* AddressSpace, Object, int)
|
||||
* AddressSpace, Object, int, Reason)
|
||||
*/
|
||||
default int abstractReadUninit(PcodeTraceDataAccess acc, PcodeThread<?> thread,
|
||||
PcodeExecutorStatePiece<A, T> piece, AddressSpace space, A offset, int length) {
|
||||
PcodeExecutorStatePiece<A, T> piece, AddressSpace space, A offset, int length,
|
||||
Reason reason) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -542,7 +544,8 @@ public enum TraceEmulationIntegration {
|
||||
*/
|
||||
@Override
|
||||
public int abstractReadUninit(PcodeTraceDataAccess acc, PcodeThread<?> thread,
|
||||
PcodeExecutorStatePiece<A, T> piece, AddressSpace space, A offset, int length) {
|
||||
PcodeExecutorStatePiece<A, T> piece, AddressSpace space, A offset, int length,
|
||||
Reason reason) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -783,14 +786,16 @@ public enum TraceEmulationIntegration {
|
||||
|
||||
@Override
|
||||
public <B, U> int readUninitialized(PcodeThread<Object> thread,
|
||||
PcodeExecutorStatePiece<B, U> piece, AddressSpace space, B offset, int length) {
|
||||
PcodeExecutorStatePiece<B, U> piece, AddressSpace space, B offset, int length,
|
||||
Reason reason) {
|
||||
PcodeTraceDataAccess acc = space.isRegisterSpace() ? getRegAccess(thread) : memAccess;
|
||||
return handlerFor(piece).abstractReadUninit(acc, thread, piece, space, offset, length);
|
||||
return handlerFor(piece).abstractReadUninit(acc, thread, piece, space, offset, length,
|
||||
reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B, U> AddressSetView readUninitialized(PcodeThread<Object> thread,
|
||||
PcodeExecutorStatePiece<B, U> piece, AddressSetView set) {
|
||||
PcodeExecutorStatePiece<B, U> piece, AddressSetView set, Reason reason) {
|
||||
if (set.isEmpty()) {
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class TaintPcodeExecutorStatePiece
|
||||
@Override
|
||||
protected TaintVec getFromSpace(TaintSpace space, long offset, int size, Reason reason,
|
||||
PcodeStateCallbacks cb) {
|
||||
return space.get(offset, size, cb);
|
||||
return space.get(offset, size, reason, cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package ghidra.pcode.emu.taint.state;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import ghidra.pcode.exec.PcodeExecutorStatePiece.Reason;
|
||||
import ghidra.pcode.exec.PcodeStateCallbacks;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Register;
|
||||
@@ -85,14 +86,15 @@ public class TaintSpace {
|
||||
*
|
||||
* @param offset the offset
|
||||
* @param buf the vector to receive taint sets
|
||||
* @param reason the reason for reading
|
||||
* @param cb callbacks to receive emulation events
|
||||
*/
|
||||
public void getInto(long offset, TaintVec buf, PcodeStateCallbacks cb) {
|
||||
public void getInto(long offset, TaintVec buf, Reason reason, PcodeStateCallbacks cb) {
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
TaintSet s = taints.get(offset + i);
|
||||
if (s == null) {
|
||||
if (cb.readUninitialized(piece, PcodeStateCallbacks.rngSet(space, offset + i, 1))
|
||||
.isEmpty()) {
|
||||
if (cb.readUninitialized(piece, PcodeStateCallbacks.rngSet(space, offset + i, 1),
|
||||
reason).isEmpty()) {
|
||||
s = taints.get(offset + i);
|
||||
}
|
||||
}
|
||||
@@ -107,17 +109,18 @@ public class TaintSpace {
|
||||
* Retrieve the taint sets for the variable at the given offset
|
||||
*
|
||||
* <p>
|
||||
* This works the same as {@link #getInto(long, TaintVec, PcodeStateCallbacks)}, but creates a
|
||||
* new vector of the given size, reads the taint sets, and returns the vector.
|
||||
* This works the same as {@link #getInto(long, TaintVec, Reason, PcodeStateCallbacks)}, but
|
||||
* creates a new vector of the given size, reads the taint sets, and returns the vector.
|
||||
*
|
||||
* @param offset the offset
|
||||
* @param size the size of the variable
|
||||
* @param reason the reason for reading
|
||||
* @param cb callbacks to receive emulation events
|
||||
* @return the taint vector for that variable
|
||||
*/
|
||||
public TaintVec get(long offset, int size, PcodeStateCallbacks cb) {
|
||||
public TaintVec get(long offset, int size, Reason reason, PcodeStateCallbacks cb) {
|
||||
TaintVec vec = new TaintVec(size);
|
||||
getInto(offset, vec, cb);
|
||||
getInto(offset, vec, reason, cb);
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -153,7 +156,7 @@ public class TaintSpace {
|
||||
}
|
||||
PcodeOp pcodeOp = ops.get(offset); // Needed here to generate the TaintVec
|
||||
TaintVec vec = new TaintVec(MathUtilities.unsignedMin(1024, end - offset), pcodeOp);
|
||||
getInto(offset, vec, PcodeStateCallbacks.NONE);
|
||||
getInto(offset, vec, Reason.INSPECT, PcodeStateCallbacks.NONE);
|
||||
return Map.entry(offset, vec);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user