Skip to content

Commit

Permalink
Add extension settings: verbose, debugPort
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Apr 11, 2024
1 parent e5fd635 commit 0f3817b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
"onDebugResolve:hl"
],
"contributes": {
"configuration": {
"title": "HashLink Debugger",
"properties": {
"hldebug.verbose": {
"markdownDescription": "Show verbose debugger trace.",
"type": "boolean",
"default": false
},
"hldebug.defaultPort": {
"markdownDescription": "Default debug port used to connect to HL virtual machine.",
"type": "integer",
"default": 6112
}
}
},
"debuggers": [
{
"type": "hl",
Expand Down
5 changes: 4 additions & 1 deletion src/Extension.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Extension {
}

static function createDebugAdapterDescriptor(session: DebugSession, ?executable:DebugAdapterExecutable): ProviderResult<vscode.DebugAdapterDescriptor> {
return new vscode.DebugAdapterInlineImplementation(cast new HLAdapter());
var config = Vscode.workspace.getConfiguration("hldebug");
HLAdapter.DEBUG = config.get("verbose", false);
var adapter = new HLAdapter(config.get("defaultPort", 6112));
return new vscode.DebugAdapterInlineImplementation(cast adapter);
}
}
10 changes: 5 additions & 5 deletions src/HLAdapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class HLAdapter extends DebugSession {

static var UID = 0;
public static var inst : HLAdapter;
public static var DEBUG = false;

var proc : ChildProcessObject;
var workspaceDirectory : String;
Expand All @@ -38,14 +39,13 @@ class HLAdapter extends DebugSession {
var threads : Map<Int,Bool>;
var allowEvalGetters : Bool;

static var DEBUG = false;
static var isWindows = Sys.systemName() == "Windows";
static var isMac = Sys.systemName() == "Mac";

public function new() {
public function new( defaultPort : Int = 6112 ) {
super();
allowEvalGetters = false;
debugPort = 6112;
debugPort = defaultPort;
doDebug = true;
threads = new Map();
startTime = haxe.Timer.stamp();
Expand Down Expand Up @@ -211,8 +211,6 @@ class HLAdapter extends DebugSession {
hlArgs.unshift("--profile");
}

debug("start process");

if( args.args != null ) hlArgs = hlArgs.concat(args.args);
if( args.argsFile != null ) {
var words = sys.io.File.getContent(args.argsFile).split(" ");
Expand Down Expand Up @@ -243,6 +241,8 @@ class HLAdapter extends DebugSession {
js.Node.process.env.set('LIBHL_PATH', js.node.Path.dirname(args.hl));
}

debug("start process " + hlPath + " " + hlArgs);

proc = ChildProcess.spawn(hlPath, hlArgs, {cwd: args.cwd, env:args.env});
proc.stdout.setEncoding('utf8');
var prev = "";
Expand Down

0 comments on commit 0f3817b

Please sign in to comment.