MCPcopy Create free account
hub / github.com/KDE/kdevelop / testAttach

Method testAttach

plugins/gdb/unittests/test_gdb.cpp:168–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168void 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
198void GdbTest::testManualAttach()
199{

Callers

nothing calls this directly

Calls 8

findSourceFileFunction · 0.85
toLocalFileMethod · 0.80
attachToProcessMethod · 0.80
findExecutableFunction · 0.50
startMethod · 0.45
addCodeBreakpointMethod · 0.45
runMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected