Skip to content

Commit

Permalink
Add some breakpoint logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Oct 4, 2023
1 parent 4309027 commit 77be661
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/adapters/DebugProtocolAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ export class DebugProtocolAdapter {

private syncBreakpointsPromise = Promise.resolve();
public async syncBreakpoints() {
this.logger.log('syncBreakpoints()');
//wait for the previous sync to finish
this.syncBreakpointsPromise = this.syncBreakpointsPromise
//ignore any errors
Expand All @@ -766,6 +767,7 @@ export class DebugProtocolAdapter {

//compute breakpoint changes since last sync
const diff = await this.breakpointManager.getDiff(this.projectManager.getAllProjects());
this.logger.log('Syncing breakpoints', diff);

// REMOVE breakpoints (delete these breakpoints from the device)
if (diff.removed.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/debugProtocol/client/DebugProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ export class DebugProtocolClient {

this.activeRequests.set(request.data.requestId, request);

return new Promise<T>((resolve) => {
return new Promise<T>((resolve, reject) => {
let unsubscribe = this.on('response', (response) => {
if (response.data.requestId === request.data.requestId) {
unsubscribe();
Expand All @@ -774,7 +774,9 @@ export class DebugProtocolClient {
request: request
});
} else {
throw new Error(`Control socket was closed - Command: ${Command[request.data.command]}`);
reject(
new Error(`Control socket was closed - Command: ${Command[request.data.command]}`)
);
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
}

//send any compile errors to the client
await this.rokuAdapter.sendErrors();
await this.rokuAdapter?.sendErrors();
this.logger.error('Error. Shutting down.', e);
return this.shutdown();
}
Expand Down Expand Up @@ -720,6 +720,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');
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 @@ -729,6 +730,7 @@ export class BrightScriptDebugSession extends BaseDebugSession {
};
this.sendResponse(response);

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

Expand Down
3 changes: 3 additions & 0 deletions src/managers/ProjectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class ProjectManager {
enableDebugProtocol?: boolean;
};

public logger = logger.createLogger('[ProjectManager]');

public mainProject: Project;
public componentLibraryProjects = [] as ComponentLibraryProject[];

Expand Down Expand Up @@ -158,6 +160,7 @@ export class ProjectManager {
//convert entry point staging location to source location
let sourceLocation = await this.getSourceLocation(entryPoint.relativePath, entryPoint.lineNumber);

this.logger.info(`Registering entry breakpoint at ${sourceLocation.filePath}:${sourceLocation.lineNumber} (${entryPoint.pathAbsolute}:${entryPoint.lineNumber})`);
//register the entry breakpoint
this.breakpointManager.setBreakpoint(sourceLocation.filePath, {
//+1 to select the first line of the function
Expand Down

0 comments on commit 77be661

Please sign in to comment.