summaryrefslogtreecommitdiffstats
path: root/covoar
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2011-01-25 21:26:00 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2011-01-25 21:26:00 +0000
commit898a5e8205b2736ea7e455174b5f4e529dc04c07 (patch)
tree8a290411a6173cc53a68aecdd65702268868041d /covoar
parent2011-01-25 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-testing-898a5e8205b2736ea7e455174b5f4e529dc04c07.tar.bz2
2011-01-25 Jennifer Averett <Jennifer.Averett@OARcorp.com>
* CoverageMapBase.cc, CoverageMapBase.h, CoverageReaderQEMU.cc, DesiredSymbols.cc, ExecutableInfo.cc, SymbolTable.cc, SymbolTable.h: Modifications to track multiple address ranges for the same symbol.
Diffstat (limited to 'covoar')
-rw-r--r--covoar/ChangeLog6
-rw-r--r--covoar/CoverageMapBase.cc196
-rw-r--r--covoar/CoverageMapBase.h99
-rw-r--r--covoar/CoverageReaderQEMU.cc19
-rw-r--r--covoar/DesiredSymbols.cc8
-rw-r--r--covoar/ExecutableInfo.cc8
-rw-r--r--covoar/SymbolTable.cc18
-rw-r--r--covoar/SymbolTable.h7
8 files changed, 283 insertions, 78 deletions
diff --git a/covoar/ChangeLog b/covoar/ChangeLog
index e2a669b..c475336 100644
--- a/covoar/ChangeLog
+++ b/covoar/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-25 Jennifer Averett <Jennifer.Averett@OARcorp.com>
+
+ * CoverageMapBase.cc, CoverageMapBase.h, CoverageReaderQEMU.cc,
+ DesiredSymbols.cc, ExecutableInfo.cc, SymbolTable.cc, SymbolTable.h:
+ Modifications to track multiple address ranges for the same symbol.
+
2011-01-25 Joel Sherrill <joel.sherrill@oarcorp.com>
* ExecutableInfo.cc: Hack a shot at seeing if symbol is already known.
diff --git a/covoar/CoverageMapBase.cc b/covoar/CoverageMapBase.cc
index 225cd34..d118123 100644
--- a/covoar/CoverageMapBase.cc
+++ b/covoar/CoverageMapBase.cc
@@ -22,15 +22,22 @@ namespace Coverage {
CoverageMapBase::CoverageMapBase(
uint32_t low,
uint32_t high
- ) : lowAddress(low), highAddress(high)
+ )
{
- uint32_t a;
+ uint32_t a;
+ AddressRange_t range;
+
+ range.lowAddress = low;
+ range.highAddress = high;
+ RangeList.push_back( range );
+
+ Size = high - low + 1;
- Info = new perAddressInfo_t[ high - low + 1 ];
+ Info = new perAddressInfo_t[ Size ];
- for (a=low; a<=high; a++) {
+ for (a=0; a<Size; a++) {
- perAddressInfo_t *i = &Info[ a-low ];
+ perAddressInfo_t *i = &Info[ a ];
i->isStartOfInstruction = false;
i->wasExecuted = false;
@@ -45,6 +52,33 @@ namespace Coverage {
if (Info)
delete Info;
}
+
+ void CoverageMapBase::Add( uint32_t low, uint32_t high )
+ {
+ AddressRange_t range;
+
+ range.lowAddress = low;
+ range.highAddress = high;
+ RangeList.push_back( range );
+ }
+
+ bool CoverageMapBase::determineOffset(
+ uint32_t address,
+ uint32_t *offset
+ )const
+ {
+ AddressRange::const_iterator itr;
+
+ for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
+ if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
+ *offset = address - itr->lowAddress;
+ return true;
+ }
+ }
+ *offset = 0;
+ return false;
+ }
+
void CoverageMapBase::dump( void ) const {
@@ -53,14 +87,18 @@ namespace Coverage {
fprintf( stderr, "Coverage Map Contents:\n" );
- for (a = lowAddress; a <= highAddress; a++) {
+ /*
+ * XXX - Dump is only marking the first Address Range.
+ */
+
+ for (a = 0; a < Size; a++) {
- entry = &Info[ a - lowAddress ];
+ entry = &Info[ a ];
fprintf(
stderr,
"0x%x - isStartOfInstruction = %s, wasExecuted = %s\n",
- a,
+ a + RangeList.front().lowAddress,
entry->isStartOfInstruction ? "TRUE" : "FALSE",
entry->wasExecuted ? "TRUE" : "FALSE"
);
@@ -79,16 +117,19 @@ namespace Coverage {
uint32_t* beginning
) const
{
- bool status = false;
- uint32_t start;
+ bool status = false;
+ uint32_t start;
+ AddressRange_t range;
- if ((address < lowAddress) || (address > highAddress))
+
+ status = getRange( address, &range );
+ if ( status != true )
return status;
start = address;
- while (start >= lowAddress ) {
- if (Info[ start - lowAddress ].isStartOfInstruction) {
+ while (start >= range.lowAddress ) {
+ if (Info[ start - range.lowAddress ].isStartOfInstruction) {
*beginning = start;
status = true;
break;
@@ -100,119 +141,184 @@ namespace Coverage {
return status;
}
- uint32_t CoverageMapBase::getHighAddress( void ) const
+ int32_t CoverageMapBase::getFirstLowAddress() const
{
- return highAddress;
+ return RangeList.front().lowAddress;
}
- uint32_t CoverageMapBase::getLowAddress( void ) const
+ bool CoverageMapBase::getRange( uint32_t address, AddressRange_t *range ) const
{
- return lowAddress;
+ AddressRange::const_iterator itr;
+
+ for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
+ if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
+ range->lowAddress = itr->lowAddress;
+ range->highAddress = itr->highAddress;
+ return true;
+ }
+ }
+
+ range->lowAddress = 0;
+ range->highAddress = 0;
+
+ return false;
+
+ }
+
+ uint32_t CoverageMapBase::getSize() const
+ {
+ return Size;
}
void CoverageMapBase::setIsStartOfInstruction(
uint32_t address
)
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].isStartOfInstruction = true;
+
+ Info[ offset ].isStartOfInstruction = true;
}
bool CoverageMapBase::isStartOfInstruction( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return Info[ address - lowAddress ].isStartOfInstruction;
+
+ return Info[ offset ].isStartOfInstruction;
}
void CoverageMapBase::setWasExecuted( uint32_t address )
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].wasExecuted = true;
+
+ Info[ offset ].wasExecuted = true;
}
bool CoverageMapBase::wasExecuted( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return Info[ address - lowAddress ].wasExecuted;
+
+ return Info[ offset ].wasExecuted;
}
void CoverageMapBase::setIsBranch(
uint32_t address
)
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].isBranch = true;
+
+ Info[ offset ].isBranch = true;
}
bool CoverageMapBase::isNop( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return Info[ address - lowAddress ].isNop;
+
+ return Info[ offset ].isNop;
}
void CoverageMapBase::setIsNop(
uint32_t address
)
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].isNop = true;
+
+ Info[ offset ].isNop = true;
}
bool CoverageMapBase::isBranch( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return Info[ address - lowAddress ].isBranch;
+
+ return Info[ offset ].isBranch;
}
void CoverageMapBase::setWasTaken(
uint32_t address
)
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].wasTaken = true;
+
+ Info[ offset ].wasTaken = true;
}
void CoverageMapBase::setWasNotTaken(
uint32_t address
)
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return;
- Info[ address - lowAddress ].wasNotTaken = true;
+
+ Info[ offset ].wasNotTaken = true;
}
bool CoverageMapBase::wasAlwaysTaken( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return (Info[ address - lowAddress ].wasTaken &&
- !Info[ address - lowAddress ].wasNotTaken);
+
+ return (Info[ offset ].wasTaken &&
+ !Info[ offset ].wasNotTaken);
}
bool CoverageMapBase::wasNeverTaken( uint32_t address ) const
{
- if ((address < lowAddress) || (address > highAddress))
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
return false;
- return (!Info[ address - lowAddress ].wasTaken &&
- Info[ address - lowAddress ].wasNotTaken);
+
+ return (!Info[ offset ].wasTaken &&
+ Info[ offset ].wasNotTaken);
}
bool CoverageMapBase::wasNotTaken( uint32_t address ) const
{
- return (Info[ address - lowAddress ].wasNotTaken);
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
+ return false;
+
+ return Info[ offset ].wasNotTaken;
}
bool CoverageMapBase::wasTaken( uint32_t address ) const
{
- return (Info[ address - lowAddress ].wasTaken);
+ uint32_t offset;
+
+ if (determineOffset( address, &offset ) != true)
+ return false;
+
+ return Info[ offset ].wasTaken;
}
}
diff --git a/covoar/CoverageMapBase.h b/covoar/CoverageMapBase.h
index 40f3d6c..a3e22d5 100644
--- a/covoar/CoverageMapBase.h
+++ b/covoar/CoverageMapBase.h
@@ -13,6 +13,7 @@
#include <stdint.h>
#include <string>
+#include <list>
namespace Coverage {
@@ -24,6 +25,29 @@ namespace Coverage {
public:
+ /*!
+ * This structure identifies the low and high addresses
+ * of one range. Note:: There may be more than one address
+ * range per symbol.
+ */
+ typedef struct {
+ /*!
+ * This is the low address of the address map range.
+ */
+ uint32_t lowAddress;
+
+ /*!
+ * This is the high address of the address map range.
+ */
+ uint32_t highAddress;
+
+ } AddressRange_t;
+
+ /*
+ * This type identifies a list of ranges.
+ */
+ typedef std::list< AddressRange_t > AddressRange;
+
/*!
* This method constructs a CoverageMapBase instance.
*
@@ -41,11 +65,65 @@ namespace Coverage {
virtual ~CoverageMapBase();
/*!
+ * This method adds a address range to the RangeList.
+ *
+ * @param[in] Low specifies the lowAddress
+ * @param[in] High specifies the highAddress
+ *
+ */
+ void Add( uint32_t low, uint32_t high );
+
+ /*!
+ * This method returns true and sets the offset if
+ * the address falls with the bounds of an address range
+ * in the RangeList.
+ *
+ * @param[in] address specifies the address to find
+ * @param[out] offset contains the offset from the low
+ * address of the address range.
+ *
+ * @return Returns TRUE if the address range can be found
+ * and FALSE if it was not.
+ */
+ bool determineOffset( uint32_t address, uint32_t *offset ) const;
+
+ /*!
* This method prints the contents of the coverage map to stdout.
*/
void dump( void ) const;
/*!
+ * This method will return the low address of the first range in
+ * the RangeList.
+ *
+ * @return Returns the low address of the first range in
+ * the RangeList.
+ */
+ int32_t getFirstLowAddress() const;
+
+ /*!
+ * This method returns true and sets the address range if
+ * the address falls with the bounds of an address range
+ * in the RangeList.
+ *
+ * @param[in] address specifies the address to find
+ * @param[out] range contains the high and low addresse for
+ * the range
+ *
+ * @return Returns TRUE if the address range can be found
+ * and FALSE if it was not.
+ */
+ bool getRange( uint32_t address, AddressRange_t *range ) const;
+
+ /*!
+ * This method returns the size of the address range.
+ *
+ * @return Returns Size of the address range.
+ */
+ uint32_t getSize() const;
+
+
+ /*!
* This method returns the address of the beginning of the
* instruction that contains the specified address.
*
@@ -65,15 +143,15 @@ namespace Coverage {
* This method returns the high address of the coverage map.
*
* @return Returns the high address of the coverage map.
- */
uint32_t getHighAddress( void ) const;
+ */
/*!
* This method returns the low address of the coverage map.
*
* @return Returns the low address of the coverage map.
- */
uint32_t getLowAddress( void ) const;
+ */
/*!
* This method sets the boolean which indicates if this
@@ -250,21 +328,22 @@ namespace Coverage {
} perAddressInfo_t;
/*!
- * This is a dynamically allocated array of data that is
- * kept for each address.
+ *
+ * This is a list of address ranges for this symbolic address.
*/
- perAddressInfo_t* Info;
+ AddressRange RangeList;
/*!
- * This is the low address of the address map range.
+ *
+ * This variable contains the size of the code block.
*/
- uint32_t lowAddress;
+ uint32_t Size;
/*!
- * This is the high address of the address map range.
+ * This is a dynamically allocated array of data that is
+ * kept for each address.
*/
- uint32_t highAddress;
-
+ perAddressInfo_t* Info;
};
}
diff --git a/covoar/CoverageReaderQEMU.cc b/covoar/CoverageReaderQEMU.cc
index a7f16ac..d44cb58 100644
--- a/covoar/CoverageReaderQEMU.cc
+++ b/covoar/CoverageReaderQEMU.cc
@@ -141,23 +141,20 @@ namespace Coverage {
// Determine if additional branch information is available.
if ( (entry->op & branchInfo) != 0 ) {
- unsigned int a = entry->pc + entry->size - 1;
- if ( (entry->pc < aCoverageMap->getLowAddress()) ||
- (entry->pc > aCoverageMap->getHighAddress()) ||
- (a < aCoverageMap->getLowAddress()) ||
- (a > aCoverageMap->getHighAddress()) ) {
+ uint32_t offset_e, offset_a;
+ uint32_t a = entry->pc + entry->size - 1;
+ if ((aCoverageMap->determineOffset( a, &offset_a ) != true) ||
+ (aCoverageMap->determineOffset( entry->pc, &offset_e ) != true))
+ {
fprintf(
stderr,
"*** Trace block is inconsistent with coverage map\n"
"*** Trace block (0x%08x - 0x%08x) for %d bytes\n"
- "*** Coverage map (0x%08x - 0x%08x) for %d bytes\n",
+ "*** Coverage map XXX \n",
entry->pc,
a,
- entry->size,
- aCoverageMap->getLowAddress(),
- aCoverageMap->getHighAddress(),
- aCoverageMap->getHighAddress() - aCoverageMap->getLowAddress()
- );
+ entry->size
+ );
} else {
while (!aCoverageMap->isStartOfInstruction(a))
a--;
diff --git a/covoar/DesiredSymbols.cc b/covoar/DesiredSymbols.cc
index b4ca2c2..5d86654 100644
--- a/covoar/DesiredSymbols.cc
+++ b/covoar/DesiredSymbols.cc
@@ -89,6 +89,8 @@ namespace Coverage {
line,
inputBuffer
);
+
+ delete symInfo;
}
// Add this to the set of symbols.
@@ -627,7 +629,7 @@ namespace Coverage {
uint32_t sAddress;
uint32_t sBaseAddress;
uint32_t sMapSize;
-
+
// Ensure that the symbol is a desired symbol.
itr = set.find( symbolName );
@@ -645,8 +647,8 @@ namespace Coverage {
// Ensure that the source and destination coverage maps
// are the same size.
dMapSize = itr->second.stats.sizeInBytes;
- sBaseAddress = sourceCoverageMap->getLowAddress();
- sMapSize = sourceCoverageMap->getHighAddress() - sBaseAddress + 1;
+ sBaseAddress = sourceCoverageMap->getFirstLowAddress();
+ sMapSize = sourceCoverageMap->getSize();
if (dMapSize != sMapSize) {
fprintf(
diff --git a/covoar/ExecutableInfo.cc b/covoar/ExecutableInfo.cc
index 7705c8b..26a1e50 100644
--- a/covoar/ExecutableInfo.cc
+++ b/covoar/ExecutableInfo.cc
@@ -90,13 +90,15 @@ namespace Coverage {
uint32_t highAddress
)
{
- CoverageMapBase* theMap;
+ CoverageMapBase *theMap;
+ ExecutableInfo::coverageMaps_t::iterator itr;
- theMap = coverageMaps.find( symbolName );
- if ( theMap == std::map.end() ) {
+ itr = coverageMaps.find( symbolName );
+ if ( itr == coverageMaps.end() ) {
theMap = new CoverageMap( lowAddress, highAddress );
coverageMaps[ symbolName ] = theMap;
} else {
+ theMap = itr->second;
theMap->Add( lowAddress, highAddress );
}
return theMap;
diff --git a/covoar/SymbolTable.cc b/covoar/SymbolTable.cc
index 2ce7d56..c7ed638 100644
--- a/covoar/SymbolTable.cc
+++ b/covoar/SymbolTable.cc
@@ -33,9 +33,9 @@ namespace Coverage {
const uint32_t length
)
{
- uint32_t end = 0;
- symbol_entry_t entry;
- symbolInfo symbolData;
+ uint32_t end = 0;
+ symbol_entry_t entry;
+ symbolInfo_t symbolData;
// Add an entry to the address map.
end = start + length - 1;
@@ -47,7 +47,15 @@ namespace Coverage {
// Add an entry to the symbol information map.
symbolData.startingAddress = start;
symbolData.length = length;
- info[ symbol ] = symbolData;
+
+ if ( info[ symbol ].empty() == false ) {
+ if ( info[symbol ].front().length != length ) {
+ fprintf(stderr, "ERROR==> Different lengths for the symbol %s\n", symbol.c_str() );
+ exit( 0 );
+ }
+ }
+
+ info[ symbol ].push_back( symbolData );
}
SymbolTable::symbolInfo* SymbolTable::getInfo(
@@ -71,7 +79,7 @@ namespace Coverage {
if (it == info.end())
return 0;
else
- return ((*it).second.length);
+ return ((*it).second.front().length);
}
std::string SymbolTable::getSymbol(
diff --git a/covoar/SymbolTable.h b/covoar/SymbolTable.h
index ac8ac69..792731a 100644
--- a/covoar/SymbolTable.h
+++ b/covoar/SymbolTable.h
@@ -14,6 +14,7 @@
#include <stdint.h>
#include <string>
#include <map>
+#include <list>
namespace Coverage {
@@ -33,7 +34,11 @@ namespace Coverage {
typedef struct {
uint32_t startingAddress;
uint32_t length;
- } symbolInfo;
+ } symbolInfo_t;
+
+ typedef std::list< symbolInfo_t > symbolInfo;
+
+
/*!
* This method constructs a SymbolTable instance.