Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialize __brs_err__ when stepping or continuing #207

Merged
merged 42 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6b658ce
Add support for breaking on caught or uncaught exceptions
Christian-Holbrook Nov 7, 2024
0dfdf64
WIP, displaying the caught and uncaught exceptions
Christian-Holbrook Nov 7, 2024
d4d669f
Add unit tests for the new exceptions breakpoints
Christian-Holbrook Nov 8, 2024
ce4728e
Piped through to pass exceptions filters to the debug client
Christian-Holbrook Nov 12, 2024
39a12ec
Some fixes and tweaks
TwitchBronBron Nov 12, 2024
964b4e9
Fix lint issues
TwitchBronBron Nov 13, 2024
b9c7a34
Lift some responses to vars for better debugging
TwitchBronBron Nov 14, 2024
abb9238
Guard agaist setting exception breakpoints when not supported on the …
Christian-Holbrook Nov 14, 2024
edec32d
Fix incorrect init flow for exception breakpoints
TwitchBronBron Nov 15, 2024
ecd206a
Fix some lint issues
TwitchBronBron Nov 15, 2024
dc49429
Merge branch 'caught-uncaught-exceptions' of https://github.com/rokuc…
TwitchBronBron Nov 15, 2024
3e2aaa8
Add unit tests, and state to track when a debug session is persists b…
Christian-Holbrook Nov 18, 2024
70e5231
Rename any "exceptionsBreakpoints" to exceptionBreakpoints
Christian-Holbrook Nov 19, 2024
4551d78
Add more unit tests
Christian-Holbrook Nov 20, 2024
de0b916
Revert some `file:/` package dependencies
TwitchBronBron Nov 20, 2024
3fcca83
Add eslint as a recommended extension
TwitchBronBron Nov 20, 2024
035f87b
Fix lint issues
TwitchBronBron Nov 20, 2024
b19bfaa
Fix heap overflow issue
TwitchBronBron Nov 20, 2024
c747e3e
Fix most of the broken unit tests
Christian-Holbrook Nov 20, 2024
1bdc4b3
Fix unit test
Christian-Holbrook Nov 21, 2024
ee3f80b
Try increasing heap allocation
Christian-Holbrook Nov 21, 2024
ce17dda
Revert "Try increasing heap allocation"
Christian-Holbrook Nov 23, 2024
fa5aca2
Roll back all package.json changes, deleted node_modules/ and ran $ n…
Christian-Holbrook Nov 23, 2024
353f5eb
Revert package.json to master
Christian-Holbrook Nov 23, 2024
1273830
Remove `filter` from most exception breakpoint names
TwitchBronBron Nov 25, 2024
5e8f77f
add protocol version to constant comment
TwitchBronBron Nov 25, 2024
6ad38aa
Send proper unverified exception breakpoints when not supported on th…
TwitchBronBron Nov 25, 2024
bd9ecd4
Fix unit tests by stubbing the support flag
Christian-Holbrook Dec 2, 2024
01c0b58
Merge branch 'master' into caught-uncaught-exceptions
Christian-Holbrook Dec 2, 2024
7d2dfd7
Merge branch 'master' into caught-uncaught-exceptions
Christian-Holbrook Jan 7, 2025
f7d9081
Make __brs_err__ virtual so it is greyed out
Christian-Holbrook Jan 8, 2025
c2cbced
Add unit test for CaughtRuntimeError
Christian-Holbrook Jan 8, 2025
12ca7ff
Use util for checking if a variable matches __brs_*
Christian-Holbrook Jan 8, 2025
5fb5422
Add unit tests, and make the test more strict
Christian-Holbrook Jan 8, 2025
ee77847
Use the correct util for the regex test
Christian-Holbrook Jan 8, 2025
e7e9ddb
Do not emit suspend when processing the step request
Christian-Holbrook Jan 15, 2025
13d19c6
Clear the state when continue, or steps are processed. Set the __brs_…
Christian-Holbrook Jan 15, 2025
ae54b5a
Merge branch 'master' into caught-uncaught-exceptions
Christian-Holbrook Jan 15, 2025
f418e55
Add back the supports virtual varibales
Christian-Holbrook Jan 15, 2025
288a763
Renaming and clarifying boolean expression
Christian-Holbrook Jan 17, 2025
9ed1480
Create new functcion to handle code run between both suspend and runt…
Christian-Holbrook Jan 17, 2025
637467d
Fix unit tests
Christian-Holbrook Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/debugProtocol/client/DebugProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,8 @@ export class DebugProtocolClient {
this.isStopped = false;
let stepResult = await this.sendRequest<GenericResponse>(request);
if (stepResult.data.errorCode === ErrorCode.OK) {
this.isStopped = true;
//TODO this is not correct. Do we get a new threads event after a step? Perhaps that should be what triggers the event instead of us?
this.emit('suspend', stepResult as AllThreadsStoppedUpdate);
} else {
//Step command received and will recieve a separate update when threads have reattached
} else if (stepResult.data.errorCode === ErrorCode.CANT_CONTINUE) {
// there is a CANT_CONTINUE error code but we can likely treat all errors like a CANT_CONTINUE
this.emit('cannot-continue');
}
Expand Down Expand Up @@ -1222,8 +1220,8 @@ export class DebugProtocolClient {
this.logger.log('[destroy] controlSocket is: ', this.controlSocketClosed.isResolved ? 'closed' : 'not closed');

//destroy the controlSocket
this.controlSocket.removeAllListeners();
this.controlSocket.destroy();
this.controlSocket?.removeAllListeners();
this.controlSocket?.destroy();
this.controlSocket = undefined;
this.isDestroyingControlSocket = false;
}
Expand Down
29 changes: 29 additions & 0 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ export class BrightScriptDebugSession extends BaseDebugSession {
}
}


protected async uninitializeExceptionsBreakpointVariables() {
Christian-Holbrook marked this conversation as resolved.
Show resolved Hide resolved
let brsErr = Object.values(this.variables).find((v) => v.name === '__brs_err__');
if (brsErr && brsErr.type !== VariableType.Uninitialized) {
// Assigning the variable to the function call results in it becoming unintialized
await this.rokuAdapter.evaluate(`__brs_err__ = [].clear()`, brsErr.frameId);
}
}

private showPopupMessage(message: string, severity: 'error' | 'warn' | 'info', modal = false) {
this.logger.trace('[showPopupMessage]', severity, message);
this.sendEvent(new PopupMessageEvent(message, severity, modal));
Expand Down Expand Up @@ -1076,6 +1085,10 @@ export class BrightScriptDebugSession extends BaseDebugSession {
}

this.logger.log('continueRequest');
await this.uninitializeExceptionsBreakpointVariables(); // call before clearState
this.clearState();

// The debug session ends after the next line. Do not put new work after this line.
await this.rokuAdapter.continue();
this.sendResponse(response);
}
Expand Down Expand Up @@ -1114,6 +1127,10 @@ export class BrightScriptDebugSession extends BaseDebugSession {
return;
}

await this.uninitializeExceptionsBreakpointVariables(); // call before clearState
this.clearState();

// The debug session ends after the next line. Do not put new work after this line.
try {
await this.rokuAdapter.stepOver(args.threadId);
this.logger.info('[nextRequest] end');
Expand All @@ -1133,6 +1150,9 @@ export class BrightScriptDebugSession extends BaseDebugSession {
return;
}

await this.uninitializeExceptionsBreakpointVariables(); // call before clearState
this.clearState();
// The debug session ends after the next line. Do not put new work after this line.
await this.rokuAdapter.stepInto(args.threadId);
this.sendResponse(response);
this.logger.info('[stepInRequest] end');
Expand All @@ -1148,6 +1168,10 @@ export class BrightScriptDebugSession extends BaseDebugSession {
return;
}

await this.uninitializeExceptionsBreakpointVariables(); // call before clearState
this.clearState();

// The debug session ends after the next line. Do not put new work after this line.
await this.rokuAdapter.stepOut(args.threadId);
this.sendResponse(response);
this.logger.info('[stepOutRequest] end');
Expand Down Expand Up @@ -1221,6 +1245,11 @@ export class BrightScriptDebugSession extends BaseDebugSession {
let filteredChildVariables = this.launchConfiguration.showHiddenVariables !== true ? childVariables.filter(
(child: AugmentedVariable) => !child.name.startsWith(this.tempVarPrefix)) : childVariables;

filteredChildVariables = this.launchConfiguration.showHiddenVariables !== true
? childVariables.filter((child: AugmentedVariable) => !util.isTransientVariable(child.name) ||
Christian-Holbrook marked this conversation as resolved.
Show resolved Hide resolved
(child.name === '__brs_err__' && child.type !== VariableType.Uninitialized))
: childVariables;

response.body = {
variables: filteredChildVariables
};
Expand Down
Loading