Class Utils

java.lang.Object
ghidra.pcode.utils.Utils

public class Utils extends Object
  • Field Details

    • endl

      public static final String endl
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • convertToSignedValue

      public static BigInteger convertToSignedValue(BigInteger val, int byteSize)
    • convertToUnsignedValue

      public static BigInteger convertToUnsignedValue(BigInteger val, int byteSize)
    • calc_mask

      public static long calc_mask(int size)
    • calc_bigmask

      public static BigInteger calc_bigmask(int size)
    • signbit_negative

      public static boolean signbit_negative(long val, int size)
      Returns true if signbit is set (negative).
      Parameters:
      val - the raw value as a long
      size - the actual size (in bytes) of the value
      Returns:
      true if signbit is set (negative)
    • uintb_negate

      public static long uintb_negate(long in, int size)
    • sign_extend

      public static long sign_extend(long in, int sizein, int sizeout)
    • zzz_sign_extend

      public static long zzz_sign_extend(long val, int bit)
    • zzz_zero_extend

      public static long zzz_zero_extend(long val, int bit)
    • byte_swap

      public static long byte_swap(long val, int size)
      Swap the least-significant bytes of the given value

      The size must be less than 8, as that is the largest possible size of the given value. If size is larger than 8, there may be undefined behavior, e.g., bytes getting truncated.

      Parameters:
      val - the value whose bytes to swap
      size - the number of least-signifcant bytes to swap
      Returns:
      the value with the swapped bytes
    • bytesToLong

      public static long bytesToLong(byte[] byteBuf, int size, boolean bigEndian)
    • longToBytes

      public static byte[] longToBytes(long val, int size, boolean bigEndian)
    • bytesToBigInteger

      public static BigInteger bytesToBigInteger(byte[] byteBuf, int size, boolean bigEndian, boolean signed)
    • bigIntegerToBytes

      public static byte[] bigIntegerToBytes(BigInteger val, int size, boolean bigEndian)