vscode-hxcpp-debug icon indicating copy to clipboard operation
vscode-hxcpp-debug copied to clipboard

Proper timeout / error when project doesn't connect to debugger

Open jcward opened this issue 9 years ago • 4 comments

Need to message the user that their project didn't connect to the debug server (perhaps wasn't compiled in debug, didn't include new HaxeRemote(), was firewalled, etc.) Though we don't know where the user put the HaxeRemote() call in their code, it may not be quickly after launch?

jcward avatar Dec 09 '15 14:12 jcward

Is there a way to adjust the timeout period? Whenever I'm not using the debugger I'd like it to fail gracefully rather than having it hang and have to comment out the new HaxeRemote()

MintPaw avatar Jan 18 '16 23:01 MintPaw

Hi @MintPaw, it appears there isn't currently a timeout in HaxeRemote. This issue is for a timeout in the debug adapter if the client indeed doesn't connect.

However, if you put your new HaxeRemote() inside a check for both debug and HXCPP_DEBUGGER like this:

#if (debug && HXCPP_DEBUGGER)
    new debugger.HaxeRemote(true, "localhost");
#end

Then perhaps you could add a "Release build" configuration in your launch.json without the -DHXCPP_DEBUGGER option:

        {
            "runtimeExecutable": "${execPath}",
            "args": [
                "compilePath=${workspaceRoot}",
                "compileCommand=openfl build linux",
                "runPath=${workspaceRoot}/Export/linux64/cpp/bin/",
                "runCommand=DisplayingABitmap",
                "runInTerminal=false"
            ],
            "name": "Release build",
            "type": "hxcpp",
            "request": "launch",
            "stopOnEntry": true
        },

So you could switch between debug builds and release builds. It may be slow to switch between builds unless 1) you use hxcpp compile cache, or 2) you use different output directories for release vs debug.

Are you using openfl? If you fiddle with your project.xml, you can get the release and debug versions to build to different locations so the compile steps don't overwrite each other, and each will compile fast for iterative changes. Something like e.g.

  <app path="export/debug" if="debug" />
  <app path="export/release" unless="debug" />

(you'd also have to update the runPath in the launch.json accordingly)

Hope this helps!

jcward avatar Jan 19 '16 00:01 jcward

Yes I use openfl, but changes of defines like that almost always cause completely rebuilds, I should set up a build system using multiple directories, or can you link me to something about hxcpp compile caches?

On Mon, Jan 18, 2016 at 5:53 PM, Jeff Ward [email protected] wrote:

Hi @MintPaw https://github.com/MintPaw, it appears there isn't currently a timeout in HaxeRemote. This issue is for a timeout in the debug adapter if the client indeed doesn't connect.

However, if you put your new HaxeRemote() inside a check for both debug and HXCPP_DEBUGGER like this:

#if (debug && HXCPP_DEBUGGER) new debugger.HaxeRemote(true, "localhost"); #end

Then perhaps you could add a "Release build" configuration in your launch.json without the -DHXCPP_DEBUGGER option:

    {
        "runtimeExecutable": "${execPath}",
        "args": [
            "compilePath=${workspaceRoot}",
            "compileCommand=openfl build linux",
            "runPath=${workspaceRoot}/Export/linux64/cpp/bin/",
            "runCommand=DisplayingABitmap",
            "runInTerminal=false"
        ],
        "name": "Release build",
        "type": "hxcpp",
        "request": "launch",
        "stopOnEntry": true
    },

So you could switch between debug builds and release builds. It may be slow to switch between builds unless 1) you use hxcpp compile cache, or 2) you use different output directories for release vs debug.

Are you using openfl? If you fiddle with your project.xml, you can get the release and debug versions to build to different locations so the compile steps don't overwrite each other, and each will compile fast for iterative changes. Something like e.g.

(you'd also have to update the runPath in the launch.json accordingly)

Hope this helps!

— Reply to this email directly or view it on GitHub https://github.com/jcward/vscode-hxcpp-debug/issues/16#issuecomment-172694657 .

MintPaw avatar Jan 19 '16 01:01 MintPaw

I just tried the HXCPP compile cache, it's pretty easy to setup - create a directory and set an environment variable pointing to that directory. What platform are you on? On Linux/mac it should be as easy as:

mkdir $HOME/hxcpp_cc
export HXCPP_COMPILE_CACHE=$HOME/hxcpp_cc

That sets an environment variable for only one session. To make it permanent, you'll need to set that export in your bash startup file (e.g. on linux: ~/.bashrc).

You can be sure it's working if, after you compile, that folder is being filled with directories:

>ls $HXCPP_COMPILE_CACHE 
00  0d  1a  27  34  41  4e  5b  68  75  82  8f  9c  a9  b6  c3  d0  dd  ea  f7
...

jcward avatar Jan 19 '16 02:01 jcward