summaryrefslogtreecommitdiffstats
path: root/tester/covoar/CoverageRanges.cc
blob: cfd58df4695963f2f4e173729274e43994caa2df (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
/*! @file CoverageRanges.cc
 *  @brief CoverageRanges Implementation
 *
 *  This file contains the implementation of the functions
 *  which provide a base level of functionality of a CoverageRanges.
 */

#include "CoverageRanges.h"
#include <stdio.h>

namespace Coverage {

  /*!
   *  This member variable tracks a unique index for the ranges_t block.
   */
  uint32_t id_m = 0;

  CoverageRanges::CoverageRanges()
  {
  }

  CoverageRanges::~CoverageRanges()
  {
  }

  void CoverageRanges::add(
    uint32_t          lowAddressArg,
    uint32_t          highAddressArg,
    uncoveredReason_t why,
    uint32_t          numInstructions
  )
  {
    coverageRange_t c;

    id_m++;
    c.id               = id_m;
    c.lowAddress       = lowAddressArg;
    c.highAddress      = highAddressArg;
    c.reason           = why;
    c.instructionCount = numInstructions;
    set.push_back(c);
  }

  uint32_t CoverageRanges::getId( uint32_t lowAddress )
  {
    Coverage::CoverageRanges::ranges_t::iterator ritr;
    uint32_t                                     result = 0;

    for ( ritr =  set.begin() ; ritr != set.end() ; ritr++ ) {
      if ( ritr->lowAddress == lowAddress ) {
        result = ritr->id;
        break;
      }
    }

    return result;
  }
}