Previous Next Title Page Contents

5 Building a Visual Debugger for the Watch Example with the API

One of the most common questions regarding the DSM approach is how to track down bugs in the generated code. Conventional debugging strategies may be handy when we are building the framework and code generator for DSM, but for the developer who is working with the DSM environment, the game of debugging is indeed a fair bit different than with traditional IDEs. Let us first consider these differences:
No manual changes to generated code. The benefits of domain-specific modeling are mostly due to the 100% code generation, and working only on the design level. Bug corrections are thus not made to the final code, but to the models instead.
Errors originate from design, not from code. As code is generated automatically and always with the same rules, there are no typical code level errors like typos or syntactical mistakes. This means that for normal developers, errors originate from the design level (the metamodeler will correct errors in the code generators).

Both these factors lead to the conclusion that with DSM, the debugging must be carried out on the model level. This is without a doubt a remarkable benefit: traditionally the developer had to separately update design models after making the code corrections, now it is possible to make corrections in one place only.

When debugging on the model level, the important question is how to find the faulty part of the model? Our original test environment for watch applications provided a very limited solution for this problem by providing information about the current application state at the run-time. A nice option, but it would be much better if we could somehow animate the execution of our state models at the same time as we are running them within the test environment.

This chapter explains how this kind of visual trace or debugging aid can be built for your DSM environment by employing the API facilities of MetaEdit+. We will first have a brief look at the MetaEdit+ API in general and what additional components are required for its use. Then we will learn how to make calls back to MetaEdit+ from our generated code and to play around with the visual debugger.

Previous Next Title Page Contents