Skip to content

Debugging Overview

m0rkeulv edited this page Oct 25, 2026 · 5 revisions

The plugin debugs Haxe programs on several targets. Each target has its own debugger and its own kind of run configuration, but they all work inside the IDE's standard debugger: the same breakpoints, stepping actions and Variables view. This page shows which debugger to use for your target and the workflow they share. The per-target pages cover setup, requirements and limitations.

The feature differences listed on this page cover the HashLink, HXCPP and interpreter debuggers. For JavaScript, Flash and AIR, see their own pages.

Which debugger for which target

Target Run configuration Details
HashLink bytecode (-hl out.hl) HashLink Application Debugging HashLink
C++ (hxcpp) desktop programs HXCPP Application (IntelliJ); also HXCPP Application (vshaxe) and HXCPP Application (legacy) for existing setups Debugging HXCPP
JavaScript (-js) in a browser Haxe Web Browser Debugging JavaScript
JavaScript (-js) in Node.js Node.js Application Debugging JavaScript
The Haxe interpreter (--interp) and macros Haxe Interpreter Debugging with the Interpreter
Flash (-swf) and AIR Haxe Flash Application, Haxe AIR Application (IntelliJ IDEA Ultimate) Debugging Flash and AIR

Other targets, such as Neko, can be run but not debugged.

The debuggers reach your program in different ways, which is why their requirements differ:

flowchart LR
    ide["IntelliJ IDEA<br/>debugger"]
    hld["HashLink debugger,<br/>ships with the plugin"] -->|attaches to| hlp["Your program<br/>on the HashLink VM"]
    cpp["Your C++ program, with the<br/>debug server library compiled in"]
    adapter["Debug adapter<br/>on Node.js"] --> js["Browser or Node.js<br/>running your JavaScript"]
    haxe["The haxe compiler (eval),<br/>running your program or macros"]
    flex["Flash/Flex plugin and fdb<br/>(IntelliJ IDEA Ultimate)"] --> player["Flash Player<br/>or adl"]
    ide <--> hld
    ide <-->|"the program connects"| cpp
    ide <--> adapter
    ide <--> haxe
    ide <--> flex
Loading

All these configurations live under the Haxe group in Run | Edit Configurations…. See Run Configurations for every configuration type and its fields.

Unit tests can be debugged too, on the interpreter, HashLink, C++, Flash and JavaScript (under Node.js). See Unit Tests.

Requirements

  • Haxe 4.1 or later.
  • The runtime or toolchain of your target: a HashLink runtime, a C++ compiler with the hxcpp library or a browser and Node.js. The interpreter needs nothing extra.
  • For Flash and AIR: IntelliJ IDEA Ultimate with the Flash/Flex plugin, and a Flex/AIR SDK.

Each debugger page lists what it needs. Installation points you to the downloads.

Start a debug session

The quickest way is the Haxe tool window:

  1. Open the Haxe tool window and expand your build file and its Actions group.
  2. Right-click the Build & run entry and choose Debug.

The first time, the plugin creates a run configuration named after the build file, for example build.hxml (HashLink). It builds the file before every launch, and the next launch reuses the configuration. The Build & run entry appears when the build produces something the plugin can launch: HashLink bytecode, JavaScript for a browser or Node.js, a Flash or AIR SWF, a Neko program and C++ executables. An interpreter build has a Run entry instead, with Debug in its context menu. See Building and Running.

You can also select any Haxe run configuration in the toolbar and click Debug. To create one by hand, use Run | Edit Configurations…, click +, open the Haxe group and pick the configuration type.

Debug builds are made for you

A debugger needs a debug build, usually compiled with -debug. When a configuration builds through a Run Haxe action step under Before launch (configurations created from Build & run have one; see The Run Haxe action before-launch step), a Debug launch adds the target's debug arguments to the build, and a Run launch builds without them. You don't need to keep a separate debug build file.

Build file and target Added when you launch with Debug
hxml: HashLink, JavaScript -debug
hxml: Flash -debug; for a Haxe Flash Application also -D fdb, which the Flash Player debugger needs
hxml: C++ -debug and the debug server library of the configuration being debugged: -lib intellij-hxcpp-debug-server for HXCPP Application (IntelliJ), -lib hxcpp-debug-server for HXCPP Application (vshaxe), nothing more for HXCPP Application (legacy)
Lime and OpenFL (also HXP projects) -debug; for the windows, mac, linux and cpp targets also --haxelib= and the configuration's debug server library; for the flash target of a Haxe Flash Application also -Dfdb
NME -debug; for the windows, mac, linux and cpp targets also --library and the configuration's debug server library; for the flash target of a Haxe Flash Application also -Dfdb
HXP scripts nothing

To check or turn this off, edit the configuration, select the Run Haxe action step under Before launch and edit it. The Run Haxe Action dialog has the Add debug arguments when launched with Debug option and shows below it the exact arguments it adds. Turn it off when your build file already carries its own debug flags.

C++ debugging compiles the configuration's debug server library into your program. If it is not installed, the launch stops with a notification such as Debugging HXCPP builds needs the intellij-hxcpp-debug-server haxelib, which is not installed, naming the library of the configuration you debug. Click Install, then start debugging again.

The Haxe Interpreter configuration has no build step: compiling and running are one step, and Debug adds -debug to it. See Debugging with the Interpreter.

Breakpoints

Click the gutter next to a line of a .hx file to set a line breakpoint. Run | View Breakpoints… lists them under Haxe Breakpoints. The IDE's general breakpoint features are described in the IntelliJ IDEA help.

  • Rejected lines. The HashLink and HXCPP (IntelliJ) debuggers check each breakpoint against the compiled program. A breakpoint on a line without code is shown as invalid, with the message no executable code at this line (stale build?). If the line does have code, either the program is older than your source, and rebuilding helps, or the compiler optimized the line's code away; see Code the compiler optimized away.
  • Conditions. A breakpoint with a Condition stops only when the condition is true. Write the condition in Haxe. Conditions work with HashLink, both newer HXCPP debuggers and the interpreter, but not with the legacy HXCPP debugger. In JavaScript the browser evaluates conditions as JavaScript; see Debugging JavaScript.
  • Logging and non-suspending breakpoints are not supported by the HashLink, HXCPP and interpreter debuggers: every breakpoint suspends the program, and the logging options have no effect.
  • When a session starts, the console prints a [debug] line listing the line breakpoints it armed (not with the legacy HXCPP debugger). If a breakpoint never stops, check that its file is listed there.

Exception breakpoints

Exception breakpoints are in Run | View Breakpoints…, under Haxe Exception Breakpoints. The Any exception breakpoint is enabled by default. Select it and choose under Notifications when to stop:

Option Stops when Default
Caught exception any exception is thrown, even one a catch handles off
Uncaught exception an exception is thrown that no catch handles on
Critical errors (null access, out-of-bounds, ...) the runtime itself raises an error on

To stop on one exception class only, click + and enter the class name, fully qualified or simple. Such a breakpoint stops when that class or a subclass is thrown, caught or not.

Not every debugger supports every kind:

Debugger Caught Uncaught Critical errors One class
HashLink yes yes yes yes
HXCPP (IntelliJ) haxe.Exception and subclasses only yes yes haxe.Exception subclasses only
HXCPP (vshaxe) no always on, cannot be turned off no no
Interpreter yes yes no no

The legacy HXCPP debugger has no exception breakpoints. When a debugger stops on an exception, the exception's message is also printed to the console.

Stepping and run control

The debuggers support the IDE's stepping actions: Step Over, Step Into, Step Out, Run to Cursor, Pause and Resume. See the IntelliJ IDEA help for what each one does.

  • Smart Step Into lets you choose which call on the current line to enter, in the Choose Method to Step Into popup. It works with HashLink, HXCPP (IntelliJ) and the interpreter.
  • Run to Cursor works everywhere except with the legacy HXCPP debugger.
  • With HashLink and HXCPP (IntelliJ), all threads of the program stop together. The Frames view lets you pick a thread; select it to see its stack and variables.

Inspect and change values

  • Variables shows the variables of the selected frame. Expand objects, arrays, maps, enums and anonymous structures to see their contents.
  • Evaluate Expression, watches and value tooltips on hover take Haxe expressions. You get code completion for the names visible at the current position. Select a variable and open Evaluate Expression to start from its path.
  • Set Value changes a variable while the program is stopped. Where it can be used differs per debugger; see the debugger's page.
  • Jump to Source on a variable opens its declaration. A value that names a class or function shows a ... Navigate link that opens it.

The Variables view with an expanded event object, value types in braces and Navigate links

An expanded object in Variables; values that name a class have a ... Navigate link

Warning

With HashLink and HXCPP (IntelliJ), an expression you evaluate can call functions of your program and create objects. That code really runs, and anything it changes stays changed when you resume. A watch runs again at every stop.

Show objects with toString()

By default, an object is labeled with its class name. Turn on Render Objects with toString() to label it with the result of its own toString() instead. The option is in Settings | Build, Execution, Deployment | Debugger | Haxe, and, while a session runs, in the debugger settings menu of the Debug tool window. Only the HXCPP (IntelliJ) debugger uses it at the moment; HashLink sessions do not offer it yet.

Warning

The debugger then runs your program's toString() every time it shows a value. That code can have side effects, and on HXCPP a toString() that ends up calling itself crashes the program. Turn the option off if debugging behaves strangely.

If the debugger does not stop

  • The breakpoint is shown as invalid. If you changed the code since the last build, rebuild. If the line is unchanged, the compiler probably removed its code; see Code the compiler optimized away.
  • The breakpoint looks fine but never stops. Look at the [debug] line at the top of the console. A file reported as outside this build's classpaths, not armed is not part of the build the configuration launches.
  • The program exits before the debugger attaches. The console says why and suggests what to check, usually a missing debug build. Rebuild with Debug, or check the debug flags of your build file.

Code the compiler optimized away

The compiler simplifies code whose outcome it can work out while compiling, also in debug builds (-debug) and with --no-opt. A breakpoint on such a line is shown as invalid, or never stops with a debugger that does not check breakpoint lines:

  • A switch on a known value keeps only the matching branch. In switch (Quality.MEDIUM), where MEDIUM is an enum abstract value, the switch and case lines have no code left; only the body of the matching case does.
  • A loop over a small constant range, such as for (i in 0...3), is unrolled, so a breakpoint in it may stop less often than expected.
  • A local variable whose value the compiler folds into the code that uses it may not exist in the compiled program, and then does not appear in Variables.

To keep a function's code as you wrote it while you debug, add @:analyzer(ignore) to the function or its class. It turns off the compiler's analyzer, which removes the unused switch branches, for that code only; remove it again when you are done. Switching on a local variable (var quality = Quality.MEDIUM; switch (quality)) also keeps the switch. Loop unrolling does not depend on the analyzer and cannot be turned off: put the breakpoint inside a function the loop calls.

Clone this wiki locally