Skip to content

Commit

Permalink
[trace-view] Added support for line breakpoints (#19961)
Browse files Browse the repository at this point in the history
## Description 

Added support for line breakpoints.

## Test plan 

Old and new tests must pass
  • Loading branch information
awelc authored Oct 24, 2024
1 parent eef06e5 commit 786cf73
Show file tree
Hide file tree
Showing 27 changed files with 453 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Breakpoint,
Handles,
Logger,
logger,
Expand All @@ -22,6 +23,7 @@ import {
IRuntimeRefValue
} from './runtime';


const enum LogLevel {
Log = 'log',
Verbose = 'verbose',
Expand Down Expand Up @@ -103,6 +105,9 @@ export class MoveDebugSession extends LoggingDebugSession {
this.runtime.on(RuntimeEvents.stopOnStep, () => {
this.sendEvent(new StoppedEvent('step', MoveDebugSession.THREAD_ID));
});
this.runtime.on(RuntimeEvents.stopOnLineBreakpoint, () => {
this.sendEvent(new StoppedEvent('breakpoint', MoveDebugSession.THREAD_ID));
});
this.runtime.on(RuntimeEvents.end, () => {
this.sendEvent(new TerminatedEvent());
});
Expand All @@ -117,6 +122,12 @@ export class MoveDebugSession extends LoggingDebugSession {
// the adapter implements the configurationDone request
response.body.supportsConfigurationDoneRequest = false;

// the adapter supports conditional breakpoints
response.body.supportsConditionalBreakpoints = false;

// the adapter supports breakpoints that break execution after a specified number of hits
response.body.supportsHitConditionalBreakpoints = false;

// make VS Code use 'evaluate' when hovering over source
response.body.supportsEvaluateForHovers = false;

Expand Down Expand Up @@ -176,6 +187,7 @@ export class MoveDebugSession extends LoggingDebugSession {
): Promise<void> {
logger.setup(convertLoggerLogLevel(args.logLevel ?? LogLevel.None), false);
logger.log(`Launching trace viewer for file: ${args.source} and trace: ${args.traceInfo}`);

try {
await this.runtime.start(args.source, args.traceInfo, args.stopOnEntry || false);
} catch (err) {
Expand All @@ -186,13 +198,6 @@ export class MoveDebugSession extends LoggingDebugSession {
this.sendEvent(new StoppedEvent('entry', MoveDebugSession.THREAD_ID));
}

protected configurationDoneRequest(
response: DebugProtocol.ConfigurationDoneResponse,
_args: DebugProtocol.ConfigurationDoneArguments
): void {
this.sendResponse(response);
}

protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
response.body = {
threads: [
Expand All @@ -216,7 +221,7 @@ export class MoveDebugSession extends LoggingDebugSession {
}).reverse(),
totalFrames: stack_height,
optimized_lines: stack_height > 0
? runtimeStack.frames[stack_height - 1].sourceMap.optimizedLines
? runtimeStack.frames[stack_height - 1].optimizedLines
: []
};
} catch (err) {
Expand Down Expand Up @@ -490,6 +495,27 @@ export class MoveDebugSession extends LoggingDebugSession {
this.sendResponse(response);
}

protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): void {
try {
const finalBreakpoints = [];
if (args.breakpoints && args.source.path) {
const breakpointLines = args.breakpoints.map(bp => bp.line);
const validatedBreakpoints = this.runtime.setLineBreakpoints(args.source.path, breakpointLines);
for (let i = 0; i < breakpointLines.length; i++) {
finalBreakpoints.push(new Breakpoint(validatedBreakpoints[i], breakpointLines[i]));
}
}
response.body = {
breakpoints: finalBreakpoints
};
} catch (err) {
response.success = false;
response.message = err instanceof Error ? err.message : String(err);
}
this.sendResponse(response);
}


protected disconnectRequest(
response: DebugProtocol.DisconnectResponse,
_args: DebugProtocol.DisconnectArguments
Expand Down
Loading

0 comments on commit 786cf73

Please sign in to comment.