コード例 #1
0
ファイル: PsExecuteMV.java プロジェクト: evilimp/scouter
  @Override
  public void visitInsn(int opcode) {
    if ((opcode >= IRETURN && opcode <= RETURN)) {
      int lvPosReturn;
      switch (returnType.getSort()) {
        case Type.ARRAY:
          if (returnType.getElementType().getSort() == Type.INT) {
            lvPosReturn = newLocal(returnType);
            mv.visitVarInsn(Opcodes.ASTORE, lvPosReturn);
            mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn);
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(
                GETFIELD,
                owner,
                TraceSQL.CURRENT_TRACESQL_FIELD,
                "Lscouter/agent/batch/trace/TraceSQL;");
            mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADDS_METHOD, ADDS_SIGNATURE, false);
          }
          break;
        case Type.INT:
          lvPosReturn = newLocal(returnType);
          mv.visitVarInsn(Opcodes.ISTORE, lvPosReturn);
          mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn);
          mv.visitVarInsn(ALOAD, 0);
          mv.visitFieldInsn(
              GETFIELD,
              owner,
              TraceSQL.CURRENT_TRACESQL_FIELD,
              "Lscouter/agent/batch/trace/TraceSQL;");
          mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn);
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADD_METHOD, ADD_SIGNATURE, false);
          break;
          /*           case Type.BOOLEAN:
               	lvPosReturn = newLocal(returnType);
                   mv.visitVarInsn(Opcodes.ISTORE, lvPosReturn);
          mv.visitVarInsn(ALOAD, 0);
             mv.visitFieldInsn(GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;");
                   mv.visitVarInsn(ALOAD, 0);
          mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, STATMENT, GETUPDATECOUNT_METHOD, GETUPDATECOUNT_SIGNATURE,false);
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, ADD_METHOD, ADD_SIGNATURE,false);
                   mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn);
               	break;*/
      }

      // Return 결과 셋팅
      mv.visitVarInsn(ALOAD, 0);
      mv.visitFieldInsn(
          GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;");
      mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, END_METHOD, END_SIGNATURE, false);
    }

    mv.visitInsn(opcode);
  }
コード例 #2
0
ファイル: InitialContextASM.java プロジェクト: mymee/scouter
 public InitialContextMV(
     int access,
     String desc,
     MethodVisitor mv,
     String classname,
     String methodname,
     String methoddesc) {
   super(ASM4, access, desc, mv);
   this.returnType = Type.getReturnType(desc);
 }
コード例 #3
0
ファイル: MethodASM.java プロジェクト: breadval/scouter
  @Override
  public void visitCode() {
    AsmUtil.PUSH(mv, fullname_hash);
    mv.visitLdcInsn(fullname);

    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false);

    statIdx = newLocal(Type.getType(Object.class));

    mv.visitVarInsn(Opcodes.ASTORE, statIdx);
    mv.visitLabel(startFinally);
    mv.visitCode();
  }
コード例 #4
0
ファイル: SqlMapASM.java プロジェクト: KUNHO-YANG/scouter
  @Override
  public void visitCode() {

    AsmUtil.PUSH(mv, methodName);

    boolean flag = false;
    int sidx = isStatic ? 0 : 1;
    for (int i = 0; i < paramTypes.length; i++) {
      Type tp = paramTypes[i];
      if ("java/lang/String".equals(tp.getInternalName())) {
        mv.visitVarInsn(Opcodes.ALOAD, sidx);
        flag = true;
        break;
      }
      sidx += tp.getSize();
    }

    if (flag == false) {
      AsmUtil.PUSH(mv, "");
    }
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false);
    super.visitCode();
  }
コード例 #5
0
ファイル: MethodASM.java プロジェクト: breadval/scouter
  @Override
  public void visitMaxs(int maxStack, int maxLocals) {
    Label endFinally = new Label();
    mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null);
    mv.visitLabel(endFinally);
    mv.visitInsn(DUP);
    int errIdx = newLocal(Type.getType(Throwable.class));
    mv.visitVarInsn(Opcodes.ASTORE, errIdx);

    mv.visitVarInsn(Opcodes.ALOAD, statIdx);
    mv.visitVarInsn(Opcodes.ALOAD, errIdx);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false);
    mv.visitInsn(ATHROW);
    mv.visitMaxs(maxStack + 8, maxLocals + 2);
  }
コード例 #6
0
ファイル: PsExecuteMV.java プロジェクト: evilimp/scouter
  @Override
  public void visitMaxs(int maxStack, int maxLocals) {
    Label endFinally = new Label();
    mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null);
    mv.visitLabel(endFinally);

    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(
        GETFIELD, owner, TraceSQL.CURRENT_TRACESQL_FIELD, "Lscouter/agent/batch/trace/TraceSQL;");
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TRACESQL, END_METHOD, END_SIGNATURE, false);

    int errIdx = newLocal(Type.getType(Throwable.class));
    mv.visitVarInsn(Opcodes.ASTORE, errIdx);
    mv.visitInsn(ATHROW);

    mv.visitMaxs(maxStack + 8, maxLocals + 2);
  }
コード例 #7
0
ファイル: SqlMapASM.java プロジェクト: KUNHO-YANG/scouter
 @Override
 public MethodVisitor visitMethod(
     int access, String methodName, String desc, String signature, String[] exceptions) {
   MethodVisitor mv = super.visitMethod(access, methodName, desc, signature, exceptions);
   if (mv == null) {
     return mv;
   }
   if (SqlMapASM.targetMethod.contains(methodName) == false) {
     return mv;
   }
   return new SqlMapMV(
       access,
       desc,
       mv,
       Type.getArgumentTypes(desc),
       (access & ACC_STATIC) != 0,
       className,
       methodName,
       desc);
 }
コード例 #8
0
ファイル: PsExecuteMV.java プロジェクト: evilimp/scouter
 public PsExecuteMV(int access, String desc, MethodVisitor mv, String owner, String name) {
   super(ASM4, access, desc, mv);
   this.owner = owner;
   this.returnType = Type.getReturnType(desc);
 }
コード例 #9
0
ファイル: PsExecuteMV.java プロジェクト: evilimp/scouter
 public static void main(String[] args) {
   Type type = Type.getReturnType("(Z)[I");
   System.out.println("type = " + type.getSort());
   System.out.println("dim = " + type.getDimensions());
   System.out.println("element = " + type.getElementType());
 }