| 166 | } |
| 167 | |
| 168 | void GdbTest::testAttach() |
| 169 | { |
| 170 | SKIP_IF_ATTACH_FORBIDDEN(); |
| 171 | |
| 172 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); |
| 173 | |
| 174 | KProcess debugeeProcess; |
| 175 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); |
| 176 | debugeeProcess.start(); |
| 177 | QVERIFY(debugeeProcess.waitForStarted()); |
| 178 | QTest::qWait(100); |
| 179 | |
| 180 | auto *session = new TestDebugSession; |
| 181 | session->attachToProcess(debugeeProcess.processId()); |
| 182 | WAIT_FOR_STATE(session, DebugSession::PausedState); |
| 183 | |
| 184 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 39); // the blank line in main() |
| 185 | WAIT_FOR_A_WHILE(session, 100); |
| 186 | session->run(); |
| 187 | WAIT_FOR_A_WHILE(session, 2000); |
| 188 | WAIT_FOR_STATE(session, DebugSession::PausedState); |
| 189 | QCOMPARE(session->line(), 40); // return 0; (GDB automatically moves the breakpoint from its no-op line) |
| 190 | |
| 191 | session->run(); |
| 192 | #ifdef Q_OS_FREEBSD |
| 193 | QSKIP("The test freezes while waiting for the ended state, so skip it"); |
| 194 | #endif |
| 195 | WAIT_FOR_STATE(session, DebugSession::EndedState); |
| 196 | } |
| 197 | |
| 198 | void GdbTest::testManualAttach() |
| 199 | { |
nothing calls this directly
no test coverage detected