1 | /*
|
---|
2 | * TOPPERS/JSP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Just Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | *
|
---|
9 | * ä¸è¨è使¨©è
|
---|
10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
11 | * ã«ãã£ã¦å
|
---|
12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
15 | å¸ï¼ä»¥ä¸ï¼
|
---|
16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
21 | * ç¨ã§ããå½¢ã§åé
|
---|
22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
24 | * è
|
---|
25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
30 | * ã¨ï¼
|
---|
31 | * (a) åé
|
---|
32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
34 | * 使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
35 | * (b) åé
|
---|
36 | å¸ã®å½¢æ
|
---|
37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
38 | * å ±åãããã¨ï¼
|
---|
39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
40 | * 害ãããï¼ä¸è¨è使¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
42 | 責ãããã¨ï¼
|
---|
43 | *
|
---|
44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨è使¨©è
|
---|
45 | ã
|
---|
46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id: coverage_defs.h,v 1.4 2003/12/15 07:32:13 takayuki Exp $
|
---|
51 | */
|
---|
52 |
|
---|
53 | /*
|
---|
54 | #ifdefé¢ä¿
|
---|
55 | coverage_defsã¯ãundefsã§è§£é¤ãããã¨ã«èªã¿è¾¼ãå ´åãããã®ã§ã
|
---|
56 | ãã¼ããããã¤ãã«åå²ãã¦ãã.
|
---|
57 | - COVERAGE : ã«ãã¬ãã¸æ©è½ã使ç¨ãããã©ãã
|
---|
58 | - COVERAGE_H : coverage.cppã«é¢é£ããé¨åã§ãå¤éå®ç¾©ããã¦ã¯å°ããã®
|
---|
59 | - COVERAGE_DEFS : ã«ãã¬ãã¸ã«é¢é£ããé¨åã§ãcoverage_undefs.hã§undefã§ããããä¸åº¦coverage_defs.hãèªãã§ã大ä¸å¤«ãªãã®
|
---|
60 | */
|
---|
61 |
|
---|
62 |
|
---|
63 | #ifdef COVERAGE
|
---|
64 |
|
---|
65 | #include "base/singleton.h"
|
---|
66 |
|
---|
67 | /* ããã */
|
---|
68 | #include <string>
|
---|
69 | #include <map>
|
---|
70 | #include <set>
|
---|
71 | #include <iostream>
|
---|
72 |
|
---|
73 |
|
---|
74 | #ifndef COVERAGE_H
|
---|
75 | #define COVERAGE_H
|
---|
76 | /*
|
---|
77 | * ç°¡åãªã«ãã¬ãã¸ãã§ãã¯
|
---|
78 | */
|
---|
79 |
|
---|
80 | class Coverage {
|
---|
81 | public:
|
---|
82 | /* å ´æãä¿æããã¯ã©ã¹ */
|
---|
83 | class Location {
|
---|
84 | protected:
|
---|
85 | const char * filename;
|
---|
86 | unsigned int lineno;
|
---|
87 | const char * additional;
|
---|
88 |
|
---|
89 | public:
|
---|
90 | Location(const char * _filename, unsigned int _lineno, const char * _additional = "") : filename(_filename), lineno(_lineno), additional(_additional) {}
|
---|
91 | Location(const Location & src) : filename(src.filename), lineno(src.lineno), additional(src.additional) {}
|
---|
92 |
|
---|
93 | inline Location & operator = (const Location & right)
|
---|
94 | {
|
---|
95 | filename = right.filename;
|
---|
96 | lineno = right.lineno;
|
---|
97 | additional = right.additional;
|
---|
98 |
|
---|
99 | return *this;
|
---|
100 | }
|
---|
101 |
|
---|
102 | inline bool operator == (const Location & right) const
|
---|
103 | { return lineno == right.lineno && std::string(filename).compare(right.filename) == 0 && std::string(additional).compare(right.additional) == 0; }
|
---|
104 |
|
---|
105 | inline bool operator < (const Location & right) const
|
---|
106 | {
|
---|
107 | if(lineno < right.lineno)
|
---|
108 | return true;
|
---|
109 | if(std::string(filename).compare(right.filename) < 0)
|
---|
110 | return true;
|
---|
111 |
|
---|
112 | return false;
|
---|
113 | }
|
---|
114 |
|
---|
115 | inline std::string getFilename(void) const
|
---|
116 | { return std::string(filename); }
|
---|
117 |
|
---|
118 | inline unsigned int getLineno(void) const
|
---|
119 | { return lineno; }
|
---|
120 |
|
---|
121 | inline std::string getAdditional(void) const
|
---|
122 | { return std::string(additional); }
|
---|
123 |
|
---|
124 | //ãã©ã¼ãããæ¸ã¿ãã¡ã¤ã«ä½ç½®æ
|
---|
125 | å ±ã®åå¾ filename:lineno(additional)
|
---|
126 | std::string getDetails(void) const;
|
---|
127 | };
|
---|
128 |
|
---|
129 | //åå²ã«ãã¬ãã¸å¤å®ã®ãã¼ã¹ã¯ã©ã¹
|
---|
130 | class BranchBase {
|
---|
131 | protected:
|
---|
132 | BranchBase(const Location & location) throw(); //è¦ç´ ã®ç»é²
|
---|
133 | static BranchBase * find(const Location & location) throw(); //locationã«ä¸è´ããè¦ç´ ã®åå¾
|
---|
134 |
|
---|
135 | public:
|
---|
136 | virtual ~BranchBase(void) throw() {} //ãã¹ãã©ã¯ã¿
|
---|
137 | virtual bool checkValidity(void) const throw(...) = 0; //æ£å½æ§å¤å®
|
---|
138 | virtual std::string getDetails(void) const throw(...) = 0; //ãã¼ã¿è¡¨ç¤º
|
---|
139 | };
|
---|
140 |
|
---|
141 | //if-statementã«å¼ã£ãããã¯ã©ã¹
|
---|
142 | class If : public BranchBase {
|
---|
143 | protected:
|
---|
144 | bool true_case;
|
---|
145 | bool false_case;
|
---|
146 |
|
---|
147 | If(const Location & location) throw(); //branchçµç±ã§ç¡ãã¨çæãããªã
|
---|
148 |
|
---|
149 | public:
|
---|
150 | virtual bool checkValidity(void) const throw(); //æ£å½æ§ã®å¤å®
|
---|
151 | virtual std::string getDetails(void) const throw(); //ãã¼ã¿è¡¨ç¤º
|
---|
152 |
|
---|
153 | static bool branch(const Location & location, bool expression) throw();
|
---|
154 | };
|
---|
155 |
|
---|
156 | //while-statementã«å¼ã£ãããã¯ã©ã¹
|
---|
157 | class While : public BranchBase {
|
---|
158 | protected:
|
---|
159 | bool valid;
|
---|
160 |
|
---|
161 | While(const Location & location) throw();
|
---|
162 | public:
|
---|
163 | virtual bool checkValidity(void) const throw(); //æ£å½æ§ã®å¤å®
|
---|
164 | virtual std::string getDetails(void) const throw(); //ãã¼ã¿è¡¨ç¤º
|
---|
165 |
|
---|
166 | static bool branch(const Location & location, bool expression) throw();
|
---|
167 | };
|
---|
168 |
|
---|
169 | //switch-statementã«å¼ã£ãããã¯ã©ã¹
|
---|
170 | class Switch : public BranchBase {
|
---|
171 | protected:
|
---|
172 | std::set<int> checkpoint;
|
---|
173 |
|
---|
174 | Switch(const Location & location) throw();
|
---|
175 | static void _branch(const Location & location, int expression) throw();
|
---|
176 |
|
---|
177 | public:
|
---|
178 | virtual bool checkValidity(void) const throw(); //æ£å½æ§ã®å¤å®
|
---|
179 | virtual std::string getDetails(void) const throw(); //ãã¼ã¿è¡¨ç¤º
|
---|
180 |
|
---|
181 | template<class T>
|
---|
182 | static T branch(const Location & location, T expression) throw()
|
---|
183 | {
|
---|
184 | _branch(location, (int)expression);
|
---|
185 | return expression;
|
---|
186 | }
|
---|
187 | };
|
---|
188 |
|
---|
189 |
|
---|
190 | protected:
|
---|
191 | class BranchMap : public std::map<Location, BranchBase *> {
|
---|
192 | public:
|
---|
193 | SINGLETON_CONSTRUCTOR(BranchMap) {}
|
---|
194 | ~BranchMap(void) throw();
|
---|
195 |
|
---|
196 | };
|
---|
197 | class NewBranchList : public std::list<BranchBase *>
|
---|
198 | { public: SINGLETON_CONSTRUCTOR(NewBranchList) {} };
|
---|
199 |
|
---|
200 | //é
|
---|
201 | ç®ã®è¡¨ç¤º
|
---|
202 | static std::string getBranchName(BranchBase * node);
|
---|
203 |
|
---|
204 | public:
|
---|
205 | //å
|
---|
206 | ¨ã¦ééãããã©ããã®ãã§ãã¯
|
---|
207 | static bool checkValidity(void);
|
---|
208 |
|
---|
209 | //å
|
---|
210 | ¨ã¦ã®é
|
---|
211 | ç®ã表示
|
---|
212 | static void printCoverage(std::ostream & out);
|
---|
213 |
|
---|
214 | };
|
---|
215 |
|
---|
216 | #endif /* COVERAGE_H */
|
---|
217 |
|
---|
218 |
|
---|
219 | #ifndef COVERAGE_DEFS
|
---|
220 | #define COVERAGE_DEFS
|
---|
221 |
|
---|
222 | #define if(x) i##f(Coverage::If::branch(Coverage::Location(__FILE__, __LINE__, "if"), (x) ? true : false))
|
---|
223 | #define while(x) w##hile(Coverage::While::branch(Coverage::Location(__FILE__, __LINE__, "while"), (x) ? true : false))
|
---|
224 | #define switch(x) s##witch(Coverage::Switch::branch(Coverage::Location(__FILE__, __LINE__, "switch"), (x)))
|
---|
225 |
|
---|
226 | #endif /* COVERAGE_DEFS */
|
---|
227 |
|
---|
228 | #else
|
---|
229 |
|
---|
230 | #include <iostream>
|
---|
231 |
|
---|
232 | #ifndef COVERAGE_H
|
---|
233 | #define COVERAGE_H
|
---|
234 | class Coverage {
|
---|
235 | public:
|
---|
236 | static bool checkValidity(void) { return true; }
|
---|
237 | static void printCoverage(std::ostream &) {}
|
---|
238 | };
|
---|
239 | #endif /* COVERAGE_H */
|
---|
240 |
|
---|
241 | #endif
|
---|
242 |
|
---|