Skip to content

Debugging with the Interpreter

m0rkeulv edited this page Oct 20, 2026 · 2 revisions

Haxe has a built-in interpreter, called eval. It runs programs started with --interp, and it runs every macro during a compilation. The Haxe Interpreter run configuration debugs both: your program's own code and the macros of a regular build. For the workflow all debuggers share, see Debugging Overview.

Requirements

  • Haxe 4.1 or later. The debugger is part of the Haxe compiler. You don't need a library or a separate debug build.
  • The configuration runs the haxe of the module's Haxe SDK, or of the default SDK under Build Tools | Haxe. Only without any SDK does it use haxe from your PATH.

Create the run configuration

For an hxml file that builds with --interp, the Haxe tool window has a Run entry in the file's Actions group: double-click it to run, or right-click it and choose Debug. The first time, it creates a configuration named like build.hxml (Interpreter).

To create one by hand, open Run | Edit Configurations…, click +, open the Haxe group and choose Haxe Interpreter.

Field What it does
Module: The module the code belongs to.
Compiler arguments (hxml file or e.g. -cp src -main Main): The compilation to run: an hxml file such as build.hxml, or the arguments themselves, such as -cp src -main Main.
Working directory (empty = module folder): The folder haxe runs in. Relative paths in the arguments resolve against it. A relative working directory counts from the module's folder.
Run as interpreter (adds --interp unless the arguments already select it; uncheck to debug the macros of a regular build) On (the default): runs your program in the interpreter. Off: runs the compilation as a normal build, so you can debug its macros.

When the option is on, the plugin adds --interp to the arguments, unless they, or the hxml file they name, already contain it. Run starts haxe with these arguments. Debug also adds -debug, so code under #if debug is compiled in, and connects the debugger, which holds the program until your breakpoints are set, so even a breakpoint on the first line of main stops.

Debug a program in the interpreter

  1. Create a Haxe Interpreter configuration with Run as interpreter turned on, and enter your compilation in Compiler arguments, for example -cp src -main Main or run.hxml.
  2. Set breakpoints in your code.
  3. Start the configuration with Debug.

The program's output appears in the console. The session ends when the program ends.

Debug macros

The interpreter runs your macros while the compiler builds the project, so you can debug them like any other code.

  1. Create a Haxe Interpreter configuration and turn Run as interpreter off.
  2. In Compiler arguments, enter your normal build, for example build.hxml.
  3. Set breakpoints in macro code: build macros, initialization macros called with --macro or expression macros.
  4. Start the configuration with Debug.

The compiler stops at your breakpoints while the macros run. This is a real compilation: when it finishes, it writes its output as usual, and the session ends.

What you can do

  • Line breakpoints, with conditions. A condition that cannot be evaluated, for example because it names an unknown variable, counts as false. A condition that is not one valid Haxe expression marks the breakpoint as invalid, with Condition is not valid Haxe (...); breakpoint not armed or Condition must be one Haxe expression; breakpoint not armed.
  • Stepping: Step Over, Step Into, Step Out, Run to Cursor and Pause, plus Smart Step Into. Step Into stops when the line or the function changes. Step Out inside a call chain such as a.first().second() stops at the start of the next call in the chain.
  • Expression stepping: while a session runs, turn on Expression Stepping (eval) in the debugger settings menu of the Debug tool window. Each step then runs a single expression, and the editor highlights the expression that runs next. The option is off again in every new session.
  • Threads: the Frames view lists the program's threads.
  • Variables, Evaluate Expression, watches and hover.
  • Set Value. The contents of a String are read-only.
  • Exception breakpoints: Caught exception and Uncaught exception. See Exception breakpoints.

With Caught exception off, every exception stop is an uncaught exception, and the program cannot continue past it: Resume or any step lets the exception end the program, which prints its error and exits.

Limitations

  • Exception breakpoints: the Critical errors (null access, out-of-bounds, ...) option and breakpoints for a single exception class have no effect.
  • Debugging the macros of a regular build needs a configuration you create by hand; the tool window's Run entry is only offered for --interp builds.

To debug unit tests that run in the interpreter, see Unit Tests.

Clone this wiki locally