Skip to content

Commit

Permalink
Add more logging around breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed May 17, 2024
1 parent 522abb6 commit 2e76ff1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/adapters/DebugProtocolAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ export class DebugProtocolAdapter {
//we can't send breakpoints unless we're stopped (or in a protocol version that supports sending them while running).
//So...if we're not stopped, quit now. (we'll get called again when the stop event happens)
if (!this.client?.supportsBreakpointRegistrationWhileRunning && !this.isAtDebuggerPrompt) {
this.logger.info('Cannot sync breakpoints because the debugger', this.client.supportsBreakpointRegistrationWhileRunning ? 'does not support sending breakpoints while running' : 'is not paused');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/debugProtocol/client/DebugProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import type { AddConditionalBreakpointsResponse } from '../events/responses/AddC

export class DebugProtocolClient {

public logger = logger.createLogger(`[client]`);
public logger = logger.createLogger(`[dpclient]`);

// The highest tested version of the protocol we support.
public supportedVersionRange = '<=3.2.0';
Expand Down
3 changes: 1 addition & 2 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
* Called every time a breakpoint is created, modified, or deleted, for each file. This receives the entire list of breakpoints every time.
*/
public async setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments) {
this.logger.log('setBreakpointsRequest');
this.logger.log('setBreakpointsRequest', args);
let sanitizedBreakpoints = this.breakpointManager.replaceBreakpoints(args.source.path, args.breakpoints);
//sort the breakpoints
let sortedAndFilteredBreakpoints = orderBy(sanitizedBreakpoints, [x => x.line, x => x.column]);
Expand All @@ -814,7 +814,6 @@ export class BrightScriptDebugSession extends BaseDebugSession {
};
this.sendResponse(response);

this.logger.debug('[setBreakpointsRequest] syncBreakpoints()', args);
await this.rokuAdapter?.syncBreakpoints();
}

Expand Down
28 changes: 28 additions & 0 deletions src/managers/BreakpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { SourceMapManager } from './SourceMapManager';
import type { LocationManager } from './LocationManager';
import { util } from '../util';
import { EventEmitter } from 'eventemitter3';
import { logger, Logger } from '../logging';

export class BreakpointManager {

Expand All @@ -20,6 +21,8 @@ export class BreakpointManager {

}

private logger = logger.createLogger('[bpManager]');

public launchConfiguration: {
sourceDirs: string[];
rootDir: string;
Expand Down Expand Up @@ -79,6 +82,8 @@ export class BreakpointManager {
* breakpoint lines are 1-based, and columns are zero-based
*/
public setBreakpoint(srcPath: string, breakpoint: AugmentedSourceBreakpoint | DebugProtocol.SourceBreakpoint) {
this.logger.debug('setBreakpoint', { srcPath, breakpoint });

srcPath = this.sanitizeSourceFilePath(srcPath);

//if a breakpoint gets set in rootDir, and we have sourceDirs, convert the rootDir path to sourceDirs path
Expand All @@ -100,6 +105,8 @@ export class BreakpointManager {
//only a single breakpoint can be defined per line. So, if we find one on this line, we'll augment that breakpoint rather than builiding a new one
const existingBreakpoint = breakpointsArray.find(x => x.line === breakpoint.line);

this.logger.debug('existingBreakpoint', existingBreakpoint);

let bp = Object.assign(existingBreakpoint ?? {}, {
//remove common attributes from any existing breakpoint so we don't end up with more info than we need
...{
Expand Down Expand Up @@ -136,6 +143,9 @@ export class BreakpointManager {
this.setBreakpointDeviceId(bp.srcHash, bp.srcHash, bp.id);
this.verifyBreakpoint(bp.id, true);
}

this.logger.debug('setBreakpoint done', bp);

return bp;
}

Expand All @@ -155,6 +165,8 @@ export class BreakpointManager {
* Delete a set of breakpoints
*/
public deleteBreakpoints(args: BreakpointRef[]) {
this.logger.debug('deleteBreakpoints', args);

for (const breakpoint of this.getBreakpoints(args)) {
const actualBreakpoint = this.getBreakpoint(breakpoint);
if (actualBreakpoint) {
Expand Down Expand Up @@ -697,8 +709,11 @@ export class BreakpointManager {
* All projects should be passed in every time.
*/
public async getDiff(projects: Project[]): Promise<Diff> {
this.logger.debug('getDiff');

//if the diff is currently running, return an empty "nothing has changed" diff
if (this.isGetDiffRunning) {
this.logger.debug('another diff is already running, exiting early');
return {
added: [],
removed: [],
Expand All @@ -713,6 +728,9 @@ export class BreakpointManager {
projects.map(async (project) => {
//get breakpoint data for every project
const work = await this.getBreakpointWork(project);

this.logger.debug('[bpmanager] getDiff breakpointWork', work);

for (const filePath in work) {
const fileWork = work[filePath];
for (const bp of fileWork) {
Expand All @@ -736,6 +754,16 @@ export class BreakpointManager {
const added = new Map<string, BreakpointWorkItem>();
const removed = new Map<string, BreakpointWorkItem>();
const unchanged = new Map<string, BreakpointWorkItem>();

this.logger.debug('lastState:', this.lastState);
this.logger.debug('currentState:', currentState);

this.logger.debug('[bpmanager] getDiff before processing:', {
added: [...added.entries()],
removed: [...removed.entries()],
unchanged: [...unchanged.entries()]
});

for (const key of [...currentState.keys(), ...this.lastState.keys()]) {
const inCurrent = currentState.has(key);
const inLast = this.lastState.has(key);
Expand Down

0 comments on commit 2e76ff1

Please sign in to comment.