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

@@ -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
);

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

@@ -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
);
}
}