Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.

Slides:



Advertisements
Similar presentations
Overview Structural Testing Introduction – General Concepts
Advertisements

Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction of.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Aspect Oriented Programming Written by Michael Beder.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
Language Evaluation Criteria
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Mining Coding Patterns to Detect Crosscutting Concerns.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University ICSE 2003 Java.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A lightweight.
2006/09/19AOAsia 21 Towards Locating a Functional Concern Based on a Program Slicing Technique Takashi Ishio 1,2, Ryusuke Niitani 2 and Katsuro Inoue 2.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Investigation.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Change Impact Analysis for AspectJ Programs Sai Zhang, Zhongxian Gu, Yu Lin and Jianjun Zhao Shanghai Jiao Tong University.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University Analysis and Implementation Method of Program to Detect Inappropriate.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Design and Implementation.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Applying Clone.
Aspect Oriented Programming Gülşah KARADUMAN.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
Static Program Analyses of DSP Software Systems Ramakrishnan Venkitaraman and Gopal Gupta.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Assertion with.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Static Program Analysis of Embedded Software Ramakrishnan Venkitaraman Graduate Student, Computer Science Advisor: Dr. Gopal Gupta
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University July 21, 2008WODA.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
CASE/Re-factoring and program slicing
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cage: A Keyword.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Introduction to OOP CPS235: Introduction.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Extracting Sequence.
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Structural testing, Path Testing
Aspect-Oriented Programming
Chapter 6 Methods: A Deeper Look
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support for Aspect-Oriented Program Using Program Slicing and Call Graph Takashi Ishio, Shinji Kusumoto, Katsuro Inoue Osaka University {t-isio, kusumoto,

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 2 Overview Aspect-Oriented Programming AOP’s advantage and disadvantages Difficulties in debugging AOP program Proposed Method Program Slicing extended for AOP Loop Detection based on Call Graph (not included in this presentation) Implementation Evaluation Conclusion

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 3 Aspect-Oriented Programming Key Idea: Separation of crosscutting concerns In OOP, programmers cannot encapsulate crosscutting concerns: logging, error handling, transactions, security,... Code for object interaction is scattered to related classes. It is hard to manage scattered code. In AOP: A crosscutting concern == An aspect When a concern is changed, programmers modify one aspect instead of related classes.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 4 AspectJ, an AOP extension for Java AspectJ: an AOP extension for Java An aspect is defined as a set of advices. Advice: a procedure + a condition when the procedure is executed. A condition = before or after specific events, or instead of the events (around). Around advice uses proceed keyword to execute the original event. Events are specified by Pointcut Designators (PCDs) including: –Method Call and Execution –Field Assignment and Reference –Exception Handling A procedure is written in plain Java with thisJoinPoint object representing the event information.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 5 Simple Example of Aspect aspect LoggingExample { after(): execution(void *.foo(int)) { Logger.logs(thisJoinPoint.getSignature()); } } An advice knows when the advice is executed. Call statements in classes are removed. C.foo(int v) B.foo(int v) A.foo(int v) Logging Class Logging Aspect C.foo(int v) B.foo(int v) A.foo(int v) Logger.logs(“A.foo”); when a method is executed, logger.logs(v) is called. Logger.logs(“C.foo”);

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 6 Advantages of AOP AOP improves: Maintainability Programmers change one aspect instead of multiple classses. Reusability Programmers can reuse classes and aspects independently. –Reuse classes without aspect, or –Reuse aspects for other classes

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 7 Disadvantages of AOP AOP is useful, but... several drawbacks exist. Fault localization is difficult since: A programmer needs to investigate related classes and aspects to understand the system behavior. When a class is affected by several aspects, the result is hard to predict. e.g. Logging + Transaction  ??? A transaction process is logged, or Logging is transactional, or... ? The result depends on the definition of aspects, or compiler/interpreter implementation

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 8 Our Approach Debugging Support esp. fault localization (investigation) task Extending Program Slicing for AOP Program Slicing is a technique to aid fault localization.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 9 Program Slicing Program Slicing extracts a slice of codes, which affects the value of a specific variable. Program Slicing excludes unrelated codes to aid fault localization. a slice based on slice criteria ( 6, b ) 1: a = 5; 2: b = a + a; 3: if (b > 0) { 4: c = a; 5: } 6: d = b; 1: a = 5; 2: b = a + a; 3: if (b > 0) { 4: c = a; 5: } 6: d = b;

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 10 Slice Calculation Process Phase 1: Extraction of dependence relations Data: assignment  reference Control: conditional statement  controlled block Phase 2: Construction of Program Dependence Graph node: a statement. edge: a dependence relation Phase 3: Traversal of PDG traversal backward from a node corresponding a slice criterion 1: a = 1; 2: c = 4; 3: b = a; 1: a = 1; 2: c = 4; 3: b = a; a Data Dependence 4: if (a < 1) { 5: b = a; 6: } 4: if (a < 1) { 5: b = a; 6: } Control Dependence Program Dependence Graph slice criterion

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 11 DC-Slicing for OOP DC-Slicing: a slicing method combining static and dynamic information. control dependence relations  static analysis data dependence relations  dynamic analysis Dynamic information is used for data dependence analysis to distinguish object instances method call analysis to solve polymorhpic method calls Size and Cost: Size: Dynamic Slice < DC-slice < Static Slice Cost: Static Slice < DC-slice < Dynamic Slice

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 12 DC-Slicing Extended for AOP Basic Idea: Advice Execution is similar to Method Call An advice is executed when a condition is satisfied.  A statement which satisfies a condition calls the advice. AspectJ Developement Tools plug-in indicates an advice execution as a marker. Extending PDG and Call Graph Advice Call Vertex and Advice Execution Edge A vertex is inserted into the place of the statement which calls an advice An edge connected to an advice body

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 13 Control Flow Modified by Aspect a.foo(); after: call(A.foo()) {...} around: call(A.foo()) {...} the part of around advice proceed after advice call the rest part of the around advice a path without proceed A method call statement Advices executed for each method call

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 14 Dynamic Elements in AOP Dynamic Pointcut: if, cflow if(expr): When expr is true, the advice is executed. cflow(PCD): all events reached from PCD cflow( execution(C.foo() ) ) == all events during C.foo() is executing. Converted to an advice call with “may be executed” control dependence relation. We use dynamic information to resolve dynamic pointcut.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 15 Implementation Slicing tool as an Eclipse plug-in Environment: Eclipse AspectJ Integrated Function: PDG construction –[Compile]-[Rebuild All] constructs PDG –A call graph is also constructed. –A method call loop including advices is recorded as “infinite loop candidates”. Slice Calculation –is started by a button of a tool bar –calculates a slice and indicates a slice on the text editor. Dynamic Analysis is not integerated to IDE. Dynamic analysis code is also inserted using AspectJ. A programmer need to execute a program once.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 16 Screenshot

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 17 Experiment Debugging Experiment We have 12 students debug an AspectJ program. All students have used Java, but not AspectJ. devided into two groups; a group working with a program slice, another without the slice Environment: Eclipse AspectJ Development Tools Procedure: A lecture for using Eclipse Debugging a Java program using Eclipse. (PRE1) A lecture for AspectJ Write an AspectJ program using Eclipse. (PRE2) Debugging a AspectJ program using Eclipse. (DEBUG)

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 18 Debugged Program An AspectJ Program “Eval Expression” Input: an expression represented by a graph. An evaluation = graph traversal Output: (* (+ 2 3) (+ 2 3) ) = 25 5 classes (Graph nodes) and 4 aspects, 340 LOC Loop Detection, Caching, Print, Cleanup The program contains a bug. Print Aspect generates a String representation of a graph. But the generated string is incorrect in several test cases. Gives test cases to all students. Gives a program slice to one group (6 students). The variable contains the output is specified as a slice criterion.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 19 A fragment of program slice public aspect CachingAspect { // member of this Aspect static private Set workers = new HashSet(); // add a member to Worker class private boolean Worker.isAlreadyCalculated = false; pointcut work_call() : call(void Worker.work()); pointcut first_work_call() : work_call() && !cflowbelow(work_call()); void around(): work_call() { Worker w = (Worker)thisJoinPoint.getTarget(); if (w.isAlreadyCalculated) return; else { proceed(); w.isAlreadyCalculated = true; workers.add(w); } // clear the flag when calculation process is finished after(): first_work_call() { for (Iterator it = workers.iterator(); it.hasNext(); ) { Worker w = (Worker)it.next(); w.isAlreadyCalculated = false; } workers.clear(); } When a node is already visited, return the value of the node. Otherwise, visit the node and set a “visited” flag. Reset flags after evaluation When a node is skipped, Print Aspect’s advice is also skipped. Excluded because flags do not affect the output.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 20 Result Effectiveness is evaluated based on working time. Program slicing is used only “DEBUG” task. Students working with a program slice completed DEBUG task faster than students without a slice. However, the effectiveness is not statistically confirmed. Group PRE1 (Java) PRE2 (AspectJ) DEBUG (AspectJ) 1 (without a slice) (with a slice) Average Working Time (Unit: Minutes)

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 21 Discussion From an interview to the students: A program slice is useful to investigate the problem. A slice is a good starting point to read a program. A slice is used to reduce the scope of investigation. “unrelated aspects” is very useful information. A program slice is not useful to fix a problem. A programmer must investigate the influence of the modification to fix a problem. Changes of classes and aspects may affect other aspects.  Other methods such as impact analysis should be combined to support bug-fixing task.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 22 Conclusion Debugging Support for AOP Key Idea: Advice Execution == Method Call Loop Detection using Call Graph Application of Program Slicing Program Slicing indicates dependence relations changed by aspects is effective to localize a fault. Future Work Visualization of Inter-aspect relations for large-scale software Combining other technique to fix a fault, e.g. impact analysis

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 23 Any questions/comments ?

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 24 Applicability Our program slicing extension is based on Join Point Model. Dynamic slicing for Java byte-code is also applicable. However, join point shadows are embedded into the byte code. It is hard to untangle byte-code without aspect information.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 25 Overview of Aspects Relation Two aspects included in the program slice. Print and Cleanup are dominated by Caching Caching LoopDetect Cleanup Print included in the Slice join point: visit a node ② around call visit method body ③ proceed recursive call ① before, after ④ after ⑤ after

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 26 Collected Data Students submitted: What causes a problem How to fix a problem Modified Source Code Time requried to complete the work Thought about Program Slicing

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 27 Experiment 1: Applying tool Apply program slicing to 5 AspectJ design pattern implementation. Evaluate analysis cost Target: 5 Design Pattern implementation in AspectJ Observer, ChainOfResponsibility,... Average size: about 500 lines of code Test: Execute a sample code, and calculates a slice specify a output variable as a slice criterion. Comparation to AJDT’s marker

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 28 Evaluation Program slicing reduces complexity Aspects added dependence relations. tracking by hands is costly since relations crosscutting many modules (files). Slice can indicates a lost of dependence relations. A statement skipped by an aspect (e.g. around advice)

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 29 Modified Dependence Relation void f1() { x = f2(); : } int f2() { return doSomething(); } int f3() { return doSomething2(); } aspect redirectMethodCall { int around(): call(f2) { return f3(); } void f1() { x = f2(); : } int f2() { return doSomething(); } int f3() { return doSomething2(); } aspect redirectMethodCall { int around(): call(f2) { return f3(); } A calculated slice: A developer tracks: An advice replaces a method call

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 30 Analysis Cost Time Static analysis = a traversal to AST generated by compiler. Dynamic analysis: executes a program with dynamic analysis. The performance depends on a target program and a test case. about 2 times longer than normal execution on the average. Memory The analysis cost depends on a number of join points affected by aspects. Analyze LOC Java Code  20MB LOC Aspect Logging All Events  100MB required ! Too many method calls, executions, field set and get are extracted.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 31 Dynamic Analysis Aspect We implement dynamic analysis using AspectJ. Dynamic analysis aspect records a position of the assignment statement when a new value is assigned to a field, extracts a dynamic data dependence relation when the field is referred, collects method-call information for each thread (multi- threading), collects information when an exception is thrown and which handling clause caught the exception (exception- handling).

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 32 Call Graph Example Aspect Class call 凡例 An inifnite loop