Interface IDTryData


public interface IDTryData
dexdec exception handling information, optionally provided by an IR method context.
See Also:
  • 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 of hasProtectedBlocks().
      Returns:
      true if not a single block is protected
    • hasProtectedBlocks

      boolean hasProtectedBlocks()
      Determine whether this object carries some protection information. The reverse of isEmpty().
      Returns:
      true if at least one block is protected
    • getProtectedBlocks

      List<Integer> 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

      List<IDExceptionHandler> getHandlers(int handlerAddress)
      Parameters:
      handlerAddress -
      Returns:
    • getHandledExceptionTypesAt

      Set<Integer> getHandledExceptionTypesAt(int handlerOffset)
      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

      List<IDExceptionHandler> getBlockHandlers(int blkOffset)
      Retrieve the handlers protecting the provided block.
      Parameters:
      blkOffset - block
      Returns:
      the list of handlers protecting the provided block
    • setBlockHandlers

      void setBlockHandlers(int blkOffset, Collection<IDExceptionHandler> handlers)
      Set the handlers for the provided block. The list of provided handlers will be copied.
      Parameters:
      blkOffset - block
      handlers - 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 block
      blkOffset2 - 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 - block
      exTypeIndex - exception type index (-1 means untyped, i.e., all types)
      handlerOffset - offset of the handler entry-point
      position - 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

      boolean replaceHandler(int blkOffset, IDExceptionHandler handler, IDExceptionHandler newHandler)
      Replace or remove a handler by reference.
      Parameters:
      blkOffset - protected block offset
      handler - mandatory handler
      newHandler - 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 block
      dstBlkOffset - 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 block
      dstBlkOffset - 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 block
      dstBlkOffset - 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 - block
      handlerOffset - 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 - block
      handlerOffset - offset of the handler
      exTypeIndex - expected handled exception type
      Returns:
      true if the handler was removed; false otherwise (no change)
    • updateTargets

      int updateTargets(Map<Integer,Integer> oldToNewOffsets)
      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

      int updateTargets(Map<Integer,Integer> oldToNewOffsets, boolean failOnMissedEntry)
      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
      failOnMissedEntry - 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