VSCode Hashlink Debugger traces

Hej all,

I’m sorry I have looked at every thread talking about this subject but nothing worked for me.

I’m on Linux, last VSCode, last VSHaxe extension and HashLink debugger and when I hit F5 (debug) or CTRL+F5 (run), HashLink VM opens, I even get breakpoints working (when debugging) but I can’t get traces in “real-time”.
Traces only shows when I close the hashLink VM (when I close my app) in the Debug Console in VSCode.
When I launch my HL App from the normal terminal, I get traces in real-time, but could not get it working in real-time in VSCode.

Does anyone encounter this thing please ?

(I also tried to build HashLink Debugger form sourcdes) but there is a lot of errors due to different libraries version I suppose…)

Here is my lauch.json :

{
	"version": "0.2.0",
	"configurations": [
        {
            "name": "HashLink",
            "request": "launch",
            "type": "hl",
            "cwd": "${workspaceFolder}",
            "preLaunchTask": {
                "type": "haxe",
                "args": "active configuration"
            }
        },
		{
			"type": "chrome",
			"request": "launch",
			"runtimeExecutable": "/usr/bin/brave-browser-stable",
			"runtimeArgs": ["--disable-web-security"],
			"name": "Brave",
			"url": "file://${workspaceFolder}/index.html",
			"webRoot": "${workspaceFolder}",
			"preLaunchTask": {
				"type" : "haxe",
				"args" : "active configuration"
			}
		}
	]
}

And the tasks.json :

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "haxe",
			"args": "active configuration",
			"problemMatcher": [
				"$haxe-absolute",
				"$haxe",
				"$haxe-error",
				"$haxe-trace"
			],
			"group": "build",
			"label": "haxe: active configuration"
		}
	]
}

That happens if your app is not console app (uses window). Redirect stdout to the text file and tail it.

Thanks for your answer.
I don’t think it’s linked with that.
When I launch my HL app in a “normal” terminal it shows me traces in real-time.

Hello,

that was a workaround of course in case you don’t find a cause, probably a miss-configuration.

Here is my launch/task json (having trace output in debug console)

{
	"configurations": [
		{
			"name": "HashLink/JIT",
			"type": "hl",
			"request": "launch",
			"preLaunchTask": "",
			"hxml": "SDL1.hxml",
			"cwd": "${workspaceFolder}",
			"program": "hlboot.dat"
		}	
	]
}
{
    "version": "2.0.0",
    "command": "haxe",
    "args": ["SDL1.hxml"],
    "problemMatcher": {
        "owner": "haxe",
        "pattern": {
            "regexp": "^(.+):(\\d+): (?:lines \\d+-(\\d+)|character(?:s (\\d+)-| )(\\d+)) : (?:(Warning) : )?(.*)$",
            "file": 1,
            "line": 2,
            "endLine": 3,
            "column": 4,
            "endColumn": 5,
            "severity": 6,
            "message": 7
        }
    },
    "tasks": [
        {
            "type": "hxml",
            "file": "SDL1.hxml",
            "problemMatcher": [
                "$haxe-absolute",
                "$haxe",
                "$haxe-error",
                "$haxe-trace"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "label": "haxe: SDL1.hxml"
        }
    ]
}

Thanks for your interest.
I tried your config but it doesn’t make changes for me, still all traces gome when I close the app :frowning_face:

Then it is possible you have outdated HashLink debugger extension, you can manually download and install it from here

This is the same version 1.3.4 as in VS MarketPlace.
No, I also tried to build all extensions from sources, but I don’t know which versions build all this stuff because I have latests github versions and all together don’t compile :stuck_out_tongue:

Then I can’t help you more. First I thought you are maybe using some framework which redirects stdout to some log file, or even worse, /dev/null. But since you are getting output after app is closed, that’s not the case.

Anyway, I use VSCodium on Windows and have no such problem. Maybe HL extension is not redirecting stdout to debug console on Linux, maybe is something other going on. Wait till someone else comes with an idea.

Good luck.

1 Like

One more thing: problem you are facing comes from the fact that Linux is using stdout buffering (usually 4096 to 8912 bytes) before flushing.the content. So, trace can appear much later than expected (as result of such performance optimization).

Try following:

export NSUnbufferedIO=YES

This will set the terminal unbuffered (start VSCode.from there).

Check GNU coreutils which can modify I/O stream buffering,.e.g.

stdbuf -oL /usr/bin/some_binary

Later is more advanced, using LD_PRELOAD trick. Of course, real solution would be to have trace command flushing content in debug mode (assuming it is not doing that).

I tried withotu success
But when I run my HL app from the normal terminal it traces on the fly, even if I lauch my app in the VSCode terminal, it works fine.
It’s only in the Debug Console in VSCode that the “freeze” occurs, it’s really strange

That’s normal. Same is on Windows. When started from command prompt (terminal on Linux), trace appears. When started as desktop app, stdout detaches (because there is no parent), trace doesn’t appear.

I believe.debug console acts as parent to the adapter (trough pipe), but because buffer content is not flushed, you don’t see traces. That might be responsibility of the adapter, but it could be also responsibility of the HL VM not flushing traces in debug mode. Don’t know which one.

I wonder: what happens if you add to launch.json configuration following?

"outputCapture": "std"

Property outputCapture is not allowed.
And even, it does nothing.
I wonder if there are other people on linux and if it works for them (in debuc console i mean)

I succeed building from sources this : GitHub - vshaxe/hashlink-debugger: Visual Studio Code Debugger for Haxe/HashLink applications

  • I cloned this git into ~/.vscode/extensions
  • I’ve got this dir ~/.vscode/extensions/hashlink-debugger
  • I went into this dir and ran haxe build.hxml (without errors)
  • I opened VSCode, I can see the extension is installed
  • When I launch the debug, it launch the build as expected, the Debugger view open, but it doesn’t launch my HL App

(launch.json and tasts.json are the same)

What am I doing wrong now please ?