cjadviser: smt-based debugging support for contextj* shizuka uchio(kyushu university, japan) naoyasu...

22
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 COP 2011

Upload: brooke-brown

Post on 04-Jan-2016

224 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

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

COP 2011

Page 2: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

Overview-- Trace analysis with SMT-solver

2

SMT

SMT: Satisfiability Modulo Theories

Context Dependence Graph

Unit Test

We can check a variety ofobject-context

dependencies such as“Do two objects A and

B exist in the Context X

at the same time ? ” A

BX

Page 3: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

3

Outline

Motivation --Debugging issues in COP

CJAdviser: Trace analysis with SMT solver

Related work

Conclusion and Future work

Page 4: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

4

Motivation

Page 5: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

5

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.

Page 6: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

6

Example: ContextJ* Code

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 Person implements IPerson {layers.define(Layers.Address,new IPerson() { public String toString() { return layers.next(this) + "; Address: " + address;}}); layers.define(Layers.Employment,new IPerson() { public String toString() { return layers.next(this) + "; [Employer] " + employer;}});

public class Employer implements IEmployer {layers.define(Layers.Address,new IEmployer() { public String toString() { return layers.next(this) + "; Address: " + address;}});

Employer Person

Employment Layer

Address Layer

Name: UchioShizuka; Address: Arae1

Name: UchioShizuka; Address: Arae1;[Employer] Name: Ubayashi; Address: Motooka

Page 7: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

7

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 ?

Page 8: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

8

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 ?

Page 9: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

9

CJAdviser:Trace analysis with SMT solver

Page 10: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

Our approach

10

SMT

SMT: Satisfiability Modulo Theories

Context Dependence Graph

Unit Test

Page 11: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

11

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

Page 12: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

12

CJLogger

CXDG: Context dependence graph

ContextJ*execution (period)

Context

Context

Object

Object

Logging

Page 13: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

13

Yices encoding -- CXDG

: ; 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 (-> int obj-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

Syntax is similar to Scheme

Page 14: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

CJQuery

14

(period)

Context

Context

Object

Object

Query

SAT or UNSAT

Yices

Debug Concern

s

Page 15: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

15

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 (/= i j) (= (test-run i) (mk-tuple t Person Address)) (= (test-run j) (mk-tuple t Employer Address))))

(check)

SAT i = 2, j = 3, and t = 2

Page 16: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

16

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 (/= i j) (= (test-run i) (mk-tuple t Person l)) (= (test-run j) (mk-tuple t Employer l))))(check)

SAT i = 2, j = 3, t = 2, andl=Address.

Page 17: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

Case 3:Does a person exist in the Employment layer sometime?

17

(define i::log-count)(define t::with-period)

(assert (= (test-run i) (mk-tuple t Person Employment)))(check)

SAT i = 4 and t = 2

Page 18: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

Related work

18

Page 19: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

19

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.

Page 20: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

20

Conclusion and Future work

Page 21: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

21

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

Page 22: CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu

22

Thank you for your attention.