Package jadx.core.dex.trycatch

Examples of jadx.core.dex.trycatch.CatchAttr


          BlockNode thisBlock = getBlock(jump.getDest(), blocksMap);
          connect(srcBlock, thisBlock);
        }

        // connect exception handlers
        CatchAttr catches = insn.get(AType.CATCH_BLOCK);
        // get synthetic block for handlers
        SplitterBlockAttr spl = block.get(AType.SPLITTER_BLOCK);
        if (catches != null && spl != null) {
          BlockNode splitterBlock = spl.getBlock();
          boolean tryEnd = insn.contains(AFlag.TRY_LEAVE);
          for (ExceptionHandler h : catches.getTryBlock().getHandlers()) {
            BlockNode handlerBlock = getBlock(h.getHandleOffset(), blocksMap);
            // skip self loop in handler
            if (splitterBlock != handlerBlock) {
              connect(splitterBlock, handlerBlock);
            }
View Full Code Here


  private static void searchTryCatchDominators(MethodNode mth, Map<BlockNode, TryCatchBlock> tryBlocksMap) {
    final Set<TryCatchBlock> tryBlocks = new HashSet<TryCatchBlock>();
    // collect all try/catch blocks
    for (BlockNode block : mth.getBasicBlocks()) {
      CatchAttr c = block.get(AType.CATCH_BLOCK);
      if (c != null) {
        tryBlocks.add(c.getTryBlock());
      }
    }

    // for each try block search nearest dominator block
    for (TryCatchBlock tb : tryBlocks) {
      BitSet bs = null;
      // build bitset with dominators of blocks covered with this try/catch block
      for (BlockNode block : mth.getBasicBlocks()) {
        CatchAttr c = block.get(AType.CATCH_BLOCK);
        if (c != null && c.getTryBlock() == tb) {
          if (bs == null) {
            bs = (BitSet) block.getDoms().clone();
          } else {
            bs.and(block.getDoms());
          }
View Full Code Here

    for (InsnNode insn : mth.getInstructions()) {
      if (insn == null) {
        continue;
      }
      // remove 'exception catch' for instruction which don't throw any exceptions
      CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
      if (catchAttr != null) {
        switch (insn.getType()) {
          case RETURN:
          case IF:
          case GOTO:
          case MOVE:
          case MOVE_EXCEPTION:
          case ARITH: // ??
          case NEG:
          case CONST:
          case CONST_STR:
          case CONST_CLASS:
          case CMP_L:
          case CMP_G:
            catchAttr.getTryBlock().removeInsn(insn);
            break;

          default:
            break;
        }
View Full Code Here

          }
          remover.perform();

          for (InsnNode insn : excBlock.getInstructions()) {
            if (insn.getType() == InsnType.THROW) {
              CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
              if (catchAttr != null) {
                TryCatchBlock handlerBlock = handlerAttr.getTryBlock();
                TryCatchBlock catchBlock = catchAttr.getTryBlock();
                if (handlerBlock != catchBlock) {
                  handlerBlock.merge(mth, catchBlock);
                  catchBlock.removeInsn(insn);
                }
              }
View Full Code Here

        code.startLine(getLabelName(insn.getOffset()) + ":");
        code.incIndent();
      }
      try {
        if (insnGen.makeInsn(insn, code)) {
          CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
          if (catchAttr != null) {
            code.add("\t " + catchAttr);
          }
        }
      } catch (CodegenException e) {
View Full Code Here

        remover.perform();

        // if 'throw' in exception handler block have 'catch' - merge these catch blocks
        for (InsnNode insn : excBlock.getInstructions()) {
          if (insn.getType() == InsnType.THROW) {
            CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
            if (catchAttr != null) {
              TryCatchBlock handlerBlock = handlerAttr.getTryBlock();
              TryCatchBlock catchBlock = catchAttr.getTryBlock();
              if (handlerBlock != catchBlock) { // TODO: why it can be?
                handlerBlock.merge(mth, catchBlock);
                catchBlock.removeInsn(insn);
              }
            }
View Full Code Here

    }
  }

  private static void processTryCatchBlocks(MethodNode mth, BlockNode block) {
    // if all instructions in block have same 'catch' attribute mark it as 'TryCatch' block
    CatchAttr commonCatchAttr = null;
    for (InsnNode insn : block.getInstructions()) {
      CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
      if (catchAttr == null) {
        continue;
      }
      if (commonCatchAttr == null) {
        commonCatchAttr = catchAttr;
View Full Code Here

      throw new JadxRuntimeException("Unknown container type: " + container.getClass());
    }
  }

  public static List<IContainer> getExcHandlersForRegion(IContainer region) {
    CatchAttr cb = region.get(AType.CATCH_BLOCK);
    if (cb != null) {
      TryCatchBlock tb = cb.getTryBlock();
      List<IContainer> list = new ArrayList<IContainer>(tb.getHandlersCount());
      for (ExceptionHandler eh : tb.getHandlers()) {
        list.add(eh.getHandlerRegion());
      }
      return list;
View Full Code Here

      IRegion r = (IRegion) container;

      // process sub blocks
      for (IContainer b : r.getSubBlocks()) {
        // process try block
        CatchAttr cb = b.get(AType.CATCH_BLOCK);
        if (cb != null && (b instanceof IRegion)) {
          TryCatchBlock tb = cb.getTryBlock();
          for (ExceptionHandler eh : tb.getHandlers()) {
            if (isRegionContainsRegion(eh.getHandlerRegion(), region)) {
              return true;
            }
          }
View Full Code Here

TOP

Related Classes of jadx.core.dex.trycatch.CatchAttr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.