[rtems-tools commit] covoar: Covert CoverageMapBase C to C++
Chris Johns
chrisj at rtems.org
Thu Jun 21 07:57:16 UTC 2018
Module: rtems-tools
Branch: master
Commit: bf8e59f83bf8d520bd550c50f566bd8cbccdd88c
Changeset: http://git.rtems.org/rtems-tools/commit/?id=bf8e59f83bf8d520bd550c50f566bd8cbccdd88c
Author: Chris Johns <chrisj at rtems.org>
Date: Thu Jun 21 17:55:24 2018 +1000
covoar: Covert CoverageMapBase C to C++
Updates #3462
---
tester/covoar/CoverageMapBase.cc | 93 +++++++++++++++++++---------------------
tester/covoar/CoverageMapBase.h | 47 ++++++++++----------
tester/covoar/ExecutableInfo.cc | 6 +--
3 files changed, 69 insertions(+), 77 deletions(-)
diff --git a/tester/covoar/CoverageMapBase.cc b/tester/covoar/CoverageMapBase.cc
index d2b60d2..87c8e8f 100644
--- a/tester/covoar/CoverageMapBase.cc
+++ b/tester/covoar/CoverageMapBase.cc
@@ -7,8 +7,9 @@
*/
#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
+
+#include <iostream>
+#include <iomanip>
#include "CoverageMapBase.h"
@@ -20,21 +21,21 @@ namespace Coverage {
uint32_t high
)
{
- uint32_t a;
- AddressRange_t range;
+ uint32_t a;
+ AddressRange range;
range.fileName = exefileName;
range.lowAddress = low;
range.highAddress = high;
- RangeList.push_back( range );
+ Ranges.push_back( range );
Size = high - low + 1;
- Info = new perAddressInfo_t[ Size ];
+ Info = new perAddressInfo[ Size ];
- for (a=0; a<Size; a++) {
+ for (a = 0; a < Size; a++) {
- perAddressInfo_t *i = &Info[ a ];
+ perAddressInfo *i = &Info[ a ];
i->isStartOfInstruction = false;
i->wasExecuted = 0;
@@ -53,11 +54,11 @@ namespace Coverage {
void CoverageMapBase::Add( uint32_t low, uint32_t high )
{
- AddressRange_t range;
+ AddressRange range;
range.lowAddress = low;
range.highAddress = high;
- RangeList.push_back( range );
+ Ranges.push_back( range );
}
bool CoverageMapBase::determineOffset(
@@ -65,11 +66,11 @@ namespace Coverage {
uint32_t *offset
)const
{
- AddressRange::const_iterator itr;
+ AddressRanges::const_iterator itr;
- for ( itr = RangeList.begin(); itr != RangeList.end(); itr++ ) {
- if ((address >= itr->lowAddress) && (address <= itr->highAddress)){
- *offset = address - itr->lowAddress;
+ for ( auto& r : Ranges ) {
+ if ((address >= r.lowAddress) && (address <= r.highAddress)){
+ *offset = address - r.lowAddress;
return true;
}
}
@@ -78,35 +79,29 @@ namespace Coverage {
}
- void CoverageMapBase::dump( void ) const {
-
- uint32_t a;
- perAddressInfo_t* entry;
-
+ void CoverageMapBase::dump( void ) const
+ {
fprintf( stderr, "Coverage Map Contents:\n" );
-
/*
* XXX - Dump is only marking the first Address Range.
*/
-
- for (a = 0; a < Size; a++) {
-
- entry = &Info[ a ];
-
- fprintf(
- stderr,
- "0x%x - isStartOfInstruction = %s, wasExecuted = %s\n",
- a + RangeList.front().lowAddress,
- entry->isStartOfInstruction ? "TRUE" : "FALSE",
- entry->wasExecuted ? "TRUE" : "FALSE"
- );
- fprintf(
- stderr,
- " isBranch = %s, wasTaken = %s, wasNotTaken = %s\n",
- entry->isBranch ? "TRUE" : "FALSE",
- entry->wasTaken ? "TRUE" : "FALSE",
- entry->wasNotTaken ? "TRUE" : "FALSE"
- );
+ for (uint32_t a = 0; a < Size; a++) {
+ perAddressInfo* entry = &Info[ a ];
+ std::cerr << std::hex << std::setfill('0')
+ << "0x" << a + Ranges.front().lowAddress
+ << "- isStartOfInstruction:"
+ << (char*) (entry->isStartOfInstruction ? "yes" : "no")
+ << " wasExecuted:"
+ << (char*) (entry->wasExecuted ? "yes" : "no")
+ << std::endl
+ << " isBranch:"
+ << (char*) (entry->isBranch ? "yes" : "no")
+ << " wasTaken:"
+ << (char*) (entry->wasTaken ? "yes" : "no")
+ << " wasNotTaken:"
+ << (char*) (entry->wasNotTaken ? "yes" : "no")
+ << std::dec << std::setfill(' ')
+ << std::endl;
}
}
@@ -115,9 +110,9 @@ namespace Coverage {
uint32_t* beginning
) const
{
- bool status = false;
- uint32_t start;
- AddressRange_t range;
+ bool status = false;
+ uint32_t start;
+ AddressRange range;
status = getRange( address, &range );
@@ -141,17 +136,15 @@ namespace Coverage {
int32_t CoverageMapBase::getFirstLowAddress() const
{
- return RangeList.front().lowAddress;
+ return Ranges.front().lowAddress;
}
- bool CoverageMapBase::getRange( uint32_t address, AddressRange_t *range ) const
+ bool CoverageMapBase::getRange( uint32_t address, AddressRange *range ) const
{
- 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;
+ for ( auto r : Ranges ) {
+ if ((address >= r.lowAddress) && (address <= r.highAddress)){
+ range->lowAddress = r.lowAddress;
+ range->highAddress = r.highAddress;
return true;
}
}
diff --git a/tester/covoar/CoverageMapBase.h b/tester/covoar/CoverageMapBase.h
index e1310c9..c8cd90f 100644
--- a/tester/covoar/CoverageMapBase.h
+++ b/tester/covoar/CoverageMapBase.h
@@ -23,10 +23,10 @@ namespace Coverage {
/*!
* This structure identifies the low and high addresses
- * of one range. Note:: There may be more than one address
+ * of one range. Note:: There may be more than one address
* range per symbol.
*/
- typedef struct {
+ struct AddressRange {
/*!
* This is the file from which this originated.
*/
@@ -42,15 +42,14 @@ namespace Coverage {
*/
uint32_t highAddress;
- } AddressRange_t;
+ };
/*
* This type identifies a list of ranges.
*/
- typedef std::list< AddressRange_t > AddressRange;
- typedef std::list< AddressRange_t >::iterator AddressRangeIterator_t;
+ typedef std::list< AddressRange > AddressRanges;
- /*!
+ /*!
* This method constructs a CoverageMapBase instance.
*
* @param[in] exefileName specifies the executable this originated in
@@ -63,7 +62,7 @@ namespace Coverage {
uint32_t high
);
- /*!
+ /*!
* This method destructs a CoverageMapBase instance.
*/
virtual ~CoverageMapBase();
@@ -73,19 +72,19 @@ namespace Coverage {
*
* @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
+ * 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.
*/
@@ -107,21 +106,21 @@ namespace Coverage {
/*!
* This method returns true and sets the address range if
- * the address falls with the bounds of an address range
+ * 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;
+ bool getRange( uint32_t address, AddressRange *range ) const;
/*!
* This method returns the size of the address range.
- *
+ *
* @return Returns Size of the address range.
*/
uint32_t getSize() const;
@@ -134,7 +133,7 @@ namespace Coverage {
* @param[in] address specifies the address to search from
* @param[out] beginning contains the address of the beginning of
* the instruction.
- *
+ *
* @return Returns TRUE if the beginning of the instruction was
* found and FALSE if it was not.
*/
@@ -191,7 +190,7 @@ namespace Coverage {
* at the specified address was executed.
*
* @param[in] address specifies the address to check
- *
+ *
* @return Returns TRUE if the instruction at the specified
* address was executed and FALSE otherwise.
*/
@@ -213,7 +212,7 @@ namespace Coverage {
* the instruction at the specified address was executed.
*
* @param[in] address specifies the address to check
- *
+ *
* @return Returns number of executins
*/
uint32_t getWasExecuted( uint32_t address ) const;
@@ -365,7 +364,7 @@ namespace Coverage {
* This structure defines the information that is gathered and
* tracked per address.
*/
- typedef struct {
+ struct perAddressInfo {
/*!
* This member indicates that the address is the start of
* an instruction.
@@ -393,16 +392,16 @@ namespace Coverage {
* instruction at the address was NOT taken.
*/
uint32_t wasNotTaken;
- } perAddressInfo_t;
+ };
/*!
- *
+ *
* This is a list of address ranges for this symbolic address.
*/
- AddressRange RangeList;
+ AddressRanges Ranges;
/*!
- *
+ *
* This variable contains the size of the code block.
*/
uint32_t Size;
@@ -411,7 +410,7 @@ namespace Coverage {
* This is a dynamically allocated array of data that is
* kept for each address.
*/
- perAddressInfo_t* Info;
+ perAddressInfo* Info;
};
}
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 4c72d0d..710b25c 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -31,6 +31,7 @@ namespace Coverage {
executable.load_symbols(symbols);
debug.begin(executable.elf());
debug.load_debug();
+ debug.load_functions();
}
ExecutableInfo::~ExecutableInfo()
@@ -89,7 +90,6 @@ namespace Coverage {
return loadAddress;
}
-
SymbolTable* ExecutableInfo::getSymbolTable ( void )
{
return &theSymbolTable;
@@ -102,8 +102,8 @@ namespace Coverage {
uint32_t highAddress
)
{
- CoverageMapBase *theMap;
- ExecutableInfo::CoverageMaps::iterator itr;
+ CoverageMapBase *theMap;
+ CoverageMaps::iterator itr;
itr = coverageMaps.find( symbolName );
if ( itr == coverageMaps.end() ) {
More information about the vc
mailing list