Skip to content

Commit

Permalink
Create jl_clear_coverage_data to dynamically reset coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed May 4, 2024
1 parent da6892f commit f9ace68
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,36 @@ JL_DLLEXPORT uint64_t *jl_malloc_data_pointer(StringRef filename, int line)
return allocLine(mallocData[filename], line);
}

// Resets the malloc counts.
extern "C" JL_DLLEXPORT void jl_clear_malloc_data(void)
static void clear_log_data(logdata_t &logData, int resetValue)
{
logdata_t::iterator it = mallocData.begin();
for (; it != mallocData.end(); it++) {
logdata_t::iterator it = logData.begin();
for (; it != logData.end(); it++) {
SmallVector<logdata_block*, 0> &bytes = (*it).second;
SmallVector<logdata_block*, 0>::iterator itb;
for (itb = bytes.begin(); itb != bytes.end(); itb++) {
if (*itb) {
logdata_block &data = **itb;
for (int i = 0; i < logdata_blocksize; i++) {
if (data[i] > 0)
data[i] = 1;
data[i] = resetValue;
}
}
}
}
jl_gc_sync_total_bytes(0);
}

// Resets the malloc counts.
extern "C" JL_DLLEXPORT void jl_clear_malloc_data(void)
{
clear_log_data(mallocData, 1);
}

// Resets the code coverage
extern "C" JL_DLLEXPORT void jl_clear_coverage_data(void)
{
clear_log_data(coverageData, 0);
}

static void write_log_data(logdata_t &logData, const char *extension)
{
std::string base = std::string(jl_options.julia_bindir);
Expand Down

0 comments on commit f9ace68

Please sign in to comment.