Class SleighDebugLogger
java.lang.Object
ghidra.app.plugin.processors.sleigh.SleighDebugLogger
SleighDebugLogger
provides the ability to obtain detailed instruction
parse details.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionSleighDebugLogger
(Program program, Address start, SleighDebugLogger.SleighDebugMode mode) Performs a parse debug at the specified memory location within program.SleighDebugLogger
(MemBuffer buf, ProcessorContextView context, Language language, SleighDebugLogger.SleighDebugMode mode) Performs a parse debug at the specified memory location within program. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContextPattern
(PatternBlock maskvalue) Add instruction context pattern to the current pattern group.void
addInstructionPattern
(int offset, PatternBlock maskvalue) Add instruction bit pattern to the current pattern group.void
append
(byte[] value, int startbit, int bitcount) Append a binary formatted byte array with the specified range of bits bracketed to the log.void
append
(int[] value, int startbit, int bitcount) Append a binary formatted integer array with the specified range of bits bracketed to the log.void
append
(int value, int startbit, int bitcount) Append a binary formatted integer value with the specified range of bits bracketed to the log.void
Append message string to log buffer.void
Shift log indent leftvoid
dropIndent
(int levels) void
dumpContextPattern
(int[] maskvec, int[] valvec, int byteOffset, SleighParserContext pos) Dump context pattern details.void
dumpContextSet
(SleighParserContext pos, int num, int value, int mask) Dump transient context setting details.void
dumpGlobalSet
(SleighParserContext pos, ConstructState state, TripleSymbol sym, int num, int mask, int value) Dump globalset details.void
endPatternGroup
(boolean commit) Terminate the current pattern groupGet list of constructor names with line numbers.static String
getFormattedBytes
(byte[] value) Convenience method for formatting bytes as a bit sequencegetFormattedInstructionMask
(int opIndex) Return general/operand bit mask formatted as a StringgetFormattedMaskedValue
(int opIndex) Return general/operand bit values formatted as a Stringbyte[]
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).byte[]
getMaskedBytes
(byte[] mask) Apply an appropriate mask for the resulting instruction bytes to obtain the corresponding masked bytes.int
Get the number of operands for the resulting prototypebyte[]
getOperandValueMask
(int opIndex) Get the byte value mask corresponding to the specified operand.void
indent()
Shift log indent rightvoid
indent
(int levels) boolean
boolean
void
startPatternGroup
(String name) Start new pattern group for a specific sub-table.toString()
Return log text
-
Constructor Details
-
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
- the memory buffercontext
- the processor contextlanguage
- the sleigh languagemode
- the sleigh debug mode- Throws:
IllegalArgumentException
- if program language provider is not Sleigh
-
SleighDebugLogger
Performs a parse debug at the specified memory location within program.- Parameters:
program
- the program the memory location is found instart
- the start address of the memory locationmode
- the sleigh debug mode- Throws:
IllegalArgumentException
- if program language provider is not Sleigh
-
-
Method Details
-
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 getMaskedBytes() and getInstructionMask() should only be invoked if this method returns false.
-
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 valuestartbit
- 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 arraystartbit
- 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 arraystartbit
- 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
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
Return log text -
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
Dump transient context setting details. NOTE: Method has no affect unless constructed with VERBOSE logging mode.- Parameters:
pos
- instruction contextnum
- 4-byte offset within base context register for mask and valuevalue
- 4-byte context valuemask
- 4-byte context mask
-
dumpGlobalSet
public void dumpGlobalSet(SleighParserContext pos, ConstructState state, TripleSymbol sym, int num, int mask, int value) throws MemoryAccessException Dump globalset details. The target address is currently not included in the log. NOTE: Method has no affect unless constructed with VERBOSE logging mode.- Parameters:
pos
-state
-sym
-num
-mask
-value
-- Throws:
MemoryAccessException
-
startPatternGroup
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
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
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:
IllegalStateException
- if prototype parse failed- See Also:
-
getFormattedInstructionMask
Return general/operand bit mask formatted as a String- Parameters:
opIndex
- operand index or -1 for mnemonic mask- Returns:
- bit mask string
-
getFormattedMaskedValue
Return general/operand bit values formatted as a String- Parameters:
opIndex
- operand index or -1 for mnemonic bit values- Returns:
- bit value string
-
getFormattedBytes
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:
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:
IllegalStateException
- if prototype parse failedIndexOutOfBoundsException
- if opIndex is not a valid operand index
-