Best approach for debugging cpp target?


#1

How do you guys work with debugging when targeting cpp? Using Haxe/Flashdevelop.
The commandline debugger? Debugging the generated c++ code in Visual studio? Whats the preferred solution for now?


#2

I use a lot of traces and switching targets to neko sometimes gives you a bit more info. You do have to run

lime test neko

via the command line though to get any stack traces.


#3

for cpp-only i watching traces to (while running program from console),
to show only msg from special parts of code,
its easy to switch between them with haxe-defines in project.xml like:

<haxedef name="debuginput" />
<haxedef name="debugnetwork" />
<!--<haxedef name="debugaudio" />-->

<haxedef name="no-traces" /><!-- disables traces at all for production build -->

and inside code something like:
#if debugnetwork trace('somethingwrong with ${inputBuffer.length}'); #end

;)=


#4

In Windows, compile with HXCPP_DEBUG_LINK and use “Debug->Attach to process” in Visual Studio


#5

If you’re using the cpp target we’re working on getting Visual Studio Code and the hxcpp debugger to play nice together so that you can set breakpoints in VSCode and debug from an IDE.


#6

Aha… Getting the hxcpp debugger working with VSCode would be a major step then… Ofcourse i’m hoping for a debug solution for Flash/Haxedevelop but it absolutely will help the workflow… What is the status of this? Who are working on it? :slight_smile:


#7

Me and @jeff_ward are on it. Jeff made all the work on the VSCode integration while I fixed the debugger to actually work on Mac/Linux/Windows.

It’s a work in progress but we’re getting near the end :slight_smile:


#8

Thats really cool. Having proper cpp debugging will help so much! Really excited to see when you are releasing this!
Hopefully this could help with getting Flash/Haxedevelop integrated debugging working also?


#9

You can follow along at the repo for the vscode-hxcpp-debug project: https://github.com/jcward/vscode-hxcpp-debug

And as @tanis said, there’s currently an issue using it on Mac/Windows that’s very close to being resolved: https://github.com/jcward/vscode-hxcpp-debug/issues/25

And while this project is entirely about a Visual Studio Code plugin – there is the side benefit that people are working with the hxcpp-debugger, and making it more stable and working in more places. :slight_smile:

We’ll announce via various channels (repo, Twitter, haxe roundup, here, etc) when the PRs are in place and it’s ready to be used. Cheers!


Debugging iOS, hxcpp, obj-c
#10

@jeff_ward Awesome work guys! Keep it up!


#11

FYI for future reference,

The issue #25 on the vscode-hxcpp-debug is fixed, so that should represent good progress toward stability. Note that you need to use a recent version of the hxcpp-debugger for it to work. e.g. install from git:

haxelib git hxcpp-debugger https://github.com/HaxeFoundation/hxcpp-debugger

#12

Nice! Great work!.. Being able to debug from the cpp target in vsc is a great step forward. Now ultimately i wish for integrated haxedevelop/flashdevelop debugger support but… until then, this is very nice!


#13

In case anybody stumbles over this old thread, these days there’s a hxcpp debugger extension available that can be downloaded conveniently from VSCode’s marketplace:

https://marketplace.visualstudio.com/items?itemName=vshaxe.hxcpp-debugger


#14

Thank you for sharing. How do I setup this targeting Android?


#15

I haven’t tried that myself yet, but there’s some defines you can set for the host / port: https://github.com/vshaxe/hxcpp-debugger/blob/d82307235fef5f1c7f18bf7a31d85d6b8593be88/hxcpp-debug-server/hxcpp/debug/jsonrpc/Server.hx#L58-L59

And you would probably need an attach rather than a launch request in launch.json.


#16

I’ve been trying this for some time… But i cant get the hxcpp debugger to work. Dont know why.
App starts but without debugging… I’ve checked many setups and my lauch / settings / hxml files seem ok…


#17

You could try with this workspace to make 100% sure it’s not some config error. It has working launch configs for all targets that support debugging in VSCode.