Package ghidra.program.model.block
Class MultEntSubModel
java.lang.Object
ghidra.program.model.block.MultEntSubModel
- All Implemented Interfaces:
CodeBlockModel,SubroutineBlockModel
MultEntSubModel (M-model) defines subroutines which do not share code with
any other subroutine and may have one or more entry points. Each entry-
points represent either a source or called entry-point.
MODEL-M subroutines should be used to determine which subroutine(s) contains a particular instruction. Since model-M subroutines yield the largest subroutines, they should be particular useful in the process of program slicing -- the process of splitting the program into modules or subroutine cliques -- in order to begin to understand the structure and functionality of the program.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected Listingstatic final Stringprotected ProgramFields inherited from interface ghidra.program.model.block.CodeBlockModel
emptyBlockArray -
Constructor Summary
ConstructorsConstructorDescriptionMultEntSubModel(Program program) Construct aMultEntSubModelfor a program.MultEntSubModel(Program program, boolean includeExternals) Construct aMultEntSubModelfor a program. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true if this model allows overlapping of address sets for the blocks it returns.booleanReturns true if externals are handled by the model, false if externals are ignored.getAddressSet(CodeBlock block) Compute an address set that represents all the addresses contained in all instructions that are part of this blockprotected CodeBlockgetAddressSetContaining(Address addr, TaskMonitor monitor) Get the M-Model subroutine address set which contains the specified address.Get the underlying base subroutine model.Get the basic block model used by this model.getCodeBlockAt(Address addr, TaskMonitor monitor) Get the code block that has an entry point at addr.getCodeBlocks(TaskMonitor monitor) Get an iterator over the code blocks in the entire program.getCodeBlocksContaining(Address addr, TaskMonitor monitor) Returns the one code block contained by addr (only for a model that has shared subroutines would this method return more than one code block)getCodeBlocksContaining(AddressSetView addrSet, TaskMonitor monitor) Get an iterator over CodeBlocks which overlap the specified address set.getDestinations(CodeBlock block, TaskMonitor monitor) Get an iterator over the destination flows out of the block.getFirstCodeBlockContaining(Address addr, TaskMonitor monitor) Get the MultEntSubModel Code Block that contains the address.getFlowType(CodeBlock block) Return in general how things flow out of this node.Returns the listing associated with this block model.getName()Returns the model name.Get a name for this block.intgetNumDestinations(CodeBlock block, TaskMonitor monitor) Get number of destination references flowing out of this subroutine (block).intgetNumSources(CodeBlock block, TaskMonitor monitor) Get the number of source flows into the block.Returns the program object associated with this CodeBlockModel instance.getSources(CodeBlock block, TaskMonitor monitor) Get an iterator over the source flows into the block.
-
Field Details
-
NAME
- See Also:
-
program
-
listing
-
includeExternals
protected final boolean includeExternals
-
-
Constructor Details
-
MultEntSubModel
Construct aMultEntSubModelfor a program.- Parameters:
program- program to create blocks from.
-
MultEntSubModel
Construct aMultEntSubModelfor a program.- Parameters:
program- program to create blocks from.includeExternals- external blocks will be included if true
-
-
Method Details
-
getCodeBlockAt
Get the code block that has an entry point at addr.- Specified by:
getCodeBlockAtin interfaceCodeBlockModel- Parameters:
addr- one of the entry points for a Model-M subroutinemonitor- task monitor which allows user to cancel operation.- Returns:
- null if there is no subroutine with an entry at addr.
- Throws:
CancelledException- if the monitor cancels the operation.
-
getAddressSetContaining
protected CodeBlock getAddressSetContaining(Address addr, TaskMonitor monitor) throws CancelledException Get the M-Model subroutine address set which contains the specified address. This method also identifies the entry points and caches the resulting CodeBlock.- Parameters:
addr- Address inside the subroutine that we are seekingmonitor- task monitor which allows user to cancel operation.- Returns:
- The
CodeBlockfor aMultEntSubModelSubroutine. Null is returned if there is no instruction at addr. - Throws:
CancelledException- if the monitor cancels the operation.
-
getFirstCodeBlockContaining
public CodeBlock getFirstCodeBlockContaining(Address addr, TaskMonitor monitor) throws CancelledException Get the MultEntSubModel Code Block that contains the address.- Specified by:
getFirstCodeBlockContainingin interfaceCodeBlockModel- Parameters:
addr- Address to find a containing block.monitor- task monitor which allows user to cancel operation.- Returns:
- A CodeBlock if any block contains the address. null otherwise.
- Throws:
CancelledException- if the monitor cancels the operation.
-
getCodeBlocksContaining
public CodeBlock[] getCodeBlocksContaining(Address addr, TaskMonitor monitor) throws CancelledException Returns the one code block contained by addr (only for a model that has shared subroutines would this method return more than one code block)- Specified by:
getCodeBlocksContainingin interfaceCodeBlockModel- Parameters:
addr- Address to find a containing block.monitor- task monitor which allows user to cancel operation.- Returns:
- A CodeBlock if any block contains the address. empty array otherwise.
- Throws:
CancelledException- if the monitor cancels the operation.
-
getCodeBlocks
Get an iterator over the code blocks in the entire program.- Specified by:
getCodeBlocksin interfaceCodeBlockModel- Parameters:
monitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.
-
getCodeBlocksContaining
public CodeBlockIterator getCodeBlocksContaining(AddressSetView addrSet, TaskMonitor monitor) throws CancelledException Get an iterator over CodeBlocks which overlap the specified address set.- Specified by:
getCodeBlocksContainingin interfaceCodeBlockModel- Parameters:
addrSet- an address set within programmonitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.
-
getProgram
Description copied from interface:CodeBlockModelReturns the program object associated with this CodeBlockModel instance.- Specified by:
getProgramin interfaceCodeBlockModel- Returns:
- program associated with this CodeBlockModel.
- See Also:
-
getListing
Returns the listing associated with this block model.- Returns:
- the listing associated with this block model.
-
getName
Description copied from interface:CodeBlockModelGet a name for this block.- Specified by:
getNamein interfaceCodeBlockModel- Returns:
- usually the label at the start address of the block however the model can choose any name it wants for its blocks.
- See Also:
-
getFlowType
Return in general how things flow out of this node. This method exists for the SIMPLEBLOCK model.Since it doesn't make a great deal of sense to ask for this method in the case of subroutines, we return FlowType.UNKNOWN as long as the block exists.
If this block has no valid instructions, it can't flow, so FlowType.INVALID is returned.
- Specified by:
getFlowTypein interfaceCodeBlockModel- Returns:
- flow type of this node
-
getSources
public CodeBlockReferenceIterator getSources(CodeBlock block, TaskMonitor monitor) throws CancelledException Description copied from interface:CodeBlockModelGet an iterator over the source flows into the block.- Specified by:
getSourcesin interfaceCodeBlockModel- Parameters:
block- the block to get the destination flows for.monitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getNumSources
Description copied from interface:CodeBlockModelGet the number of source flows into the block.- Specified by:
getNumSourcesin interfaceCodeBlockModel- Parameters:
block- the code blocks to get the destination flows for.monitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getDestinations
public CodeBlockReferenceIterator getDestinations(CodeBlock block, TaskMonitor monitor) throws CancelledException Description copied from interface:CodeBlockModelGet an iterator over the destination flows out of the block.- Specified by:
getDestinationsin interfaceCodeBlockModel- Parameters:
block- the block to get the destination flows for.monitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getNumDestinations
Get number of destination references flowing out of this subroutine (block). All Calls from this block, and all external FlowType block references from this block are counted.- Specified by:
getNumDestinationsin interfaceCodeBlockModel- Parameters:
block- code block to get the number of destination references from.monitor- task monitor which allows user to cancel operation.- Throws:
CancelledException- if the monitor cancels the operation.
-
getAddressSet
Compute an address set that represents all the addresses contained in all instructions that are part of this block- Parameters:
block- code block to compute address set for.
-
getBasicBlockModel
Description copied from interface:CodeBlockModelGet the basic block model used by this model.- Specified by:
getBasicBlockModelin interfaceCodeBlockModel- See Also:
-
getName
Description copied from interface:CodeBlockModelReturns the model name.- Specified by:
getNamein interfaceCodeBlockModel- Returns:
- the model name
- See Also:
-
getBaseSubroutineModel
Description copied from interface:SubroutineBlockModelGet the underlying base subroutine model. This is generally the MultEntSubModel (M-Model).- Specified by:
getBaseSubroutineModelin interfaceSubroutineBlockModel- Returns:
- base subroutine model. If there is no base model, this subroutine model is returned.
- See Also:
-
allowsBlockOverlap
public boolean allowsBlockOverlap()Description copied from interface:CodeBlockModelReturn true if this model allows overlapping of address sets for the blocks it returns.- Specified by:
allowsBlockOverlapin interfaceCodeBlockModel- Returns:
- true if this model allows overlapping of address sets for the blocks it returns. This implies that getBlocksContaining() can return more than one block. false implies that getBlocksContaining() will return at most one block.
- See Also:
-
externalsIncluded
public boolean externalsIncluded()Description copied from interface:CodeBlockModelReturns true if externals are handled by the model, false if externals are ignored. When handled, externals are represented by an ExtCodeBlockImpl.- Specified by:
externalsIncludedin interfaceCodeBlockModel- See Also:
-