Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI debugger exits after spawning hl process and connecting #116

Open
dmlary opened this issue Feb 19, 2023 · 5 comments
Open

CLI debugger exits after spawning hl process and connecting #116

dmlary opened this issue Feb 19, 2023 · 5 comments

Comments

@dmlary
Copy link

dmlary commented Feb 19, 2023

Summary

Using hashlink-debugger as a command-line debugger does not appear to work for the hl build. When I start the debugger, it spawns the process to be debugged, then immediately exits.

This is how I'm building & running the debugger:

cd debugger
haxe compile.hxml
hl debug.hl ~/src/heaps-hello/hello.hl

Analysis

Digging into the source, it looks like it's hard-coded not to work for HLDebugApi.hx. This is the call-chain I traced:

After the connection is established Debugger.init() calls api.start() and will return false if the API fails to start:

public function init( api : Api ) {
this.api = api;
eval = new Eval(module, api, jit);
eval.resumeDebug = evalResumeDebug;
if( !api.start() )
return false;
wait(); // wait first break
return true;
}

In my case api is HLDebugApi, and its implementation is simply to return debugStart():

public function start() {
return debugStart(pid);
}

Which will always return false:

static function debugStart( pid : Int ) : Bool { return false; }

Questions

Is there a way to debug a process from the command-line using the hashlink vm?

@ncannasse
Copy link
Member

ncannasse commented Feb 19, 2023 via email

@dmlary
Copy link
Author

dmlary commented Feb 19, 2023

Ok, I’ll dig into the c code to see what’s going wrong. I’m getting no prompt from the debugger; it just drops back to the command line.

@dmlary
Copy link
Author

dmlary commented Feb 19, 2023

Ahh, damnit, I figured it out. I used homebrew to install hashlink. The homebrew recipe does not run the make codesign_osx step.

Is there any way to add an error message somewhere along the mac codepath to remind the user to check for codesigning? Right now the debugger just exits with no output.

@rcstuber
Copy link
Contributor

This is only implemented in the VSCode extension. See here:

try {
var entitlements:String = js.node.ChildProcess.execSync('codesign -d --entitlements - $$(which $hl)');
validSignature = entitlements.indexOf("com.apple.security.get-task-allow") >= 0;
} catch(ex: Dynamic) {}
if(!validSignature) {
Vscode.window.showErrorMessage('Your Hashlink executable is not properly codesigned. Run `make codesign_osx` during Hashlink installation.\n\nPath: ${hl}');
return null;
}

Note that the Mac Debugger won't work on Apple Silicon processors with Rosetta2!

@ncannasse
Copy link
Member

ncannasse commented Feb 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants