Download presentation
Presentation is loading. Please wait.
1
DynaMine DynaMine Finding Common Error Patterns by Mining Software Revision Histories Benjamin Livshits Stanford University Thomas Zimmermann Saarland University
2
Error Pattern Iceberg The usual suspects null dereferences, buffer overruns,... Application specific J2EE servlets Linux code Device drivers
3
The Mission: Find Patterns Program understanding Detecting violations
4
The Technique: Look at Version Archives...and apply data mining.
5
Crucial Observation Things that are frequently changed together often form a pattern...also known as co-change
6
Co-changed items = patterns
7
Co-added Method Calls public void createPartControl(Composite parent) {... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } public void dispose() {... getSite().getPage().removePartListener(partListener); }
8
Co-added Method Calls public void createPartControl(Composite parent) {... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } public void dispose() {... getSite().getPage().removePartListener(partListener); }
9
Co-added Method Calls public void createPartControl(Composite parent) {... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } public void dispose() {... getSite().getPage().removePartListener(partListener); } co-added
10
How DynaMine Works report bugs report patterns reporting run the application post-process usage patterns error patterns unlikely patterns dynamic analysis instrument relevant method calls mine CVS histories patterns rank and filter revision history mining
11
Mining Patterns report bugs report patterns reporting run the application post-process usage patterns error patterns unlikely patterns dynamic analysis instrument relevant method calls mine CVS histories patterns rank and filter revision history mining
12
Mining Method Calls o1.addListener() o1.removeListener() Foo.java 1.12 o2.addListener() o2.removeListener() System.out.println() Bar.java 1.47 o3.addListener() o3.removeListener() list.iterator() iter.hasNext() iter.next() Baz.java 1.23 o4.addListener() System.out.println() Qux.java 1.41 o4.removeListener() 1.42
13
Finding Pairs o1.addListener() o1.removeListener() o2.addListener() o2.removeListener() System.out.println() o3.addListener() o3.removeListener() list.iterator() iter.hasNext() iter.next() o4.addListener() System.out.println() o4.removeListener() Foo.java 1.12 Bar.java 1.47 Baz.java 1.23 Qux.java 1.41 1.42 1 Pair 0 Pairs 1 Pair 2 Pairs 0 Pairs
14
Mining Method Calls Co-added calls often represent a usage pattern o1.addListener() o1.removeListener() o2.addListener() o2.removeListener() System.out.println() o3.addListener() o3.removeListener() list.iterator() iter.hasNext() iter.next() o4.addListener() System.out.println() o4.removeListener() Foo.java 1.12 Bar.java 1.47 Baz.java 1.23 Qux.java 1.41 1.42
15
o.enterAlignment() o.exitAlignment() o.redoAlignment() iter.hasNext() iter.next() o.enterAlignment() o.exitAlignment() o.redoAlignment() iter.hasNext() iter.next() o.enterAlignment() o.exitAlignment() o.redoAlignment() iter.hasNext() iter.next() o.enterAlignment() o.exitAlignment() o.redoAlignment() iter.hasNext() iter.next() Finding Patterns Find “frequent itemsets” (with Apriori) {enterAlignment(), exitAlignment(), redoAlignment()} \
16
Ranking Patterns Support count = #occurrences of a pattern Confidence = strength of a pattern, P(A|B) o1.addListener() o1.removeListener() o2.addListener() o2.removeListener() System.out.println() o3.addListener() o3.removeListener() list.iterator() iter.hasNext() iter.next() o4.addListener() System.out.println() o4.removeListener() Foo.java 1.12 Bar.java 1.47 Baz.java 1.23 Qux.java 1.41 1.42
17
Ranking Patterns o1.addListener() o1.removeListener() o2.addListener() o2.removeListener() System.out.println() o3.addListener() o3.removeListener() list.iterator() iter.hasNext() iter.next() o4.addListener() System.out.println() o4.removeListener() Foo.java 1.12 Bar.java 1.47 Baz.java 1.23 Qux.java 1.41 1.42 This is a fix! Rank removeListener() patterns higher
18
Investigated ProjectsJEDITECLIPSEsince 20002001 developers 92112 lines of code 700,0002,900,000 revisions 40,000400,000
19
Simple Method Pairs GUIs & Listener Usage pattern Error pattern
20
Simple Method Pairs Locking of Resources Not hit at runtime
21
State Machines in Eclipse Pretty-printing Usage pattern
22
State Machines in Eclipse Memory context manupilation Not hit at runtime
23
State Machines in JEdit Compound edits (for undo/redo) Usage pattern
24
Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
25
Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
26
Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
27
Workspace Transactions S → O* O → w.prepareOperation() w.beginOperation() U* w.endOperation() U → w.getWorkManager().beginUnprotected() S [w.getWorkManager().operationCanceled()] w.getWorkManager().beginUnprotected() Usage pattern
28
Dynamic Validation report bugs report patterns reporting run the application post-process usage patterns error patterns unlikely patterns dynamic analysis instrument relevant method calls mine CVS histories patterns rank and filter revision history mining
29
Matches and Mismatches Find and count matches and mismatches. o.register(d) o.deregister(d) o.deregister(d) Static vs dynamic counts. matches o.register(d) mismatch
30
Pattern classification post-process v validations, e violations usage patterns e<v/10 error patterns v/10<=e<=2v unlikely patterns otherwise
31
Experiments total 56 patterns
32
Future Work Automatically generate state machines Additional patterns by textual matching Programmer assist tools Programmers who inserted a call to open() inserted a call to close() Aspect Mining
33
Contibutions DynaMine learns usage patterns from large version archives. DynaMine ranks patterns effectively, especially for finding error patterns. DynaMine increases trust in patterns by dynamic analysis
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.