250 likes | 270 Views
Analysis and Testing of Programs with Exception-Handling Constructs. Saurabh Sinha and Jean Harrold. Sookmyung Women ’ s Univ. PSLAB Ohe, hee jeong. 1. Introduction. Motivation
E N D
Analysis and Testing of Programs with Exception-Handling Constructs Saurabh Sinha and Jean Harrold Sookmyung Women’s Univ. PSLAB Ohe, hee jeong
1. Introduction • Motivation • Many software-engineering tasks require information about the control flow, control dependence, and data dependence among statements in a program • analysis techniques should account for the effects of exception-handling constructs • Contribution • Effects of exception-handling constructs on several analysis • Control flow analysis • Control dependency analysis
2. Exception in Java • Exception is an object • derived from the class java.lang.Throwable • Throw statement • variable, method call, new instance expression • Exception criteria • Non-resumable model of exception handing • A java exception can be propagated up on the call stack
3. Effects of Exception-handling Constructs on Analysis Techniques
Exception-handling constructs • Belong to a class of structure that cause arbitrary interprocedural control flow • Interprocedural contorl • Jump statement, halt statement • Common effect • Control may not return from the called procedure back to the call site • Affect the flow of control across procedure
3.2 Effects of Exception on analysis techniques • Control flow analysis • incorporate the exception-induced control flow • influence control flow not only within a method, but across methods • Data flow analysis • Definition-use pair may not be detected the pair • Exception-handling constructs introduce additional definition-use pairs in a program through the exception object. • Data dependence analysis • Consider the presence of potentially non-returning call site (PNRCs) • Necessitate the computation of interprocedural control dependence
4. Analysis Techniques to Accommodate Exception-Handling Constructs
4. 1 Control-Flow Analysis • Control flow analysis • exception-handling constructs • The intraprocedural control-flow • The interprocedural control-flow
4.1.1 Intraprocedural analysis <Intraprocedure control flow in java exception-handling constructs>
4.1.2 Interprocedural analysis • Interprocedural control-flow graph • Program P consists of CFGs for each method or procedure in P • call node--->connected to the entry node of the called method by a call edge • exit node ---> connected to the corresponding return node by a return edge
4.1.3 Type inferencing for exception types • The CFG construction requires information about exception types that can be raised at throw statements. • Recent work uses points-to analysis to infer types in programs that contain exception-handling constructs • Only consider the variables or method call
4.1.3 Type inferencing for exception types • Four inexpensive approaches • Conservative approximation • Intraprocedural flow-sensitive analysis • Interprocedural flow-insensitive analysis • Combination of the intraprocedural flow-sensitive and the interprocedural flow-insensitive analysis
4.2 Control-Dependence Analysis • The interprocedural control-dependence algorithm computes statement-based control dependences without constructing an IIFG • Phase 1 • identifies PNRCs that are caused by throw statement and halt statement • Uses this information to compute partial control dependences • Phase 2 • Use partial control dependences to compute statement-based interprocedural control dependences
4.2.1 Computation of partial control dependency • Phase 1 : identifies call sites that are PNRCs Step1 : for each call site, computes the set of nodes to which control can return following the call site Step 2 : constructs an augmented control-flow graph that summarized the effects of external control dependences on statements in a method.
4.2.1 Computation of partial control dependency • Partial control dependence • Intraprocedural control dependences that are computed by applying a traditional technique for computing control dependence to the ACFG • The partial control dependences for nodes that are control dependent on predicates in called methods contain a return-predicate node
4.2.1 Computation of partial control dependency
4.2.2 computation of interprocedural control dependences • Partial control dependences • Contain placeholder nodes-representing entry or return predicates-must be adjusted • To compute interprocedural control dependences, phase 2 constructs an interprocedural representation of the program by connecting the ACFGs using call, return, and exceptional-return edges
4.2.2 computation of interprocedural control dependences