Kha icon indicating copy to clipboard operation
Kha copied to clipboard

Trying both of the vscode hxcpp debuggers with Kha results in a C++ Runtime Library error

Open Jarrio opened this issue 8 years ago • 13 comments

I believe this issue is unique to Kha as I've tried 2 different debuggers and both seem to work in Haxe, OpenFL and with Haxeflixel. I think it would be a more convenient option to be able to use a cpp debugger from within vscode if it's all possible.

The two available debuggers are:

I am able to get the debugger to initiate and report in the console that it is running but at the moment of connection with vscode the program crashes with the following error:

image

Does kha just not include things that these debuggers use during compilation? Or is it actually something to do with the debuggers themselves?

Jarrio avatar Jun 12 '17 17:06 Jarrio

I don't know, never looked into it. Open it in Visual Studio and see where abort is called (or just debug in Visual Studio alltogether).

RobDangerous avatar Jun 12 '17 20:06 RobDangerous

It's not quite running yet, but some progress.

  • khafile.js: project.addDefine('HXCPP_DEBUGGER'); (not sure if actually required)
  • khafile.js: project.addCDefine('HXCPP_DEBUGGER'); so Kha passes down the compiler flag to Kore
  • khafile.js: project.addLibrary('hxcpp-debugger');
  • khafile.js project.addParameter('-debug');
  • it seems Debugger.cpp is excluded via Kha/korefile.js
    • remove the exlusion so the line reads project.addExcludes('Backends/Kore/khacpp/src/hx/Profiler.cpp', 'Backends/Kore/khacpp/src/hx/Telemetry.cpp');
  • build solution
  • (copy /build/windows-build/debug/myapp.exe to /build/windows)
  • wait until https://github.com/vshaxe/vshaxe-debugadapter/issues/15 is fixed, b/c your app can't load the assets now

Edit: Maybe it will work with jcward's debugger as you can set the cwd it seems, but i'm too tired now to try 😪 Edit2: uncomment Kha/Backends/Kore/khacpp/src/hx/Thread.cpp line 332

sh-dave avatar Jun 12 '17 20:06 sh-dave

@RobDangerous Debugging in Visual Studio is an option yes. When I'm away from my desktop and developing on a laptop, visual studio can be a huge battery drain and is generally not very "low performance" plus it's just nice and convenient to have a debugger which works with your haxe code rather than (HXLINE X) in an external IDE.

@sh-dave Thank you! I will try this later when I get a chance. Much appreciated!

Jarrio avatar Jun 12 '17 23:06 Jarrio

We have the html5 debugger for that. But I'll integrate native debugging as an additional option once it's a bit less quirky of course.

RobDangerous avatar Jun 13 '17 16:06 RobDangerous

Closing this for now, somebody tell me when that works.

RobDangerous avatar Jun 27 '17 08:06 RobDangerous

@RobDangerous hxcpp-debugger is works now (after little fix), but very unstable and strange :D 123 kha_application_dbg.zip

Also Kha/korefile.js:33 was replaced with:

//project.addExcludes('Backends/Kore/khacpp/src/hx/Debugger.cpp');
//project.addExcludes('Backends/Kore/khacpp/src/hx/Telemetry.cpp');
project.addExcludes('Backends/Kore/khacpp/src/hx/Profiler.cpp');

Lauched in Linux Mint 18.3 x64 vscode-debug-adapted and hxcpp-debugger is latest from git (for Linux needed gnome-terminal) Kha is latest from git

R3D9477 avatar Feb 20 '18 09:02 R3D9477

Cool spot, let's put it in.

RobDangerous avatar Feb 20 '18 09:02 RobDangerous

@RobDangerous think, it is needed much more work and tests, but it led to progress in this question :)

R3D9477 avatar Feb 20 '18 09:02 R3D9477

Maybe having an easy way to set it up (aka Kode Studio) will help the debugger along.

RobDangerous avatar Feb 20 '18 09:02 RobDangerous

Did somebody have success with more older hxcpp-debugger (from branch protocol_v1.1) and KodeStudio (as I see, KodeStudio used this version of hxcpp-debugger)?

R3D9477 avatar Feb 20 '18 09:02 R3D9477

Kode Studio didn't use this yet, I just put in the repo for preparation a long while ago.

RobDangerous avatar Feb 20 '18 09:02 RobDangerous

It is would be cool, to include into the KodeStudio. But still several troubles with hxcpp-debugger and Kha (clean HXCPP-projects haven't these troubles with debugger):

  1. Window of the debuggable application don't opening
  2. Breakpoints don't works correctly

And I think that both troubles have a one root. I'll do several experiments, maybe I'll find solution.

Also I'm not tested hxcpp-debugger for Windows, yet.


UPD: probably, [1,2] is bugs of the debugger. I reproduced it with clean HXCPP application.

R3D9477 avatar Feb 20 '18 09:02 R3D9477

breakpoints works with only with startStopped=true

so, debugger freezes on Kha/Backends/Kore/kha/SystemImpl.hx:113 untyped __cpp__('post_kore_init()');


UPD:

workaround: just needed to change this line to

#if !(debug && cpp)
	untyped __cpp__('post_kore_init()');
#end

profit: 1

R3D9477 avatar Feb 20 '18 19:02 R3D9477