220 likes | 325 Views
COP 2011. CJAdviser : SMT-based Debugging Support for ContextJ *. Shizuka Uchio (Kyushu University, Japan) Naoyasu Ubayashi (Kyushu University, Japan) Yasutaka Kamei (Kyushu University, Japan) July 25, 2011. Overview -- Trace analysis with SMT-solver. We can check a variety of
E N D
COP 2011 CJAdviser:SMT-based Debugging Support forContextJ* • ShizukaUchio (Kyushu University, Japan) • NaoyasuUbayashi (Kyushu University, Japan) • Yasutaka Kamei (Kyushu University, Japan) • July 25, 2011
Overview-- Trace analysis with SMT-solver We can check a variety of object-context dependencies such as “Do two objects A and B exist in the Context X at the same time ? ” SMT Unit Test A B X Context Dependence Graph SMT: Satisfiability Modulo Theories
Outline • Motivation --Debugging issues in COP • CJAdviser: Trace analysis with SMT solver • Related work • Conclusion and Future work
Motivation • Context-awareness plays an important role in developing adaptive software. • COP can treat context as a module and enables programmers to describe the context-aware behavior elegantly. • However, it becomes difficult to debug the programs due to the complexity of COP execution and the dependence between objects and contexts.
Example: ContextJ* Code Employer Person Address Layer Employment Layer Name: UchioShizuka; Address: Arae1 Name: UchioShizuka; Address: Arae1; [Employer] Name: Ubayashi; Address: Motooka Employer ubayashi = new Employer("Ubayashi", "Motooka"); Person uchio = new Person("UchioShizuka", "Arae1", ubayashi); with(Layers.Address).eval( new Block() { public void eval() { System.out.println(uchio); }}); with(Layers.Address, Layers.Employment).eval( newBlock() { public void eval() { System.out.println(uchio); }}); public class Employer implements IEmployer { layers.define(Layers.Address,newIEmployer() { public String toString() { return layers.next(this) + "; Address: " + address;}}); public class Person implements IPerson { layers.define(Layers.Address,newIPerson() { public String toString() { return layers.next(this) + "; Address: " + address;}}); layers.define(Layers.Employment,newIPerson() { public String toString() { return layers.next(this) + "; [Employer] " + employer;}});
Execution Trace • Q2: When uchio enters Address and Employment layers, the layered method toString (Address layer) is invoked after the layered method toString (Employment layer) is invoked. • Where is this order specified ? • Is the order defined by layers.define ? Q1: Address layer and Employment layer are instantiated just after Employer object is instantiated. Why ?
More concerns … • Is there a possibility of simultaneously activating two layers A and B ? • Is the layer A activated sometime ? • Do two objects X and Y exist in the layer A at the same time ?
Our approach SMT Unit Test Context Dependence Graph SMT: Satisfiability Modulo Theories
SMT (Satisfiability Modulo Theories) • SMT generalizes SAT (Boolean satisfiability) by adding equality reasoning, arithmetic, and other first-order theories. • Yices is an SMT solver that decides the satisfiability of formulas containing • uninterpreted function symbols with equality, • linear real and integer arithmetic, scalar types recursive datatypes, tuples, records, extensional arrays, fixed-size bit-vectors, • quantifiers • lambda expressions
CJLogger Context Object ContextJ* execution (period) Context Logging Object CXDG: Context dependence graph
Yices encoding -- CXDG Syntax is similar to Scheme : ; Type definitions (define-type obj (scalar Employer Person)) (define-type layer (scalar Address Employment)) (define-type with-period (subrange 1 2)) (define-type log-count (subrange 0 4)) (define-type obj-with-layer (tuple with-period obj layer)) (define-type logging (-> intobj-with-layer)) (define log::logging) : ; Log data (CXDG: Context dependence graph) (define test-run::logging (update (update (update (update (update (update log (0) (mk-tuple 1 Person Address)) (1) (mk-tuple 1 Employer Address)) (2) (mk-tuple 2 Person Address)) (3) (mk-tuple 2 Employer Address)) (4) (mk-tuple 2 Person Employment)))) Array
CJQuery DebugConcerns Context Object Query (period) Context SAT or UNSAT Object Yices
Case 1:Do a person and an employer exist in the Address layer at the same time ? (define i::log-count) (define j::log-count) (define t::with-period) (assert (and (/= ij) (= (test-run i) (mk-tuplet Person Address)) (= (test-run j) (mk-tuplet Employer Address)))) (check) SAT i = 2, j = 3, and t = 2
Case 2:Do a person and an employer exist in the same layer at the same time ? (define i::log-count) (define j::log-count) (define t::with-period) (define l::layer) (assert (and (/= ij) (= (test-run i) (mk-tuplet Person l)) (= (test-run j) (mk-tuplet Employer l)))) (check) SAT i = 2, j = 3, t = 2, and l=Address.
Case 3:Does a person exist in the Employment layer sometime? (define i::log-count) (define t::with-period) (assert (= (test-run i) (mk-tuplet Person Employment))) (check) SAT i = 4 and t = 2
Related work • Whyline [Ko, A. J. et al. ICSE2008] • allows programmers to ask “Why did” and “Why didn‘t” questions about the bugs. • provides answers of the bug causes. • DebugAdvisor [Ashok, B. et al. FSE2009] • allows programmers to express the context of the bugs and search through diverse data such as natural language text and core dumps.
Conclusion and Future work • We proposed CJAdviser, SMT-based Debugging Support for ContextJ*. • Future work • Support for Jcop • User Interface (cf. Whyline) • Scalability • Real case Studies