mirror of
https://git.rtems.org/rtems-tools/
synced 2025-06-09 12:21:56 +08:00
Remove BranchInfoAvailable global variable
- Removed BranchInfoAvailable from app_common - Created member variable in CoverageReaderBase and ReportsBase and a function to get the value of the member variable
This commit is contained in:
parent
a1d0e5515e
commit
b93e8dd9bd
@ -16,4 +16,9 @@ namespace Coverage {
|
||||
CoverageReaderBase::~CoverageReaderBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool CoverageReaderBase::getBranchInfoAvailable() const
|
||||
{
|
||||
return branchInfoAvailable_m;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,16 @@ namespace Coverage {
|
||||
const char* const file,
|
||||
ExecutableInfo* const executableInformation
|
||||
) = 0;
|
||||
|
||||
/*!
|
||||
* This method retrieves the branchInfoAvailable_m variable
|
||||
*/
|
||||
bool getBranchInfoAvailable() const;
|
||||
|
||||
/*!
|
||||
* This member variable tells whether the branch info is available.
|
||||
*/
|
||||
bool branchInfoAvailable_m = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Coverage {
|
||||
|
||||
CoverageReaderQEMU::CoverageReaderQEMU()
|
||||
{
|
||||
BranchInfoAvailable = true;
|
||||
branchInfoAvailable_m = true;
|
||||
}
|
||||
|
||||
CoverageReaderQEMU::~CoverageReaderQEMU()
|
||||
|
@ -90,11 +90,11 @@ namespace Coverage {
|
||||
aCoverageMap->setWasExecuted( a + 3 );
|
||||
if ( cover & 0x08 ) {
|
||||
aCoverageMap->setWasTaken( a );
|
||||
BranchInfoAvailable = true;
|
||||
branchInfoAvailable_m = true;
|
||||
}
|
||||
if ( cover & 0x10 ) {
|
||||
aCoverageMap->setWasNotTaken( a );
|
||||
BranchInfoAvailable = true;
|
||||
branchInfoAvailable_m = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,16 @@ ReportsBase::ReportsBase(
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const DesiredSymbols& symbolsToAnalyze
|
||||
const DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
): reportExtension_m( "" ),
|
||||
symbolSetName_m( symbolSetName ),
|
||||
timestamp_m( timestamp ),
|
||||
allExplanations_m( allExplanations ),
|
||||
projectName_m( projectName ),
|
||||
outputDirectory_m( outputDirectory ),
|
||||
symbolsToAnalyze_m( symbolsToAnalyze )
|
||||
symbolsToAnalyze_m( symbolsToAnalyze ),
|
||||
branchInfoAvailable_m( branchInfoAvailable )
|
||||
{
|
||||
}
|
||||
|
||||
@ -311,7 +313,7 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
|
||||
|
||||
if (
|
||||
( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) == 0 ) ||
|
||||
( BranchInfoAvailable == false )
|
||||
( branchInfoAvailable_m == false )
|
||||
) {
|
||||
hasBranches = false;
|
||||
}
|
||||
@ -325,7 +327,7 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
|
||||
// If no branches were found then branch coverage is not supported
|
||||
if (
|
||||
( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0 ) &&
|
||||
( BranchInfoAvailable == true )
|
||||
( branchInfoAvailable_m == true )
|
||||
) {
|
||||
// Process uncovered branches for each symbol in the set.
|
||||
const std::vector<std::string>& symbols =
|
||||
@ -476,7 +478,8 @@ void ReportsBase::WriteSummaryReport(
|
||||
const std::string& fileName,
|
||||
const std::string& symbolSetName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
)
|
||||
{
|
||||
// Calculate coverage statistics and output results.
|
||||
@ -546,7 +549,7 @@ void ReportsBase::WriteSummaryReport(
|
||||
|
||||
if (
|
||||
( symbolsToAnalyze.getNumberBranchesFound( symbolSetName ) == 0 ) ||
|
||||
( BranchInfoAvailable == false )
|
||||
( branchInfoAvailable == false )
|
||||
) {
|
||||
report << "No branch information available" << std::endl;
|
||||
} else {
|
||||
@ -580,7 +583,8 @@ void GenerateReports(
|
||||
bool verbose,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
)
|
||||
{
|
||||
typedef std::list<ReportsBase *> reportList_t;
|
||||
@ -599,7 +603,8 @@ void GenerateReports(
|
||||
allExplanations,
|
||||
projectName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
);
|
||||
reportList.push_back( reports );
|
||||
reports = new ReportsHtml(
|
||||
@ -608,7 +613,8 @@ void GenerateReports(
|
||||
allExplanations,
|
||||
projectName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
);
|
||||
reportList.push_back( reports );
|
||||
|
||||
@ -661,7 +667,8 @@ void GenerateReports(
|
||||
"summary.txt",
|
||||
symbolSetName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ class ReportsBase {
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const DesiredSymbols& symbolsToAnalyze
|
||||
const DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
);
|
||||
virtual ~ReportsBase();
|
||||
|
||||
@ -95,7 +96,8 @@ class ReportsBase {
|
||||
const std::string& fileName,
|
||||
const std::string& symbolSetName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
);
|
||||
|
||||
/*!
|
||||
@ -153,6 +155,11 @@ class ReportsBase {
|
||||
*/
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze_m;
|
||||
|
||||
/*!
|
||||
* This member variable tells whether the branch info is available
|
||||
*/
|
||||
bool branchInfoAvailable_m = false;
|
||||
|
||||
/*!
|
||||
* This method Opens a report file and verifies that it opened
|
||||
* correctly. Upon failure NULL is returned.
|
||||
@ -430,6 +437,7 @@ class ReportsBase {
|
||||
* @param[in] projectName specifies the name of the project
|
||||
* @param[in] outputDirectory specifies the directory for the output
|
||||
* @param[in] symbolsToAnalyze the symbols to be analyzed
|
||||
* @param[in] branchInfoAvailable tells if branch info is available
|
||||
*/
|
||||
void GenerateReports(
|
||||
const std::string& symbolSetName,
|
||||
@ -437,7 +445,8 @@ void GenerateReports(
|
||||
bool verbose,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -43,14 +43,16 @@ namespace Coverage {
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
): ReportsBase(
|
||||
timestamp,
|
||||
symbolSetName,
|
||||
allExplanations,
|
||||
projectName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
),
|
||||
lastState_m( A_SOURCE )
|
||||
{
|
||||
@ -442,7 +444,7 @@ namespace Coverage {
|
||||
bool ReportsHtml::PutNoBranchInfo( std::ofstream& report )
|
||||
{
|
||||
if (
|
||||
BranchInfoAvailable &&
|
||||
branchInfoAvailable_m &&
|
||||
symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
|
||||
) {
|
||||
report << "All branch paths taken." << std::endl;
|
||||
|
@ -31,7 +31,8 @@ class ReportsHtml: public ReportsBase {
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze
|
||||
const Coverage::DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
);
|
||||
~ReportsHtml();
|
||||
|
||||
|
@ -22,14 +22,16 @@ ReportsText::ReportsText(
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const DesiredSymbols& symbolsToAnalyze
|
||||
const DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
): ReportsBase(
|
||||
timestamp,
|
||||
symbolSetName,
|
||||
allExplanations,
|
||||
projectName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
)
|
||||
{
|
||||
reportExtension_m = ".txt";
|
||||
@ -62,7 +64,7 @@ void ReportsText::PutAnnotatedLine(
|
||||
bool ReportsText::PutNoBranchInfo( std::ofstream& report )
|
||||
{
|
||||
if (
|
||||
BranchInfoAvailable &&
|
||||
branchInfoAvailable_m &&
|
||||
symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
|
||||
) {
|
||||
report << "All branch paths taken." << std::endl;
|
||||
|
@ -27,7 +27,8 @@ class ReportsText: public ReportsBase {
|
||||
Coverage::Explanations& allExplanations,
|
||||
const std::string& projectName,
|
||||
const std::string& outputDirectory,
|
||||
const DesiredSymbols& symbolsToAnalyze
|
||||
const DesiredSymbols& symbolsToAnalyze,
|
||||
bool branchInfoAvailable
|
||||
);
|
||||
virtual ~ReportsText();
|
||||
|
||||
|
@ -56,7 +56,6 @@
|
||||
/*
|
||||
* Global variables for the program
|
||||
*/
|
||||
bool BranchInfoAvailable = false;
|
||||
Target::TargetBase* TargetInfo = NULL;
|
||||
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "Explanations.h"
|
||||
#include "TargetBase.h"
|
||||
|
||||
extern bool BranchInfoAvailable;
|
||||
extern Target::TargetBase* TargetInfo;
|
||||
|
||||
|
||||
|
@ -183,6 +183,7 @@ int covoar(
|
||||
std::string projectName;
|
||||
std::string outputDirectory = ".";
|
||||
Coverage::DesiredSymbols symbolsToAnalyze;
|
||||
bool branchInfoAvailable = false;
|
||||
Coverage::ObjdumpProcessor objdumpProcessor( symbolsToAnalyze );
|
||||
|
||||
//
|
||||
@ -486,13 +487,16 @@ int covoar(
|
||||
std::cerr << "Generate Reports" << std::endl;
|
||||
|
||||
for (const auto& setName : symbolsToAnalyze.getSetNames()) {
|
||||
branchInfoAvailable = coverageReader->getBranchInfoAvailable();
|
||||
|
||||
Coverage::GenerateReports(
|
||||
setName,
|
||||
allExplanations,
|
||||
verbose,
|
||||
projectName,
|
||||
outputDirectory,
|
||||
symbolsToAnalyze
|
||||
symbolsToAnalyze,
|
||||
branchInfoAvailable
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user