Skip to content

Commit a7d7194

Browse files
bors[bot]noppej
andauthored
Merge #22
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]>
2 parents a35df1b + af7c052 commit a7d7194

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "probe-rs-debugger",
33
"displayName": "Debugger for probe-rs",
4-
"version": "0.3.1",
4+
"version": "0.3.2",
55
"publisher": "probe-rs",
66
"description": "probe-rs Debug Adapter for VS Code.",
77
"author": {

src/extension.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ export async function activate(context: vscode.ExtensionContext) {
1717

1818
const descriptorFactory = new ProbeRSDebugAdapterServerDescriptorFactory();
1919

20-
if (probeRsLogLevel === 'Debug') { // The only way this will be true, is if a developer changes the default value where this var is declared above
21-
context.subscriptions.push(
22-
vscode.debug.registerDebugAdapterTrackerFactory('probe-rs-debug', trackerFactory),
23-
);
24-
}
25-
2620
context.subscriptions.push(
2721
vscode.debug.registerDebugAdapterDescriptorFactory('probe-rs-debug', descriptorFactory),
22+
vscode.debug.registerDebugAdapterTrackerFactory('probe-rs-debug', trackerFactory),
2823
vscode.debug.onDidReceiveDebugSessionCustomEvent(descriptorFactory.receivedCustomEvent.bind(descriptorFactory)),
2924
vscode.debug.onDidTerminateDebugSession(descriptorFactory.dispose.bind(descriptorFactory)),
3025
);
@@ -40,7 +35,7 @@ var debuggerReadySignature: string;
4035

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

301296
onWillReceiveMessage(message: any) {
302-
logToConsole("DEBUG: Sending message to debug adapter:\n" + JSON.stringify(message, null, 2));
297+
if (probeRsLogLevel === 'Debug') {
298+
logToConsole("DEBUG: Sending message to debug adapter:\n" + JSON.stringify(message, null, 2));
299+
}
303300
}
304301

305302
onDidSendMessage(message: any) {
306-
logToConsole("DEBUG: Received message from debug adapter:\n" + JSON.stringify(message, null, 2));
303+
if (probeRsLogLevel === 'Debug') {
304+
logToConsole("DEBUG: Received message from debug adapter:\n" + JSON.stringify(message, null, 2));
305+
}
307306
}
308307

309308
onError(error: Error) {
310-
logToConsole("ERROR: Error in communication with debug adapter:\n" + JSON.stringify(error, null, 2));
309+
if (probeRsLogLevel === 'Debug')
310+
{
311+
logToConsole("ERROR: Error in communication with debug adapter:\n" + JSON.stringify(error, null, 2));
312+
}
311313
}
312314

313-
onExit(code: number, signal: string) {
315+
onExit(code: number, _signal: string) {
314316
if (code) {
315-
logToConsole("ERROR: Debug Adapter exited with exit code" + JSON.stringify(code, null, 2));
317+
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'));
316318
}
317319
}
318320

0 commit comments

Comments
 (0)