A Generative Approach to Define Rich Domain-Specific Trace

Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
A Generative Approach to Define Rich
Domain-Specific Trace Metamodels
ECMFA’15
Erwan Bousse
1
Tanja Mayerhofer 2 Benoit Combemale
Benoit Baudry 4
1 University
2 Vienna
3
of Rennes 1 (IRISA), France
University of Technology, Austria
3 Inria,
France
July 22, 2015
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
1/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Outline
1 Context and Motivation
2 Rich Domain-Specific Trace Metamodels
3 Evaluation
4 Conclusion
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
2/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Thesis Overview
Runtime representation
of clone-based traces
Scalable model
cloning
(MODELS 2014)
reification of some
ideas into generative
approach
Trace metamodels
Rich domain-specific trace
metamodel generation
(ECMFA 2015)
direct
application
Advanced and Efficient
Omniscient debugging for xDSMLs
(SLE 2015)
Application to V&V
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
3/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Outline
1 Context and Motivation
2 Rich Domain-Specific Trace Metamodels
3 Evaluation
4 Conclusion
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
Conclusion
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Context: xDSMLs and traces
Recently, a lot of effort in the field of executable Domain
Specific (Modeling) Languages (xDSMLs)
From a Verification and Validation (V&V) point of view, need
for dynamic V&V approaches to analyse the behaviors of
executable models, ie. temporal properties
Central concept in dynamic V&V approaches: execution traces!
Examples of trace usages in dynamic V&V:
Omniscient Debugging: a trace is used to step backward
Model checking: counter example in the form of a trace
Runtime monitoring: to check if a trace satisfies a property
Semantic differencing: trace comparison of different models
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
4/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Context: xDSMLs and traces
Recently, a lot of effort in the field of executable Domain
Specific (Modeling) Languages (xDSMLs)
From a Verification and Validation (V&V) point of view, need
for dynamic V&V approaches to analyse the behaviors of
executable models, ie. temporal properties
Central concept in dynamic V&V approaches: execution traces!
Examples of trace usages in dynamic V&V:
Omniscient Debugging: a trace is used to step backward
Model checking: counter example in the form of a trace
Runtime monitoring: to check if a trace satisfies a property
Semantic differencing: trace comparison of different models
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
4/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Execution Trace
fire(t1)
p1
t1
p3
t2
p4
fire(t2)
p1
t1
p2
p3
t2
p2
p4
p1
t1
p3
t2
p4
p2
An alternate sequence of states and events
A state contains the values of all the mutable parts of a model
An event is the application of a transformation rule (focus on
operational semantics)
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
5/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Problem: generic trace metamodels are not good enough
Example of generic clone-based trace metamodel:
{ordered=true}
states *
target
objects *
State
1
1
Object
source
Trace
incoming
transitions *
0..1 0..1
Transition
outgoing
Event
event 1
qualifiedName : String
Scalability in time issue: sequential structure ⇒ to navigate
in a trace, each execution state has to be visited
Usability issue: domain-specific trace analyses have to
handle domain-specific data that may be arbitrarily complex,
and a generic set of objects is not convenient
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
6/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Problem: generic trace metamodels are not good enough
Example of generic clone-based trace metamodel:
{ordered=true}
states *
target
objects *
State
1
1
Object
source
Trace
incoming
transitions *
0..1 0..1
Transition
outgoing
Event
event 1
qualifiedName : String
Scalability in time issue: sequential structure ⇒ to navigate
in a trace, each execution state has to be visited
Usability issue: domain-specific trace analyses have to
handle domain-specific data that may be arbitrarily complex,
and a generic set of objects is not convenient
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
6/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example: Petri net xDSML
Event Metamodel
Abstract Syntax
Net
places
*
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
Transition
Execution Metamodel
transitions
*
Transition
+name: string
merges
Place
(from Exe. MM)
imports
+name: string
fired
1
+tokens: int
FireEvent
imports
: while there is an enabled transition, fires it.
run(Net)
isEnabled(Transition) : returns true if tokens > 0 for each input Place, false otherwise.
: removes a token from each input Place and adds a token to each output Place.
fire(Transition)
Operational Semantics (set of transformation rules)
Properties of the abstract syntax (e.g. initialTokens)
are said immutable
Properties of the execution metamodel (tokens)
are said mutable
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
7/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example: generic Petri net trace
fire(t1)
p1
p3
t1
t2
p4
fire(t2)
p1
t1
p3
t2
p4
p1
t1
p3
p2
p2
t2
p4
p2
states
: Trace
objects
s1 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
1
2
3
: Place
name = “p1"
tokens = 1
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 0
objects
s2 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 1
: Place
name = “p4"
tokens = 0
objects
s3 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 0
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 1
Generic types require type checks and casting
Redundancy, both with immutable and mutable data
Trace can be only queried by visiting all states
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
8/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example: generic Petri net trace
fire(t1)
p1
p3
t1
t2
p4
fire(t2)
p1
t1
p3
t2
p4
p1
t1
p3
p2
p2
t2
p4
p2
states
: Trace
objects
s1 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
1
2
3
: Place
name = “p1"
tokens = 1
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 0
objects
s2 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 1
: Place
name = “p4"
tokens = 0
objects
s3 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 0
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 1
Generic types require type checks and casting
Redundancy, both with immutable and mutable data
Trace can be only queried by visiting all states
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
8/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example: generic Petri net trace
fire(t1)
p1
p3
t1
t2
p4
fire(t2)
p1
t1
p3
t2
p4
p1
t1
p3
p2
p2
t2
p4
p2
states
: Trace
objects
s1 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
1
2
3
: Place
name = “p1"
tokens = 1
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 0
objects
s2 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 1
: Place
name = “p4"
tokens = 0
objects
s3 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 0
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 1
Generic types require type checks and casting
Redundancy, both with immutable and mutable data
Trace can be only queried by visiting all states
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
8/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example: generic Petri net trace
fire(t1)
p1
p3
t1
t2
p4
fire(t2)
p1
t1
p3
t2
p4
p1
t1
p3
p2
p2
t2
p4
p2
states
: Trace
objects
s1 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
1
2
3
: Place
name = “p1"
tokens = 1
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 0
objects
s2 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 1
: Place
name = “p3"
tokens = 1
: Place
name = “p4"
tokens = 0
objects
s3 : State
: Net
: Transition
name = “t1"
: Transition
name = “t2"
: Place
name = “p1"
tokens = 0
: Place
name = “p2"
tokens = 0
: Place
name = “p3"
tokens = 0
: Place
name = “p4"
tokens = 1
Generic types require type checks and casting
Redundancy, both with immutable and mutable data
Trace can be only queried by visiting all states
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
8/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Outline
1 Context and Motivation
2 Rich Domain-Specific Trace Metamodels
3 Evaluation
4 Conclusion
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
Conclusion
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Approach: generating a domain-specific trace metamodel
To provide usability
Generative approach to automatically derive a domain-specific
trace metamodel for a given xDSML
Domain-specific: domain concepts are directly accessible
Automation: save language engineers the design of a complex
metamodel, which is time-consuming and error-prone
To provide scalability in time
Rich navigation facilities, e.g. browsing a trace according to the
values reached by a specific mutable element
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
9/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Overview
Abstract Syntax
imports
merges
Execution Metamodel
Rich Domain-Specific
Trace metamodel
generator
Rich Domain Specific
Trace Metamodel
imports
Event Metamodel
xDSML
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
10/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (1)
Event Metamodel
Abstract Syntax
Place
+name: string
+initialTokens: int
Transition
Execution Metamodel
input
1..*
output
1..*
Transition
+name: string
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
11/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (1)
Petri net Trace Metamodel
Event Metamodel
Abstract Syntax
Place
+name: string
+initialTokens: int
Transition
Execution Metamodel
input
1..*
output
1..*
Transition
+name: string
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
11/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (2)
Petri net Trace Metamodel
TokensValue
+tokens: int
Event Metamodel
Abstract Syntax
Place
+name: string
+initialTokens: int
Transition
Execution Metamodel
input
1..*
output
1..*
Transition
+name: string
merges
Place
(from Exe. MM)
imports
+tokens: int
+name: string
fired
1
FireEvent
Reification of mutable properties into classes
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
12/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (3)
Petri net Trace Metamodel
TracedPlace
parent
1
{ordered=true}
tokensTrace
0..*
TokensValue
+tokens: int
Event Metamodel
Abstract Syntax
originalObject
1
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
Transition
+name: string
Transition
Execution Metamodel
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Class for value sequences of mutable data of objects
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
13/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (4)
Petri net Trace Metamodel
TracedPlace
ExecutionState
parent
1
1..*
executionStates
{ordered=true}
tokensTrace
0..*
TokensValue
tokensValues
0..*
+tokens: int
Event Metamodel
Abstract Syntax
originalObject
1
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
Transition
+name: string
Transition
Execution Metamodel
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Class for the model state ≡ tuple of all mutable values
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
14/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (5)
Petri net Trace Metamodel
TracedPlace
ExecutionState
parent
1
followingEventOcc
0..1
{ordered=true}
tokensTrace
0..*
precedingState
1
1..*
executionStates
TokensValue
tokensValues
0..*
<<abstract>>
Event
+tokens: int
FireEvent
Event Metamodel
Abstract Syntax
originalObject
1
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
fired
1
Transition
+name: string
Transition
Execution Metamodel
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Class for each event, with one event following each state
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
15/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (6)
Petri net Trace Metamodel
Trace
tracedPlaces
*
{ordered=true}
exeTrace
0..*
precedingState
ExecutionState
1
TracedPlace
parent
1
followingEventOcc
0..1
{ordered=true}
tokensTrace
0..*
{ordered=true}
fireTrace
1..*
executionStates
TokensValue
tokensValues
0..*
<<abstract>>
Event
+tokens: int
*
FireEvent
Event Metamodel
Abstract Syntax
originalObject
1
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
fired
1
Transition
+name: string
Transition
Execution Metamodel
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Class for the trace, which includes event sequences
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
16/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Trace metamodel generation (6)
Petri net Trace Metamodel
Trace
tracedPlaces
*
{ordered=true}
exeTrace
0..*
precedingState
ExecutionState
1
TracedPlace
parent
1
followingEventOcc
0..1
{ordered=true}
tokensTrace
0..*
{ordered=true}
fireTrace
1..*
executionStates
TokensValue
tokensValues
0..*
<<abstract>>
Event
+tokens: int
*
FireEvent
Event Metamodel
Abstract Syntax
originalObject
1
Place
+name: string
+initialTokens: int
input
1..*
output
1..*
fired
1
Transition
+name: string
Transition
Execution Metamodel
merges
Place
+tokens: int
(from Exe. MM)
imports
+name: string
fired
1
FireEvent
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
16/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Example of Domain Specific Trace
p1
t1
p3
t2
p4
fire(t1)
p1
t1
p2
tracedPlaces
- name = "p1"
- initialTokens = 1
: Place
- name = "p2"
- initialTokens = 1
: Place
- name = "p3"
- initialTokens = 0
: Place
- name = "p4"
- initialTokens = 0
t2
p4
fire(t2)
p1
p2
: Trace
: Place
p3
t1
p3
t2
p4
p2
exeTrace
s1 : ExecutionState
s0 : ExecutionState
p1 : TracedPlace
originalObject
tokens
Trace
s2 : ExecutionState
executionState
executionState
executionState
tokensValues
tokensValues
tokensValues
: TokensValue
: TokensValue
tokens = 1
tokens = 0
value
p2 : TracedPlace
originalObject
tokens
Trace
object state
: TokensValue
: TokensValue
tokens = 1
tokens = 0
model state
model element
p3 : TracedPlace
originalObject
tokens
Trace
: TokensValue
: TokensValue
: TokensValue
tokens = 0
tokens = 1
tokens = 0
p4 : TracedPlace
originalObject
tokens
Trace
: TokensValue
: TokensValue
tokens = 0
tokens = 1
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
17/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Implementation
Implementation available for EMF
Trace metamodel generator (generic)
– Input abstract syntax: Ecore
– Input execution semantics: xMOF or Kermeta
– Output trace metamodel: Ecore
Trace builder (generic)
– Instruments xMOF/fUML virtual machine
– Produces traces conforming to generated rich domain-specific
trace metamodel
Git repository:
https://gforge.inria.fr/projects/lastragen/
Also part of the GEMOC Studio: http://gemoc.org/studio
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
18/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Outline
1 Context and Motivation
2 Rich Domain-Specific Trace Metamodels
3 Evaluation
4 Conclusion
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
Conclusion
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Case study
Trace manipulations: Semantic Differencing
Consists in comparing traces of different versions of a model
according to a set of semantic differencing rules
A set of semantic differencing rules is:
– specific to an xDSML, hence domain-specific
– specific to a given trace metamodel
– written using the Epsilon Comparison Language (ECL)
xDSML: fUML
Real world xDSML, subset of UML
Used models: activity diagrams taken from [Maoz etal. 2011]
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
19/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
matching time (ms) Lg 10^x
Evaluation: scalability in time
100000
10000
1000
generic trace
100
rich domainspecific trace
10
1
400
450
500
550
600
650
700
750
800
number of states
Result: Match rules on rich domain-specific traces are
between 170 and 400 times faster (on average 250 times)
Reason: Rich structure of traces allow efficient querying of
state changes of particular model elements
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
20/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Evaluation: usability
Elements
Generic
Rich Domain-Specific
Gain
Lines of code
136
55
60%
Statements
58
21
64%
Operation calls
32
13
60%
Loops
5
4
40%
Type checks
4
0
100%
Result: Complexity of rules reduced between 40% and 100%
Reasons:
– Rich structure of traces allow efficient querying of state
changes of particular model elements
– Domain-specific structure makes type checks and casting
obsolete
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
21/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Outline
1 Context and Motivation
2 Rich Domain-Specific Trace Metamodels
3 Evaluation
4 Conclusion
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
Conclusion
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Conclusion
xDSMLs bring a lot of possibilities: simulation, dynamic V&V
Dynamic V&V uses traces, and hence a trace data structure
Generic trace metamodels have two weaknesses: usability and
scalability in time
To cope with these issues, generation of rich domain-specific
trace metamodels
Perspectives
Enhancing customisation of trace metamodels
Experiment other V&V activities on top of generated trace
metamodels
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
22/23
Context and Motivation
Rich Domain-Specific Trace Metamodels
Evaluation
Conclusion
Done!
Thank you for your attention! ,
Bousse, Mayerhofer, Combemale, Baudry
Rich Domain-Specific Trace Metamodels
23/23