Skip to content

Commit 179394c

Browse files
committed
Create jl_clear_coverage_data to dynamically reset coverage
1 parent da6892f commit 179394c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/coverage.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,37 @@ JL_DLLEXPORT uint64_t *jl_malloc_data_pointer(StringRef filename, int line)
7777
return allocLine(mallocData[filename], line);
7878
}
7979

80-
// Resets the malloc counts.
81-
extern "C" JL_DLLEXPORT void jl_clear_malloc_data(void)
80+
static void clear_log_data(logdata_t &logData, int resetValue)
8281
{
83-
logdata_t::iterator it = mallocData.begin();
84-
for (; it != mallocData.end(); it++) {
82+
logdata_t::iterator it = logData.begin();
83+
for (; it != logData.end(); it++) {
8584
SmallVector<logdata_block*, 0> &bytes = (*it).second;
8685
SmallVector<logdata_block*, 0>::iterator itb;
8786
for (itb = bytes.begin(); itb != bytes.end(); itb++) {
8887
if (*itb) {
8988
logdata_block &data = **itb;
9089
for (int i = 0; i < logdata_blocksize; i++) {
9190
if (data[i] > 0)
92-
data[i] = 1;
91+
data[i] = resetValue;
9392
}
9493
}
9594
}
9695
}
9796
jl_gc_sync_total_bytes(0);
9897
}
9998

99+
// Resets the malloc counts.
100+
extern "C" JL_DLLEXPORT void jl_clear_malloc_data(void)
101+
{
102+
clear_log_data(mallocData, 1);
103+
}
104+
105+
// Resets the code coverage
106+
extern "C" JL_DLLEXPORT void jl_clear_coverage_data(void)
107+
{
108+
clear_log_data(coverageData, 0);
109+
}
110+
100111
static void write_log_data(logdata_t &logData, const char *extension)
101112
{
102113
std::string base = std::string(jl_options.julia_bindir);

0 commit comments

Comments
 (0)