1 / 13

Evidence-Based Automated Program Fixing

Evidence-Based Automated Program Fixing. Yu Pei , Yi Wei, Carlo Furia, Martin Nordio, Bertrand Meyer Chair of Software Engineering, ETH Zürich . Program Fixing. Automated . Evidence-based. Program fixing. Automated fixing. Evidence-based fixing. Find a fault Analyze the fault Where

vanida
Download Presentation

Evidence-Based Automated Program Fixing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Evidence-Based Automated Program Fixing Yu Pei, Yi Wei, Carlo Furia, Martin Nordio, Bertrand Meyer Chair of Software Engineering, ETH Zürich

  2. Program Fixing Automated Evidence-based Program fixing Automated fixing Evidence-based fixing • Find a fault • Analyze the fault • Where • What • Fix the fault • How • Validate the fix • Test case generation • Fault localization • Design-by-contract • Dynamic/static analysis • Fix synthesis • By enumeration • Regression testing

  3. Evidence-based Fixing: Example Faults 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 move_item (v: G) -- Move `v' to the left of cursor. require v /= Void ; has (v) localidx: INTEGER ; found: BOOLEAN do idx := index from start until found or after loop found := (v = item) ifnot found then forth end end check found andnot after end remove go_i_th (idx) put_left (v) end -- idx <= count + 1 -- not before 16 17 go_i_th (i: INTEGER) require 0 <= i and then i <= count + 1 put_left (v: G) requirenot before before: BOOLEANdoResult := (index = 0) end 18 19

  4. Evidence-based Fixing: Fixes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 move_item (v: G) -- Move `v' to the left of cursor. require v /= Void ; has (v) localidx: INTEGER ; found: BOOLEAN do idx := index from start until found or after loop found := (v = item) ifnot found then forth end end check found andnot after end remove go_i_th (idx) put_left (v) end if index < idx then idx := idx – 1 end if before then start end

  5. Evidence in Program State Components • <p, l, v> • p : state predicate • l : program location • v : value of predicate p at location l • Design-by-contract • Faults that cause contract violations • A fault can by characterized by cf= <pf , lf , F> • Helps us narrow down faulty code to routine level • Allows us to inspect program states inmore detail

  6. Evidence-based Techniques

  7. Dynamic Analysis • Exercise the original program using test cases • Each test case contributes to the score of a state component • The contribution • from failing test cases cannot be canceled out completely • from the first a few test cases is crucial • from one failing test case is stronger than the counter-part from one passing test case • αi for each i-th failing test case, and β∙αi for each i-th passing test case (0 < α, β < 1)

  8. Static Analysis • Given a state component <p, l, v> • Expression dependence • the syntactic similarity between pf and p • Control dependence • the distance, in terms of number of instructions, between lf and l

  9. Combining Static and Dynamic Analysis • Suspiciousness score fixme as the harmonic mean of dyn, edep, and cdep • cf= <idx<=count+1 , l-13 , F>, #f(cf)=15, #p(cf)=0 • cdep = 1-0/9 = 1 • edep = 3/3 = 1 • dyn ≈ 1.4999 • fixme ≈ 1.125 • Program state components with higher suspiciousness scores are more likely to reflect the fault cause • < index<idx , l-13 , T> • <not before, l-14, F> 12 13 14 15 remove go_i_th (idx) put_left (v) end -- idx <= count + 1

  10. Fixing Actions • Given a state component <p, l, v>, how the state should be changed to avoid that? • Try with applicable operations • Fixing with state modification • Fixing with expression substitution -- <index<idx, l-13, T> go_i_th (idx) idx := idx – 1 -- <index<idx, l-13, T> go_i_th (idx) go_i_th (idx - 1)

  11. Fix Candidate Generation and Validation • Fix schemas and fix candidates • failing_condition • Predicate of the state component • Potential state invariant only observed in failing runs • Fix validation iffail_conditionthen fixing_action end original_instruction iffail_conditionthen fixing_action else original_instruction end

  12. Evidence-based Fixing: Experiments • 15 faults in 7 classes from EiffelBase • Classes supposed to have high quality • Routine size, in number of loc, varies from 1 to 30 • 11 precondition violations and 4postcondition violations • Generated proper fixes for 12 faults • 5 faults in 4 classes from a library manipulating text documents • Classes from student project • Routine size varies from 20 to 40 • All precondition violations • Generated proper fixes for 3 faults • 7.6 min on average per fault

  13. Summary • Evidence-based automatic program fixing • Design-by-contract • Fault localization: dynamic and static analysis • Fix generation: operation enumeration • Future work • More empirical evaluation • User study • Multiple faults • Programs with weak/no/incorrect contracts

More Related