# Debugging Rego

In addition to being a [language server](https://www.openpolicyagent.org/projects/regal/language-server), Regal can act as a [Debug Adapter](https://microsoft.github.io/debug-adapter-protocol/) for supported clients. A Debug Adapter is a long running program that can communicate with a debugger client, such as Visual Studio Code's debugger, to provide live, step-by-step, debugging capabilities for a language.

![Animation showing the a debugging session in VS Code](/assets/images/animation-46e09b8fe23af200262bb24e40bbec20.gif)

_A debugging session in VS Code_

## Getting Started

See the documentation in the Editor Support page for supported clients:

*   [Visual Studio Code](https://www.openpolicyagent.org/projects/regal/editor-support#visual-studio-code)
*   [Neovim](https://www.openpolicyagent.org/projects/regal/editor-support#neovim)

info

If your evaluation depends on a `data.json` file, please make sure to have `.manifest` files to mark your bundles, or [configure roots](https://www.openpolicyagent.org/projects/regal/configuration/project-roots) in Regal's config.

## Features

The Regal Debug Adapter currently supports the following features:

### Breakpoints

Breakpoints allow you to continue execution of a policy until a given point. This can be helpful for:

*   Inspection of variables at a given point in time
*   Seeing how many times a given block of Rego code is executed, if at all
*   Avoiding the need to step through code as it's run line by line

![Screenshot of a breakpoint in VS Code](/assets/images/breakpoint-2b9fcd45f25ced4d6e27acaec249d334.png)

### Variable Inspection

Either at a breakpoint or while stepping through code, you can inspect the local variables in scope as well as the contents of the global `input` and `data` documents.

`input` will be loaded from `input.json` in the workspace if it exists.

![Variables being inspected during execution in VS Code](/assets/images/variables-82f5203f9ce2dfea232385a6c50d2954.png)

### Print Statements

Print statements are also supported, these are shown in the debug console:

![Print statements shown in the debug output console](/assets/images/print-7ec6efef09353dacf0b5c8aa6d4ca76a.png)