File tree Expand file tree Collapse file tree 1 file changed +30
-15
lines changed Expand file tree Collapse file tree 1 file changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -184,24 +184,11 @@ export class CmsisDebugSession extends GDBDebugSession {
184184
185185 protected async disconnectRequest ( response : DebugProtocol . DisconnectResponse , args : DebugProtocol . DisconnectArguments ) : Promise < void > {
186186 try {
187- if ( this . isRunning ) {
188- // Need to pause first
189- const waitPromise = new Promise ( resolve => this . waitPaused = resolve ) ;
190- this . gdb . pause ( ) ;
191- await waitPromise ;
192- }
193- if ( ( this . gdb as CmsisBackend ) . isRunning ) {
194- try {
195- await mi . sendTargetDetach ( this . gdb ) ;
196- } catch ( e ) {
197- // Need to catch here as the command result being returned will never exist as it's detached
198- }
199- }
200- await super . disconnectRequest ( response , args ) ;
201- this . gdbServer . kill ( ) ;
187+ this . stopSession ( ) ;
202188 if ( ! args || ! args . restart ) {
203189 this . sendEvent ( new TerminatedEvent ( ) ) ;
204190 }
191+ this . sendResponse ( response ) ;
205192 } catch ( err ) {
206193 this . sendErrorResponse ( response , 1 , err . message ) ;
207194 }
@@ -350,4 +337,32 @@ export class CmsisDebugSession extends GDBDebugSession {
350337 message
351338 } ) ) ;
352339 }
340+
341+ protected async stopSession ( ) {
342+ // Pause debugging
343+ if ( this . isRunning ) {
344+ // Need to pause first
345+ const waitPromise = new Promise ( resolve => this . waitPaused = resolve ) ;
346+ this . gdb . pause ( ) ;
347+ await waitPromise ;
348+ }
349+
350+ // Detach
351+ if ( ( this . gdb as CmsisBackend ) . isRunning ) {
352+ try {
353+ await mi . sendTargetDetach ( this . gdb ) ;
354+ } catch ( e ) {
355+ // Need to catch here as the command result being returned will never exist as it's detached
356+ }
357+ }
358+
359+ // Stop gdb client and server
360+ await this . gdb . sendGDBExit ( ) ;
361+ this . gdbServer . kill ( ) ;
362+ }
363+
364+ public async shutdown ( ) {
365+ await this . stopSession ( ) ;
366+ super . shutdown ( ) ;
367+ }
353368}
You can’t perform that action at this time.
0 commit comments