| 1521 | } |
| 1522 | |
| 1523 | void DAPDebugger::launchSession(int port, const QMap<QString, QVariant> ¶m, const QString &kitName) |
| 1524 | { |
| 1525 | if (!port) { |
| 1526 | printOutput(tr("\nThe dap port is not ready, please retry.\n"), OutputPane::OutputFormat::ErrorMessage); |
| 1527 | return; |
| 1528 | } |
| 1529 | |
| 1530 | printOutput(tr("Debugging starts")); |
| 1531 | QString launchTip = tr("Launch dap session with port %1 ...") |
| 1532 | .arg(port); |
| 1533 | printOutput(launchTip); |
| 1534 | |
| 1535 | d->currentDebugKit = kitName; |
| 1536 | auto iniRequet = d->rtCfgProvider->initalizeRequest(); |
| 1537 | bool bSuccess = false; |
| 1538 | if (!d->isRemote) |
| 1539 | bSuccess = d->currentSession->initialize(d->rtCfgProvider->ip(), |
| 1540 | port, |
| 1541 | iniRequet); |
| 1542 | else |
| 1543 | bSuccess = d->currentSession->initialize(param.value("ip").toString().toLatin1(), |
| 1544 | port, |
| 1545 | iniRequet); |
| 1546 | |
| 1547 | if (!bSuccess) { |
| 1548 | updateRunState(DAPDebugger::RunState::kNoRun); |
| 1549 | notify(2, tr("Debugging service initialization failed")); |
| 1550 | qCritical() << "startDebug failed!"; |
| 1551 | return; |
| 1552 | } |
| 1553 | |
| 1554 | // Launch debuggee. |
| 1555 | switch (d->debugState) { |
| 1556 | case Normal: { |
| 1557 | auto &ctx = dpfInstance.serviceContext(); |
| 1558 | LanguageService *service = ctx.service<LanguageService>(LanguageService::name()); |
| 1559 | if (service) { |
| 1560 | auto generator = service->create<LanguageGenerator>(kitName); |
| 1561 | if (generator) { |
| 1562 | if (generator->isLaunchNotAttach()) { |
| 1563 | dap::LaunchRequest request = generator->launchDAP(param); |
| 1564 | bSuccess &= d->currentSession->launch(request); |
| 1565 | } else { |
| 1566 | dap::AttachRequest request = generator->attachDAP(port, param); |
| 1567 | bSuccess &= d->currentSession->attach(request); |
| 1568 | } |
| 1569 | } |
| 1570 | } else { |
| 1571 | bSuccess &= false; |
| 1572 | } |
| 1573 | break; |
| 1574 | } |
| 1575 | case Attaching: { |
| 1576 | dap::object obj; |
| 1577 | obj["processId"] = param.value("targetPath").toString().toStdString(); |
| 1578 | dap::AttachRequest request; |
| 1579 | request.name = kitName.toStdString(); //kitName: gdb |
| 1580 | request.connect = obj; |
nothing calls this directly
no test coverage detected