GCC6.3.0: flag “--coverage” not functioning (no gdca files generated)

血红的双手。 提交于 2020-01-11 12:56:29

问题


Having a code snippet in C and the same in C++, which generates gdca files executing the exe which is compiled with GCC 4.1.2. The same code snippet compiled with GCC6.3.0 after executing is not generating gdca files, not the C.exe not the c++.exe

I found out that the implementation of the gcov library is different, in GCC4.1.2 and GCC6.3.0, the version of the gcov library in GCC6.3.0 seems to be empty:

_gcov_merge_add.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_merge_add>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov_merge_single.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_merge_single>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov_merge_delta.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_merge_delta>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov_merge_ior.o:     file format elf32-i386
_gcov_merge_time_profile.o:     file format elf32-i386
_gcov_merge_icall_topn.o:     file format elf32-i386
_gcov_interval_profiler.o:     file format elf32-i386
_gcov_pow2_profiler.o:     file format elf32-i386
_gcov_one_value_profiler.o:     file format elf32-i386
_gcov_indirect_call_profiler.o:     file format elf32-i386
_gcov_average_profiler.o:     file format elf32-i386
_gcov_ior_profiler.o:     file format elf32-i386

_gcov_indirect_call_profiler_v2.o:     file format elf32-i386

_gcov_time_profiler.o:     file format elf32-i386
_gcov_indirect_call_topn_profiler.o:     file format elf32-i386
_gcov_dump.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_dump>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov_flush.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_flush>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov_fork.o:     file format elf32-i386
_gcov_execl.o:     file format elf32-i386
_gcov_execlp.o:     file format elf32-i386
_gcov_execle.o:     file format elf32-i386
_gcov_execv.o:     file format elf32-i386
_gcov_execvp.o:     file format elf32-i386
_gcov_execve.o:     file format elf32-i386
_gcov_reset.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_reset>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
_gcov.o:     file format elf32-i386

Disassembly of section .text:
00000000 <__gcov_init>:
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret

The gcov within the GCC 6.3.0 was build with following flags:

/usr/gnu/gcc/V6.3.0/gcc-6.3.0_build/./gcc/xgcc
-B/usr/gnu/gcc/V6.3.0/gcc-6.3.0_build/./gcc/
-B/opt/V6.3.0/i686-elf/bin/ -B/opt/V6.3.0/i686-elf/lib/ -isystem
/opt/V6.3.0/i686-elf/include -isystem /opt/V6.3.0/i686-elf/sys-include
-fpic -O2 -mpreferred-stack-boundary=3 -O2  -fpic -O2
-mpreferred-stack-boundary=3 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W
-Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition  -isystem ./include
-fpic -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector
-Dinhibit_libc  -fpic -I. -I. -I../.././gcc
-I../../../gcc-6.3.0/libgcc -I../../../gcc-6.3.0/libgcc/.
-I../../../gcc-6.3.0/libgcc/../gcc
-I../../../gcc-6.3.0/libgcc/../include    -o _gcov_flush.o -MT
_gcov_flush.o -MD -MP -MF _gcov_flush.dep -DL_gcov_flush -c
../../../gcc-6.3.0/libgcc/libgcov-interface.c

Any idea what could be wrong with the gcov library? Or is anything else missing in the GCC6.3.0? Does anybody else having difficulties with gcov under GCC 6.3.0?


回答1:


When the target != host, and your libc flag is set to true, you will not get the gcov library implemented, object dump of gcov.a shows no implementation. In such a case, set the inhibit-libc flag for libgcc to false, recompile and you have gcov implemented.



来源:https://stackoverflow.com/questions/53298186/gcc6-3-0-flag-coverage-not-functioning-no-gdca-files-generated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!