Package ghidra.app.decompiler

# 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

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `DecompileOptions.AliasBlockEnum`
  `static enum`
  `DecompileOptions.BraceStyle`
  `static enum`
  `DecompileOptions.CommentStyleEnum`
  `static enum`
  `DecompileOptions.IntegerFormatEnum`
  `static enum`
  `DecompileOptions.NamespaceStrategy`
  `static enum`
  `DecompileOptions.NanIgnoreEnum`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_FONT_ID`
  `static final int`
  `SUGGESTED_DECOMPILE_TIMEOUT_SECS`
  `static final int`
  `SUGGESTED_MAX_INSTRUCTIONS`
  `static final int`
  `SUGGESTED_MAX_JUMPTABLE_ENTRIES`
  `static final int`
  `SUGGESTED_MAX_PAYLOAD_BYTES`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DecompileOptions()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `encode(Encoder encoder, DecompInterface iface)`
  Encode all the configuration options to a stream for the decompiler process.
  `Color`
  `getBackgroundColor()`
  `int`
  `getCacheSize()`
  Return the maximum number of decompiled function results that should be cached by the controller of the decompiler process.
  `Color`
  `getCommentColor()`
  `DecompileOptions.CommentStyleEnum`
  `getCommentStyle()`
  `Color`
  `getConstantColor()`
  `Color`
  `getCurrentVariableHighlightColor()`
  `Color`
  `getDefaultColor()`
  `Font`
  `getDefaultFont()`
  `int`
  `getDefaultTimeout()`
  If the time a decompiler process is allowed to analyze a single function exceeds this value, decompilation is aborted.
  `DecompilerLanguage`
  `getDisplayLanguage()`
  `Color`
  `getErrorColor()`
  `DecompileOptions.BraceStyle`
  `getFunctionBraceFormat()`
  `Color`
  `getGlobalColor()`
  `DecompileOptions.BraceStyle`
  `getIfElseBraceFormat()`
  `Color`
  `getKeywordColor()`
  `DecompileOptions.BraceStyle`
  `getLoopBraceFormat()`
  `int`
  `getMaxInstructions()`
  If the number of assembly instructions in a function exceeds this value, the function is not decompiled.
  `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.
  `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.
  `int`
  `getMaxWidth()`
  `int`
  `getMiddleMouseHighlightButton()`
  `Color`
  `getMiddleMouseHighlightColor()`
  `NameTransformer`
  `getNameTransformer()`
  Retrieve the transformer being applied to data-type, function, and namespace names.
  `Color`
  `getParameterColor()`
  `String`
  `getProtoEvalModel()`
  `Color`
  `getSearchHighlightColor()`
  `Color`
  `getSpecialColor()`
  `DecompileOptions.BraceStyle`
  `getSwitchBraceFormat()`
  `Color`
  `getTypeColor()`
  `Color`
  `getVariableColor()`
  `void`
  `grabFromProgram(Program program)`
  Grab all the decompiler options from the program specifically and cache them in this object.
  `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.
  `boolean`
  `isConventionPrint()`
  `boolean`
  `isDisplayLineNumbers()`
  `boolean`
  `isEliminateUnreachable()`
  `boolean`
  `isEOLCommentIncluded()`
  `boolean`
  `isHeadCommentIncluded()`
  `boolean`
  `isNoCastPrint()`
  `boolean`
  `isPLATECommentIncluded()`
  `boolean`
  `isPOSTCommentIncluded()`
  `boolean`
  `isPRECommentIncluded()`
  `boolean`
  `isRespectReadOnly()`
  `boolean`
  `isSimplifyDoublePrecision()`
  If the decompiler currently applies transformation rules that identify and simplify double precision arithmetic operations, true is returned.
  `boolean`
  `isWARNCommentIncluded()`
  `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
  `void`
  `setCommentStyle(DecompileOptions.CommentStyleEnum commentStyle)`
  Set the style in which comments are printed as part of decompiler output
  `void`
  `setConventionPrint(boolean conventionPrint)`
  Set whether the calling convention name should be displayed as part of function signatures in decompiler output.
  `void`
  `setDefaultTimeout(int timeout)`
  Set the maximum time (in seconds) a decompiler process is allowed to analyze a single function.
  `void`
  `setDisplayLanguage(DecompilerLanguage val)`
  Set the source programming language that decompiler output should be rendered in.
  `void`
  `setEliminateUnreachable(boolean eliminateUnreachable)`
  Set whether the decompiler should eliminate unreachable code as part of its analysis.
  `void`
  `setEOLCommentIncluded(boolean commentEOLInclude)`
  Set whether End-of-line comments are displayed as part of decompiler output.
  `void`
  `setFunctionBraceFormat(DecompileOptions.BraceStyle style)`
  Set how braces are formatted around a function body
  `void`
  `setHeadCommentIncluded(boolean commentHeadInclude)`
  Set whether function header comments are included as part of decompiler output.
  `void`
  `setIfElseBraceFormat(DecompileOptions.BraceStyle style)`
  Set how braces are formatted around an if/else code block
  `void`
  `setLoopBraceFormat(DecompileOptions.BraceStyle style)`
  Set how braces are formatted a loop body
  `void`
  `setMaxInstructions(int num)`
  Set the maximum number of assembly instructions in a function to decompile.
  `void`
  `setMaxJumpTableEntries(int num)`
  Set the maximum number of entries the decompiler will recover from a single jumptable.
  `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.
  `void`
  `setMaxWidth(int maxwidth)`
  Set the maximum number of characters the decompiler displays in a single line of output
  `void`
  `setNameTransformer(NameTransformer transformer)`
  Set a specific transformer to be applied to all data-type, function, and namespace names in decompiler output.
  `void`
  `setNoCastPrint(boolean noCastPrint)`
  Set whether decompiler output should display cast operations.
  `void`
  `setPLATECommentIncluded(boolean commentPLATEInclude)`
  Set whether Plate comments are displayed as part of decompiler output
  `void`
  `setPOSTCommentIncluded(boolean commentPOSTInclude)`
  Set whether Post comments are displayed as part of decompiler output
  `void`
  `setPRECommentIncluded(boolean commentPREInclude)`
  Set whether Pre comments are displayed as part of decompiler output
  `void`
  `setProtoEvalModel(String protoEvalModel)`
  Set the default prototype model for the decompiler.
  `void`
  `setRespectReadOnly(boolean readOnly)`
  Set whether the decompiler should respect read-only flags as part of its analysis.
  `void`
  `setSimplifyDoublePrecision(boolean simplifyDoublePrecision)`
  Set whether the decompiler should apply transformation rules that identify and simplify double precision arithmetic operations.
  `void`
  `setSwitchBraceFormat(DecompileOptions.BraceStyle style)`
  Set how braces are formatted around a switch block
  `void`
  `setWARNCommentIncluded(boolean commentWARNInclude)`
  Set whether automatically generated WARNING comments are displayed as part of decompiler output.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SUGGESTED_DECOMPILE_TIMEOUT_SECS

    public static final int SUGGESTED_DECOMPILE_TIMEOUT_SECS
    See Also:
      - Constant Field Values

  - ### SUGGESTED_MAX_PAYLOAD_BYTES

    public static final int SUGGESTED_MAX_PAYLOAD_BYTES
    See Also:
      - Constant Field Values

  - ### SUGGESTED_MAX_INSTRUCTIONS

    public static final int SUGGESTED_MAX_INSTRUCTIONS
    See Also:
      - Constant Field Values

  - ### SUGGESTED_MAX_JUMPTABLE_ENTRIES

    public static final int SUGGESTED_MAX_JUMPTABLE_ENTRIES
    See Also:
      - Constant Field Values

  - ### DEFAULT_FONT_ID

    public static final String DEFAULT_FONT_ID
    See Also:
      - Constant Field Values

- ## 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

  - ### 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