260 likes | 272 Views
Integrating Influence Mechanisms into Impact Analysis for Increased Precision. Ben Breech Lori Pollock. Mike Tegtmeyer. University of Delaware. Army Research Lab. Background: Impact Analysis. G. H. If I change function C, what other functions could be affected (impacted)? Uses
E N D
Integrating Influence Mechanisms into Impact Analysis for Increased Precision Ben Breech Lori Pollock Mike Tegtmeyer University of Delaware Army Research Lab
Background: Impact Analysis G H • If I change function C, what other functions could be affected (impacted)? • Uses • Regression testing • Planning changes F B main C C E A D
Background: Challenges • Conservative -- impacts shouldn’t be missed • Precision -- impacts should be close as possible to “true” results • Efficiency -- analysis should be quick
Background:Impact Analysis Kinds Obtain conservative results • Accounts for all possible inputs and behaviors • Can give very large impact sets Bohner, Arnold 1996, Ryder and Tip, 2001, Turver and Munro, 1994 Source Code Static Analyzer Impacts
Background:Impact Analysis Kinds Execute Instrumented Program Dynamic Information Post Exec Analysis Input Impacts • Not conservative -- results depend on input • Give impacts related to program use Orso et al. 2003, Law and Rothermel, 2003, Breech et al. 2005, Apiwattanapong et al. 2005
Method B Method A stmt a1 stmt a2 … stmt b1 stmt b2 … Background:Impact Analysis Kinds • Expensive • Precise Slicing Statement Level
Method B Method A Background:Impact Analysis Kinds • Less expensive • Less precise Call graph traversals Method Level
Our Approach • Augment method level analysis with some statement level information • Use influence graph to capture how changes propagate • Both static and dynamic analysis • Goal: better results w/out large overhead
Example of Dynamic Impact Analysis PathImpact, Law and Rothermel, ICSE 03 Find Impact of G: G G H F F B main main C C E E A A D D Trace: Main G r A C F C r r D r E r D r r r x (call graph only for demonstration)
Can we improve results? • PathImpact is “safe” • Doesn’t miss impacts among exec’d methods • Purely method level • What can statement level info add?
How do changes propagate? int G (void) { int x, y; …. if (x != 0) y = 10; else y = -10; return y; } int G (void) { int x, y; …. if (x == 0) y = 10; else y = -10; return y; } int G (void) { int x, y; …. if (x == 0) y = 10; else y = -10; return y; }
Insight: Propagation of Changes • Change propagates through variables • Change propagates into methods by parameters/return values • Global variables can propagate change
Example Revisited Find Impact of G: G G H F F B main main C C E E A A D D Trace: Main G r A C F C r r D r E r D r r r x Assume: No Global Variables in program C has no parameters/return vals
Basis of Approach: Influence Graph Formalize ideas in influence graph • Nodes are methods • Edge p q change can propagate from p to q • 3 Types of edges • Parameters/returns by value • Parameters/returns by reference • Global variables
v v r r v, r r r Influence Graph Example int G (void) int H (int x) H H G G F void C (void) main B C C E A A D void A (struct_type &x) r: ref. edge v: val. edge (none): call edge (demo only)
Conservative Assumptions Building influence graph • Ignore const • Ref. Parameters always modified • Function pointers edges to all functions with address taken
Dynamic Impact Analysis with the Influence Graph • Generate influence graph statically • Perform impact analysis for function of interest • Intuition: Check influence graph at each call/return to see if change can propagate • Global variables require more book keeping (details in paper)
v v r r v, r r r Example Find Impact of C: H G F main B C E C E A D D Trace: Main G r A C F C r r D r E r D r r r x r: ref. edge v: val. edge
Research Questions • Is the impact analysis cost reasonable? • Does the dynamic analysis give more precision than current techniques?
Methodology • Analyzed 8 medium sized C programs(5,000 - 40,000 LoC) • Created gcc passes to build influence graph (little overhead) • Generated traces 8KB - 9 GB
Timing Results • Influence Graph - little overhead to build • Impact Analysis on 9 GB trace ~ 7 mins • PathImpact ~ 5mins • Reasonable time for analysis
Precision Results • Always subset of PathImpact • ~ 4% savings
Why so little precision gain? • Changes propagated due to parameters/returns (esp. reference) • Conservatively assumed all reference vars were modified • Large percentage of functions with ref. vars • Performed basic analysis to build infl. graph
Better Results?(new work!) • More static program analysis better influence graph better precision • Danger: more static analysis, more expensive build influence graph • Analyzed small program by hand • Got 10% gain when using def-use pairs
Summary and Future Work • Can improve method level impact analysis by using some statement level information • Reasonable impact analysis time • Reasonable to spend time building better influence graph?