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

breakpoints are ignored in debug mode #268

Open
Krysl opened this issue May 3, 2024 · 3 comments
Open

breakpoints are ignored in debug mode #268

Krysl opened this issue May 3, 2024 · 3 comments
Labels
possible bug Could be a bug

Comments

@Krysl
Copy link

Krysl commented May 3, 2024

test code from #74

If I have another file also have some breakpoints (such as Ztest.g, which is used by setBreakPointsRequest() later than test.g).
The breakpoints set by test.g will be clear by Ztest.g in this.debugger.clearBreakPoints();

protected override setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse,
args: DebugProtocol.SetBreakpointsArguments): void {
if (this.debugger) {
this.debugger.clearBreakPoints();
if (args.breakpoints && args.source.path) {
const actualBreakpoints = args.breakpoints.map((sourceBreakPoint) => {
const { validated, line, id } = this.debugger!.addBreakPoint(args.source.path!,

@Krysl
Copy link
Author

Krysl commented May 3, 2024

path in this.contexts need to be normalized, otherwise entry.fileName === breakPoint.source may be false

private validateBreakPoint(breakPoint: IGrammarBreakPoint) {
const context = this.contexts.find((entry) => {
return entry.fileName === breakPoint.source;
});

@Krysl
Copy link
Author

Krysl commented May 3, 2024

a simple patch just work for myself

just to solve my own problem, without studying the code carefully, this patch may cause other problems.

 src/backend/facade.ts             | 2 ++
 src/frontend/AntlrDebugAdapter.ts | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/facade.ts b/src/backend/facade.ts
index 88e712a..4f5a732 100644
--- a/src/backend/facade.ts
+++ b/src/backend/facade.ts
@@ -24,6 +24,7 @@ import {
 } from "../types.js";
 import { IATNGraphData } from "../webview-scripts/types.js";
 import { SentenceGenerator } from "./SentenceGenerator.js";
+import { Uri } from 'vscode';
 
 export class AntlrFacade {
     // Mapping file names to SourceContext instances.
@@ -362,6 +363,7 @@ export class AntlrFacade {
     }
 
     public createDebugger(fileName: string, actionFile: string, dataDir: string): GrammarDebugger | undefined {
+        fileName = Uri.file(fileName).fsPath;
         const context = this.getContext(fileName);
         if (!context) {
             return;
diff --git a/src/frontend/AntlrDebugAdapter.ts b/src/frontend/AntlrDebugAdapter.ts
index 24bf0d6..9e90e99 100644
--- a/src/frontend/AntlrDebugAdapter.ts
+++ b/src/frontend/AntlrDebugAdapter.ts
@@ -239,7 +239,6 @@ export class AntlrDebugSession extends DebugSession {
     protected override setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse,
         args: DebugProtocol.SetBreakpointsArguments): void {
         if (this.debugger) {
-            this.debugger.clearBreakPoints();
             if (args.breakpoints && args.source.path) {
                 const actualBreakpoints = args.breakpoints.map((sourceBreakPoint) => {
                     const { validated, line, id } = this.debugger!.addBreakPoint(args.source.path!,

@mike-lischke
Copy link
Owner

Thanks for reporting the issue and providing a possible solution. I'll look at this later when I come back to the extension development.

@mike-lischke mike-lischke added the possible bug Could be a bug label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Could be a bug
Projects
None yet
Development

No branches or pull requests

2 participants