Skip to content

Commit

Permalink
Merge #22
Browse files Browse the repository at this point in the history
22: Catch `probe-rs-debugger` panic AND unexpected exits r=Yatekii a=noppej

Previously a `probe-rs-debugger` panic would fail silently, and the VSCode user would have no hint as to what went wrong.

With this PR, the user will be shown an error message that includes the `stderr` from the `probe-rs-debugger` process. In most cases, this will point to a bug, but it may also be an issue in the environment of the user. Either way, I would not expect most users to be able to resolve this kind of error without logging an issue.

This PR also updates the extension version number to `0.3.2` and will require a new release binary.

Co-authored-by: JackN <[email protected]>
  • Loading branch information
bors[bot] and noppej authored Nov 15, 2021
2 parents a35df1b + af7c052 commit a7d7194
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "probe-rs-debugger",
"displayName": "Debugger for probe-rs",
"version": "0.3.1",
"version": "0.3.2",
"publisher": "probe-rs",
"description": "probe-rs Debug Adapter for VS Code.",
"author": {
Expand Down
26 changes: 14 additions & 12 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ export async function activate(context: vscode.ExtensionContext) {

const descriptorFactory = new ProbeRSDebugAdapterServerDescriptorFactory();

if (probeRsLogLevel === 'Debug') { // The only way this will be true, is if a developer changes the default value where this var is declared above
context.subscriptions.push(
vscode.debug.registerDebugAdapterTrackerFactory('probe-rs-debug', trackerFactory),
);
}

context.subscriptions.push(
vscode.debug.registerDebugAdapterDescriptorFactory('probe-rs-debug', descriptorFactory),
vscode.debug.registerDebugAdapterTrackerFactory('probe-rs-debug', trackerFactory),
vscode.debug.onDidReceiveDebugSessionCustomEvent(descriptorFactory.receivedCustomEvent.bind(descriptorFactory)),
vscode.debug.onDidTerminateDebugSession(descriptorFactory.dispose.bind(descriptorFactory)),
);
Expand All @@ -40,7 +35,7 @@ var debuggerReadySignature: string;

// If the "launch" fails, inform the user with error information
export function launchCallback(error: child_process.ExecFileException | null, stdout: string, stderr: string) {
if (!debuggerReady) { //Only show this if we receive errors before the debugger started up
if (error !== null) {
vscode.window.showErrorMessage("ERROR: ".concat(`${error}`).concat('\t').concat(stderr).concat('\n').concat(stdout));
}
}
Expand Down Expand Up @@ -299,20 +294,27 @@ class ProbeRsDebugAdapterTrackerFactory implements DebugAdapterTrackerFactory {
class ProbeRsDebugAdapterTracker implements DebugAdapterTracker {

onWillReceiveMessage(message: any) {
logToConsole("DEBUG: Sending message to debug adapter:\n" + JSON.stringify(message, null, 2));
if (probeRsLogLevel === 'Debug') {
logToConsole("DEBUG: Sending message to debug adapter:\n" + JSON.stringify(message, null, 2));
}
}

onDidSendMessage(message: any) {
logToConsole("DEBUG: Received message from debug adapter:\n" + JSON.stringify(message, null, 2));
if (probeRsLogLevel === 'Debug') {
logToConsole("DEBUG: Received message from debug adapter:\n" + JSON.stringify(message, null, 2));
}
}

onError(error: Error) {
logToConsole("ERROR: Error in communication with debug adapter:\n" + JSON.stringify(error, null, 2));
if (probeRsLogLevel === 'Debug')
{
logToConsole("ERROR: Error in communication with debug adapter:\n" + JSON.stringify(error, null, 2));
}
}

onExit(code: number, signal: string) {
onExit(code: number, _signal: string) {
if (code) {
logToConsole("ERROR: Debug Adapter exited with exit code" + JSON.stringify(code, null, 2));
vscode.window.showErrorMessage("ERROR: `probe-rs-debugger` exited with an unexpected code: ".concat(`${code}`).concat('\tPlease log this as an issue at https://github.com/probe-rs/probe-rs/issues/new'));
}
}

Expand Down

0 comments on commit a7d7194

Please sign in to comment.