Package ghidra.app.decompiler
Class DecompileOptions
java.lang.Object
ghidra.app.decompiler.DecompileOptions
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
Modifier and TypeClassDescriptionstatic enum
static enum
static enum
static enum
static enum
static enum
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(Encoder encoder, DecompInterface iface) Encode all the configuration options to a stream for the decompiler process.int
Return the maximum number of decompiled function results that should be cached by the controller of the decompiler process.int
If the time a decompiler process is allowed to analyze a single function exceeds this value, decompilation is aborted.int
If the number of assembly instructions in a function exceeds this value, the function is not decompiled.int
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
If the size (in megabytes) of the payload returned by the decompiler process exceeds this value for a single function, decompilation is aborted.int
int
Retrieve the transformer being applied to data-type, function, and namespace names.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
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
If the decompiler currently applies transformation rules that identify and simplify double precision arithmetic operations, true is returned.boolean
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 existvoid
setCommentStyle
(DecompileOptions.CommentStyleEnum commentStyle) Set the style in which comments are printed as part of decompiler outputvoid
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
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
Set how braces are formatted around a function bodyvoid
setHeadCommentIncluded
(boolean commentHeadInclude) Set whether function header comments are included as part of decompiler output.void
Set how braces are formatted around an if/else code blockvoid
Set how braces are formatted a loop bodyvoid
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 outputvoid
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 outputvoid
setPOSTCommentIncluded
(boolean commentPOSTInclude) Set whether Post comments are displayed as part of decompiler outputvoid
setPRECommentIncluded
(boolean commentPREInclude) Set whether Pre comments are displayed as part of decompiler outputvoid
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
Set how braces are formatted around a switch blockvoid
setWARNCommentIncluded
(boolean commentWARNInclude) Set whether automatically generated WARNING comments are displayed as part of decompiler output.
-
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
- See Also:
-
-
Constructor Details
-
DecompileOptions
public DecompileOptions()
-
-
Method Details
-
grabFromToolAndProgram
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 fieldsopt
- the Options object that contains the "tool options" specific to the decompilerprogram
- the program whose "program options" are relevant to the decompiler
-
grabFromProgram
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
- Returns:
- the default prototype to assume if no other information about a function is known
-
setProtoEvalModel
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
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 fieldsopt
- the options object specific to the decompilerprogram
- the program
-
encode
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 encoderiface
- specific DecompInterface being sent options- Throws:
IOException
- for errors writing to the underlying stream
-
getFunctionBraceFormat
- Returns:
- the brace formatting style for function bodies
-
setFunctionBraceFormat
Set how braces are formatted around a function body- Parameters:
style
- is the formatting style
-
getIfElseBraceFormat
- Returns:
- the brace formatting style for if/else code blocks
-
setIfElseBraceFormat
Set how braces are formatted around an if/else code block- Parameters:
style
- is the formatting style
-
getLoopBraceFormat
- Returns:
- the brace formatting style for loop bodies
-
setLoopBraceFormat
Set how braces are formatted a loop body- Parameters:
style
- is the formatting style
-
getSwitchBraceFormat
- Returns:
- the brace formatting style for switch blocks
-
setSwitchBraceFormat
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
- Returns:
- color associated with keyword tokens
-
getTypeColor
- Returns:
- color associated with data-type tokens
-
getFunctionColor
- Returns:
- color associated with a function name token
-
getCommentColor
- Returns:
- color used to display comments
-
getConstantColor
- Returns:
- color associated with constant tokens
-
getVariableColor
- Returns:
- color associated with (local) variable tokens
-
getParameterColor
- Returns:
- color associated with parameter tokens
-
getGlobalColor
- Returns:
- color associated with global variable tokens
-
getSpecialColor
- Returns:
- color associated with volatile variables or other special tokens
-
getDefaultColor
- Returns:
- color for generic syntax or other unspecified tokens
-
getErrorColor
- Returns:
- color used on tokens that need to warn of an error or other unusual conditions
-
getBackgroundColor
- Returns:
- the background color for the decompiler window
-
getCurrentVariableHighlightColor
- Returns:
- the color used display the current highlighted variable
-
getMiddleMouseHighlightColor
- Returns:
- color used to highlight token(s) selected with a middle button clock
-
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
- Returns:
- the source programming language that decompiler output is rendered in
-
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
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
Set the source programming language that decompiler output should be rendered in.- Parameters:
val
- is the source language
-
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
- Returns:
- the style in which comments are printed in decompiler output
-
setCommentStyle
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
-