Class SleighDebugLogger


  • public class SleighDebugLogger
    extends java.lang.Object
    SleighDebugLogger provides the ability to obtain detailed instruction parse details.
    • Constructor Detail

      • SleighDebugLogger

        public SleighDebugLogger​(MemBuffer buf,
                                 ProcessorContextView context,
                                 Language language,
                                 SleighDebugLogger.SleighDebugMode mode)
        Performs a parse debug at the specified memory location within program.
        Parameters:
        buf -
        programContext -
        verbose - if true extended debug information may be provided
        Throws:
        java.lang.IllegalArgumentException - if program language provider is not Sleigh
      • SleighDebugLogger

        public SleighDebugLogger​(Program program,
                                 Address start,
                                 SleighDebugLogger.SleighDebugMode mode)
        Performs a parse debug at the specified memory location within program.
        Parameters:
        program -
        start -
        verbose - if true extended debug information may be provided
        Throws:
        java.lang.IllegalArgumentException - if program language provider is not Sleigh
    • Method Detail

      • isVerboseEnabled

        public boolean isVerboseEnabled()
        Returns:
        true if constructed for verbose logging
      • parseFailed

        public boolean parseFailed()
        Returns:
        true if a parse error was detected, otherwise false is returned. The methods getMaskedInstructionBytes() and getInstructionBitMask() should only be invoked if this method returns false.
      • getConstructorLineNumbers

        public java.util.List<java.lang.String> getConstructorLineNumbers()
        Get list of constructor names with line numbers. Any debug mode may be used.
        Returns:
        list
      • append

        public void append​(int value,
                           int startbit,
                           int bitcount)
        Append a binary formatted integer value with the specified range of bits bracketed to the log. A -1 value for both startbit and bitcount disable the bit range bracketing. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        value - integer value
        startbit - identifies the first most-significant bit within the bracketed range (left-most value bit is bit-0, right-most value bit is bit-31)
        bitcount - number of bits included within range
      • append

        public void append​(int[] value,
                           int startbit,
                           int bitcount)
        Append a binary formatted integer array with the specified range of bits bracketed to the log. A -1 value for both startbit and bitcount disable the bit range bracketing. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        value - integer array
        startbit - identifies the first most-significant bit within the bracketed range (left-most value[0] bit is bit-0, right-most value[n] bit is bit-<32(n+1)-1> ).
        bitcount - number of bits included within range
      • append

        public void append​(byte[] value,
                           int startbit,
                           int bitcount)
        Append a binary formatted byte array with the specified range of bits bracketed to the log. A -1 value for both startbit and bitcount disable the bit range bracketing. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        value - byte array
        startbit - identifies the first most-significant bit within the bracketed range (left-most value[0] bit is bit-0, right-most value[n] bit is bit-<8(n+1)-1> ).
        bitcount - number of bits included within range
      • append

        public void append​(java.lang.String str)
        Append message string to log buffer. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        str - message string
      • indent

        public void indent()
        Shift log indent right
      • indent

        public void indent​(int levels)
      • dropIndent

        public void dropIndent()
        Shift log indent left
      • dropIndent

        public void dropIndent​(int levels)
      • toString

        public java.lang.String toString()
        Return log text
        Overrides:
        toString in class java.lang.Object
      • dumpContextPattern

        public void dumpContextPattern​(int[] maskvec,
                                       int[] valvec,
                                       int byteOffset,
                                       SleighParserContext pos)
        Dump context pattern details. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        maskvec -
        valvec -
        byteOffset -
        pos -
      • dumpContextSet

        public void dumpContextSet​(SleighParserContext pos,
                                   int num,
                                   int value,
                                   int mask)
        Dump transient context setting details. NOTE: Method has no affect unless constructed with VERBOSE logging mode.
        Parameters:
        pos - instruction context
        num - 4-byte offset within base context register for mask and value
        value - 4-byte context value
        mask - 4-byte context mask
      • startPatternGroup

        public void startPatternGroup​(java.lang.String name)
        Start new pattern group for a specific sub-table. A null can correspond to a top-level constructor or low level complex pattern (AND, OR). All committed unnamed groups with the same parent group will be combined.
        Parameters:
        name - group name or null for unnamed group
      • endPatternGroup

        public void endPatternGroup​(boolean commit)
        Terminate the current pattern group
        Parameters:
        commit - if false group will be discarded, if true group will be retained
      • addInstructionPattern

        public void addInstructionPattern​(int offset,
                                          PatternBlock maskvalue)
        Add instruction bit pattern to the current pattern group.
        Parameters:
        offset - base offset at which the specified maskvalue can be applied.
        maskvalue - pattern mask/value
      • addContextPattern

        public void addContextPattern​(PatternBlock maskvalue)
        Add instruction context pattern to the current pattern group.
        Parameters:
        maskvalue - pattern mask/value
      • getInstructionMask

        public byte[] getInstructionMask()
        Returns the instruction bit mask which identifies those bits used to uniquely identify the instruction (includes addressing modes, generally excludes register selector bits associated with attaches or immediate values used in for semantic values only).
        Throws:
        java.lang.IllegalStateException - if prototype parse failed
        See Also:
        SleighDebugLogger#getMaskedInstructionBytes()
      • getFormattedInstructionMask

        public java.lang.String getFormattedInstructionMask​(int opIndex)
        Return general/operand bit mask formatted as a String
        Parameters:
        opIndex - operand index or -1 for mnemonic mask
        Returns:
        bit mask string
      • getFormattedMaskedValue

        public java.lang.String getFormattedMaskedValue​(int opIndex)
        Return general/operand bit values formatted as a String
        Parameters:
        opIndex - operand index or -1 for mnemonic bit values
        Returns:
        bit value string
      • getFormattedBytes

        public static java.lang.String getFormattedBytes​(byte[] value)
        Convenience method for formatting bytes as a bit sequence
        Parameters:
        value - byte array
        Returns:
        binary formatted bytes
      • getNumOperands

        public int getNumOperands()
        Get the number of operands for the resulting prototype
        Returns:
        operand count
        Throws:
        java.lang.IllegalStateException - if prototype parse failed
      • getMaskedBytes

        public byte[] getMaskedBytes​(byte[] mask)
        Apply an appropriate mask for the resulting instruction bytes to obtain the corresponding masked bytes.
        Parameters:
        mask - instruction, operand or similarly sized mask
        Returns:
        masked instruction bytes
      • getOperandValueMask

        public byte[] getOperandValueMask​(int opIndex)
        Get the byte value mask corresponding to the specified operand.
        Parameters:
        opIndex - operand index within the instruction representation
        Returns:
        byte mask or null if operand does not have a corresponding sub-constructor or attach
        Throws:
        java.lang.IllegalStateException - if prototype parse failed
        java.lang.IndexOutOfBoundsException - if opIndex is not a valid operand index