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

Fix #772 - Fixes for attached debugging and related improvements. #784

Merged
merged 3 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/debugger/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
5 changes: 4 additions & 1 deletion src/debugger/godot4/debug_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

Expand Down
17 changes: 13 additions & 4 deletions src/debugger/godot4/server_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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://", "");
Expand Down Expand Up @@ -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++];
Expand Down Expand Up @@ -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 ?? []);
Expand Down