source: rtems-tools/tester/covoar/GcovData.h @ f9a4b2c

5
Last change on this file since f9a4b2c 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: 5.1 KB
Line 
1/*! @file GcovData.h
2 *  @brief GcovData Specification
3 *
4 *  This file contains the specification of the GcovGcnoWriter class.
5 */
6
7#ifndef __GCOV_DATA_H__
8#define __GCOV_DATA_H__
9
10#include <stdint.h>
11#include <list>
12#include <iostream>
13#include "GcovFunctionData.h"
14
15namespace Gcov {
16
17#define GCDA_MAGIC ((uint32_t) 0x67636461 )     /* "gcda" */
18#define GCNO_MAGIC ((uint32_t) 0x67636e6f )     /* "gcno" */
19
20/* we are using gcc 4.6 release format, coded as "406R" */
21#define GCNO_VERSION ((uint32_t) 0x34303652 )
22
23/* GCOV tags */
24#define GCOV_TAG_FUNCTION                       ((uint32_t)0x01000000)
25#define GCOV_TAG_BLOCKS                         ((uint32_t)0x01410000)
26#define GCOV_TAG_ARCS                           ((uint32_t)0x01430000)
27#define GCOV_TAG_LINES                          ((uint32_t)0x01450000)
28#define GCOV_TAG_COUNTER                        ((uint32_t)0x01a10000)
29#define GCOV_TAG_OBJECT_SUMMARY         ((uint32_t)0xa1000000)
30#define GCOV_TAG_PROGRAM_SUMMARY        ((uint32_t)0xa3000000)
31
32
33typedef std::list<Gcov::GcovFunctionData*>              functions_t;
34typedef std::list<Gcov::GcovFunctionData*>::iterator    functions_iterator_t;
35
36struct gcov_preamble
37{
38    uint32_t magic;
39    uint32_t version;
40    uint32_t timestamp;
41};
42
43struct gcov_frame_header
44{
45    uint32_t tag;
46    uint32_t length;
47};
48
49struct gcov_statistics
50{
51    uint32_t checksum;          // checksum
52    uint32_t counters;          // number of counters
53    uint32_t runs;              // number of runs
54    uint64_t sum;               // sum of all couter values
55    uint64_t max;               // max value on a single run
56    uint64_t sumMax;            // sum of individual runs max values
57};
58
59  /*! @class GcovData
60   *
61   *  This is the specification of the GcovData class.
62   */
63  class GcovData {
64
65  public:
66
67    /*!
68     *  This method constructs a GcnoReader instance.
69     */
70    GcovData();
71
72    /*!
73     *  This method destructs a GcnoReader instance.
74     */
75    virtual ~GcovData();
76
77    /*!
78     *  This method reads the *.gcno file
79     *
80     *  @param[in] fileName name of the file to read
81     *
82     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
83     */
84    bool readGcnoFile( const char* const  fileName );
85
86    /*!
87     *  This method writes the *.gcda file. It also produces and stores
88     *  gcda and txt file names for future outputs.
89     *
90     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
91     */
92    bool writeGcdaFile ();
93
94    /*!
95     *  This method writes all contained information to stdout file
96     *
97     *  @return Returns TRUE if the method succeeded and FALSE if it failed.
98     */
99    bool writeReportFile();
100
101    /*!
102     *  This method runs gcov to generate report. This method should
103     *  be used only when gcno and gcda files are already generated.
104     */
105    void writeGcovFile( );
106
107    /*!
108     *  This method calculates values of counters for all functions
109     */
110    bool processCounters( void );
111
112  private:
113
114    uint32_t                            numberOfFunctions;
115    gcov_preamble                       gcnoPreamble;
116    char                                gcnoFileName[FILE_NAME_LENGTH];
117    char                                gcdaFileName[FILE_NAME_LENGTH];
118    char                                textFileName[FILE_NAME_LENGTH];
119    char                                cFileName[FILE_NAME_LENGTH];
120    functions_t                         functions;
121
122
123    /*!
124     *  This method reads a frame from *.gcno file
125     *
126     *  @param[in] file points to a file to read
127     *
128     *  @return true if read was succesfull, false otherwise
129     */
130    bool readFrame(
131            FILE*       gcovFile
132    );
133
134    /*!
135     *  This method reads a string from gcov file
136     *
137     *  @param[in] buffer stores the string
138     *  @param[in] file specifies the name of the file to read
139     *
140     *  @return Returns length of words read (word = 32bit) or -1 if error ocurred
141     */
142    int readString(
143            char*       buffer,
144            FILE*       gcovFile
145    );
146
147    /*!
148     *  This method reads a frame header from gcov file
149     *
150     *  @param[in] header stores the header
151     *  @param[in] file specifies the name of the file to read
152     *
153     *  @return Returns length of words read (word = 32bit)
154     *  or -1 if error ocurred
155     */
156    int readFrameHeader(
157            gcov_frame_header*  header,
158            FILE*               gcovFile
159    );
160
161    /*!
162     *  This method reads a frame header from gcov file
163     *
164     *  @param[in] preamble stores the preamble
165     *  @param[in] gcovFile specifies the name of the file to read
166     *  @param[in] desiredMagic stores the expected magic of a file
167     *
168     *  @return Returns length of words read (word = 32bit)
169     *          or -1 if error ocurred
170     */
171    int readFilePreamble(
172            gcov_preamble*      preamble,
173            FILE*               gcovFile,
174            const uint32_t      desiredMagic
175    );
176
177    /*!
178     *  This method reads a function frame from gcov file
179     *
180     *  @param[in] header passes frame header
181     *  @param[in] gcovFile specifies the name of the file to read
182     *  @param[in] function stores the expected magic of a file
183     *
184     *  @return Returns true if operation was succesfull
185     */
186    bool readFunctionFrame(
187            gcov_frame_header   header,
188            FILE*               gcovFile,
189            GcovFunctionData*   function
190    );
191
192    /*!
193     *  This method prints info about previously read *.gcno file
194     *  to a specified report file
195     */
196    void printGcnoFileInfo( FILE * textFile );
197  };
198}
199#endif
Note: See TracBrowser for help on using the repository browser.