covoar: Add information to improve diagnostics.

This commit is contained in:
Hermann Felbinger
2017-08-26 09:15:53 +01:00
committed by Chris Johns
parent b857151112
commit cb018bcdff
9 changed files with 67 additions and 38 deletions

View File

@@ -10,9 +10,10 @@
namespace Coverage {
CoverageMap::CoverageMap(
uint32_t low,
uint32_t high
) : CoverageMapBase(low, high)
const std::string& exefileName,
uint32_t low,
uint32_t high
) : CoverageMapBase(exefileName, low, high)
{
}

View File

@@ -27,8 +27,9 @@ namespace Coverage {
* @param[in] high specifies the highest address of the coverage map.
*/
CoverageMap(
uint32_t low,
uint32_t high
const std::string& exefileName,
uint32_t low,
uint32_t high
);
/* Inherit documentation from base class. */

View File

@@ -16,13 +16,15 @@
namespace Coverage {
CoverageMapBase::CoverageMapBase(
uint32_t low,
uint32_t high
const std::string& exefileName,
uint32_t low,
uint32_t high
)
{
uint32_t a;
AddressRange_t range;
range.fileName = exefileName;
range.lowAddress = low;
range.highAddress = high;
RangeList.push_back( range );

View File

@@ -27,6 +27,11 @@ namespace Coverage {
* range per symbol.
*/
typedef struct {
/*!
* This is the file from which this originated.
*/
std::string fileName;
/*!
* This is the low address of the address map range.
*/
@@ -48,12 +53,14 @@ namespace Coverage {
/*!
* This method constructs a CoverageMapBase instance.
*
* @param[in] exefileName specifies the executable this originated in
* @param[in] low specifies the lowest address of the coverage map
* @param[in] high specifies the highest address of the coverage map
*/
CoverageMapBase(
uint32_t low,
uint32_t high
const std::string& exefileName,
uint32_t low,
uint32_t high
);
/*!

View File

@@ -335,6 +335,7 @@ namespace Coverage {
void DesiredSymbols::createCoverageMap(
const std::string& exefileName,
const std::string& symbolName,
uint32_t size
)
@@ -363,19 +364,27 @@ namespace Coverage {
// ensure that the specified size matches the existing size.
if (itr->second.stats.sizeInBytes != size) {
// Changed ERROR to INFO because size mismatch is not treated as
// error anymore.
// Set smallest size as size and continue.
// Update value for longer byte size.
// 2015-07-22
fprintf(
stderr,
"ERROR: DesiredSymbols::createCoverageMap - Attempt to create "
"unified coverage maps for %s with different sizes (%d != %d)\n",
"INFO: DesiredSymbols::createCoverageMap - Attempt to create "
"unified coverage maps for %s with different sizes (%s/%d != %s/%d)\n",
symbolName.c_str(),
exefileName.c_str(),
itr->second.stats.sizeInBytes,
itr->second.sourceFile->getFileName().c_str(),
size
);
if ( itr->second.stats.sizeInBytes < size )
itr->second.stats.sizeInBytes = size;
else
size = itr->second.stats.sizeInBytes;
// exit( -1 );
}
}
@@ -384,13 +393,14 @@ namespace Coverage {
highAddress = size - 1;
aCoverageMap = new CoverageMap( 0, highAddress );
aCoverageMap = new CoverageMap( exefileName, 0, highAddress );
if (!aCoverageMap) {
fprintf(
stderr,
"ERROR: DesiredSymbols::createCoverageMap - Unable to allocate "
"coverage map for %s\n",
"coverage map for %s:%s\n",
exefileName.c_str(),
symbolName.c_str()
);
exit( -1 );
@@ -653,6 +663,8 @@ namespace Coverage {
// Ensure that the source and destination coverage maps
// are the same size.
// Changed from ERROR msg to INFO, because size mismatch is not
// treated as error anymore. 2015-07-20
dMapSize = itr->second.stats.sizeInBytes;
sBaseAddress = sourceCoverageMap->getFirstLowAddress();
sMapSize = sourceCoverageMap->getSize();
@@ -660,12 +672,11 @@ namespace Coverage {
fprintf(
stderr,
"ERROR: DesiredSymbols::mergeCoverageMap - Unable to merge "
"INFO: DesiredSymbols::mergeCoverageMap - Unable to merge "
"coverage map for %s because the sizes are different\n",
symbolName.c_str()
);
return;
// exit( -1 );
}
// Merge the data for each address.

View File

@@ -20,8 +20,8 @@
namespace Coverage {
/*!
*
/*!
*
* This class defines the statistics that are tracked.
*/
class Statistics {
@@ -34,7 +34,7 @@ namespace Coverage {
int branchesAlwaysTaken;
/*!
* This member variable contains the total number of branches where
* This member variable contains the total number of branches where
* one or more paths were executed.
*/
int branchesExecuted;
@@ -55,7 +55,7 @@ namespace Coverage {
* This member contains the size in Bytes.
*/
uint32_t sizeInBytes;
/*!
* This member contains the size in Bytes.
*/
@@ -93,7 +93,7 @@ namespace Coverage {
/*!
* This method constructs a Statistics instance.
*/
*/
Statistics():
branchesAlwaysTaken(0),
branchesExecuted(0),
@@ -137,7 +137,7 @@ namespace Coverage {
/*!
* This member contains the statistics kept on each symbol.
*/
*/
Statistics stats;
/*!
@@ -186,24 +186,24 @@ namespace Coverage {
typedef std::map<std::string, SymbolInformation> symbolSet_t;
/*!
* This variable contains a map of symbol sets for each
* This variable contains a map of symbol sets for each
* symbol in the system keyed on the symbol name.
*/
symbolSet_t set;
/*!
/*!
* This method constructs a DesiredSymbols instance.
*/
DesiredSymbols();
/*!
/*!
* This method destructs a DesiredSymbols instance.
*/
~DesiredSymbols();
/*!
* This method loops through the coverage map and
* calculates the statistics that have not already
* calculates the statistics that have not already
* been filled in.
*/
void calculateStatistics( void );
@@ -218,11 +218,14 @@ namespace Coverage {
* This method creates a coverage map for the specified symbol
* using the specified size.
*
* @param[in] exefileName specifies the executable from which the
* coverage map is being created
* @param[in] symbolName specifies the symbol for which to create
* a coverage map
* @param[in] size specifies the size of the coverage map to create
*/
void createCoverageMap(
const std::string& exefileName,
const std::string& symbolName,
uint32_t size
);
@@ -316,7 +319,7 @@ namespace Coverage {
/*!
* This member contains the statistics kept on each symbol.
*/
*/
Statistics stats;
private:

View File

@@ -89,6 +89,7 @@ namespace Coverage {
}
CoverageMapBase* ExecutableInfo::createCoverageMap (
const std::string& fileName,
const std::string& symbolName,
uint32_t lowAddress,
uint32_t highAddress
@@ -99,7 +100,7 @@ namespace Coverage {
itr = coverageMaps.find( symbolName );
if ( itr == coverageMaps.end() ) {
theMap = new CoverageMap( lowAddress, highAddress );
theMap = new CoverageMap( fileName, lowAddress, highAddress );
coverageMaps[ symbolName ] = theMap;
} else {
theMap = itr->second;

View File

@@ -93,6 +93,7 @@ namespace Coverage {
/*!
* This method creates a coverage map for the specified symbol.
*
* @param[in] exefileName specifies the source of the information
* @param[in] symbolName specifies the name of the symbol
* @param[in] lowAddress specifies the low address of the coverage map
* @param[in] highAddress specifies the high address of the coverage map
@@ -100,6 +101,7 @@ namespace Coverage {
* @return Returns a pointer to the coverage map
*/
CoverageMapBase* createCoverageMap (
const std::string& exefileName,
const std::string& symbolName,
uint32_t lowAddress,
uint32_t highAddress

View File

@@ -3,7 +3,7 @@
*
* This file contains the implementation of the functions supporting
* the reading of an objdump output file and adding nops to a
* coverage map.
* coverage map.
*/
#include <assert.h>
@@ -97,7 +97,7 @@ namespace Coverage {
// Create a coverage map for the symbol.
aCoverageMap = executableInfo->createCoverageMap(
symbolName, lowAddress, endAddress
executableInfo->getFileName().c_str(), symbolName, lowAddress, endAddress
);
if (aCoverageMap) {
@@ -112,7 +112,8 @@ namespace Coverage {
// Create a unified coverage map for the symbol.
SymbolsToAnalyze->createCoverageMap(
symbolName, endAddress - lowAddress + 1
executableInfo->getFileName().c_str(), symbolName,
endAddress - lowAddress + 1
);
}
}
@@ -170,7 +171,7 @@ namespace Coverage {
std::string tmp = inLibName;
if ( tmp.find( Library ) != tmp.npos ) {
// fprintf( stderr, "%s - 0x%08x\n", inLibName, offset );
address = offset;
address = offset;
break;
}
}
@@ -182,9 +183,9 @@ namespace Coverage {
}
bool ObjdumpProcessor::IsBranch(
const char *instruction
const char *instruction
)
{
{
if ( !TargetInfo ) {
fprintf(
stderr,
@@ -230,7 +231,7 @@ namespace Coverage {
return TargetInfo->isNopLine( line, size );
}
FILE* ObjdumpProcessor::getFile( std::string fileName )
FILE* ObjdumpProcessor::getFile( std::string fileName )
{
char dumpFile[128];
FILE* objdumpFile;
@@ -238,7 +239,7 @@ namespace Coverage {
int status;
sprintf( dumpFile, "%s.dmp", fileName.c_str() );
// Generate the objdump.
if (FileIsNewer( fileName.c_str(), dumpFile )) {
sprintf(
@@ -259,7 +260,7 @@ namespace Coverage {
);
exit( -1 );
}
}
}
// Open the objdump file.
objdumpFile = fopen( dumpFile, "r" );
@@ -283,7 +284,7 @@ namespace Coverage {
if (itr == objdumpList.end()) {
return 0;
}
itr++;
if (itr == objdumpList.end()) {
return 0;