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

5
Last change on this file since cb018bc was cb018bc, checked in by Hermann Felbinger <hermann19829@…>, on 08/26/17 at 08:15:53

covoar: Add information to improve diagnostics.

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