/[eiffelstudio]/branches/eth/eve/Src/framework/auto_fix/utility/afx_fix_proposer.e
ViewVC logotype

Contents of /branches/eth/eve/Src/framework/auto_fix/utility/afx_fix_proposer.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88355 - (show annotations)
Sat Mar 3 11:08:44 2012 UTC (7 years, 7 months ago) by mpei
File size: 7071 byte(s)
Complete the previous fix.
1 note
2 description: "[Summary description for {AFX_FIX_PROPOSER}.]"
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 AFX_FIX_PROPOSER
9
10 inherit
11
12 SHARED_WORKBENCH
13
14 SHARED_DEBUGGER_MANAGER
15
16 EPA_SHARED_CLASS_THEORY
17
18 EPA_DEBUGGER_UTILITY
19
20 AFX_SHARED_STATE_SERVER
21
22 SHARED_EIFFEL_PARSER
23
24 AFX_UTILITY
25
26 EPA_COMPILATION_UTILITY
27
28 AFX_SHARED_DYNAMIC_ANALYSIS_REPORT
29
30 EPA_SHARED_EQUALITY_TESTERS
31
32 EQA_TEST_EXECUTION_MODE
33
34 SHARED_SERVER
35
36 AFX_PROGRAM_EXECUTION_INVARIANT_ACCESS_MODE
37
38 AFX_SHARED_SESSION
39
40 create
41 make
42
43 feature{NONE} -- Initialization
44
45 make
46 -- Initialize Current.
47 local
48 l: AFX_INTERPRETER
49 do
50 create test_case_start_actions
51 create test_case_breakpoint_hit_actions
52 create application_exited_actions
53 end
54
55 feature -- Access
56
57 test_case_start_actions: ACTION_SEQUENCE[TUPLE [EPA_TEST_CASE_SIGNATURE]]
58 -- Actions to be performed when a test case is to be analyzed.
59 -- The information about the test case is passed as the argument to the agent.
60
61 test_case_breakpoint_hit_actions: ACTION_SEQUENCE [TUPLE [a_tc: EPA_TEST_CASE_SIGNATURE; a_state: EPA_STATE; a_bpslot: INTEGER]]
62 -- Actions to be performed when a breakpoint is hit in a test case.
63 -- `a_tc' is the test case currently analyzed.
64 -- `a_state' is the state evaluated at the breakpoint.
65 -- `a_bpslot' is the breakpoint slot number.
66
67 application_exited_actions: ACTION_SEQUENCE [TUPLE [DEBUGGER_MANAGER]]
68 -- Actions to be performed when application exited in debugger
69
70 feature -- Basic operations
71
72 execute
73 -- <Precursor>
74 local
75 l_file: PLAIN_TEXT_FILE
76 l_validator: AFX_FIX_VALIDATOR
77 do
78 reset_report
79 session.initialize_logging
80 session.start
81
82 event_actions.notify_on_session_starts
83
84 -- HACK: force re-compiling the root class by "touch"ing it, otherwise expression evaluation might fail.
85 create l_file.make (root_class_of_system.file_name)
86 l_file.touch
87
88 -- Compile project
89 compile_project (eiffel_project, True)
90
91 -- Start test case analysis
92 event_actions.notify_on_test_case_analysis_starts
93 analyze_test_cases
94 event_actions.notify_on_test_case_analysis_ends
95
96 -- Generate and store fixes.
97 event_actions.notify_on_fix_generation_starts
98 generate_fixes
99 store_fixes (fixes, "fixes.txt")
100 event_actions.notify_on_fix_generation_ends (fixes)
101
102 -- Validate generated fixes.
103 check exception_signature /= Void end
104 create l_validator.make (fixes)
105 event_actions.notify_on_fix_validation_starts(l_validator.melted_fixes)
106 l_validator.validate
107 event_actions.notify_on_fix_validation_ends(l_validator.valid_fixes)
108
109 -- Generate profiling data about AutoFix.
110 event_actions.notify_on_report_generation_starts
111 sort_valid_fixes
112 store_fixes (valid_fixes, "valid_fixes.txt")
113 event_actions.notify_on_report_generation_ends
114
115 event_actions.notify_on_session_ends
116 session.clean_up
117 end
118
119 feature{NONE} -- Implementation
120
121 store_fixes (a_fixes: DS_LINKED_LIST [AFX_FIX]; a_file_name: STRING)
122 -- Store fixes in to files.
123 local
124 l_big_file: PLAIN_TEXT_FILE
125 l_file_name: FILE_NAME
126 do
127 create l_file_name.make_from_string (config.data_directory)
128 l_file_name.set_file_name (a_file_name)
129 create l_big_file.make_create_read_write (l_file_name)
130 a_fixes.do_all (agent store_fix_in_file (config.fix_directory, ?, False, l_big_file))
131 l_big_file.close
132 end
133
134 analyze_test_cases
135 -- Analyze the execution of test cases.
136 local
137 l_intra_feature_trace_collector: AFX_INTRA_FEATURE_TRACE_COLLECTOR
138 l_trace_repository: AFX_PROGRAM_EXECUTION_TRACE_REPOSITORY
139 l_trace_analyzer: AFX_EXECUTION_TRACE_ANALYZER
140 l_ranker: AFX_PROGRAM_STATE_RANKER
141 l_invariant_detecter: AFX_PROGRAM_EXECUTION_INVARIANT_DETECTER
142 do
143 create l_intra_feature_trace_collector.make
144 l_intra_feature_trace_collector.collect_trace
145 l_trace_repository := trace_repository
146 progression_monitor.set_progression (progression_monitor.progression_test_case_analysis_execution_end)
147
148 if session.should_continue then
149 if config.is_using_random_based_strategy then
150 create l_trace_analyzer
151 l_trace_analyzer.set_breakpoint_index_range (
152 [exception_recipient_feature.first_breakpoint_in_body,
153 exception_recipient_feature.last_breakpoint_in_body])
154 l_trace_analyzer.collect_statistics_from_trace_repository ({AFX_EXECUTION_TRACE_STATISTICS_UPDATE_MODE}.Update_mode_merge_presence)
155
156 create l_ranker
157 l_ranker.compute_ranks
158 elseif config.is_using_model_based_strategy and then config.is_daikon_enabled then
159 create l_invariant_detecter
160 l_invariant_detecter.detect
161 end
162 end
163 end
164
165 generate_fixes
166 -- <Precursor>
167 local
168 l_generator: AFX_FIX_GENERATOR
169 l_text_equal_fixes: HASH_TABLE [INTEGER, STRING]
170 l_fix: AFX_FIX
171 l_text: STRING
172 l_count: INTEGER
173 l_fixes: like fixes
174 do
175 if session.should_continue then
176 if config.is_using_random_based_strategy then
177 create {AFX_RANDOM_BASED_FIX_GENERATOR} l_generator
178 elseif config.is_using_model_based_strategy then
179 create {AFX_ASSERTION_VIOLATION_FIX_GENERATOR} l_generator
180 end
181 l_generator.generate
182
183 if session.should_continue then
184 l_fixes := fixes
185 l_fixes.append_last (l_generator.fixes)
186
187 -- Remove syntactially equivalent fixes.
188 create l_text_equal_fixes.make (l_fixes.count)
189 l_text_equal_fixes.compare_objects
190 from
191 l_fixes.start
192 until
193 l_fixes.after
194 loop
195 l_fix := l_fixes.item_for_iteration
196 l_text := l_fix.text
197 if l_text_equal_fixes.has (l_text) then
198 l_fixes.remove_at
199 else
200 l_text_equal_fixes.put (1, l_text)
201 l_fixes.forth
202 end
203 end
204 end
205 end
206 end
207
208 validate_fixes
209 -- Validate `fix_skeletons'.
210 local
211 l_validator: AFX_FIX_VALIDATOR
212 do
213 check exception_signature /= Void end
214 create l_validator.make (fixes)
215 l_validator.validate
216 end
217
218 feature{NONE} -- Auxiliary
219
220 fixes: DS_LINKED_LIST [AFX_FIX]
221 -- Generated fixes
222 do
223 if fixes_cache = Void then
224 create fixes_cache.make
225 end
226 Result := fixes_cache
227 ensure
228 result_attached: Result /= Void
229 end
230
231 valid_fixes: DS_LINKED_LIST [AFX_FIX]
232 -- List of valid fixes.
233 do
234 if valid_fixes_cache = Void then
235 create valid_fixes_cache.make
236 end
237 Result := valid_fixes_cache
238 end
239
240 sort_valid_fixes
241 -- Sort valid fixes into `valid_fixes'.
242 local
243 l_sorter: DS_QUICK_SORTER [AFX_FIX]
244 do
245 fixes.do_if (agent valid_fixes.force_last, agent (a_fix: AFX_FIX): BOOLEAN do Result := a_fix.is_valid end)
246 create l_sorter.make (
247 create {AGENT_BASED_EQUALITY_TESTER [AFX_FIX]}.make (
248 agent (af, bf: AFX_FIX): BOOLEAN
249 do
250 Result := (af.ranking.post_validation_score + af.ranking.pre_validation_score)
251 <
252 (bf.ranking.post_validation_score + bf.ranking.pre_validation_score)
253 end))
254 l_sorter.sort (valid_fixes)
255 end
256
257 feature{NONE} -- Cache
258
259 valid_fixes_cache: DS_LINKED_LIST [AFX_FIX]
260 -- Cache for `valid_fixes'.
261
262 fixes_cache: DS_LINKED_LIST[AFX_FIX]
263 -- Cache for 'fixes'.
264
265 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23