From 5a39be832268d5263c7103f68309781a1b98901f Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Wed, 18 Aug 2021 21:13:40 +0200 Subject: [PATCH] add hook for manually adding coverage data (#41904) This would allow packages like JuliaInterpreter to properly report coverage data. --- src/codegen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/codegen.cpp b/src/codegen.cpp index d05080ee4216e..744d29629b0ca 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1897,6 +1897,16 @@ static void coverageAllocLine(StringRef filename, int line) allocLine(coverageData[filename], line); } +extern "C" JL_DLLEXPORT void jl_coverage_visit_line(const char* filename_, size_t len_filename, int line) +{ + StringRef filename = StringRef(filename_, len_filename); + if (imaging_mode || filename == "" || filename == "none" || filename == "no file" || filename == "" || line < 0) + return; + std::vector &vec = coverageData[filename]; + uint64_t *ptr = allocLine(vec, line); + (*ptr)++; +} + // Memory allocation log (malloc_log) static logdata_t mallocData;