Hi ,
I am having problem understanding branches ( number ) generated by gcov
report for
c++ program. Might you please clear my doubts.
#include<iostream>
using namespace std;
class A
{
public:
A()
{
}
virtual void functionABC (int value)
{
cout<<value;
}
virtual ~A()
{
}
};
class B : public virtual A
{
public:
B()
{
}
virtual ~B()
{
}
};
class C : public B
{
public:
C()
{
}
virtual ~C()
{
}
};
int main(int argc, char ** argv)
{
A a;
B b;
C c;
return 0;
}
Gcov report for the following is attached.
Any help will be greatly appreciated.
--
Thanks& Regards,
Rohit Gupta
-: 0:Source:test.cpp
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include <iostream>
-: 2:
-: 3:using namespace std;
-: 4:
-: 5:class A
-: 6:{
-: 7:public:
function A::A() called 3 returned 100% blocks executed 100%
3: 8: A()
3: 9: {
3: 10: cout<<"In A constructor\n";
call 0 returned 100%
3: 11: }
function A::functionABC(int) called 0 returned 0% blocks executed 0%
#####: 12: virtual void functionABC (int value)
-: 13: {
#####: 14: cout<<value;
call 0 never executed
#####: 15: }
function A::~A() called 3 returned 100% blocks executed 75%
function A::~A() called 0 returned 0% blocks executed 0%
3: 16: virtual ~A()
3: 17: {
3: 18: cout<<"In A Destructor\n";
call 0 returned 100%
3: 19: }
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
call 2 never executed
call 3 never executed
call 4 never executed
-: 20:};
-: 21:class B : public virtual A
-: 22:{
-: 23:public:
function B::B() called 1 returned 100% blocks executed 67%
function B::B() called 1 returned 100% blocks executed 50%
2: 24: B()
2: 25: {
call 0 returned 100%
2: 26: cout<<"In B constructor\n";
call 0 returned 100%
call 1 returned 100%
2: 27: }
call 0 never executed
function B::~B() called 1 returned 100% blocks executed 40%
function B::~B() called 1 returned 100% blocks executed 50%
function B::~B() called 0 returned 0% blocks executed 0%
2: 28: virtual ~B()
2: 29: {
2: 30: cout<<"In B Destructor\n";
call 0 returned 100%
call 1 returned 100%
2: 31: }
branch 0 taken 0%
branch 1 taken 100%
branch 2 never executed
branch 3 never executed
call 4 never executed
call 5 never executed
call 6 never executed
branch 7 taken 0% (fallthrough)
branch 8 taken 100%
call 9 never executed
branch 10 taken 100%
branch 11 taken 0%
branch 12 never executed
branch 13 never executed
call 14 never executed
call 15 never executed
call 16 returned 100%
branch 17 taken 0% (fallthrough)
branch 18 taken 100%
call 19 never executed
call 20 never executed
call 21 never executed
-: 32:};
-: 33:class C : public B
-: 34:{
-: 35:public:
function C::C() called 1 returned 100% blocks executed 40%
1: 36: C()
1: 37: {
call 0 returned 100%
call 1 returned 100%
1: 38: cout<<"In C constructor\n";
call 0 returned 100%
1: 39: }
call 0 never executed
call 1 never executed
function C::~C() called 1 returned 100% blocks executed 43%
function C::~C() called 0 returned 0% blocks executed 0%
1: 40: virtual ~C()
1: 41: {
1: 42: cout<<"In C Destructor\n";
call 0 returned 100%
1: 43: }
call 0 returned 100%
call 1 never executed
branch 2 taken 100%
branch 3 taken 0%
branch 4 never executed
branch 5 never executed
call 6 never executed
call 7 never executed
call 8 returned 100%
branch 9 taken 0% (fallthrough)
branch 10 taken 100%
call 11 never executed
call 12 never executed
call 13 never executed
-: 44:
-: 45:};
-: 46:
function main called 1 returned 100% blocks executed 54%
1: 47:int main(int argc, char ** argv)
-: 48:{
-: 49:
1: 50: A a;
call 0 returned 100%
1: 51: B b;
call 0 returned 100%
1: 52: C c;
call 0 returned 100%
1: 53: return 0;
call 0 returned 100%
call 1 returned 100%
call 2 never executed
call 3 returned 100%
call 4 never executed
function __static_initialization_and_destruction_0(int, int) called 1 returned 100% blocks executed 100%
function global constructors keyed to main called 1 returned 100% blocks executed 100%
3: 54:}
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
call 4 returned 100%