(
response: DebugProtocol.DisconnectResponse | DebugProtocol.Response,
args: DebugProtocol.DisconnectArguments)
| 1459 | } |
| 1460 | |
| 1461 | protected disconnectRequest2( |
| 1462 | response: DebugProtocol.DisconnectResponse | DebugProtocol.Response, |
| 1463 | args: DebugProtocol.DisconnectArguments): Promise<void> { |
| 1464 | this.disconnectingPromise = new Promise<void>(async (resolve) => { |
| 1465 | this.serverConsoleLog('Begin disconnectRequest'); |
| 1466 | const doDisconnectProcessing = async () => { |
| 1467 | if (this.miLiveGdb) { |
| 1468 | this.miLiveGdb.quit(); |
| 1469 | await new Promise((resolve) => setTimeout(resolve, 100)); |
| 1470 | } |
| 1471 | await this.tryDeleteBreakpoints(); |
| 1472 | this.disableSendStoppedEvents = false; |
| 1473 | this.attached = false; |
| 1474 | this.waitForServerExitAndRespond(response); // Will wait asynchronously until the following actions are done |
| 1475 | if (args.terminateDebuggee || args.suspendDebuggee) { |
| 1476 | // There is no such thing as terminate for us. Hopefully, the gdb-server will |
| 1477 | // do the right thing and remain in halted state |
| 1478 | this.miDebugger.stop(); |
| 1479 | } else { |
| 1480 | // If the gdb-server behaves like gdb (and us) expects it do, then the program |
| 1481 | // should continue |
| 1482 | this.miDebugger.detach(); |
| 1483 | } |
| 1484 | resolve(); |
| 1485 | }; |
| 1486 | |
| 1487 | if (this.miDebugger) { |
| 1488 | this.disableSendStoppedEvents = true; |
| 1489 | if (!this.stopped) { |
| 1490 | // Many ways things can fail. See issue #561 |
| 1491 | // exec-interrupt can fail because gdb is wedged and does not respond with proper status ever |
| 1492 | // use a timeout and try to end session anyways. |
| 1493 | let to = setTimeout(() => { |
| 1494 | if (to) { |
| 1495 | to = null; |
| 1496 | this.handleMsg('log', 'GDB never responded to an interrupt request. Trying to end session anyways\n'); |
| 1497 | doDisconnectProcessing(); |
| 1498 | } |
| 1499 | }, 2000); |
| 1500 | this.miDebugger.once('generic-stopped', () => { |
| 1501 | if (to) { |
| 1502 | clearTimeout(to); |
| 1503 | to = null; |
| 1504 | doDisconnectProcessing(); |
| 1505 | } |
| 1506 | }); |
| 1507 | try { |
| 1508 | await this.miDebugger.sendCommand('exec-interrupt'); |
| 1509 | } |
| 1510 | catch (e) { |
| 1511 | // The timeout will take care of it... |
| 1512 | this.handleMsg('log', `Could not interrupt program. Trying to end session anyways ${e}\n`); |
| 1513 | } |
| 1514 | } else { |
| 1515 | doDisconnectProcessing(); |
| 1516 | } |
| 1517 | } else { |
| 1518 | resolve(); |
no test coverage detected