aboutsummaryrefslogtreecommitdiff
path: root/third_party/jacoco-make-probe-adapter-subclassable.patch
diff options
context:
space:
mode:
authorFabian Meumertzheim <meumertzheim@code-intelligence.com>2021-04-20 16:18:23 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2021-04-26 15:51:38 +0200
commit17d3abf666c87b66036abcee7554d6418cabcfe2 (patch)
treef845afeb860e41c42e9a75931d310000ce22f199 /third_party/jacoco-make-probe-adapter-subclassable.patch
parentf1cbb0056b3c9076e2bd285bb5e707a26a514d9c (diff)
downloadjazzer-api-17d3abf666c87b66036abcee7554d6418cabcfe2.tar.gz
Add option to generate coverage report
The new --coverage_report option triggers a coverage report to be written on fuzzer exit. The report is generated with the JaCoCo analyzer. The information about observed coverage IDs is obtained from libFuzzer and combined with the coverage obtained during fuzzerInitialize as well as the current run.
Diffstat (limited to 'third_party/jacoco-make-probe-adapter-subclassable.patch')
-rw-r--r--third_party/jacoco-make-probe-adapter-subclassable.patch84
1 files changed, 81 insertions, 3 deletions
diff --git a/third_party/jacoco-make-probe-adapter-subclassable.patch b/third_party/jacoco-make-probe-adapter-subclassable.patch
index 2d78a900..2946fa8f 100644
--- a/third_party/jacoco-make-probe-adapter-subclassable.patch
+++ b/third_party/jacoco-make-probe-adapter-subclassable.patch
@@ -1,9 +1,76 @@
-commit 93d0421590e59026c595090c468be0caa58a7948
+commit 96d079e68e8897c425d85c7a5ff0afc755b246eb
Author: Fabian Meumertzheim <meumertzheim@code-intelligence.com>
Date: Tue Apr 20 08:06:09 2021 +0200
Updated Jazzer patch
+diff --git org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
+index 0cc06ada..b65efb03 100644
+--- org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
++++ org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
+@@ -31,6 +31,8 @@ import org.jacoco.core.internal.analysis.ClassCoverageImpl;
+ import org.jacoco.core.internal.analysis.StringPool;
+ import org.jacoco.core.internal.data.CRC64;
+ import org.jacoco.core.internal.flow.ClassProbesAdapter;
++import org.jacoco.core.internal.flow.ClassProbesVisitor;
++import org.jacoco.core.internal.flow.IClassProbesAdapterFactory;
+ import org.jacoco.core.internal.instr.InstrSupport;
+ import org.objectweb.asm.ClassReader;
+ import org.objectweb.asm.ClassVisitor;
+@@ -52,6 +54,8 @@ public class Analyzer {
+
+ private final StringPool stringPool;
+
++ private final IClassProbesAdapterFactory classProbesAdapterFactory;
++
+ /**
+ * Creates a new analyzer reporting to the given output.
+ *
+@@ -63,9 +67,21 @@ public class Analyzer {
+ */
+ public Analyzer(final ExecutionDataStore executionData,
+ final ICoverageVisitor coverageVisitor) {
++ this(executionData, coverageVisitor, new IClassProbesAdapterFactory() {
++ @Override
++ public ClassProbesAdapter makeClassProbesAdapter(ClassProbesVisitor cv, boolean trackFrames) {
++ return new ClassProbesAdapter(cv, trackFrames);
++ };
++ });
++ }
++
++ public Analyzer(final ExecutionDataStore executionData,
++ final ICoverageVisitor coverageVisitor,
++ final IClassProbesAdapterFactory classProbesAdapterFactory) {
+ this.executionData = executionData;
+ this.coverageVisitor = coverageVisitor;
+ this.stringPool = new StringPool();
++ this.classProbesAdapterFactory = classProbesAdapterFactory;
+ }
+
+ /**
+@@ -99,7 +115,7 @@ public class Analyzer {
+ coverageVisitor.visitCoverage(coverage);
+ }
+ };
+- return new ClassProbesAdapter(analyzer, false);
++ return classProbesAdapterFactory.makeClassProbesAdapter(analyzer, false);
+ }
+
+ private void analyzeClass(final byte[] source) {
+diff --git org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
+index a69f34c8..ea1f0352 100644
+--- org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
++++ org.jacoco.core/src/org/jacoco/core/internal/analysis/InstructionsBuilder.java
+@@ -147,7 +147,8 @@ class InstructionsBuilder {
+ */
+ void addProbe(final int probeId, final int branch) {
+ final boolean executed = probes != null && probes[probeId];
+- currentInsn.addBranch(executed, branch);
++ if (currentInsn != null)
++ currentInsn.addBranch(executed, branch);
+ }
+
+ /**
diff --git org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java
index 3ed19a88..f2b4f5d3 100644
--- org.jacoco.core/src/org/jacoco/core/internal/flow/ClassProbesAdapter.java
@@ -58,9 +125,21 @@ index 3ed19a88..f2b4f5d3 100644
if (trackFrames) {
final AnalyzerAdapter analyzer = new AnalyzerAdapter(
ClassProbesAdapter.this.name, access, name, desc,
+diff --git org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java
+new file mode 100644
+index 00000000..45fc2709
+--- /dev/null
++++ org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java
+@@ -0,0 +1,6 @@
++package org.jacoco.core.internal.flow;
++
++public interface IClassProbesAdapterFactory {
++ ClassProbesAdapter makeClassProbesAdapter(ClassProbesVisitor cv,
++ boolean trackFrames);
++}
diff --git org.jacoco.core/src/org/jacoco/core/internal/flow/IMethodProbesAdapterFactory.java org.jacoco.core/src/org/jacoco/core/internal/flow/IMethodProbesAdapterFactory.java
new file mode 100644
-index 00000000..e939fa31
+index 00000000..4e5460f1
--- /dev/null
+++ org.jacoco.core/src/org/jacoco/core/internal/flow/IMethodProbesAdapterFactory.java
@@ -0,0 +1,8 @@
@@ -72,7 +151,6 @@ index 00000000..e939fa31
+ MethodProbesAdapter makeMethodProbesAdapter(MethodProbesVisitor probesVisitor,
+ IProbeIdGenerator idGenerator);
+}
-\ No newline at end of file
diff --git org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java
index 30253d02..e019a290 100644
--- org.jacoco.core/src/org/jacoco/core/internal/flow/MethodProbesAdapter.java