diff --git a/sampleWorkspace/readme.md b/sampleWorkspace/readme.md index 32d3646..04b68c9 100644 --- a/sampleWorkspace/readme.md +++ b/sampleWorkspace/readme.md @@ -7,7 +7,7 @@ The text of the markdown is considered the "program to debug" and certain keywor With the "Run/Debug" split button in the editor header you can easily "run" or "debug" a Markdown file without having to configure a debug configuration. "Running" a Markdown file has no visible effect. "Debugging" a Markdown file starts the debugger and stops on the first line. - + ## Stacks If debugging stops on a line, the line becomes a stack in the CALL STACK with the individual words shown as frames. @@ -39,6 +39,7 @@ If a Mock Debug session is active, breakpoints are "validated" according to thes * if a line is empty or starts with `+` we don't allow to set a breakpoint but move the breakpoint down * if a line starts with `-` we don't allow to set a breakpoint but move the breakpoint up +* if a line starts with `!`, "hardware" breakpoints can be set on the line * a breakpoint on a line containing the word `lazy` is not immediately validated, but only after hitting it once. ## Data Breakpoints @@ -89,4 +90,4 @@ log(more text in group) log(end) ```` -## The End \ No newline at end of file +## The End diff --git a/src/mockDebug.ts b/src/mockDebug.ts index b02f49e..6a63aab 100644 --- a/src/mockDebug.ts +++ b/src/mockDebug.ts @@ -218,6 +218,11 @@ export class MockDebugSession extends LoggingDebugSession { response.body.supportsFunctionBreakpoints = true; response.body.supportsDelayedStackTraceLoading = true; + response.body.breakpointModes = [ + { appliesTo: ['source', 'exception'], label: 'Software', mode: 'sw' }, + { appliesTo: ['source', 'exception'], label: 'Hardware', mode: 'hw' }, + ]; + this.sendResponse(response); // since this debug adapter can accept configuration requests like 'setBreakpoint' at any time, @@ -277,19 +282,18 @@ export class MockDebugSession extends LoggingDebugSession { protected async setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): Promise { const path = args.source.path as string; - const clientLines = args.lines || []; // clear all breakpoints for this file this._runtime.clearBreakpoints(path); // set and verify breakpoint locations - const actualBreakpoints0 = clientLines.map(async l => { - const { verified, line, id } = await this._runtime.setBreakPoint(path, this.convertClientLineToDebugger(l)); + const actualBreakpoints0 = (args.breakpoints || []).map(async ({ line: l, mode }): Promise => { + const { verified, line, id } = await this._runtime.setBreakPoint(path, this.convertClientLineToDebugger(l), mode); const bp = new Breakpoint(verified, this.convertDebuggerLineToClient(line)) as DebugProtocol.Breakpoint; bp.id = id; return bp; }); - const actualBreakpoints = await Promise.all(actualBreakpoints0); + const actualBreakpoints = await Promise.all(actualBreakpoints0); // send back the actual breakpoint positions response.body = { diff --git a/src/mockRuntime.ts b/src/mockRuntime.ts index 87858a6..898923b 100644 --- a/src/mockRuntime.ts +++ b/src/mockRuntime.ts @@ -14,6 +14,7 @@ export interface IRuntimeBreakpoint { id: number; line: number; verified: boolean; + mode: string; // hw or sw } interface IRuntimeStepInTargets { @@ -334,10 +335,10 @@ export class MockRuntime extends EventEmitter { /* * Set breakpoint in file with given line. */ - public async setBreakPoint(path: string, line: number): Promise { + public async setBreakPoint(path: string, line: number, mode = 'sw'): Promise { path = this.normalizePathAndCasing(path); - const bp: IRuntimeBreakpoint = { verified: false, line, id: this.breakpointId++ }; + const bp: IRuntimeBreakpoint = { verified: false, line, id: this.breakpointId++, mode }; let bps = this.breakPoints.get(path); if (!bps) { bps = new Array(); @@ -654,13 +655,16 @@ export class MockRuntime extends EventEmitter { bp.line++; } // if a line starts with '-' we don't allow to set a breakpoint but move the breakpoint up - if (srcLine.indexOf('-') === 0) { + if (srcLine.startsWith('-')) { bp.line--; } // don't set 'verified' to true if the line contains the word 'lazy' // in this case the breakpoint will be verified 'lazy' after hitting it once. if (srcLine.indexOf('lazy') < 0) { - bp.verified = true; + // if a line starts with '!' we allow setting hardware breakpoints there + if (srcLine.startsWith('!') || bp.mode !== 'hw') { + bp.verified = true; + } this.sendEvent('breakpointValidated', bp); } }