Skip to content

Commit

Permalink
listen to disconnect with restart event keep openocd running
Browse files Browse the repository at this point in the history
  • Loading branch information
brianignacio5 committed May 20, 2024
1 parent 046877e commit 52e25c3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ let statusBarItems: { [key: string]: vscode.StatusBarItem };

const openOCDManager = OpenOCDManager.init();
let isOpenOCDLaunchedByDebug: boolean = false;
let isDebugRestarted: boolean = false;
let debugAdapterManager: DebugAdapterManager;
let isMonitorLaunchedByDebug: boolean = false;

Expand Down Expand Up @@ -415,7 +416,7 @@ export async function activate(context: vscode.ExtensionContext) {
});

vscode.debug.onDidTerminateDebugSession((e) => {
if (isOpenOCDLaunchedByDebug) {
if (isOpenOCDLaunchedByDebug && !isDebugRestarted) {
isOpenOCDLaunchedByDebug = false;
openOCDManager.stop();
}
Expand Down Expand Up @@ -1415,6 +1416,7 @@ export async function activate(context: vscode.ExtensionContext) {
) {
isOpenOCDLaunchedByDebug = true;
}
isDebugRestarted = false;
});

vscode.debug.registerDebugAdapterTrackerFactory("gdbtarget", {
Expand All @@ -1428,6 +1430,17 @@ export async function activate(context: vscode.ExtensionContext) {
}
peripheralTreeProvider.refresh();
}

if (
m &&
m.type === "event" &&
m.event === "output" &&
m.body.output.indexOf(
`From client: disconnect({"restart":true})`
) !== -1
) {
isDebugRestarted = true;
}
},
};
},
Expand Down

0 comments on commit 52e25c3

Please sign in to comment.