Results 1 to 1 of 1
Hello all,
I'm using gcov (gcc's extension) for code coverage. I wish to use it with g++ (for c++ code). Normally works fine.
The problem arises when i try to ...
- 11-27-2008 #1Just Joined!
- Join Date
- Feb 2005
- Posts
- 4
gcov with g++
Hello all,
I'm using gcov (gcc's extension) for code coverage. I wish to use it with g++ (for c++ code). Normally works fine.
The problem arises when i try to use an embedded gcov's function (__gcov_flush()) in order to get coverage data for a running process (non terminating).
Please see the example below:
My sample code looks like this (test.cpp):
I compile the program:Code:#include <iostream> using namespace std; void one(void); void two(void); int main(void) { int i; while(true) { __gcov_flush(); cout << "Enter a number(1-2), 0 to exit " << endl; cin >> i; if ( i == 1 ) one(); else if ( i == 2 ) two(); else if ( i == 0 ) break; else continue; } return 0; } void one(void) { cout << "One is called" << endl; } void two(void) { cout << "Two is called" << endl; }
and the linker complains:Code:g++ -fprofile-arcs -ftest-coverage test.cpp -o test
Some notes in order to save some time:Code:test.cpp:(.text+0x1d9): undefined reference to `__gcov_flush()' collect2: ld returned 1 exit status
1. The c version of this program (with the invocation of the specified function) compiles fine (using gcc)
2. The c++ version of the above program (without the invocation of the specified function) compiles fine (using g++)
3. Placing -lgcov during compilation doesn't work
4. Placing something like:doesn't workCode:extern void __gcov_flush(void);
So i'd like to ask if the operation that i am trying, is valid/supported for g++ and if yes what am i missing?
PS: My system has:
1. SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2
2. gcov (GCC) 4.1.2 20070115 (SUSE Linux)
TIA
panagiotis


Reply With Quote