Package ghidra.app.util
Class SymbolInspector
- java.lang.Object
-
- ghidra.app.util.SymbolInspector
-
- All Implemented Interfaces:
OptionsChangeListener
public class SymbolInspector extends java.lang.Object implements OptionsChangeListener
Class for coloring symbols.
-
-
Constructor Summary
Constructors Constructor Description SymbolInspector(ToolOptions options, java.awt.Component repaintComp)
Constructs a new symbol inspectorSymbolInspector(ServiceProvider serviceProvider, java.awt.Component repaintComp)
Constructs a new symbol inspector It uses the tool to get the CATEGORY_BROWSER_DISPLAY options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Call this when you are done with this inspector and will not use it again.java.awt.Color
getColor(Symbol s)
Get the color used to render the given symbol.ColorAndStyle
getColorAndStyle(Symbol s)
Gets the color and style used to render the given symbol.java.awt.Color
getOffcutSymbolColor()
int
getOffcutSymbolStyle()
Program
getProgram()
Returns the program in use by this inspector; may be null;ScreenElement
getScreenElement(Symbol s)
Get the ScreenElement corresponding to the type of the symbolint
getStyle(Symbol s)
Get the style used to render the given symbolboolean
isBadReferenceSymbol(Symbol s)
Returns true if symbol is at a non-existent addressboolean
isDataSymbol(Symbol s)
Returns true if the symbol is on a data item.boolean
isDeadCodeSymbol(Symbol s)
Returns true if the symbol is on "dead" codeboolean
isEntryPointSymbol(Symbol s)
Checks if the given symbol is at an external entry pointboolean
isExternalSymbol(Symbol s)
boolean
isFunctionSymbol(Symbol s)
Checks if the symbol is at a functionboolean
isGlobalSymbol(Symbol s)
Checks if the symbol is global or localboolean
isInstructionSymbol(Symbol s)
Checks if the symbol is at or inside an instructionboolean
isLocalSymbol(Symbol s)
Checks if the symbol is localboolean
isNonPrimarySymbol(Symbol s)
Checks if the symbol is not a primary symbolboolean
isOffcutSymbol(Symbol s)
Checks if the symbol is offcutboolean
isPrimarySymbol(Symbol s)
returns true if the symbol is primaryboolean
isSubroutineSymbol(Symbol s)
Checks if the symbol is at the beginning of a subroutine.boolean
isVariableSymbol(Symbol s)
Checks if the symbol is a function variablevoid
optionsChanged(ToolOptions options, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Notification that an option changed.void
setProgram(Program p)
Associates a program with this symbol inspector
-
-
-
Constructor Detail
-
SymbolInspector
public SymbolInspector(ServiceProvider serviceProvider, java.awt.Component repaintComp)
Constructs a new symbol inspector It uses the tool to get the CATEGORY_BROWSER_DISPLAY options- Parameters:
serviceProvider
- a service provider for getting servicesrepaintComp
- the component to repaint when the options change
-
SymbolInspector
public SymbolInspector(ToolOptions options, java.awt.Component repaintComp)
Constructs a new symbol inspector- Parameters:
options
- the options from which to get colorsrepaintComp
- the component to repaint when the options change
-
-
Method Detail
-
optionsChanged
public void optionsChanged(ToolOptions options, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Description copied from interface:OptionsChangeListener
Notification that an option changed.Note: to reject an options change, you can throw a
OptionsVetoException
.- Specified by:
optionsChanged
in interfaceOptionsChangeListener
- Parameters:
options
- options object containing the property that changedname
- name of option that changedoldValue
- old value of the optionnewValue
- new value of the option
-
setProgram
public void setProgram(Program p)
Associates a program with this symbol inspector- Parameters:
p
- the program for inspecting symbols
-
getProgram
public Program getProgram()
Returns the program in use by this inspector; may be null;- Returns:
- the program in use by this inspector; may be null;
-
dispose
public void dispose()
Call this when you are done with this inspector and will not use it again. Cleans up listeners, etc.
-
isBadReferenceSymbol
public boolean isBadReferenceSymbol(Symbol s)
Returns true if symbol is at a non-existent address- Parameters:
s
- the symbol to check- Returns:
- boolean true if symbol is bad
-
isDataSymbol
public boolean isDataSymbol(Symbol s)
Returns true if the symbol is on a data item.- Parameters:
s
- the symbol to check- Returns:
- boolean true if s is a data symbol
-
isDeadCodeSymbol
public boolean isDeadCodeSymbol(Symbol s)
Returns true if the symbol is on "dead" code- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is on dead code
-
isEntryPointSymbol
public boolean isEntryPointSymbol(Symbol s)
Checks if the given symbol is at an external entry point- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is at an external entry point address.
-
isFunctionSymbol
public boolean isFunctionSymbol(Symbol s)
Checks if the symbol is at a function- Parameters:
s
- the symbol to check.- Returns:
- boolean true if there is a function at the symbol's address.
-
isVariableSymbol
public boolean isVariableSymbol(Symbol s)
Checks if the symbol is a function variable- Parameters:
s
- the symbol to check- Returns:
- true if s is a function variable symbol
-
isGlobalSymbol
public boolean isGlobalSymbol(Symbol s)
Checks if the symbol is global or local- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is global, false if the symbol is local.
-
isInstructionSymbol
public boolean isInstructionSymbol(Symbol s)
Checks if the symbol is at or inside an instruction- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is on an instruction
-
isLocalSymbol
public boolean isLocalSymbol(Symbol s)
Checks if the symbol is local- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is local, false if it is global
-
isNonPrimarySymbol
public boolean isNonPrimarySymbol(Symbol s)
Checks if the symbol is not a primary symbol- Parameters:
s
- the symbol to check.- Returns:
- boolean true if the symbol is non-primary
-
isOffcutSymbol
public boolean isOffcutSymbol(Symbol s)
Checks if the symbol is offcut- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is offcut
-
isPrimarySymbol
public boolean isPrimarySymbol(Symbol s)
returns true if the symbol is primary- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is primary
-
isSubroutineSymbol
public boolean isSubroutineSymbol(Symbol s)
Checks if the symbol is at the beginning of a subroutine.- Parameters:
s
- the symbol to check- Returns:
- boolean true if the symbol is at the beginning of a subroutine.
-
isExternalSymbol
public boolean isExternalSymbol(Symbol s)
-
getColorAndStyle
public ColorAndStyle getColorAndStyle(Symbol s)
Gets the color and style used to render the given symbol. Calling this method is faster than callinggetColor(Symbol)
andgetStyle(Symbol)
separately.- Parameters:
s
- the symbol- Returns:
- the color and style
-
getColor
public java.awt.Color getColor(Symbol s)
Get the color used to render the given symbol.- Parameters:
s
- symbol to inspect- Returns:
- Color for the symbol
-
getStyle
public int getStyle(Symbol s)
Get the style used to render the given symbol- Parameters:
s
- symbol to inspect- Returns:
- the style for the symbol
-
getScreenElement
public ScreenElement getScreenElement(Symbol s)
Get the ScreenElement corresponding to the type of the symbol- Parameters:
s
- symbol to inspect- Returns:
- the screen element
-
getOffcutSymbolColor
public java.awt.Color getOffcutSymbolColor()
-
getOffcutSymbolStyle
public int getOffcutSymbolStyle()
-
-