summaryrefslogtreecommitdiff
path: root/tester/covoar/CoverageMapBase.h
diff options
context:
space:
mode:
Diffstat (limited to 'tester/covoar/CoverageMapBase.h')
-rw-r--r--tester/covoar/CoverageMapBase.h185
1 files changed, 103 insertions, 82 deletions
diff --git a/tester/covoar/CoverageMapBase.h b/tester/covoar/CoverageMapBase.h
index c8cd90f..6ad76d3 100644
--- a/tester/covoar/CoverageMapBase.h
+++ b/tester/covoar/CoverageMapBase.h
@@ -9,45 +9,106 @@
#include <stdint.h>
#include <string>
+#include <vector>
#include <list>
namespace Coverage {
- /*! @class CoverageMapBase
- *
- * This is the base class for Coverage Map implementations.
+ /*!
+ * This structure defines the information that is gathered and
+ * tracked per address.
*/
- class CoverageMapBase {
+ struct AddressInfo {
- public:
+ AddressInfo ();
/*!
- * This structure identifies the low and high addresses
- * of one range. Note:: There may be more than one address
- * range per symbol.
+ * This member indicates that the address is the start of
+ * an instruction.
+ */
+ bool isStartOfInstruction;
+ /*!
+ * This member indicates how many times the address was executed.
+ */
+ uint32_t wasExecuted;
+ /*!
+ * This member indicates that the address is a branch instruction.
+ */
+ bool isBranch;
+ /*!
+ * This member indicates that the address is a NOP instruction.
+ */
+ bool isNop;
+ /*!
+ * When isBranch is TRUE, this member indicates that the branch
+ * instruction at the address was taken.
+ */
+ uint32_t wasTaken;
+ /*!
+ * When isBranch is TRUE, this member indicates that the branch
+ * instruction at the address was NOT taken.
*/
- struct AddressRange {
- /*!
- * This is the file from which this originated.
- */
- std::string fileName;
+ uint32_t wasNotTaken;
- /*!
- * 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;
+ typedef std::vector < AddressInfo > AddressInfos;
- };
+ /*!
+ * This structure identifies the low and high addresses
+ * of one range. Note:: There may be more than one address
+ * range per symbol.
+ */
+ struct AddressRange {
+
+ AddressRange ();
+ AddressRange (const std::string& name,
+ uint32_t lowAddress,
+ uint32_t highAddress);
+
+ size_t size () const;
+
+ bool inside (uint32_t address) const;
+
+ AddressInfo& get (uint32_t address);
+ const AddressInfo& get (uint32_t address) const;
+
+ void dump (std::ostream& out, bool show_slots = false) const;
+
+ /*!
+ * This is the file from which this originated.
+ */
+ std::string fileName;
+
+ /*!
+ * 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;
- /*
- * This type identifies a list of ranges.
+ /*!
+ * The address info for this range.
*/
- typedef std::list< AddressRange > AddressRanges;
+ AddressInfos info;
+
+ };
+
+ /*
+ * This type identifies a list of ranges.
+ */
+ typedef std::vector< AddressRange > AddressRanges;
+
+ /*! @class CoverageMapBase
+ *
+ * This is the base class for Coverage Map implementations.
+ */
+ class CoverageMapBase {
+
+ public:
/*!
* This method constructs a CoverageMapBase instance.
@@ -77,25 +138,16 @@ namespace Coverage {
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;
/*!
+ * Address valid?
+ */
+ bool validAddress( const uint32_t address ) const;
+
+ /*!
* This method will return the low address of the first range in
* the RangeList.
*
@@ -116,7 +168,7 @@ namespace Coverage {
* @return Returns TRUE if the address range can be found
* and FALSE if it was not.
*/
- bool getRange( uint32_t address, AddressRange *range ) const;
+ bool getRange( uint32_t address, AddressRange& range ) const;
/*!
* This method returns the size of the address range.
@@ -125,7 +177,6 @@ namespace Coverage {
*/
uint32_t getSize() const;
-
/*!
* This method returns the address of the beginning of the
* instruction that contains the specified address.
@@ -358,41 +409,12 @@ namespace Coverage {
*/
bool wasTaken( uint32_t address ) const;
- protected:
-
- /*!
- * This structure defines the information that is gathered and
- * tracked per address.
- */
- struct perAddressInfo {
- /*!
- * This member indicates that the address is the start of
- * an instruction.
- */
- bool isStartOfInstruction;
- /*!
- * This member indicates how many times the address was executed.
- */
- uint32_t wasExecuted;
- /*!
- * This member indicates that the address is a branch instruction.
- */
- bool isBranch;
- /*!
- * This member indicates that the address is a NOP instruction.
- */
- bool isNop;
- /*!
- * When isBranch is TRUE, this member indicates that the branch
- * instruction at the address was taken.
- */
- uint32_t wasTaken;
- /*!
- * When isBranch is TRUE, this member indicates that the branch
- * instruction at the address was NOT taken.
- */
- uint32_t wasNotTaken;
- };
+ private:
+
+ /*!
+ * The executable file name.
+ */
+ std::string exefileName;
/*!
*
@@ -401,16 +423,15 @@ namespace Coverage {
AddressRanges Ranges;
/*!
- *
- * This variable contains the size of the code block.
+ * Range checked access to the info.
*/
- uint32_t Size;
+ AddressInfo& getInfo(uint32_t offset);
/*!
- * This is a dynamically allocated array of data that is
- * kept for each address.
+ * Constant range checked access to the info.
*/
- perAddressInfo* Info;
+ const AddressInfo& getInfo(uint32_t offset) const;
+
};
}