🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCL Debugger
This page was created by Hans.karlsen on 2023-08-09. Last edited by Wikiadmin on 2026-07-29.

You can use the OCL Debugger in MDriven Designer to run OCL queries and EAL actions against a running prototype of your model, inspect the result, and test model logic interactively.

What the OCL Debugger does

The OCL Debugger opens the OCLExecuteAndDebug window for a running model. Use it to evaluate an expression against the objects currently in the prototype.

For example, you can execute House.allinstances to list every current House object. If no objects have been created, the result is empty.

OCL is a query language: an OCL expression must not change data. When you need to create objects, set values, or invoke operations that change state, use EAL (Extended Action Language).

You want to Use Example
Inspect existing objects or calculate a value OCL House.allinstances
Create or change data, or invoke an action EAL/action language action: House.Create

Open the debugger

  1. In MDriven Designer, select the Play button in the top menu.
  2. In the System Prototyper dialog, select XML.
  3. Select Start system to start the model.
  4. Select Debugger. MDriven opens the OCLExecuteAndDebug window.

The System Prototyper is the running instance of your model. After the debugger has opened, you can close the prototyper dialog and continue working in the debugger.

Execute an expression

  1. In OCLExecuteAndDebug, enter an expression.
  2. Place the cursor in the expression you want to run.
  3. Select Execute.
  4. Review the result list.

Separate expressions with an empty line. The debugger treats each block separated by an empty line as a separate expression and executes the block where the cursor is located.

Query model objects with OCL

Enter the following expression and select Execute:

House.allinstances

The result list shows the current instances of House and their available values. This is useful when you need to verify whether an action created an object or whether a derivation returns the expected objects.

Run an action with EAL

Prefix an expression with action: when it must be evaluated as action language rather than OCL. The debugger also recognizes ocl: and oclps:; ocl: is the default mode.

For example, create a House object with:

action: House.Create

Run House.allinstances again to verify that the result now includes the new object. In the example model, a newly created House starts in the Plan state according to its state machine.

Reuse a selected result

The debugger provides variables named M1, M2, and M3. They work as temporary memory slots for result selections.

  1. Execute an expression that returns objects, such as House.allinstances.
  2. Select a row in the result list.
  3. Choose Selected to M1.
  4. Use M1 in the next expression.

A memory variable represents a collection. To work with one selected object, reduce the collection first. For example:

action: M1->first.StartConstruction

This invokes StartConstruction on the first object held in M1. Whether the transition succeeds depends on the guards defined in the model's state machine.

Investigate a failed guard

Use small queries to test the conditions that control a transition. For example, if StartConstruction requires an address, inspect the value before invoking the transition:

M1->first.address.isnull

M1->first.address.notnull

An empty string is not the same as null. If a guard must reject both a missing and an empty string, test the string with IsNullOrEmpty and negate the result when the value is required:

not self.Address.IsNullOrEmpty

This approach lets you identify whether a failed action is caused by the selected object, a missing value, or the guard expression itself.

Use the editor and completion

Select Edit in OCLExecuteAndDebug to open the expression editor. The editor uses the same OCL editing experience used while defining model logic. Press Ctrl+Enter in the Action Editor to open code completion and select an available name or operation.

Use the editor when an expression needs more than a quick one-line check, or when you want completion help for a class, attribute, or operation.

Choose the right debugger

This page describes debugging expressions against objects in a running prototype of your application model. MDriven Designer can also open a debugger for the MDriven model itself. In Designer, right-click in many locations and choose Extras followed by Show autoform… or Open Model Debugger…. Use that capability when you need to query or manually alter model metadata rather than application data; see Documentation:Using the model debugger to change the model itself.

Practical workflow

  1. Start the system and open OCLExecuteAndDebug.
  2. Query the target class with ClassName.allinstances.
  3. Select an object and store it in M1.
  4. Query the values that matter to the rule or state-machine guard.
  5. Run an action: expression when you need to test a state change or other data-changing operation.
  6. Query the object again to confirm the resulting values and state.

See also