Enum Class TraceSleighUtils

java.lang.Object
java.lang.Enum<TraceSleighUtils>
ghidra.pcode.exec.trace.TraceSleighUtils
All Implemented Interfaces:
Serializable, Comparable<TraceSleighUtils>, Constable

public enum TraceSleighUtils extends Enum<TraceSleighUtils>
Various utilities for using Sleigh with traces
  • Method Details

    • values

      public static TraceSleighUtils[] 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

      public static TraceSleighUtils valueOf(String name)
      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 name
      NullPointerException - 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 trace

      This 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 PcodeEmulator with TraceEmulationIntegration.

      Parameters:
      platform - the platform
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 use
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 trace

      This 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 platform
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 use
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - 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 expression
      trace - the trace
      snap - the snap
      thread - the thread, required if register space is used
      frame - the frame, for when register space is used
      Returns:
      the value and state of the expression
    • generateExpressionForRange

      public static String generateExpressionForRange(Language language, AddressRange range)
      Generate the expression for retrieving a memory range

      In 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 language
      range - the range
      Returns:
      the expression