While reading the source for drcov (drcovlib.c), I noticed the following comment:
/* We allow duplicated basic blocks for the following reasons:
* 1. Avoids handling issues like code cache consistency, e.g.,
* module load/unload, self-modifying code, etc.
* 2. Avoids the overhead on duplication check.
* 3. Stores more information on code cache events, e.g., trace building,
* repeated bb building, etc.
* 4. The duplication can be easily handled in a post-processing step,
* which is required anyway.
*/
I compiled the following program with no optimizations:
#include <stdio.h>
void bar(int n) {
printf("%d\n", n);
}
int main() {
for (int i = 0; i < 10; i++) {
bar(i);
}
}
I ran drcov on the compiled binary:
bin64/drrun -v -t drcov -dump_text -- ./a.out
However, the log file does not have the output I expect. All basic blocks in the module for the compiled binary occur only once. Interestingly, some basic blocks related to the loop occur twice if the loop has at least 50 iterations.
Based on the drcov source, I was expecting to see basic blocks repeated for each iteration of the loop. Is this is a bug, and if not, how could I reliably have basic blocks duplicated?