COMMUNITY

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).

1 Like

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);
		Sys.stdin().readLine();
	}

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