| 208 | } |
| 209 | |
| 210 | void LldbTest::testAttach() |
| 211 | { |
| 212 | SKIP_IF_ATTACH_FORBIDDEN(); |
| 213 | |
| 214 | QString fileName = findSourceFile("debugeeslow.cpp"); |
| 215 | |
| 216 | KProcess debugeeProcess; |
| 217 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); |
| 218 | debugeeProcess.start(); |
| 219 | QVERIFY(debugeeProcess.waitForStarted()); |
| 220 | QTest::qWait(100); |
| 221 | |
| 222 | auto *session = new TestDebugSession; |
| 223 | session->attachToProcess(debugeeProcess.processId()); |
| 224 | |
| 225 | WAIT_FOR_A_WHILE(session, 100); |
| 226 | |
| 227 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 39); // the blank line in main() |
| 228 | |
| 229 | // lldb-mi silently stops when attaching to a process. Force it continue to run. |
| 230 | session->addCommand(MI::ExecContinue, QString(), MI::CmdMaybeStartsRunning); |
| 231 | WAIT_FOR_A_WHILE(session, 2000); |
| 232 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); |
| 233 | |
| 234 | QCOMPARE(session->currentLine(), 40); // return 0; (LLDB automatically moves the breakpoint from its no-op line) |
| 235 | |
| 236 | #ifdef Q_OS_FREEBSD |
| 237 | QSKIP( |
| 238 | "The test freezes while waiting for the ended state; skipping after session->run() " |
| 239 | "makes the next test function testRemoteDebugging() freeze, so skip now"); |
| 240 | #endif |
| 241 | session->run(); |
| 242 | WAIT_FOR_STATE(session, DebugSession::EndedState); |
| 243 | } |
| 244 | |
| 245 | void LldbTest::testRemoteDebugging() |
| 246 | { |
nothing calls this directly
no test coverage detected