source: rtems-tools/tester/covoar/DesiredSymbols.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: 8.1 KB
Line 
1/*! @file DesiredSymbols.h
2 *  @brief DesiredSymbols Specification
3 *
4 *  This file contains the specification of the DesiredSymbols class.
5 */
6
7#ifndef __DESIRED_SYMBOLS_H__
8#define __DESIRED_SYMBOLS_H__
9
10#include <list>
11#include <map>
12#include <stdint.h>
13#include <string>
14
15#include "CoverageMapBase.h"
16#include "CoverageRanges.h"
17#include "ExecutableInfo.h"
18#include "ObjdumpProcessor.h"
19
20namespace Coverage {
21
22
23  /*!
24   *
25   *  This class defines the statistics that are tracked.
26   */
27  class Statistics {
28    public:
29
30    /*!
31     *  This member variable contains the total number of branches always
32     *  taken.
33     */
34    int branchesAlwaysTaken;
35
36    /*!
37     *  This member variable contains the total number of branches where
38     *  one or more paths were executed.
39     */
40    int branchesExecuted;
41
42    /*!
43     *  This member variable contains the total number of branches never
44     *  taken.
45     */
46    int branchesNeverTaken;
47
48    /*!
49     *  This member variable contains the total number of branches not
50     *  executed AT ALL.
51     */
52    int branchesNotExecuted;
53
54    /*!
55     *  This member contains the size in Bytes.
56     */
57    uint32_t sizeInBytes;
58   
59    /*!
60     *  This member contains the size in Bytes.
61     */
62    uint32_t sizeInInstructions;
63
64    /*!
65     *  This member variable contains the total number of uncovered bytes.
66     */
67    int uncoveredBytes;
68
69    /*!
70     *  This member variable contains the total number of uncovered assembly
71     *  instructions.
72     */
73    int uncoveredInstructions;
74
75    /*!
76     *  This member variable contains the total number of uncovered ranges.
77     */
78    int uncoveredRanges;
79
80    /*!
81     *  This method returns the percentage of uncovered instructions.
82     *
83     *  @return Returns the percent uncovered instructions
84     */
85    uint32_t getPercentUncoveredInstructions( void ) const;
86
87    /*!
88     *  This method returns the percentage of uncovered bytes.
89     *
90     *  @return Returns the percent uncovered bytes
91     */
92     uint32_t getPercentUncoveredBytes( void ) const;
93
94    /*!
95     *  This method constructs a Statistics instance.
96     */   
97     Statistics():
98       branchesAlwaysTaken(0),
99       branchesExecuted(0),
100       branchesNeverTaken(0),
101       branchesNotExecuted(0),
102       sizeInBytes(0),
103       sizeInInstructions(0),
104       uncoveredBytes(0),
105       uncoveredInstructions(0),
106       uncoveredRanges(0)
107     {
108     }
109
110  };
111
112  /*! @class SymbolInformation
113   *
114   *  This class defines the information kept for each symbol that is
115   *  to be analyzed.
116   */
117  class SymbolInformation {
118
119  public:
120
121    /*!
122     *  This member contains the base address of the symbol.
123     */
124    uint32_t baseAddress;
125
126
127    /*!
128     *  This member contains the disassembly associated with a symbol.
129     */
130    std::list<ObjdumpProcessor::objdumpLine_t> instructions;
131
132    /*!
133     *  This member contains the executable that was used to
134     *  generate the disassembled instructions.
135     */
136    ExecutableInfo* sourceFile;
137
138    /*!
139     *  This member contains the statistics kept on each symbol.
140     */   
141    Statistics stats;
142
143    /*!
144     *  This member contains information about the branch instructions of
145     *  a symbol that were not fully covered (i.e. taken/not taken).
146     */
147    CoverageRanges* uncoveredBranches;
148
149    /*!
150     *  This member contains information about the instructions of a
151     *  symbol that were not executed.
152     */
153    CoverageRanges* uncoveredRanges;
154
155    /*!
156     *  This member contains the unified or merged coverage map
157     *  for the symbol.
158     */
159    CoverageMapBase* unifiedCoverageMap;
160
161    /*!
162     *  This method constructs a SymbolInformation instance.
163     */
164    SymbolInformation() :
165      baseAddress( 0 ),
166      uncoveredBranches( NULL ),
167      uncoveredRanges( NULL ),
168      unifiedCoverageMap( NULL )
169    {
170    }
171
172    ~SymbolInformation() {}
173  };
174
175  /*! @class DesiredSymbols
176   *
177   *  This class defines the set of desired symbols to analyze.
178   */
179  class DesiredSymbols {
180
181  public:
182
183    /*!
184     *  This map associates each symbol with its symbol information.
185     */
186    typedef std::map<std::string, SymbolInformation> symbolSet_t;
187
188    /*!
189     *  This variable contains a map of symbol sets for each
190     *  symbol in the system keyed on the symbol name.
191     */
192    symbolSet_t set;
193
194    /*!
195     *  This method constructs a DesiredSymbols instance.
196     */
197    DesiredSymbols();
198
199    /*!
200     *  This method destructs a DesiredSymbols instance.
201     */
202    ~DesiredSymbols();
203
204    /*!
205     *  This method loops through the coverage map and
206     *  calculates the statistics that have not already
207     *  been filled in.
208     */
209    void calculateStatistics( void );
210
211    /*!
212     *  This method analyzes each symbols coverage map to determine any
213     *  uncovered ranges or branches.
214     */
215    void computeUncovered( void );
216
217    /*!
218     *  This method creates a coverage map for the specified symbol
219     *  using the specified size.
220     *
221     *  @param[in] symbolName specifies the symbol for which to create
222     *             a coverage map
223     *  @param[in] size specifies the size of the coverage map to create
224     */
225    void createCoverageMap(
226      const std::string& symbolName,
227      uint32_t           size
228    );
229
230    /*!
231     *  This method looks up the symbol information for the specified symbol.
232     *
233     *  @param[in] symbolName specifies the symbol for which to search
234     *
235     *  @return Returns a pointer to the symbol's information
236     */
237    SymbolInformation* find(
238      const std::string& symbolName
239    );
240
241    /*!
242     *  This method determines the source lines that correspond to any
243     *  uncovered ranges or branches.
244     */
245    void findSourceForUncovered( void );
246
247    /*!
248     *  This method returns the total number of branches always taken
249     *  for all analyzed symbols.
250     *
251     *  @return Returns the total number of branches always taken
252     */
253    uint32_t getNumberBranchesAlwaysTaken( void ) const;
254
255    /*!
256     *  This method returns the total number of branches found for
257     *  all analyzed symbols.
258     *
259     *  @return Returns the total number of branches found
260     */
261    uint32_t getNumberBranchesFound( void ) const;
262
263    /*!
264     *  This method returns the total number of branches never taken
265     *  for all analyzed symbols.
266     *
267     *  @return Returns the total number of branches never taken
268     */
269    uint32_t getNumberBranchesNeverTaken( void ) const;
270
271    /*!
272     *  This method returns the total number of uncovered ranges
273     *  for all analyzed symbols.
274     *
275     *  @return Returns the total number of uncovered ranges
276     */
277    uint32_t getNumberUncoveredRanges( void ) const;
278
279    /*!
280     *  This method returns an indication of whether or not the specified
281     *  symbol is a symbol to analyze.
282     *
283     *  @return Returns TRUE if the specified symbol is a symbol to analyze
284     *   and FALSE otherwise.
285     */
286    bool isDesired (
287      const std::string& symbolName
288    ) const;
289
290    /*!
291     *  This method creates the set of symbols to analyze from the symbols
292     *  listed in the specified file.
293     */
294    void load(
295      const char* const symbolsFile
296    );
297
298    /*!
299     *  This method merges the coverage information from the source
300     *  coverage map into the unified coverage map for the specified symbol.
301     *
302     *  @param[in] symbolName specifies the symbol associated with the
303     *             destination coverage map
304     *  @param[in] sourceCoverageMap specifies the source coverage map
305     */
306    void mergeCoverageMap(
307      const std::string&           symbolName,
308      const CoverageMapBase* const sourceCoverageMap
309    );
310
311    /*!
312     *  This method preprocesses each symbol's coverage map to mark nop
313     *  and branch information.
314     */
315    void preprocess( void );
316
317    /*!
318     *  This member contains the statistics kept on each symbol.
319     */   
320    Statistics stats;
321
322  private:
323
324    /*!
325     *  This method uses the specified executable file to determine the
326     *  source lines for the elements in the specified ranges.
327     */
328    void determineSourceLines(
329      CoverageRanges* const theRanges,
330      ExecutableInfo* const theExecutable
331    );
332
333  };
334}
335
336#endif
Note: See TracBrowser for help on using the repository browser.