0

Due to very limited memory amounts, I would like to modify the size of the counters (currently 64 bits) used for coverage data with gcov (gcc -fprofile-arcs -ftest-coverage), and need some guidance in order to achieve this.

  1. Is it possible to alter the size of the counters without modifying and recompiling gcc?

  2. If 1 is not possible, what parts of gcc need to be altered in order to use 32 bit (or even smaller) counters instead?

Thank you in advance for any input that may be helpful.

MartinSuecia
  • 111
  • 2
  • 6

1 Answers1

0

GCC instrument the (counter increase) statement in its source code, so I don't think it's possible not to modify GCC itself.

For question 2: GCC instrument counter code in this process: (profile.c/branch_prob)-->(profile.c/instrument_edges)-->(profile.c/gen_edge_profiler)

profile.c is source file of GCC under GCC_SOURCE_CODE/gcc. Function branch_prob will allocate all the counters(as you know, each in 8 bytes), so this is the first part you need to modify. Function gen_edge_profiler generate the rtl(turned into assembly after compilation) code to increase the counter, you should modify the (ADD instruction) generated in it. This two function is the most important, and you also need to modify gcov read write functions to fit in with (4 bytes counter).

ShenYi
  • 121
  • 1
  • 7