summaryrefslogtreecommitdiffstats
path: root/covoar/CoverageRanges.h
blob: 17640b7239422c562182ca564b324937f6431c82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*! @file CoverageRanges.h
 *  @brief CoverageRanges Specification
 *
 *  This file contains the specification of the CoverageRanges class.
 */

#ifndef __COVERAGE_RANGES_H__
#define __COVERAGE_RANGES_H__

#include <stdint.h>
#include <list>
#include <string>

namespace Coverage {

  /*! @class CoverageRanges
   *
   *  This class defines a set of address ranges for which coverage
   *  did not occur.  Each address range can either define a range of
   *  bytes that was not executed or a range of bytes for a branch
   *  instruction that was not completely covered (i.e. taken and NOT
   *  taken).
   */
  class CoverageRanges {

  public:

    /*!
     *  This type defines the reasons to associate with a range.
     */
    typedef enum {
      UNCOVERED_REASON_NOT_EXECUTED,
      UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN,
      UNCOVERED_REASON_BRANCH_NEVER_TAKEN
    } uncoveredReason_t;

    /*!
     *  This type defines the information kept for each range.
     */
    typedef struct {
      /*!
       *  This member contains an identification number for this 
       *  coverage range.
       */
      uint32_t          id;

      /*!
       *  This member contains the low address of this coverage 
       *  range.
       */
      uint32_t          lowAddress;

      /*!
       *  This member contains the source line associated with the 
       *  low address for this coverage range.
       */
      std::string       lowSourceLine;

      /*!
       * This member contains the high address for this coverage range.
       */
      uint32_t          highAddress;

      /*!
       *  This member contains the high source line for this coverage range.
       */
      std::string       highSourceLine;

      /*!
       * This member contains an instruction count for this coverage 
       * address range.
       */
      uint32_t          instructionCount;

      /*!
       *  This member contains the reason that this area was uncovered.
       */
      uncoveredReason_t reason;
    } coverageRange_t;

    /*!
     *  This type contains a list of CoverageRange instances.
     */
    typedef std::list<coverageRange_t> ranges_t;

    /*!
     *  This member contains a list of the CoverageRange instances.
     */
    ranges_t set;

    /*! 
     *  This method constructs a CoverageRanges instance.
     */
    CoverageRanges();

    /*! 
     *  This method destructs a CoverageRanges instance.
     */
    ~CoverageRanges();

    /*!
     *  This method adds a range entry to the set of ranges.
     *
     *  @param[in] lowAddressArg specifies the lowest address of the range
     *  @param[in] highAddressArg specifies the highest address of the range
     *  @param[in] why specifies the reason that the range was added
     *
     */
    void add(
      uint32_t          lowAddressArg,
      uint32_t          highAddressArg,
      uncoveredReason_t why,
      uint32_t          numInstructions
    );
 

    /*!
     *  This method returns the index of a range given the low address.
     *  Upon failure on finding the adress 0 is returned.
     */
    uint32_t getId( uint32_t lowAddress );
 
    protected:


  };

}
#endif