source: rtems-tools/tester/covoar/CoverageMapBase.h @ 100f517

4.104.115
Last change on this file since 100f517 was 100f517, checked in by Chris Johns <chrisj@…>, on 05/09/14 at 11:50:37

covoar: Merger the covoar source from rtems-testing.git.

Use waf to build covoar.

  • Property mode set to 100644
File size: 12.2 KB
Line 
1/*! @file CoverageMapBase.h
2 *  @brief CoverageMapBase Specification
3 *
4 *  This file contains the specification of the CoverageMapBase class.
5 */
6
7#ifndef __COVERAGE_MAP_BASE_H__
8#define __COVERAGE_MAP_BASE_H__
9
10#include <stdint.h>
11#include <string>
12#include <list>
13
14namespace Coverage {
15
16  /*! @class CoverageMapBase
17   *
18   *  This is the base class for Coverage Map implementations.
19   */
20  class CoverageMapBase {
21
22  public:
23
24    /*!
25     *  This structure identifies the low and high addresses
26     *  of one range.  Note:: There may be more than one address
27     *  range per symbol.
28     */
29    typedef struct {
30      /*!
31       *  This is the low address of the address map range.
32       */
33      uint32_t lowAddress;
34
35      /*!
36       *  This is the high address of the address map range.
37       */
38      uint32_t highAddress;
39
40    } AddressRange_t;
41
42    /*
43     *  This type identifies a list of ranges.
44     */
45    typedef std::list< AddressRange_t >           AddressRange;
46    typedef std::list< AddressRange_t >::iterator AddressRangeIterator_t;
47
48    /*!
49     *  This method constructs a CoverageMapBase instance.
50     *
51     *  @param[in] low specifies the lowest address of the coverage map
52     *  @param[in] high specifies the highest address of the coverage map
53     */
54    CoverageMapBase(
55      uint32_t low,
56      uint32_t high
57    );
58
59    /*!
60     *  This method destructs a CoverageMapBase instance.
61     */
62    virtual ~CoverageMapBase();
63
64    /*!
65     *  This method adds a address range to the RangeList.
66     *
67     *  @param[in]  Low specifies the lowAddress
68     *  @param[in]  High specifies the highAddress
69     * 
70     */
71    void Add( uint32_t low, uint32_t high );
72 
73    /*!
74     *  This method returns true and sets the offset if
75     *  the address falls with the bounds of an address range
76     *  in the RangeList.
77     *
78     *  @param[in]  address specifies the address to find
79     *  @param[out] offset contains the offset from the low
80     *              address of the address range.
81     * 
82     *  @return Returns TRUE if the address range can be found
83     *   and FALSE if it was not.
84      */
85    bool determineOffset( uint32_t address, uint32_t *offset ) const;
86
87    /*!
88     *  This method prints the contents of the coverage map to stdout.
89     */
90    void dump( void ) const;
91
92    /*!
93     *  This method will return the low address of the first range in
94     *  the RangeList.
95     *
96     *  @return Returns the low address of the first range in
97     *  the RangeList.
98     */
99    int32_t getFirstLowAddress() const;
100
101    /*!
102     *  This method returns true and sets the address range if
103     *  the address falls with the bounds of an address range
104     *  in the RangeList.
105     *
106     *  @param[in]  address specifies the address to find
107     *  @param[out] range contains the high and low addresse for
108     *              the range
109     * 
110     *  @return Returns TRUE if the address range can be found
111     *   and FALSE if it was not.
112     */
113    bool getRange( uint32_t address, AddressRange_t *range ) const;
114
115    /*!
116     *  This method returns the size of the address range.
117     *
118     *  @return Returns Size of the address range.
119     */
120    uint32_t getSize() const;
121
122
123    /*!
124     *  This method returns the address of the beginning of the
125     *  instruction that contains the specified address.
126     *
127     *  @param[in] address specifies the address to search from
128     *  @param[out] beginning contains the address of the beginning of
129     *              the instruction.
130     * 
131     *  @return Returns TRUE if the beginning of the instruction was
132     *   found and FALSE if it was not.
133     */
134    bool getBeginningOfInstruction(
135      uint32_t  address,
136      uint32_t* beginning
137    ) const;
138
139    /*!
140     *  This method returns the high address of the coverage map.
141     *
142     *  @return Returns the high address of the coverage map.
143    uint32_t getHighAddress( void ) const;
144     */
145
146    /*!
147     *  This method returns the low address of the coverage map.
148     *
149     *  @return Returns the low address of the coverage map.
150    uint32_t getLowAddress( void ) const;
151     */
152
153    /*!
154     *  This method sets the boolean which indicates if this
155     *  is the starting address for an instruction.
156     *
157     *  @param[in] address specifies the address of the start of an instruction
158     */
159    void setIsStartOfInstruction(
160      uint32_t address
161    );
162
163    /*!
164     *  This method returns a boolean which indicates if this
165     *  is the starting address of an instruction.
166     *
167     *  @param[in] address specifies the address to check
168     *
169     *  @return Returns TRUE if the specified address is the start
170     *   of an instruction and FALSE otherwise.
171     */
172    bool isStartOfInstruction( uint32_t address ) const;
173
174    /*!
175     *  This method increments the counter which indicates how many times
176     *  the instruction at the specified address was executed.
177     *
178     *  @param[in] address specifies the address which was executed
179     */
180    virtual void setWasExecuted( uint32_t address );
181
182    /*!
183     *  This method returns a boolean which indicates if the instruction
184     *  at the specified address was executed.
185     *
186     *  @param[in] address specifies the address to check
187     * 
188     *  @return Returns TRUE if the instruction at the specified
189     *   address was executed and FALSE otherwise.
190     */
191    bool wasExecuted( uint32_t address ) const;
192
193    /*!
194     *  This method increases the counter which indicates how many times
195     *  the instruction at the specified address was executed. It is used
196     *  for merging coverage maps.
197     *
198     *  @param[in] address specifies the address which was executed
199     *  @param[in] address specifies the execution count that should be
200     *             added
201     */
202    virtual void sumWasExecuted( uint32_t address, uint32_t addition );
203
204    /*!
205     *  This method returns an unsigned integer which indicates how often
206     *  the instruction at the specified address was executed.
207     *
208     *  @param[in] address specifies the address to check
209     * 
210     *  @return Returns number of executins
211     */
212    uint32_t getWasExecuted( uint32_t address ) const;
213
214    /*!
215     *  This method sets the boolean which indicates if the specified
216     *  address is the starting address of a branch instruction.
217     *
218     *  @param[in] address specifies the address of the branch instruction
219     */
220    void setIsBranch( uint32_t address );
221
222    /*!
223     *  This method returns a boolean which indicates if the specified
224     *  address is the starting address of a NOP instruction.
225     *
226     *  @param[in] address specifies the address to check
227     *
228     *  @return Returns TRUE if a NOP instruction is at the
229     *   specified address and FALSE otherwise.
230     */
231    bool isNop( uint32_t address ) const;
232
233    /*!
234     *  This method sets the boolean which indicates if the specified
235     *  address is the starting address of a NOP instruction.
236     *
237     *  @param[in] address specifies the address of the NOP instruction
238     */
239    void setIsNop( uint32_t address );
240
241    /*!
242     *  This method returns a boolean which indicates if the specified
243     *  address is the starting address of a branch instruction.
244     *
245     *  @param[in] address specifies the address to check
246     *
247     *  @return Returns TRUE if a branch instruction is at the
248     *   specified address and FALSE otherwise.
249     */
250    bool isBranch( uint32_t address ) const;
251
252    /*!
253     *  This method increments the counter which indicates how many times
254     *  the branch at the specified address was taken.
255     *
256     *  @param[in] address specifies the address of the branch instruction
257     */
258    void setWasTaken( uint32_t address );
259
260    /*!
261     *  This method increases the counter which indicates how many times
262     *  the branch at the specified address was taken. It is used
263     *  for merging coverage maps.
264     *
265     *  @param[in] address specifies the address which was executed
266     *  @param[in] address specifies the execution count that should be
267     *             added
268     */
269    virtual void sumWasTaken( uint32_t address, uint32_t addition );
270
271    /*!
272     *  This method returns an unsigned integer which indicates how often
273     *  the branch at the specified address was taken.
274     *
275     *  @param[in] address specifies the address to check
276     *
277     *  @return Returns number of executins
278     */
279    uint32_t getWasTaken( uint32_t address ) const;
280
281    /*!
282     *  This method increments the counter which indicates how many times
283     *  the branch at the specified address was not taken.
284     *
285     *  @param[in] address specifies the address of the branch instruction
286     */
287    void setWasNotTaken( uint32_t address );
288
289    /*!
290     *  This method increases the counter which indicates how many times
291     *  the branch at the specified address was not taken. It is used
292     *  for merging coverage maps.
293     *
294     *  @param[in] address specifies the address which was executed
295     *  @param[in] address specifies the execution count that should be
296     *             added
297     */
298    virtual void sumWasNotTaken( uint32_t address, uint32_t addition );
299
300    /*!
301     *  This method returns an unsigned integer which indicates how often
302     *  the branch at the specified address was not taken.
303     *
304     *  @param[in] address specifies the address to check
305     *
306     *  @return Returns number of executins
307     */
308    uint32_t getWasNotTaken( uint32_t address ) const;
309
310
311    /*!
312     *  This method returns a boolean which indicates if the branch
313     *  instruction at the specified address is ALWAYS taken.
314     *
315     *  @param[in] address specifies the address to check
316     *
317     *  @return Returns TRUE if the branch instruction at the
318     *   specified address is ALWAYS taken and FALSE otherwise.
319     */
320    bool wasAlwaysTaken( uint32_t address ) const;
321
322    /*!
323     *  This method returns a boolean which indicates if the branch
324     *  instruction at the specified address is NEVER taken.
325     *
326     *  @param[in] address specifies the address to check
327     *
328     *  @return Returns TRUE if the branch instruction at the
329     *  specified address is NEVER taken and FALSE otherwise.
330     */
331    bool wasNeverTaken( uint32_t address ) const;
332
333    /*!
334     *  This method returns a boolean which indicates if the branch
335     *  instruction at the specified address was NOT taken.
336     *
337     *  @param[in] address specifies the address to check
338     *
339     *  @return Returns TRUE if the branch instruction at the
340     *   specified address was NOT taken and FALSE otherwise.
341     */
342    bool wasNotTaken( uint32_t address ) const;
343
344    /*!
345     *  This method returns a boolean which indicates if the branch
346     *  instruction at the specified address was taken.
347     *
348     *  @param[in] address specifies the address to check
349     *
350     *  @return Returns TRUE if the branch instruction at the
351     *  specified address was taken and FALSE otherwise.
352     */
353    bool wasTaken( uint32_t address ) const;
354
355  protected:
356
357    /*!
358     *  This structure defines the information that is gathered and
359     *  tracked per address.
360     */
361    typedef struct {
362      /*!
363       *  This member indicates that the address is the start of
364       *  an instruction.
365       */
366      bool isStartOfInstruction;
367      /*!
368       *  This member indicates how many times the address was executed.
369       */
370      uint32_t wasExecuted;
371      /*!
372       *  This member indicates that the address is a branch instruction.
373       */
374      bool isBranch;
375      /*!
376       *  This member indicates that the address is a NOP instruction.
377       */
378      bool isNop;
379      /*!
380       *  When isBranch is TRUE, this member indicates that the branch
381       *  instruction at the address was taken.
382       */
383      uint32_t wasTaken;
384      /*!
385       *  When isBranch is TRUE, this member indicates that the branch
386       *  instruction at the address was NOT taken.
387       */
388      uint32_t wasNotTaken;
389    } perAddressInfo_t;
390
391    /*!
392     *
393     *  This is a list of address ranges for this symbolic address.
394     */
395    AddressRange RangeList;
396
397    /*!
398     * 
399     *  This variable contains the size of the code block.
400     */
401    uint32_t Size;
402
403    /*!
404     *  This is a dynamically allocated array of data that is
405     *  kept for each address.
406     */
407    perAddressInfo_t* Info;
408  };
409
410}
411#endif
Note: See TracBrowser for help on using the repository browser.