Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

problem with gcov, cannot run

Writer Andrew Mclaughlin

So i'm trying to optimize a file called linpack.c. I have to use gcov to find the 10 most executed lines. I've been given these compiler options:

-fprofile-arcs -ftest-coverage -O2

So i ran this

$ gcc -fprofile-arcs -ftest-coverage -O2 linpack.c

the output was linpack, linpack.gcno.

Now when I try to run gcov linpack.c in order to generate linpack.c.gcov I get an error:

linpack.gcda, cannot open data file.

Can someone tell me what I'm doing wrong? This should be straightforward but I have been struggling for more than an hour now.

1 Answer

The linpack.gcda file should get created when you execute the program that you compiled with the profile flags. Since you didn't supply an output file name (using the -o option) on the gcc command line, you will need to execute it as a.out. For example:

$ gcc -fprofile-arcs -ftest-coverage -O2 hello.c
$ ls hello.*
hello.c hello.gcno
$
$ ./a.out
Hello world!
$ ls hello.*
hello.c hello.gcda hello.gcno
$ 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy