Skip to content

Commit 0e2bf42

Browse files
committed
fix for breakpoints
1 parent c0849e6 commit 0e2bf42

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

src/debug/debugSession.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,19 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
205205

206206
const filePath = args.source.path;
207207
const fileUri = await convertClientPathToDebugger(args.source.path, this._namespace);
208+
const [, fileName] = fileUri.match(/\|([^|]+)$/);
208209

209-
// const currentList = (await this._connection.sendBreakpointListCommand()).breakpoints.filter(breakpoint => {
210-
// if (breakpoint instanceof xdebug.LineBreakpoint) {
211-
// return breakpoint.fileUri === fileUri;
212-
// }
213-
// });
210+
const currentList = await this._connection.sendBreakpointListCommand();
211+
currentList.breakpoints
212+
.filter(breakpoint => {
213+
if (breakpoint instanceof xdebug.LineBreakpoint) {
214+
return breakpoint.fileUri === fileName;
215+
}
216+
return false;
217+
})
218+
.map(breakpoint => {
219+
this._connection.sendBreakpointRemoveCommand(breakpoint);
220+
});
214221

215222
let xdebugBreakpoints: (xdebug.ConditionalBreakpoint | xdebug.ClassLineBreakpoint | xdebug.LineBreakpoint)[] = [];
216223
xdebugBreakpoints = await Promise.all(
@@ -230,6 +237,8 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
230237
}
231238
}
232239
});
240+
} else if (filePath.endsWith("mac") || filePath.endsWith("int")) {
241+
return new xdebug.RoutineLineBreakpoint(fileUri, line, "", line - 1);
233242
} else {
234243
return new xdebug.LineBreakpoint(fileUri, line);
235244
}
@@ -294,11 +303,12 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
294303
}
295304
});
296305
}
306+
const place = `${stackFrame.method}+${stackFrame.methodOffset}`;
297307
const stackFrameId = this._stackFrameIdCounter++;
298308
this._stackFrames.set(stackFrameId, stackFrame);
299309
return {
300310
id: stackFrameId,
301-
name: source.name,
311+
name: place,
302312
source,
303313
line,
304314
column: 1,

src/debug/xdebugConnection.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,27 @@ export class ClassLineBreakpoint extends LineBreakpoint {
212212
}
213213
}
214214

215+
export class RoutineLineBreakpoint extends LineBreakpoint {
216+
public method: string;
217+
public methodOffset: number;
218+
219+
/** contructs a line breakpoint for passing to sendSetBreakpointCommand */
220+
public constructor(fileUri: string, line: number, method: string, methodOffset: number);
221+
public constructor(...rest) {
222+
if (typeof rest[0] === "object") {
223+
const breakpointNode: Element = rest[0];
224+
const connection: Connection = rest[1];
225+
super(breakpointNode, connection);
226+
this.line = parseInt(breakpointNode.getAttribute("lineno"), 10);
227+
this.fileUri = breakpointNode.getAttribute("filename");
228+
} else {
229+
super(rest[0], rest[1]);
230+
this.method = rest[2];
231+
this.methodOffset = rest[3];
232+
}
233+
}
234+
}
235+
215236
/** class for conditional breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
216237
export class ConditionalBreakpoint extends Breakpoint {
217238
/** File URI */
@@ -701,6 +722,8 @@ export class Connection extends DbgpConnection {
701722
args += ` -f ${breakpoint.fileUri}`;
702723
if (breakpoint instanceof ClassLineBreakpoint) {
703724
args += ` -m ${breakpoint.method} -n ${breakpoint.methodOffset}`;
725+
} else if (breakpoint instanceof RoutineLineBreakpoint) {
726+
args += ` -n ${breakpoint.methodOffset}`;
704727
} else {
705728
args += ` -n ${breakpoint.line}`;
706729
}

0 commit comments

Comments
 (0)