riscv-software-src / riscv-tools

RISC-V Tools (ISA Simulator and Tests)
1.13k stars 446 forks source link

Is Gcov work on riscv arch? #219

Closed BaikalHu closed 6 years ago

BaikalHu commented 6 years ago

Hi all,

Is libgcov.a and '-fprofile-arcs -ftest-coverage' option work on riscv arch? How to use libgcov.a on SiFive E31 RISC-V Core? I just want to use uart to transfer the GCOV data to PC,could someone give the suggestion? Thanks.

jim-wilson commented 6 years ago

The gcov support is mostly target independent. It should work fine for RISC-V. For an embedded target, the main problem will be getting the results off the board. Normally gcov will write results to a file on exit. If you don't have file I/O, then you have to get the results off the board some other way. Using gdb is one possibility. Which ever way you choose, you may have to write some code yourself, as I don't think there is any standard solution for this. If your program doesn't call exit, there are some hooks you can call. __gcov_reset resets the gcov data. __gcov_dump collects the data for dumping to a file, or for grabbing some other way.

A web search for "gcov gdb embedded" shows a number of links that talk about using gcov in an embedded environment with gdb.

BaikalHu commented 6 years ago

@jim-wilson Thanks for your suggestion. I'll try to do some tests.