This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Problems with gcov
- From: "Andrew Wall" <andrew dot j dot wall at ntlworld dot com>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Sun, 1 Aug 2004 21:51:23 +0100
- Subject: Problems with gcov
Hi,
I've asked on the comp.os.msdos.djgpp newsgroup about gcov and been refered
to you.
I'm using gpp/gcov from djgpp versions 3.4.1 on Windows XP.
I have written 'testctor.cpp' and 'testctor.bat' which produces the output
'testctor.cpp.gcov':
testctor.cpp: which is a small test program which has a static instance of a
class with both a constructor and a destructor.
===============
// Test constructors/destructors:
#include <iostream>
using namespace std;
class Test {
public:
Test(void){
cout<< "In Test ctor" << endl;
}
~Test(void){
cout<< "In Test dtor" << endl;
}
}T1;
void uncalled(void){
cout<< "In uncalled" << endl;
}
int main(void){
// Test T2;
cout<< "In main" << endl;
return 0;
}
===============
Testctor.bat:
===============
gpp -o testctor.exe testctor.cpp -fprofile-arcs -ftest-coverage -lgcov
testctor.exe
gcov testctor.cpp
===============
which shows how I compiled the above source file, ran the resulting program
and ran gcov to produce a .gcov output.
testctor.cpp.gcov
===============
-: 0:Source:testctor.cpp
-: 0:Graph:testctor.gcno
-: 0:Data:testctor.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:// Test constructors/destructors:
-: 2:#include <iostream>
-: 3:using namespace std;
-: 4:class Test {
-: 5:public:
function _ZN4TestC1Ev called 1 returned 100% blocks executed 100%
1: 6: Test(void){
1: 7: cout<< "In Test ctor" << endl;
-: 8: }
function _ZN4TestD1Ev called 0 returned 0% blocks executed 0%
#####: 9: ~Test(void){
#####: 10: cout<< "In Test dtor" << endl;
-: 11: }
1: 12:}T1;
-: 13:
function _Z8uncalledv called 0 returned 0% blocks executed 0%
#####: 14:void uncalled(void){
#####: 15: cout<< "In uncalled" << endl;
-: 16:}
function main called 1 returned 100% blocks executed 100%
1: 17:int main(void){
-: 18:// Test T2;
1: 19:cout<< "In main" << endl;
1: 20:return 0;
function _Z41__static_initialization_and_destruction_0ii called 1 returned
100% blocks executed 76%
2: 21:}
function _GLOBAL__I_T1 called 1 returned 100% blocks executed 100%
2: 22:/*EOF*/
function _GLOBAL__D_T1 called 0 returned 0% blocks executed 0%
#####: 23:/*EOF*/
===============
The problem I can see is that while gcov correcty reports that the function
'void uncalled(void)' is in fact not called, it incorrectly reports that the
destructor ~Test(void) is not called.
The run of the program demonstrates that the destructor _is_ called.
Can you give me any help with this?
Andrew Wall
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27/07/2004