source: rtems-tools/tester/covoar/GcovFunctionData.h @ 3e187ba

5
Last change on this file since 3e187ba 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: 6.6 KB
Line 
1/*! @file GcovFunctionData.h
2 *  @brief GcovFunctionData Specification
3 *
4 *  This file contains the specification of the GcovGcnoWriter class.
5 */
6
7#ifndef __GCOV_FUNCTION_DATA_H__
8#define __GCOV_FUNCTION_DATA_H__
9
10#include <stdint.h>
11#include <list>
12#include "CoverageMapBase.h"
13#include "DesiredSymbols.h"
14
15namespace Gcov {
16
17#define FUNCTION_NAME_LENGTH            64
18#define FILE_NAME_LENGTH                256
19
20#define ON_TREE_ARC_FLAG                0x1
21#define FAKE_ARC_FLAG                   0x2
22#define FALLTHROUGH_ARC_FLAG            0x4
23
24struct gcov_arc_info
25{
26    uint32_t    sourceBlock;
27    uint32_t    destinationBlock;
28    uint32_t    flags;
29    uint64_t    counter;
30};
31
32struct gcov_block_info
33{
34    uint32_t                    id;
35    uint32_t                    flags;
36    uint32_t                    numberOfLines;
37    uint64_t                    counter;
38    char                        sourceFileName[FILE_NAME_LENGTH];
39    std::list<uint32_t>         lines;
40};
41
42typedef std::list<gcov_arc_info>                arcs_t;
43typedef std::list<gcov_arc_info>::iterator      arcs_iterator_t;
44typedef std::list<gcov_block_info>              blocks_t;
45typedef std::list<gcov_block_info>::iterator    blocks_iterator_t;
46
47  /*! @class GcovFunctionData
48   *
49   *  This is the specification of the GcovFunctionData class.
50   */
51  class GcovFunctionData {
52
53  public:
54
55    /*!
56     *  This method constructs a GcovFunctionData instance.
57     */
58        GcovFunctionData();
59
60    /*!
61     *  This method destructs a GcovFunctionData instance.
62     */
63    virtual ~GcovFunctionData();
64
65    /*!
66     *  This method stores checksum related to function
67     *
68     *  @param[in] chk stores the checksum value
69     */
70    void setChecksum(
71            const uint32_t              chk
72    );
73
74    /*!
75     *  This method stores id of function
76     *
77     *  @param[in] idNumber stores the id value
78     */
79    void setId(
80            const uint32_t              idNumber
81    );
82
83    /*!
84     *  This method stores checksum related to function
85     *
86     *  @param[in] lineNo passes number of the line begining the function
87     */
88    void setFirstLineNumber(
89            const uint32_t              lineNo
90    );
91
92    /*!
93     *  This method stores name of the function and ties it to its
94     *  unified coverage map.
95     *
96     *  @param[in] functionName passes name of the the function
97     *
98     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
99     */
100    bool setFunctionName(
101            const char*                 fcnName
102    );
103
104    /*!
105     *  This method stores name of the source file where function is located
106     *
107     *  @param[in] fileName passes name of the the file
108     *
109     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
110     */
111    bool setFileName(
112            const char*                 fileName
113    );
114
115    /*!
116     *  This method stores name of the source file where block is located
117     *
118     *  @param[in] block identifies block
119     *  @param[in] fileName passes name of the the file
120     *
121     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
122     */
123    void setBlockFileName(
124            const blocks_iterator_t             block,
125            const char*                         fileName
126    );
127
128    /*!
129     *  This method returns arcs list
130     */
131    arcs_t getArcs() const;
132
133    /*!
134     *  This method returns blocks list
135     */
136    blocks_t getBlocks() const;
137
138    /*!
139     *  This method returns checksum
140     */
141    uint32_t getChecksum() const;
142
143    /*!
144     *  This method returns id
145     */
146    uint32_t getId() const;
147
148    /*!
149     *  This method returns counters
150     *
151     *  @param[out] counterValues array of counter values
152     *  @param[out] countersFound used to return counters number
153     *  @param[out] countersSum used to return sum counters values
154     *  @param[out] countersMax used to return max counter value
155     */
156    void getCounters( uint64_t* counterValues, uint32_t &countersFound, uint64_t &countersSum, uint64_t &countersMax );
157
158    /*!
159     *  This method adds new arc to arc list
160     *
161     *  @param[in] source passes source block number
162     *  @param[in] destination passes destination block number
163     */
164    void addArc(
165            uint32_t    source,
166            uint32_t    destination,
167            uint32_t    flags
168    );
169
170    /*!
171     *  This method adds new arc to arc list
172     *
173     *  @param[in] block identifies block
174     *  @param[in] line passes the line number
175     */
176    void addBlockLine(
177            const blocks_iterator_t     block,
178            const uint32_t              line
179    );
180
181    /*!
182     *  This method finds block by its ID
183     *
184     *  @param[in] id passes block id number
185     *
186     *  @return Returns iterator to a matching block or NULL for error.
187     */
188    blocks_iterator_t findBlockById(
189            const uint32_t              id
190    );
191
192    /*!
193     *  This method adds new block to block list
194     *
195     *  @param[in] id passes block id number
196     *  @param[in] flags passes per block flags
197     *  @param[in] sourceFileName passes containing file name
198     */
199    void addBlock(
200            const uint32_t              id,
201            const uint32_t              flags,
202            const char *                sourceFileName
203    );
204
205    /*!
206     *  This method prints info about function
207     */
208    void printFunctionInfo( FILE * textFile, uint32_t function_number );
209
210    /*!
211     *  This method prints info about coverage of this function
212     */
213    void printCoverageInfo( FILE * textFile, uint32_t function_number );
214
215    /*!
216     *  This method prints info about chosen arc in arcs list
217     *
218     *  @param[in] textFile specifies output file
219     *  @param[in] arc passes iterator identifying arc
220     */
221    void printArcInfo(
222            FILE * textFile,
223            arcs_iterator_t arc
224    );
225
226    /*!
227     *  This method prints info about chosen block in blocks list
228     *
229     *  @param[in] block passes iterator identifying block
230     */
231    void printBlockInfo(
232            FILE * textFile,
233            blocks_iterator_t block
234    );
235
236    /*!
237     *  This method calculates values of arc counters
238     */
239    bool processFunctionCounters( void );
240
241  private:
242
243    uint32_t            id;
244    uint32_t            checksum;
245    uint32_t            firstLineNumber;
246    uint32_t            numberOfBlocks;
247    uint32_t            numberOfArcs;
248    arcs_t              arcs;
249    blocks_t            blocks;
250    char                functionName[FUNCTION_NAME_LENGTH];
251    char                sourceFileName[FILE_NAME_LENGTH];
252
253    /*!
254     *  This member contains the unified or merged coverage map
255     *  and symbol info for the symbol.
256     */
257    Coverage::CoverageMapBase*          coverageMap;
258    Coverage::SymbolInformation*        symbolInfo;
259
260    /*!
261     *  This method creates list of taken/not taken values
262     *  for branches
263     *
264     *  @param[in] taken      used to return taken counts list
265     *  @param[in] notTaken   used to return not taken counts list
266     */
267    bool processBranches(
268            std::list<uint64_t> * taken ,
269            std::list<uint64_t> * notTaken
270    );
271  };
272
273}
274#endif
Note: See TracBrowser for help on using the repository browser.