Fixes for attached debugging and related improvements. (#784)

'launch' and 'attach' modes are working with these changes. The root problems were related to the version of the attached project not being detected properly and file paths not being correctly calculated when attached. The networking code that had version-dependent behavior is now a bit more robust and won't break if minor versions were to ever exceed 1 digit.
When using 'attach' mode, the version info wasn't available at all, causing most (all?) network messages to be ignored.
This commit is contained in:
Eric Cosky
2025-02-22 09:28:38 -08:00
committed by GitHub
parent 53f48ede63
commit 035211276d
3 changed files with 18 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ export class GodotDebugger implements DebugAdapterDescriptorFactory, DebugConfig
log.info(`Project version identified as ${projectVersion}`);
if (projectVersion.startsWith("4")) {
this.session = new Godot4DebugSession();
this.session = new Godot4DebugSession(projectVersion);
} else {
this.session = new Godot3DebugSession();
}

View File

@@ -29,11 +29,13 @@ export class GodotDebugSession extends LoggingDebugSession {
public variables_manager: VariablesManager;
public constructor() {
public constructor(projectVersion : string) {
super();
this.setDebuggerLinesStartAt1(false);
this.setDebuggerColumnsStartAt1(false);
this.controller.setProjectVersion(projectVersion);
}
public dispose() {
@@ -91,6 +93,7 @@ export class GodotDebugSession extends LoggingDebugSession {
this.mode = "attach";
this.debug_data.projectPath = args.project;
this.exception = false;
await this.controller.attach(args);

View File

@@ -75,10 +75,19 @@ export class ServerController {
private steppingOut = false;
private didFirstOutput = false;
private partialStackVars: GodotPartialStackVars;
private connectedVersion = "";
private projectVersionMajor: number;
private projectVersionMinor : number;
private projectVersionPoint : number;
public constructor(public session: GodotDebugSession) {}
public setProjectVersion(projectVersion: string) {
const versionParts = projectVersion.split('.').map(Number);
this.projectVersionMajor = versionParts[0] || 0;
this.projectVersionMinor = versionParts[1] || 0;
this.projectVersionPoint = versionParts[2] || 0;
}
public break() {
this.send_command("break");
}
@@ -204,7 +213,7 @@ export class ServerController {
}
}
this.connectedVersion = result.version;
this.setProjectVersion(result.version);
let command = `"${godotPath}" --path "${args.project}"`;
const address = args.address.replace("tcp://", "");
@@ -381,7 +390,7 @@ export class ServerController {
const command = new Command();
let i = 0;
command.command = dataset[i++];
if (this.connectedVersion[2] >= "2") {
if (this.projectVersionMinor >= 2) {
command.threadId = dataset[i++];
}
command.parameters = dataset[i++];
@@ -691,7 +700,7 @@ export class ServerController {
private send_command(command: string, parameters?: any[]) {
const commandArray: any[] = [command];
if (this.connectedVersion[2] >= "2") {
if (this.projectVersionMinor >= 2) {
commandArray.push(this.threadId);
}
commandArray.push(parameters ?? []);