Skip to content

Commit

Permalink
Add connectionTimeout settings
Browse files Browse the repository at this point in the history
Useful if C side takes longtime before debug server becomes ready
(e.g. sending jit info to VTune)
  • Loading branch information
yuxiaomao committed Jul 30, 2024
1 parent 7281fc9 commit bf44e13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@
"default": false
},
"hldebug.defaultPort": {
"markdownDescription": "Default debug port used to connect to HL virtual machine.",
"markdownDescription": "Default debug port used to connect with HL virtual machine, when port is not specified in launch.json.",
"type": "integer",
"default": 6112
},
"hldebug.connectionTimeout": {
"markdownDescription": "Default connection timeout in second, when connecting the debugger to HL virtual machine.",
"type": "number",
"default": 2
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/Extension.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Extension {
var config = Vscode.workspace.getConfiguration("hldebug");
var isVerbose = config.get("verbose", false);
var defaultPort = config.get("defaultPort", 6112);
var connectionTimeout = config.get("connectionTimeout", 2);

/*
// Can be used to communicate with one built-in adapter during execution. Build with -lib format -lib hscript.
Expand All @@ -83,6 +84,8 @@ class Extension {
executable.args.push("--verbose");
executable.args.push("--defaultPort");
executable.args.push("" + defaultPort);
executable.args.push("--connectionTimeout");
executable.args.push("" + connectionTimeout);
return executable;
}

Expand Down
11 changes: 9 additions & 2 deletions src/HLAdapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class HLAdapter extends DebugSession {
public static var inst : HLAdapter;
public static var DEBUG = false;
public static var DEFAULT_PORT : Int = 6112;
public static var CONNECTION_TIMEOUT : Float = 2;

var isSessionActive(default, set) : Bool;
var breakOnlyActive(default, set) : Bool;
Expand Down Expand Up @@ -335,7 +336,7 @@ class HLAdapter extends DebugSession {
dbg.loadModule(sys.io.File.getBytes(program));

debug("Connecting to 127.0.0.1:" + port);
dbg.connectTries("127.0.0.1", port, 2, function(b) {
dbg.connectTries("127.0.0.1", port, CONNECTION_TIMEOUT, function(b) {
if( !b ) {
// wait a bit (keep eventual HL error message)
haxe.Timer.delay(function() {
Expand Down Expand Up @@ -1185,7 +1186,13 @@ class HLAdapter extends DebugSession {
var port : Int;
if( param != null && (port = Std.parseInt(param)) != 0 )
HLAdapter.DEFAULT_PORT = port;
paramError("Require defaultPort int value");
paramError("--defaultPort requires int value (port number)");
case "--connectionTimeout":
param = args.shift();
var timeout : Float;
if( param != null && (timeout = Std.parseFloat(param)) != 0 )
HLAdapter.CONNECTION_TIMEOUT = timeout;
paramError("--connectionTimeout requires float value (seconds)");
default:
paramError("Unsupported parameter " + param);
}
Expand Down

0 comments on commit bf44e13

Please sign in to comment.