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

    • SUGGESTED_DECOMPILE_TIMEOUT_SECS

      public static final int SUGGESTED_DECOMPILE_TIMEOUT_SECS
      See Also:
    • SUGGESTED_MAX_PAYLOAD_BYTES

      public static final int SUGGESTED_MAX_PAYLOAD_BYTES
      See Also:
    • SUGGESTED_MAX_INSTRUCTIONS

      public static final int SUGGESTED_MAX_INSTRUCTIONS
      See Also:
    • SUGGESTED_MAX_JUMPTABLE_ENTRIES

      public static final int SUGGESTED_MAX_JUMPTABLE_ENTRIES
      See Also:
    • DEFAULT_FONT_ID

      public static final String DEFAULT_FONT_ID
      See Also:
  • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • getTypeColor

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

      public Color getFunctionColor()
      Returns:
      color associated with a function name token
    • getCommentColor

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

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

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

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

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

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

      public Color getDefaultColor()
      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
    • getBackgroundColor

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

      public Color getCurrentVariableHighlightColor()
      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
    • getSearchHighlightColor

      public Color getSearchHighlightColor()
      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
    • isPRECommentIncluded

      public boolean isPRECommentIncluded()
      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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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.
    • getDisplayLanguage

      public DecompilerLanguage getDisplayLanguage()
      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
    • 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
    • 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
    • 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