我正在cashier课堂上做代码报道,我的老师对报告的意义做了非常简短的介绍,我觉得这对我的软件工程技能的发展非常重要。因此,我需要你对以下gcov报告的解释提出建议。我希望任何有助于我理解gcov的链接或文章。
头文件
#ifndef CASHIER_H
#define CASHIER_H
#include <string>
using namespace std;
class cashier
{
public:
void setID(string);
string getID();
void setPassword(string);
string getPassword();
void settries(int);
int gettries();
void increase_tries();
private:
string ID;
string Password;
int tries;
};
#endif /* CASHIER_H */实现文件
#include "cashier.h"
void cashier::setID(string value)
{
this->ID = value;
}
void cashier::setPassword(string value)
{
this->Password = value;
}
string cashier::getID()
{
return this->ID;
}
string cashier::getPassword()
{
return this->Password;
}
void cashier::settries(int value)
{
this->tries=value;
}
int cashier::gettries()
{
return this->tries;
}
void cashier::increase_tries()
{
this->tries = this->tries + 1 ;
}我在命令提示符中键入以下命令,以便在类中使用gcov
gcov -b cashier.gnco我得到了以下结果
File 'cashier.cpp'
Lines executed:100.00% of 18 //what does the 18 mean
No branches //what does no branches mean
Calls executed:100.00% of 4 // what does 4 mean ??
cashier.cpp:creating 'cashier.cpp.gcov'
File '/usr/include/c++/4.4/bits/basic_string.h' // Where did this come from ??
Lines executed:0.00% of 2
No branches
Calls executed:0.00% of 1
/usr/include/c++/4.4/bits/basic_string.h:creating 'basic_string.h.gcov我输入以下命令
gcov -f cashier.gnco我得到了以下结果
Function '_ZN7cashier8settriesEi' // does this refer to the function :settries
Lines executed:100.00% of 3 // my teacher doesnt think so but i feel it refer
//to it , who is correct??
Function '_ZN7cashier8gettriesEv'
Lines executed:100.00% of 2
Function '_ZN7cashier14increase_triesEv'
Lines executed:100.00% of 3
Function '_ZN7cashier11getPasswordEv'
Lines executed:100.00% of 2
Function '_ZN7cashier5getIDEv'
Lines executed:100.00% of 2
Function '_ZNSsaSERKSs'
Lines executed:0.00% of 2
Function '_ZN7cashier11setPasswordESs'
Lines executed:100.00% of 3
Function '_ZN7cashier5setIDESs'
Lines executed:100.00% of 3
File 'cashier.cpp'
Lines executed:100.00% of 18
cashier.cpp:creating 'cashier.cpp.gcov'
File '/usr/include/c++/4.4/bits/basic_string.h'
Lines executed:0.00% of 2
/usr/include/c++/4.4/bits/basic_string.h:creating 'basic_string.h.gcov'为结果A问我的问题
Lines executed:100.00% of 18中的意义no branches是什么意思?Calls executed:100.00% of 4中的意义是什么?当我在类中有7个函数时,为什么有4个函数调用?为结果B问我的问题
_ZN7cashier8settriesEi。几乎匹配收银员、函数、名称等:void settries(int)。我认为它指的是同样的功能,但我的老师却有不同的感觉。哪个是对的?Lines executed:100.00% of 3中的3对_ZN7cashier8settriesEi意味着什么?发布于 2014-01-19 03:48:54
读读手册页。在终端窗口中键入man gcov。还有,谷歌gcov。网上有说明。
至于数字,有时gcov将打开和关闭大括号算作可执行语句,有时则不算,这有点让人头疼。查看cashier.cpp.gcov文件,看看哪些行计数,哪些行没有。
关于诸如_ZN7cashier8settriesEi这样的名称:这是cashier::settries(int)的错误名称。通过c++filt传递这些名字。
对于/usr/include/c++/4.4/bit/basic_string.h.h,忽略这些文件。它们不是您的,但是它们将出现在gcov输出中。
https://stackoverflow.com/questions/21212832
复制相似问题