<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Towards Debugging the Matching of Henshin Model Transformations Rules</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Matthias Tichy</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Luis Beaucamp</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefan K o¨gel</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Software Engineering and Programing Languages, Ulm University</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-Model Driven Engineering aims at improving effectiveness and efficiency of software engineering. Model transformations are a key artifact in model driven engineering as they enable transforming models into other artifacts for further processing, e.g. analysis models or executable code. However, particularly graph transformation based model transformation tools often lack detailed debugging capabilities. In this paper, we sketch how to debug the matching step of the execution of Henshin model transformation rules.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
    </sec>
    <sec id="sec-2">
      <title>Software engineering with models often requires the appli</title>
      <p>cation of model transformations, e.g., chains of model
transformations to translate state machines into code or operations in
the editor to change the models. Hence, model transformations
are a key element of model-driven software engineering.</p>
      <p>
        Existing research has identified the ability to analyze models
as a key driver w.r.t. to successful application of
modeldriven engineering in practice [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Debugging is a specific
analysis technique – not only with respect to finding defects
but also to understanding how the model transformation works,
e.g. for adding functionality. Debugging Henshin rules, a
graph-transformation based model transformation tool, has the
challenge that its execution process does not follow the typical
sequential order of imperative languages where one usually
executes statement after statement.
      </p>
      <p>
        Several model transformation frameworks offer debugging
support that offers at least basic break points and stepwise
execution on the transformation rule level. Some frameworks
extend this support by offering undo/redo (e.g. QVT-o [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]),
conditional breakpoints (e.g. QVT-o, VIATRA [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]),
visualization of matchings (e.g. GReAT [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], VMTS [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]), or even the
modification of the current match during debugging [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. All
of the above debugging features work on the rule level, i.e.,
they step over the matching phase of a rule. To the best of
our knowledge, there is no graph transformation approach that
enables developers to debug the matching step of a rule.
      </p>
    </sec>
    <sec id="sec-3">
      <title>The contribution of this paper is a sketch how the matching step can be debugged, which is the most important part of the execution of single Henshin transformation rules.</title>
    </sec>
    <sec id="sec-4">
      <title>II. HENSHIN TRANSFORMATION LANGUAGE</title>
    </sec>
    <sec id="sec-5">
      <title>Henshin supports single rules, containing a left hand side</title>
      <p>(LHS) describing the precondition of the rule and a right
hand side (RHS) describing the postcondition of the rule.</p>
    </sec>
    <sec id="sec-6">
      <title>Informally, a Henshin transformation rule is executed by first</title>
      <p>finding a match of the left hand side on the model resp. host
graph (typically a subgraph isomorphism) and then changing
the match such that it is a match of the right hand side.</p>
      <p>
        We illustrate the techniques presented in this paper using the
transferMoney rule from the Bank Example [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] provided
with Henshin (cf. Figure 1). It represents the possibility to
transfer some amount of money from one account to another
while ensuring that the sender’s credit is sufficient and that the
sender cannot transfer money to himself from the receiver’s
account by entering a negative amount.
      </p>
      <p>transferMoney(in client:Estring, in fromId:Eint, in toId:Eint,
in amount:EDouble, var x:EDouble, var y: Edouble)
&lt;&lt;preserve&gt;&gt;
:Client
name=client &lt;&lt;apcrecoseurnvtes&gt;&gt; icdre=fdriot=mxI-d&gt;x-amount
credit=y-&gt;y+amount
id=toId
? Condition financial covering
x &gt; amount
? Condition positive transfer only
amount &gt; 0
&lt;&lt;preserve&gt;&gt;
from:Account
&lt;&lt;preserve&gt;&gt;
to:Account</p>
      <p>Fig. 1. Bank example - transformation rule</p>
      <p>
        Henshin uses a constraint based approach for finding
matches of the left hand side in the host graph [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. In a
first step, a search plan is derived containing a variable
for every node in the left hand side. For each variable, a
corresponding domain slot is created which contains a set of
all potential candidates for this node – initially all instances
of the node’s type. Furthermore, the search plan also defines
which constraints should be enforced, e.g., constraints on
attributes as well as on references between nodes.
:Client
li()tccykTeeepnhC li)(tttrckae=ennAm
c
e
h
c
restrictBy
(accounts)
from: Account
()tccccykTeehpunoA iI()fttrrccke=hdoADm i()tttrrcccxkee=hdA
to: Account
()tccccykTeeunphoA iI()tttrcck=edhoAD
)
y
=
t
i
d
e
(trr
c
t
A
k
c
e
h
c
      </p>
      <p>Fig. 2. Bank example - search plan</p>
      <p>Figure 2 shows the search plan of the Henshin rule
transferMoney of the bank example. The order of matching
the variables is shown by the rectangles and the big arrows.</p>
    </sec>
    <sec id="sec-7">
      <title>Furthermore, for each variable the constraints are annotated.</title>
    </sec>
    <sec id="sec-8">
      <title>For example, for the :Client variable first the type is checked</title>
      <p>and then the attribute constraint is checked. Finally, the set of
candidates for the from:Account is restricted to those which
are reachable via the accounts reference from the current
candidate for the :Client variable.</p>
    </sec>
    <sec id="sec-9">
      <title>The match of the left hand side is then computed by</title>
      <p>a recursive back-tracking algorithm which binds potential
candidates, i.e., objects in the model (the model provided
with the Henshin example contains the clients Alice, Bob,</p>
    </sec>
    <sec id="sec-10">
      <title>Charles), to variables while removing impossible candidates from the domain slots by imposing the constraints derived from the left hand side.</title>
    </sec>
    <sec id="sec-11">
      <title>III. DEBUG STEPS FOR HENSHIN RULES</title>
    </sec>
    <sec id="sec-12">
      <title>Our approach follows the usual debugging steps (step into,</title>
      <p>step over, step return, run until) found in all typical debugging
environments. As described above the Henshin interpreter
uses a recursive backtracking algorithm to find a match for
the left hand side of the rule. Each recursive call covers the
matching of a single variable.</p>
      <p>The matching of a single variable consists of several
activities of the matching process as indicated in the search
plan (cf. Figure 2): selection of a candidate as well as
checking/enforcing the different types of constraints. Multiple
instances of each constraint type are possible, e.g., multiple
attribute constraints. Each of these activities is similar to
a function in an imperative program that “call” each other,
e.g., the function responsible for selection of candidates calls
the different functions for checking/enforcing constraints, and
the function responsible for checking/enforcing all attribute
constraints calls a function for checking an individual attribute.</p>
    </sec>
    <sec id="sec-13">
      <title>Hence, a specific state during matching in our running example has a “call stack” (cf. Table I).</title>
      <p>4.
3.
2.
1.
activity</p>
    </sec>
    <sec id="sec-14">
      <title>The search plan (cf. Figure 2) shows that the vari</title>
      <p>ables are matched in the order :Client, from:Account,
to:Account. Hence, the first debugging state is matching
the variable :Client. With step over, we would complete
the matching of the variable, i.e., selecting a candidate which
satisfies all constraints, which in our running example is Bob.</p>
    </sec>
    <sec id="sec-15">
      <title>However, if we step into, the debugging state changes to</title>
      <p>selecting the candidate Charles as it is the first object in
the model. This step into allows us to iterate with subsequent
step overs over all candidates for the variable.</p>
    </sec>
    <sec id="sec-16">
      <title>But, if we further step into, we can iterate over constraint</title>
      <p>type and instances of the constraint type. In our running
example, we first check the type (Client in our example)
and then attribute constraints like name == ‘‘Bob’’.
Unfortunately, the current candidate has the name ‘‘Charles’’.
Hence, the attribute constraint is not fulfilled and stepping
further leads to considering the next candidate (Bob). Here,
the type and attribute constraints are satisfied. Executing the
reference constraint ensures that the set of candidates for the
account variable from:Account is restricted to the candidate</p>
    </sec>
    <sec id="sec-17">
      <title>2:Account as this is the only account Bob has. However, we see later that this account does not have enough credit. The final candidate for the :Client variable also does not satisfy all constraints.</title>
      <p>While step into covers all states, step over usually stays on
the same “call stack” level, e.g., iterating over all candidates
for a variable or iterating over all constraint types. Step return
simply executes all other activities until a higher level is
reached, e.g. if the current debug state is investigating the
candidate Charles, step return executes all steps until the
matching process of the variable from:Account starts.</p>
    </sec>
    <sec id="sec-18">
      <title>Finally, run until executes all steps until a certain activity takes place, e.g., until a certain candidate is investigated, a certain constraint is checked, or a matching of a certain variable starts.</title>
    </sec>
    <sec id="sec-19">
      <title>IV. CONCLUSION AND FUTURE WORK</title>
      <p>Currently, we have implemented the debugging steps
outlined in Section III in Henshin and refactored the
interpreter in order to enable step-wise execution of the
matching process. We are currently working on integrating
the different step actions into the standard Eclipse debugging
environment and are developing specific visualizations for
the variable view as well as the call stack. Whether and
how much our approach actually improve efficiency and
effectiveness will be a focus of future user studies.</p>
    </sec>
    <sec id="sec-20">
      <title>Acknowledgment This work was funded by the German</title>
    </sec>
    <sec id="sec-21">
      <title>Research Foundation (DFG) as part of the DFG Priority</title>
      <p>Programme 1593 (TI 803/2-2 and TI 803/4-1).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>G.</given-names>
            <surname>Liebel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Marko</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Tichy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Leitner</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Hansson</surname>
          </string-name>
          , “
          <article-title>Model-based engineering in the embedded systems domain: an industrial survey on the state-of-practice,”</article-title>
          <source>Software &amp; Systems Modeling</source>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>23</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M.</given-names>
            <surname>Wimmer</surname>
          </string-name>
          et al.,
          <article-title>“Reviving QVT relations: model-based debugging using colored petri nets,” Model driven engineering languages and systems</article-title>
          , pp.
          <fpage>727</fpage>
          -
          <lpage>732</lpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>[3] “Advanced features of the viatra framework</article-title>
          ,” http://static.incquerylabs.com/projects/viatra/viatradocs/ViatraAdvanced.html, (Accessed on 07/14/
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>D.</given-names>
            <surname>Balasubramanian</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Narayanan</surname>
          </string-name>
          , C. van
          <string-name>
            <surname>Buskirk</surname>
          </string-name>
          , and G. Karsai, “
          <article-title>The graph rewriting and transformation language: Great,” Electronic Communications of the EASST</article-title>
          , vol.
          <volume>1</volume>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>T.</given-names>
            <surname>Me</surname>
          </string-name>
          ´sza´ros, P. Fehe´r, and L. Lengyel, “
          <article-title>Visual debugging support for graph rewriting-based model transformations,” in EUROCON, 2013 IEEE</article-title>
          . IEEE,
          <year>2013</year>
          , pp.
          <fpage>482</fpage>
          -
          <lpage>488</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>C.</given-names>
            <surname>Krause</surname>
          </string-name>
          , “Henshin bank example,” https://www.eclipse.org/henshin/examples.php?example=bank.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Tichy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Krause</surname>
          </string-name>
          , and G. Liebel, “
          <article-title>Detecting performance bad smells for henshin model transformations</article-title>
          ,”
          <source>in Proceedings of the Second Workshop on the Analysis of Model Transformations (AMT</source>
          <year>2013</year>
          ), Miami, FL, USA,
          <year>September 29</year>
          ,
          <year>2013</year>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>