Class DecompileOptions

java.lang.Object
ghidra.app.decompiler.DecompileOptions

public class DecompileOptions extends Object
Configuration options for the decompiler This stores the options and can create an XML string to be sent to the decompiler process
  • Field Details

  • Constructor Details

    • DecompileOptions

      public DecompileOptions()
  • Method Details

    • grabFromToolAndProgram

      public void grabFromToolAndProgram(ToolOptions fieldOptions, ToolOptions opt, Program program)
      Grab all the decompiler options from various sources within a specific tool and program and cache them in this object.
      Parameters:
      fieldOptions - the Options object containing options specific to listing fields
      opt - the Options object that contains the "tool options" specific to the decompiler
      program - the program whose "program options" are relevant to the decompiler
    • grabFromProgram

      public void grabFromProgram(Program program)
      Grab all the decompiler options from the program specifically and cache them in this object.
      Parameters:
      program - the program whose "program options" are relevant to the decompiler
    • getProtoEvalModel

      public String getProtoEvalModel()
      Returns:
      the default prototype to assume if no other information about a function is known
    • setProtoEvalModel

      public void setProtoEvalModel(String protoEvalModel)
      Set the default prototype model for the decompiler. This is the model assumed if no other information about a function is known.
      Parameters:
      protoEvalModel - is the name of the prototype model to set as default
    • registerOptions

      public void registerOptions(ToolOptions fieldOptions, ToolOptions opt, Program program)
      This registers all the decompiler tool options with ghidra, and has the side effect of pulling all the current values for the options if they exist
      Parameters:
      fieldOptions - the options object specific to listing fields
      opt - the options object specific to the decompiler
      program - the program
    • encode

      public void encode(Encoder encoder, DecompInterface iface) throws IOException
      Encode all the configuration options to a stream for the decompiler process. This object is global to all decompile processes so we can tailor to the specific process by passing in the interface.
      Parameters:
      encoder - is the stream encoder
      iface - specific DecompInterface being sent options
      Throws:
      IOException - for errors writing to the underlying stream
    • getFunctionBraceFormat

      public DecompileOptions.BraceStyle getFunctionBraceFormat()
      Returns the brace formatting style for function bodies..
      Returns:
      the brace formatting style for function bodies.
    • setFunctionBraceFormat

      public void setFunctionBraceFormat(DecompileOptions.BraceStyle style)
      Set how braces are formatted around a function body
      Parameters:
      style - is the formatting style
    • getIfElseBraceFormat

      public DecompileOptions.BraceStyle getIfElseBraceFormat()
      Returns the brace formatting style for if/else code blocks..
      Returns:
      the brace formatting style for if/else code blocks.
    • setIfElseBraceFormat

      public void setIfElseBraceFormat(DecompileOptions.BraceStyle style)
      Set how braces are formatted around an if/else code block
      Parameters:
      style - is the formatting style
    • getLoopBraceFormat

      public DecompileOptions.BraceStyle getLoopBraceFormat()
      Returns the brace formatting style for loop bodies..
      Returns:
      the brace formatting style for loop bodies.
    • setLoopBraceFormat

      public void setLoopBraceFormat(DecompileOptions.BraceStyle style)
      Set how braces are formatted a loop body
      Parameters:
      style - is the formatting style
    • getSwitchBraceFormat

      public DecompileOptions.BraceStyle getSwitchBraceFormat()
      Returns the brace formatting style for switch blocks..
      Returns:
      the brace formatting style for switch blocks.
    • setSwitchBraceFormat

      public void setSwitchBraceFormat(DecompileOptions.BraceStyle style)
      Set how braces are formatted around a switch block
      Parameters:
      style - is the formatting style
    • getMaxWidth

      public int getMaxWidth()
      Returns the maximum number of characters the decompiler displays in a single line of output..
      Returns:
      the maximum number of characters the decompiler displays in a single line of output.
    • setMaxWidth

      public void setMaxWidth(int maxwidth)
      Set the maximum number of characters the decompiler displays in a single line of output
      Parameters:
      maxwidth - is the maximum number of characters
    • getKeywordColor

      public Color getKeywordColor()
      Returns color associated with keyword tokens..
      Returns:
      color associated with keyword tokens.
    • getTypeColor

      public Color getTypeColor()
      Returns color associated with data-type tokens..
      Returns:
      color associated with data-type tokens.
    • getCommentColor

      public Color getCommentColor()
      Returns color used to display comments..
      Returns:
      color used to display comments.
    • getConstantColor

      public Color getConstantColor()
      Returns color associated with constant tokens..
      Returns:
      color associated with constant tokens.
    • getVariableColor

      public Color getVariableColor()
      Returns color associated with (local) variable tokens..
      Returns:
      color associated with (local) variable tokens.
    • getParameterColor

      public Color getParameterColor()
      Returns color associated with parameter tokens..
      Returns:
      color associated with parameter tokens.
    • getGlobalColor

      public Color getGlobalColor()
      Returns color associated with global variable tokens..
      Returns:
      color associated with global variable tokens.
    • getSpecialColor

      public Color getSpecialColor()
      Returns color associated with volatile variables or other special tokens..
      Returns:
      color associated with volatile variables or other special tokens.
    • getDefaultColor

      public Color getDefaultColor()
      Returns color for generic syntax or other unspecified tokens..
      Returns:
      color for generic syntax or other unspecified tokens.
    • getErrorColor

      public Color getErrorColor()
      Returns color used on tokens that need to warn of an error or other unusual conditions..
      Returns:
      color used on tokens that need to warn of an error or other unusual conditions.
    • getBackgroundColor

      public Color getBackgroundColor()
      Returns the background color for the decompiler window..
      Returns:
      the background color for the decompiler window.
    • getCurrentVariableHighlightColor

      public Color getCurrentVariableHighlightColor()
      Returns the color used display the current highlighted variable..
      Returns:
      the color used display the current highlighted variable.
    • getMiddleMouseHighlightColor

      public Color getMiddleMouseHighlightColor()
      Returns:
      color used to highlight token(s) selected with a middle button clock
    • getActiveSearchHighlightColor

      public Color getActiveSearchHighlightColor()
      Returns:
      color used to highlight the active search result
    • getSearchHighlightColor

      public Color getSearchHighlightColor()
      Returns color used to highlight search results..
      Returns:
      color used to highlight search results.
    • getMiddleMouseHighlightButton

      public int getMiddleMouseHighlightButton()
      Returns the mouse button that should be used to toggle the primary token highlight..
      Returns:
      the mouse button that should be used to toggle the primary token highlight.
    • isPRECommentIncluded

      public boolean isPRECommentIncluded()
      Returns true if Pre comments are included as part of decompiler output..
      Returns:
      true if Pre comments are included as part of decompiler output.
    • setPRECommentIncluded

      public void setPRECommentIncluded(boolean commentPREInclude)
      Set whether Pre comments are displayed as part of decompiler output
      Parameters:
      commentPREInclude - is true if Pre comments are output
    • isPLATECommentIncluded

      public boolean isPLATECommentIncluded()
      Returns true if Plate comments are included as part of decompiler output..
      Returns:
      true if Plate comments are included as part of decompiler output.
    • setPLATECommentIncluded

      public void setPLATECommentIncluded(boolean commentPLATEInclude)
      Set whether Plate comments are displayed as part of decompiler output
      Parameters:
      commentPLATEInclude - is true if Plate comments are output
    • isPOSTCommentIncluded

      public boolean isPOSTCommentIncluded()
      Returns true if Post comments are included as part of decompiler output..
      Returns:
      true if Post comments are included as part of decompiler output.
    • setPOSTCommentIncluded

      public void setPOSTCommentIncluded(boolean commentPOSTInclude)
      Set whether Post comments are displayed as part of decompiler output
      Parameters:
      commentPOSTInclude - is true if Post comments are output
    • isEOLCommentIncluded

      public boolean isEOLCommentIncluded()
      Returns true if End-of-line comments are included as part of decompiler output..
      Returns:
      true if End-of-line comments are included as part of decompiler output.
    • setEOLCommentIncluded

      public void setEOLCommentIncluded(boolean commentEOLInclude)
      Set whether End-of-line comments are displayed as part of decompiler output.
      Parameters:
      commentEOLInclude - is true if End-of-line comments are output
    • isWARNCommentIncluded

      public boolean isWARNCommentIncluded()
      Returns true if WARNING comments are included as part of decompiler output..
      Returns:
      true if WARNING comments are included as part of decompiler output.
    • setWARNCommentIncluded

      public void setWARNCommentIncluded(boolean commentWARNInclude)
      Set whether automatically generated WARNING comments are displayed as part of decompiler output.
      Parameters:
      commentWARNInclude - is true if WARNING comments are output
    • isHeadCommentIncluded

      public boolean isHeadCommentIncluded()
      Returns true if function header comments are included as part of decompiler output..
      Returns:
      true if function header comments are included as part of decompiler output.
    • setHeadCommentIncluded

      public void setHeadCommentIncluded(boolean commentHeadInclude)
      Set whether function header comments are included as part of decompiler output.
      Parameters:
      commentHeadInclude - is true if header comments are output
    • isEliminateUnreachable

      public boolean isEliminateUnreachable()
      Returns true if the decompiler currently eliminates unreachable code..
      Returns:
      true if the decompiler currently eliminates unreachable code.
    • setEliminateUnreachable

      public void setEliminateUnreachable(boolean eliminateUnreachable)
      Set whether the decompiler should eliminate unreachable code as part of its analysis.
      Parameters:
      eliminateUnreachable - is true if unreachable code is eliminated
    • isRespectReadOnly

      public boolean isRespectReadOnly()
      Returns true if the decompiler currently respects read-only flags..
      Returns:
      true if the decompiler currently respects read-only flags.
    • setRespectReadOnly

      public void setRespectReadOnly(boolean readOnly)
      Set whether the decompiler should respect read-only flags as part of its analysis.
      Parameters:
      readOnly - is true if read-only flags are respected
    • isSimplifyDoublePrecision

      public boolean isSimplifyDoublePrecision()
      If the decompiler currently applies transformation rules that identify and simplify double precision arithmetic operations, true is returned.
      Returns:
      true if the decompiler applies double precision rules
    • setSimplifyDoublePrecision

      public void setSimplifyDoublePrecision(boolean simplifyDoublePrecision)
      Set whether the decompiler should apply transformation rules that identify and simplify double precision arithmetic operations.
      Parameters:
      simplifyDoublePrecision - is true if double precision rules should be applied
    • isDisplayLineNumbers

      public boolean isDisplayLineNumbers()
      Returns true if line numbers should be displayed with decompiler output..
      Returns:
      true if line numbers should be displayed with decompiler output.
    • getDisplayLanguage

      public DecompilerLanguage getDisplayLanguage()
      Returns the source programming language that decompiler output is rendered in..
      Returns:
      the source programming language that decompiler output is rendered in.
    • getNameTransformer

      public NameTransformer getNameTransformer()
      Retrieve the transformer being applied to data-type, function, and namespace names. If no transform is being applied, a pass-through object is returned.
      Returns:
      the transformer object
    • setNameTransformer

      public void setNameTransformer(NameTransformer transformer)
      Set a specific transformer to be applied to all data-type, function, and namespace names in decompiler output. A null value indicates no transform should be applied.
      Parameters:
      transformer - is the transformer to apply
    • isConventionPrint

      public boolean isConventionPrint()
      Returns true if calling convention names are displayed as part of function signatures..
      Returns:
      true if calling convention names are displayed as part of function signatures.
    • setConventionPrint

      public void setConventionPrint(boolean conventionPrint)
      Set whether the calling convention name should be displayed as part of function signatures in decompiler output.
      Parameters:
      conventionPrint - is true if calling convention names should be displayed
    • isNoCastPrint

      public boolean isNoCastPrint()
      Returns:
      true if cast operations are not displayed in decompiler output
    • setNoCastPrint

      public void setNoCastPrint(boolean noCastPrint)
      Set whether decompiler output should display cast operations.
      Parameters:
      noCastPrint - is true if casts should NOT be displayed.
    • setDisplayLanguage

      public void setDisplayLanguage(DecompilerLanguage val)
      Set the source programming language that decompiler output should be rendered in.
      Parameters:
      val - is the source language
    • getDefaultFont

      public Font getDefaultFont()
      Returns the font that should be used to render decompiler output..
      Returns:
      the font that should be used to render decompiler output.
    • getDefaultTimeout

      public int getDefaultTimeout()
      If the time a decompiler process is allowed to analyze a single function exceeds this value, decompilation is aborted.
      Returns:
      the maximum time in seconds
    • setDefaultTimeout

      public void setDefaultTimeout(int timeout)
      Set the maximum time (in seconds) a decompiler process is allowed to analyze a single function. If it is exceeded, decompilation is aborted.
      Parameters:
      timeout - is the maximum time in seconds
    • getMaxPayloadMBytes

      public int getMaxPayloadMBytes()
      If the size (in megabytes) of the payload returned by the decompiler process exceeds this value for a single function, decompilation is aborted.
      Returns:
      the maximum number of megabytes in a function payload
    • setMaxPayloadMBytes

      public void setMaxPayloadMBytes(int mbytes)
      Set the maximum size (in megabytes) of the payload that can be returned by the decompiler process when analyzing a single function. If this size is exceeded, decompilation is aborted.
      Parameters:
      mbytes - is the maximum number of megabytes in a function payload
    • getMaxInstructions

      public int getMaxInstructions()
      If the number of assembly instructions in a function exceeds this value, the function is not decompiled.
      Returns:
      the maximum number of instructions
    • setMaxInstructions

      public void setMaxInstructions(int num)
      Set the maximum number of assembly instructions in a function to decompile. If the number exceeds this, the function is not decompiled.
      Parameters:
      num - is the number of instructions
    • getMaxJumpTableEntries

      public int getMaxJumpTableEntries()
      If the number of entries in a single jumptable exceeds this value, the decompiler will not recover the table and control flow from the indirect jump corresponding to the table will not be followed.
      Returns:
      the maximum number of entries
    • setMaxJumpTableEntries

      public void setMaxJumpTableEntries(int num)
      Set the maximum number of entries the decompiler will recover from a single jumptable. If the number exceeds this, the table is not recovered and control flow from the corresponding indirect jump is not followed.
      Parameters:
      num - is the number of entries
    • getCommentStyle

      public DecompileOptions.CommentStyleEnum getCommentStyle()
      Returns the style in which comments are printed in decompiler output..
      Returns:
      the style in which comments are printed in decompiler output.
    • setCommentStyle

      public void setCommentStyle(DecompileOptions.CommentStyleEnum commentStyle)
      Set the style in which comments are printed as part of decompiler output
      Parameters:
      commentStyle - is the new style to set
    • getCacheSize

      public int getCacheSize()
      Return the maximum number of decompiled function results that should be cached by the controller of the decompiler process.
      Returns:
      the number of functions to cache
    • isPredicate

      public boolean isPredicate()
      Returns true if predicate simplification is enabled..
      Returns:
      true if predicate simplification is enabled.
      See Also:
      • PREDICATE_OPTIONDESCRIPTION
    • setPredicate

      public void setPredicate(boolean predicate)
      Set whether the decompiler should simplify predication (combine conditional execution into if/else constructs).
      Parameters:
      predicate - true to enable predication simplification
      See Also:
      • PREDICATE_OPTIONDESCRIPTION
    • isIgnoreUnimplemented

      public boolean isIgnoreUnimplemented()
      Returns true if instructions with no p-code implementation are treated as NOP..
      Returns:
      true if instructions with no p-code implementation are treated as NOP.
      See Also:
      • IGNOREUNIMPL_OPTIONDESCRIPTION
    • setIgnoreUnimplemented

      public void setIgnoreUnimplemented(boolean ignore)
      Set whether instructions without p-code implementations should be treated as NOP.
      Parameters:
      ignore - true to ignore unimplemented instructions
      See Also:
      • IGNOREUNIMPL_OPTIONDESCRIPTION
    • isInferConstantPointers

      public boolean isInferConstantPointers()
      Returns true if constants that look like addresses are inferred as pointers..
      Returns:
      true if constants that look like addresses are inferred as pointers.
      See Also:
      • INFERCONSTPTR_OPTIONDESCRIPTION
    • setInferConstantPointers

      public void setInferConstantPointers(boolean infer)
      Set whether constants that can be interpreted as addresses should be treated as pointers.
      Parameters:
      infer - true to infer constant pointers
      See Also:
      • INFERCONSTPTR_OPTIONDESCRIPTION
    • isAnalyzeForLoops

      public boolean isAnalyzeForLoops()
      Returns true if the decompiler attempts to recover for-loops..
      Returns:
      true if the decompiler attempts to recover for-loops.
      See Also:
      • ANALYZEFORLOOPS_OPTIONDESCRIPTION
    • setAnalyzeForLoops

      public void setAnalyzeForLoops(boolean analyze)
      Set whether the decompiler should try to recover for-loop constructs.
      Parameters:
      analyze - true to enable for-loop recovery
      See Also:
      • ANALYZEFORLOOPS_OPTIONDESCRIPTION
    • isSplitStructures

      public boolean isSplitStructures()
      Returns true if combined structure field copies are split..
      Returns:
      true if combined structure field copies are split.
      See Also:
      • SPLITSTRUCTURES_OPTIONDESCRIPTION
    • setSplitStructures

      public void setSplitStructures(boolean split)
      Set whether copies to/from structures that touch multiple fields should be split.
      Parameters:
      split - true to split combined structure field copies
      See Also:
      • SPLITSTRUCTURES_OPTIONDESCRIPTION
    • isSplitArrays

      public boolean isSplitArrays()
      Returns true if combined array element copies are split..
      Returns:
      true if combined array element copies are split.
      See Also:
      • SPLITARRAYS_OPTIONDESCRIPTION
    • setSplitArrays

      public void setSplitArrays(boolean split)
      Set whether copies to/from arrays that touch multiple elements should be split.
      Parameters:
      split - true to split combined array element copies
      See Also:
      • SPLITARRAYS_OPTIONDESCRIPTION
    • isSplitPointers

      public boolean isSplitPointers()
      Returns true if pointer copies to combined elements are split..
      Returns:
      true if pointer copies to combined elements are split.
      See Also:
      • SPLITPOINTERS_OPTIONDESCRIPTION
    • setSplitPointers

      public void setSplitPointers(boolean split)
      Set whether pointer copies that access multiple elements/fields should be split.
      Parameters:
      split - true to split pointer copies
      See Also:
      • SPLITPOINTERS_OPTIONDESCRIPTION
    • getNanIgnore

      public DecompileOptions.NanIgnoreEnum getNanIgnore()
      Returns the current policy for ignoring NaN operations..
      Returns:
      the current policy for ignoring NaN operations.
      See Also:
      • NANIGNORE_OPTIONDESCRIPTION
    • setNanIgnore

      public void setNanIgnore(DecompileOptions.NanIgnoreEnum nanIgnore)
      Set the policy for ignoring NaN operations in decompiler output.
      Parameters:
      nanIgnore - the NanIgnoreEnum value to set
      See Also:
      • NANIGNORE_OPTIONDESCRIPTION
    • isNullToken

      public boolean isNullToken()
      Returns true if null pointers are printed as the token 'NULL'..
      Returns:
      true if null pointers are printed as the token 'NULL'.
      See Also:
      • NULLTOKEN_OPTIONDESCRIPTION
    • setNullToken

      public void setNullToken(boolean nullToken)
      Set whether null pointers should be displayed using the 'NULL' token.
      Parameters:
      nullToken - true to print 'NULL' for null pointers
      See Also:
      • NULLTOKEN_OPTIONDESCRIPTION
    • isInplaceTokens

      public boolean isInplaceTokens()
      Returns true if inplace assignment tokens (e.g., +=, *=, etc.) are used..
      Returns:
      true if inplace assignment tokens (e.g., +=, *=, etc.) are used.
      See Also:
      • INPLACEOP_OPTIONDESCRIPTION
    • setInplaceTokens

      public void setInplaceTokens(boolean inplace)
      Set whether inplace assignment tokens (e.g., +=, *=, etc.) are used.
      Parameters:
      inplace - true to enable inplace tokens
      See Also:
      • INPLACEOP_OPTIONDESCRIPTION
    • getAliasBlock

      public DecompileOptions.AliasBlockEnum getAliasBlock()
      Returns the current alias blocking policy..
      Returns:
      the current alias blocking policy.
      See Also:
      • ALIASBLOCK_OPTIONDESCRIPTION
    • setAliasBlock

      public void setAliasBlock(DecompileOptions.AliasBlockEnum aliasBlock)
      Set which data-types block pointer aliasing across stack boundaries.
      Parameters:
      aliasBlock - the AliasBlockEnum value to set
      See Also:
      • ALIASBLOCK_OPTIONDESCRIPTION
    • getIndentWidth

      public int getIndentWidth()
      Returns number of characters per indent level..
      Returns:
      number of characters per indent level.
    • setIndentWidth

      public void setIndentWidth(int indentwidth)
      Set the number of characters to indent per level.
      Parameters:
      indentwidth - number of characters per indent level
    • getCommentIndent

      public int getCommentIndent()
      Returns comment line indent level (number of characters)..
      Returns:
      comment line indent level (number of characters).
    • setCommentIndent

      public void setCommentIndent(int commentindent)
      Set the number of characters each comment line is indented.
      Parameters:
      commentindent - number of characters to indent comment lines
    • getNamespaceStrategy

      public DecompileOptions.NamespaceStrategy getNamespaceStrategy()
      Returns strategy for displaying namespaces..
      Returns:
      strategy for displaying namespaces.
    • setNamespaceStrategy

      public void setNamespaceStrategy(DecompileOptions.NamespaceStrategy namespaceStrategy)
      Set how/if namespace tokens should be displayed.
      Parameters:
      namespaceStrategy - the NamespaceStrategy to use
    • getIntegerFormat

      public DecompileOptions.IntegerFormatEnum getIntegerFormat()
      Returns how integers are formatted in output..
      Returns:
      how integers are formatted in output.
    • setIntegerFormat

      public void setIntegerFormat(DecompileOptions.IntegerFormatEnum integerFormat)
      Set how integers should be displayed (hex, dec, best fit).
      Parameters:
      integerFormat - the IntegerFormatEnum to use
    • setDisplayLineNumbers

      public void setDisplayLineNumbers(boolean displayLineNumbers)
      Set whether line numbers should be displayed with decompiler output.
      Parameters:
      displayLineNumbers - true to show line numbers
    • setMiddleMouseHighlightButton

      public void setMiddleMouseHighlightButton(int button)
      Set which mouse button toggles the primary token highlight.
      Parameters:
      button - MouseEvent button id (MouseEvent.BUTTON1 etc.)
    • setCacheSize

      public void setCacheSize(int cachedResultsSize)
      Set the maximum number of decompiled function results that should be cached by the controller of the decompiler process.
      Parameters:
      cachedResultsSize - number of functions to cache