Need some help to get VS Code to debug CPP and haxe-eval

Hello :slight_smile:. I can’t get any sort of debugging going in VS Code.

You can see everything (build hxml, .vscode/launch.json and .vscode/tasks.json) in this repo:

This is part of an ongoing open source project where I aim to demonstrate to people how Haxe can be used for Cross Platform APIs. I want to cover a very wide range of uses, including 3D engines, plugins, modding and more. I intend to demonstrate lots of language features too. And to make it all debuggable and deployable to as many targets and configs as possible. But… I’m stuck :slight_smile:

More details about why I’m doing this:

I’m working on something that will hopefully be better than the “Getting started with Haxe” series of articles. It’s somewhat opinionated in that I use Visual Studio Code.

However, what I intend to do is worth the ‘opinion’. Since I’ve chosen an IDE, users will get FULLY functional Haxe boilerplates for various types of projects, using various libraries. I plan to gather everything in one repo.

But for now, I’m focused on cross-platform API projects, which is one of the strengths of Haxe.

The repo is here:

Have a look at this repo - it has working launch configs for every Haxe target that can be debugged (JS, C++, HL, Eval, Flash).


Oooh! Sweet! :slight_smile: . Tasty configs for me to understand! Thank you! This is what I call “investigation progress” :smiley:

I cloned it, but I’m unable to debug CPP:

“Debug server connected!”

But the breakpoint I put in the code is not triggered. Or am I missing something?

I didn’t try the other targets yet. Too tired now. Must sleep.

Not sure, seems to work for me:

Are you on Windows?

Hi Jens, thanks for answering again :slight_smile: . Yes, Windows 10.

Actually, breakpoints work, but not correctly. I made the blasphemy of modifying the code a bit before running :smiley: , which is why it didn’t work:

	static function main() {
		var a:Int = 2;
		var b:Int = 4;
		var ab:Int;
		ab = a + b;
		Sys.println("The sum of a and b is: " + ab);

Put a breakpoint on ab = a + b :slight_smile: It doesn’t hit for me. It does hit BOTH the println and the b: Int = 4 assignment, but not the line with addition. Actually, it steps over it when I step. Just to be clear, the assignment DOES happen, it just doesn’t hit the breakpoint.

Bonus question: why isn’t my Sys.stdin().readLine(); working? I can’t get the program to stop no matter how many times I hit Enter in the debug console. No line seems to be read.

It looks like that line gets optimized away. It gets merged into the declaration as you can see in the AST dump (dump\cpp\Main.dump) on the right here:

Seems better with -D analyzer-no-fusion, but then you also have this ugly _hx_tmp:

Regarding readLine() not working, I think the VSCode debug console may not accept input? There may be some setting to use the Terminal instead, I don’t quite remember.

1 Like

Hej !

I just discovered the VSHaxe debugger but I can’t get it working. (2 years later I wake up :rofl: )
It tells me that it miss server.hxml configuration in lauch.json (server.hxml is my current build for PHP target…)
First, I even don’t know if I can use it for example in a large project for PHP plateform (so with my server.hxml build file - I just want to debug some macros), or I must create a smaller projet with --interp “output” ?

Sorry, I’m really a noob with VSCode, I had to put launch.json into the .vscode directory, it works fine now.
BTW it seems to be an amazing tool for debugging macros !
Thanks a lot for your work !

Hej @Gama11,

I took the files (settings and task) from your repository and pasted them into the global .config/Code/User dir and now when trying to compile, compilation runs fine but I get this error for task :

Error: The haxe task detection didn't contribute a task for the following configuration:
    "type": "haxe",
    "args": "active configuration",
    "group": {
        "kind": "build",
        "isDefault": true
The task will be ignored.

I don’t get this error when the settings and task are in my project .vscode dir.
How to solve that please ? (I’m on the last VSCode version (1.69.2) and last VSHaxe extension version (2.24.0)