Interface IDTryData
public interface IDTryData
dexdec exception handling information, optionally provided by an IR method context.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddProtectionFromBlock(int srcBlkOffset, int dstBlkOffset) Append the protection of the source block on to the destination block.booleancompareHandlers(int blkOffset1, int blkOffset2) Compare the protection information of two blocks.copy()Perform a deep-copy this object.booleancopyProtectedBlock(int srcBlkOffset, int dstBlkOffset) Copy the protection information of a block to another block.getBlockHandlers(int blkOffset) Retrieve the handlers protecting the provided block.getHandledExceptionTypesAt(int handlerOffset) Retrieve all the exception types handled by the provided handler.Retrieve a list of all handlers.getHandlers(int handlerAddress) Retrieve a copy of the list of protected blocks.booleanDetermine whether this object carries some protection information.booleanisEmpty()Determine whether this object carries some protection information.booleanisProtectedBlock(int blkOffset) Determine whether a block is protected.booleanmoveProtectedBlock(int srcBlkOffset, int dstBlkOffset) Move the protection information of a block to another block.booleanprotectBlock(int blkOffset, int exTypeIndex, int handlerOffset, int position) Add a handler to the list of exception handlers protecting the provided block.booleanreplaceHandler(int blkOffset, IDExceptionHandler handler, IDExceptionHandler newHandler) Replace or remove a handler by reference.voidsetBlockHandlers(int blkOffset, Collection<IDExceptionHandler> handlers) Set the handlers for the provided block.booleanunprotectBlock(int blkOffset) Unprotect a block.booleanunprotectBlock(int blkOffset, int handlerOffset) Remove a specific protection for a block.booleanunprotectBlock(int blkOffset, int handlerOffset, int exTypeIndex) Remove a specific specific protection for a block.booleanupdateHandlerAddress(int handlerAddress, int newAddress) Update the address of a handler.intupdateTargets(Map<Integer, Integer> oldToNewOffsets) Update the targets of this object.intupdateTargets(Map<Integer, Integer> oldToNewOffsets, boolean failOnMissedEntry) Update the targets of this object.
-
Method Details
-
copy
IDTryData copy()Perform a deep-copy this object.- Returns:
- a copy of this object
-
isEmpty
boolean isEmpty()Determine whether this object carries some protection information. The reverse ofhasProtectedBlocks().- Returns:
- true if not a single block is protected
-
hasProtectedBlocks
boolean hasProtectedBlocks()Determine whether this object carries some protection information. The reverse ofisEmpty().- Returns:
- true if at least one block is protected
-
getProtectedBlocks
Retrieve a copy of the list of protected blocks.- Returns:
- a copy of the list of block offsets, possibly empty
-
isProtectedBlock
boolean isProtectedBlock(int blkOffset) Determine whether a block is protected.- Parameters:
blkOffset- block- Returns:
- true if the block is protected (by at least one handler)
-
getHandlers
List<IDExceptionHandler> getHandlers()Retrieve a list of all handlers.- Returns:
-
getHandlers
- Parameters:
handlerAddress-- Returns:
-
getHandledExceptionTypesAt
Retrieve all the exception types handled by the provided handler.- Parameters:
handlerOffset- offset of the handler block (an entry-point block when an exception is caught)- Returns:
- a set of exception type indices; the special value -1 denotes the lowest-level throwable type (java.lang.Throwable)
-
getBlockHandlers
Retrieve the handlers protecting the provided block.- Parameters:
blkOffset- block- Returns:
- the list of handlers protecting the provided block
-
setBlockHandlers
Set the handlers for the provided block. The list of provided handlers will be copied.- Parameters:
blkOffset- blockhandlers- a list of handlers; empty to unprotect the block
-
compareHandlers
boolean compareHandlers(int blkOffset1, int blkOffset2) Compare the protection information of two blocks.- Parameters:
blkOffset1- a blockblkOffset2- another block- Returns:
- true if the blocks are protected in the exact same way (same handlers, same order, etc.), false otherwise
-
protectBlock
boolean protectBlock(int blkOffset, int exTypeIndex, int handlerOffset, int position) Add a handler to the list of exception handlers protecting the provided block. If no handler protects the block, a new list is created.- Parameters:
blkOffset- blockexTypeIndex- exception type index (-1 means untyped, i.e., all types)handlerOffset- offset of the handler entry-pointposition- insertion index (negative value is allowed, e.g. -1 means append)- Returns:
- true if the handler was created; false if a previous handler (before the insertion point) for the same type was found in the list of handlers for the block
-
replaceHandler
Replace or remove a handler by reference.- Parameters:
blkOffset- protected block offsethandler- mandatory handlernewHandler- new handler (or null to remove the handler)- Returns:
- true if the handler was replaced or removed
-
moveProtectedBlock
boolean moveProtectedBlock(int srcBlkOffset, int dstBlkOffset) Move the protection information of a block to another block. The source block will be left unprotected. The destination block will be protected as the source block was.- Parameters:
srcBlkOffset- source blockdstBlkOffset- destination- Returns:
- true if some protection information was copied over; false if the source block was not protected (false does not indicate a failure, but simply that the source block was not in any try-block)
-
copyProtectedBlock
boolean copyProtectedBlock(int srcBlkOffset, int dstBlkOffset) Copy the protection information of a block to another block.- Parameters:
srcBlkOffset- source block, whose protection information will be copied over to the destination blockdstBlkOffset- destination block, to be protected (if it was protected, the original protection information will be overwritten)- Returns:
- true if some protection information was copied over; false if the source block was not protected (false does not indicate a failure, but simply that the source block was not in any try-block)
-
addProtectionFromBlock
boolean addProtectionFromBlock(int srcBlkOffset, int dstBlkOffset) Append the protection of the source block on to the destination block.- Parameters:
srcBlkOffset- source blockdstBlkOffset- destination block- Returns:
- true if some protection information was appended; false if the source block was not protected (false does not indicate a failure, but simply that the source block was not in any try-block)
-
unprotectBlock
boolean unprotectBlock(int blkOffset) Unprotect a block.- Parameters:
blkOffset- block- Returns:
- true if the block was protected and is now unprotected; false means the block was not protected
-
unprotectBlock
boolean unprotectBlock(int blkOffset, int handlerOffset) Remove a specific protection for a block. All handling leading to the provided handler offset will be removed.- Parameters:
blkOffset- blockhandlerOffset- offset of the handler- Returns:
- true if some changes took place; false otherwise (no change)
-
unprotectBlock
boolean unprotectBlock(int blkOffset, int handlerOffset, int exTypeIndex) Remove a specific specific protection for a block.- Parameters:
blkOffset- blockhandlerOffset- offset of the handlerexTypeIndex- expected handled exception type- Returns:
- true if the handler was removed; false otherwise (no change)
-
updateTargets
Update the targets of this object. All block offsets (protected blocks, handler blocks) will be updated.- Parameters:
oldToNewOffsets- a map of old block offsets to new block offsets- Returns:
- the number of updated targets
-
updateTargets
Update the targets of this object. All block offsets (protected blocks, handler blocks) will be updated.- Parameters:
oldToNewOffsets- a map of old block offsets to new block offsetsfailOnMissedEntry- if true, the method will raise if a (current) branch target cannot be mapped to a new target (i.e., if there is no entry for a branch target in the map)- Returns:
- the number of updated targets
-
updateHandlerAddress
boolean updateHandlerAddress(int handlerAddress, int newAddress) Update the address of a handler.- Parameters:
handlerAddress-newAddress-- Returns:
- true if the handler was found and updated; false if no handler was found at that address
-