drcov duplicate basic blocks

23 views
Skip to first unread message

sea...@andrew.cmu.edu

unread,
Nov 29, 2021, 12:29:08 AM11/29/21
to DynamoRIO Users
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?

Derek Bruening

unread,
Nov 29, 2021, 11:00:56 AM11/29/21
to dynamor...@googlegroups.com
I think you're conflating dynamic execution counts with occasional static blocks that have the same start address.  Please see "transformation time" versus "execution time": http://dynamorio.org/API_BT.html#sec_control_points
and/or our tutorial slides https://github.com/DynamoRIO/dynamorio/releases/download/release_7_0_0_rc1/DynamoRIO-tutorial-feb2017.pdf.  The extra block at 50 iterations is for trace building; other duplicates happen at other points, but none of these are re-built on every execution (that would be too expensive).  If you want dynamic execution counts, code needs to be added to each block to increment a counter.

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/fd7d2630-913f-49eb-b2ab-16a447626757n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages