Skip to content

Toro Cloud Dev Center


Debugging a service

Debugging a service allows you to monitor, analyze, and control the execution of the service. With Martini, you can add breakpoints, step over or into steps, examine and manipulate the context1, perform evaluations, and more. In this section, we will go over each of Martini's debugging features for Gloop and learn how they could be used.

Starting a debug session

To start a debug session, you need to run your service in debug mode. Once a service is running in debug mode, you will be able to perform debug operations on that service.

There are multiple ways you can debug a service, such as:

Debugging a service

Debugging a service

  • Open the service and click the debug button on the toolbar.
  • Right click the service from the Navigator, or the step tree if the service is opened in the editor, then select Debug from the appearing context menu.

Use the shortcut to quickly debug services

You can press to debug the currently selected or opened service.

Toggling breakpoints

Breakpoints are used as markers to suspend the execution of a service. Breakpoints mark a particular step in a service and when that step is reached, the execution will be suspended. Breakpoints have two properties: Hit Count and Condition.

The Hit Count value is used to tell Gloop how many times the breakpoint needs to be hit before it will suspend execution of the service. This can be useful when iterating over arrays. By default, Hit Count's value is set to -1; meaning the first hit will suspend the execution.

Condition, on the other hand, has a Groovy expression for its value which returns either true or false. If the expression returns true, the execution will be suspended. If the Condition is empty or returns false, it will have no effect; the service runs as usual. The context properties of the current step are available in the expression; therefore, a property value can be used to determine if a breakpoint should suspend the execution or not.

There are multiple ways to toggle a breakpoint. You can:

Toggle breakpoint

Toggle breakpoint

  • Use the shortcut ;
  • Double click on the number ruler; or
  • Right click the number ruler, then select Toggle Step Breakpoint from the context menu.

You can toggle multiple breakpoints at a time by selecting all steps before doing any of the actions above.

Double-click to toggle breakpoints

Double-click on a line number in the line ruler to toggle a breakpoint.

Toggling tracepoints

A tracepoint is simply a breakpoint with a Condition expression that prints the service and line number instead of returning true or false. While a service is being debugged with a tracepoint, the tracepoint will log every time the tracepoint has been hit. Since a tracepoint is a breakpoint, you can also change the Condition, or even add logic to use it as both a tracepoint and a breakpoint by having the Condition expression return true.

To toggle a tracepoint:

Toggle tracepoint

Toggle breakpoint

  1. Select one or multiple steps.
  2. If in Martini Desktop, press . If in Martini Online, press . Alternatively (applicable for either IDEs), right click the line number on the line ruler located on the left side of the step tree then click Toggle Step Tracepoint.

Debugging step commands

Similar to debugging in other programming languages, Gloop provides multiple ways to step through a service once a breakpoint has been hit; all of which are described below:

Step Command Description
Resume Resumes the debug execution until a breakpoint is hit or the service is completed.
Pause Suspend the debug execution.
Terminate Stop the debug execution.
Step Into Steps into the step.
Step Over Steps over the step unless a breakpoint is hit.
Step Return Upon stepping into a service, resume until the current service has returned back to the caller, or the main service has completed.

Debug perspective

Martini provides a Gloop-specific Debug perspective, which is pre-configured with all the views and components required when debugging a service. In this perspective, you can set breakpoints, edit the values of variables at runtime, evaluate expressions, and run multiple simultaneous debugging sessions.

The image below is a screenshot of the Debug perspective, with its primary views labeled, namely:

  1. Debug view
  2. Debug Execution History view
  3. Variables view
  4. Expressions view
  5. Breakpoints view

Martini's Debug perspective for services

Martini's Debug perspective for services

When a service that is being debugged has hit a breakpoint, a prompt to switch to the Debug perspective will appear.

Debug perspective prompt

Debug perspective prompt

Debug view

The Debug view shows the debug execution stack of services that are currently being debugged. Selecting a stack will open the service in the step editor, highlighting the step that it's currently waiting on. From there, you can choose how to step through the service next, or to terminate it.

The Debug view

The Debug view

Variables view

The Variables view shows the variables and their values of the current chosen execution stack. The variables will be highlighted when their value changes.

The Variables view

The Variables view

The values can be edited at runtime by right-clicking on a variable and selecting Change Value.

Changing a variable's value in the Variables view

Changing a variable's value in the Variables view

Debug Execution History view

The Debug Execution History view shows the execution history of the service - up to the last 100 steps - and also shows the time the previous steps took to execute (which is useful in finding bottlenecks in your services). The table headers can be clicked on for sorting.

Debug Execution History view, sort by time execution

Debug Execution History view, sort by time execution

Expressions view

The Expressions view allows you to write Groovy expressions which are evaluated in the service that is currently being debugged. Expressions here cannot be used to change the value of variables that are being debugged. When a variable can't be evaluated, it will display error(s) during the evaluation.

Adding an expression in the Expressions view

Adding an expression in the Expressions view

Evaluations

The evaluations made while debugging do not alter the values of the context.

Breakpoints view

The Breakpoints view lists declared breakpoints across all Martini instances. Breakpoints can be deleted or disabled by un-checking the checkbox beside them. When a breakpoint is selected, the Hit Count and Condition fields appear below it. They can be both used to configure when to pause execution. When a breakpoint configuration is modified, press to persist the change(s).

Breakpoints view

Breakpoints view

Condition history

The previous Conditions entered are accessible in the drop-down box above the text area.

Breakpoints view, add conditional breakpoint

Breakpoints view, add conditional breakpoint

From the GIF above, you'll see that the debug execution pauses when the value of sum is 6.6.

Edit breakpoint conditions through the context menu

You could also edit the breakpoint condition via right-clicking the breakpoint from the service editor and then selecting Edit Breakpoint Properties. Breakpoint properties

You could also edit the breakpoint condition via right-clicking the step with the breakpoint from the service editor and selecting Edit Breakpoint Properties. Breakpoint properties

Shortcuts

Command Description Shortcut
Toggle breakpoint Toggles a breakpoint
Toggle tracepoint Toggles a tracepoint
Resume Resumes the debug execution until a breakpoint is hit
Terminate Stops the debug execution
Step into Goes into the Gloop step
Step over Goes over the Gloop step until a breakpoint is hit
Step return Goes out to the caller when stepped into a service

Customize shortcuts

The shortcuts listed above are the default keyboard shortcuts for Martini Desktop. These shortcuts can be be modified by going to the Preferences menu, and navigating to General > Keys.

Command Description Shortcut
Toggle breakpoint Toggles a breakpoint
Toggle tracepoint Toggles a tracepoint

  1. For example, set the value of a property or variable.