Package ghidra.pcode.exec.trace
Enum Class TraceSleighUtils
- All Implemented Interfaces:
Serializable,Comparable<TraceSleighUtils>,Constable
Various utilities for using Sleigh with traces
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Method Summary
Modifier and TypeMethodDescriptionstatic PcodeExecutor<byte[]> buildByteExecutor(TracePlatform platform, long snap, TraceThread thread, int frame) Build a p-code executor that operates directly on bytes of the given tracestatic PcodeExecutor<byte[]> buildByteExecutor(Trace trace, long snap, TraceThread thread, int frame) static PcodeExecutor<org.apache.commons.lang3.tuple.Pair<byte[], TraceMemoryState>> buildByteWithStateExecutor(TracePlatform platform, long snap, TraceThread thread, int frame) Build a p-code executor that operates directly on bytes and memory state of the given tracestatic PcodeExecutor<org.apache.commons.lang3.tuple.Pair<byte[], TraceMemoryState>> buildByteWithStateExecutor(Trace trace, long snap, TraceThread thread, int frame) static BigIntegerevaluate(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given tracestatic BigIntegerevaluate(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given tracestatic byte[]evaluateBytes(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given tracestatic byte[]evaluateBytes(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given tracestatic org.apache.commons.lang3.tuple.Pair<byte[], TraceMemoryState> evaluateBytesWithState(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given tracestatic Map.Entry<byte[], TraceMemoryState> evaluateBytesWithState(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given tracestatic org.apache.commons.lang3.tuple.Pair<BigInteger, TraceMemoryState> evaluateWithState(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given tracestatic Map.Entry<BigInteger, TraceMemoryState> evaluateWithState(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given tracestatic StringgenerateExpressionForRange(Language language, AddressRange range) Generate the expression for retrieving a memory rangestatic TraceSleighUtilsReturns the enum constant of this class with the specified name.static TraceSleighUtils[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
buildByteExecutor
public static PcodeExecutor<byte[]> buildByteExecutor(TracePlatform platform, long snap, TraceThread thread, int frame) Build a p-code executor that operates directly on bytes of the given traceThis executor is most suitable for evaluating Sleigh expression on a given trace snapshot, and for manipulating or initializing variables using Sleigh code. It is generally not suitable for use in an emulator. For that, use
PcodeEmulatorwithTraceEmulationIntegration.- Parameters:
platform- the platformsnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the executor
-
buildByteExecutor
public static PcodeExecutor<byte[]> buildByteExecutor(Trace trace, long snap, TraceThread thread, int frame) - Parameters:
trace- the trace whose host platform to usesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the executor
- See Also:
-
buildByteWithStateExecutor
public static PcodeExecutor<org.apache.commons.lang3.tuple.Pair<byte[],TraceMemoryState>> buildByteWithStateExecutor(TracePlatform platform, long snap, TraceThread thread, int frame) Build a p-code executor that operates directly on bytes and memory state of the given traceThis executor is most suitable for evaluating Sleigh expressions on a given trace snapshot, when the client would also like to know if all variables involved are
TraceMemoryState.KNOWN.- Parameters:
platform- the platformsnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the executor
-
buildByteWithStateExecutor
public static PcodeExecutor<org.apache.commons.lang3.tuple.Pair<byte[],TraceMemoryState>> buildByteWithStateExecutor(Trace trace, long snap, TraceThread thread, int frame) - Parameters:
trace- the trace whose host platform to usesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the executor
- See Also:
-
evaluateBytes
public static byte[] evaluateBytes(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value of the expression as a byte array
-
evaluate
public static BigInteger evaluate(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value of the expression as a big integer
-
evaluateBytesWithState
public static org.apache.commons.lang3.tuple.Pair<byte[],TraceMemoryState> evaluateBytesWithState(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value and state of the expression
-
evaluateWithState
public static org.apache.commons.lang3.tuple.Pair<BigInteger,TraceMemoryState> evaluateWithState(PcodeExpression expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a compiled p-code expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value and state of the expression
-
evaluateBytes
public static byte[] evaluateBytes(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value of the expression as a byte array
-
evaluate
public static BigInteger evaluate(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value of the expression as a big integer
-
evaluateBytesWithState
public static Map.Entry<byte[],TraceMemoryState> evaluateBytesWithState(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value and state of the expression
-
evaluateWithState
public static Map.Entry<BigInteger,TraceMemoryState> evaluateWithState(String expr, Trace trace, long snap, TraceThread thread, int frame) Evaluate a Sleigh expression on the given trace- Parameters:
expr- the expressiontrace- the tracesnap- the snapthread- the thread, required if register space is usedframe- the frame, for when register space is used- Returns:
- the value and state of the expression
-
generateExpressionForRange
Generate the expression for retrieving a memory rangeIn general, it does not make sense to use this directly with the above evaluation methods. More likely, this is used in the UI to aid the user in generating an expression. From the API, it's much easier to access the memory state directly.
- Parameters:
language- the languagerange- the range- Returns:
- the expression
-