source: rtems-tools/tester/covoar/DesiredSymbols.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: 8.3 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] exefileName specifies the executable from which the
222     *             coverage map is being created
223     *  @param[in] symbolName specifies the symbol for which to create
224     *             a coverage map
225     *  @param[in] size specifies the size of the coverage map to create
226     */
227    void createCoverageMap(
228      const std::string& exefileName,
229      const std::string& symbolName,
230      uint32_t           size
231    );
232
233    /*!
234     *  This method looks up the symbol information for the specified symbol.
235     *
236     *  @param[in] symbolName specifies the symbol for which to search
237     *
238     *  @return Returns a pointer to the symbol's information
239     */
240    SymbolInformation* find(
241      const std::string& symbolName
242    );
243
244    /*!
245     *  This method determines the source lines that correspond to any
246     *  uncovered ranges or branches.
247     */
248    void findSourceForUncovered( void );
249
250    /*!
251     *  This method returns the total number of branches always taken
252     *  for all analyzed symbols.
253     *
254     *  @return Returns the total number of branches always taken
255     */
256    uint32_t getNumberBranchesAlwaysTaken( void ) const;
257
258    /*!
259     *  This method returns the total number of branches found for
260     *  all analyzed symbols.
261     *
262     *  @return Returns the total number of branches found
263     */
264    uint32_t getNumberBranchesFound( void ) const;
265
266    /*!
267     *  This method returns the total number of branches never taken
268     *  for all analyzed symbols.
269     *
270     *  @return Returns the total number of branches never taken
271     */
272    uint32_t getNumberBranchesNeverTaken( void ) const;
273
274    /*!
275     *  This method returns the total number of uncovered ranges
276     *  for all analyzed symbols.
277     *
278     *  @return Returns the total number of uncovered ranges
279     */
280    uint32_t getNumberUncoveredRanges( void ) const;
281
282    /*!
283     *  This method returns an indication of whether or not the specified
284     *  symbol is a symbol to analyze.
285     *
286     *  @return Returns TRUE if the specified symbol is a symbol to analyze
287     *   and FALSE otherwise.
288     */
289    bool isDesired (
290      const std::string& symbolName
291    ) const;
292
293    /*!
294     *  This method creates the set of symbols to analyze from the symbols
295     *  listed in the specified file.
296     */
297    void load(
298      const char* const symbolsFile
299    );
300
301    /*!
302     *  This method merges the coverage information from the source
303     *  coverage map into the unified coverage map for the specified symbol.
304     *
305     *  @param[in] symbolName specifies the symbol associated with the
306     *             destination coverage map
307     *  @param[in] sourceCoverageMap specifies the source coverage map
308     */
309    void mergeCoverageMap(
310      const std::string&           symbolName,
311      const CoverageMapBase* const sourceCoverageMap
312    );
313
314    /*!
315     *  This method preprocesses each symbol's coverage map to mark nop
316     *  and branch information.
317     */
318    void preprocess( void );
319
320    /*!
321     *  This member contains the statistics kept on each symbol.
322     */
323    Statistics stats;
324
325  private:
326
327    /*!
328     *  This method uses the specified executable file to determine the
329     *  source lines for the elements in the specified ranges.
330     */
331    void determineSourceLines(
332      CoverageRanges* const theRanges,
333      ExecutableInfo* const theExecutable
334    );
335
336  };
337}
338
339#endif
Note: See TracBrowser for help on using the repository browser.