1 // Copyright 2022 Code Intelligence GmbH 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package com.code_intelligence.jazzer.instrumentor; 16 17 import com.code_intelligence.jazzer.third_party.org.jacoco.core.internal.instr.InstrSupport; 18 import org.objectweb.asm.MethodVisitor; 19 import org.objectweb.asm.Opcodes; 20 21 public class StaticMethodStrategy implements EdgeCoverageStrategy { 22 @Override instrumentControlFlowEdge( MethodVisitor mv, int edgeId, int variable, String coverageMapInternalClassName)23 public void instrumentControlFlowEdge( 24 MethodVisitor mv, int edgeId, int variable, String coverageMapInternalClassName) { 25 InstrSupport.push(mv, edgeId); 26 mv.visitMethodInsn( 27 Opcodes.INVOKESTATIC, coverageMapInternalClassName, "recordCoverage", "(I)V", false); 28 } 29 30 @Override getInstrumentControlFlowEdgeStackSize()31 public int getInstrumentControlFlowEdgeStackSize() { 32 return 1; 33 } 34 35 @Override getLocalVariableType()36 public Object getLocalVariableType() { 37 return null; 38 } 39 40 @Override loadLocalVariable( MethodVisitor mv, int variable, String coverageMapInternalClassName)41 public void loadLocalVariable( 42 MethodVisitor mv, int variable, String coverageMapInternalClassName) {} 43 44 @Override getLoadLocalVariableStackSize()45 public int getLoadLocalVariableStackSize() { 46 return 0; 47 } 48 } 49