Changeset View
Changeset View
Standalone View
Standalone View
debuggers/lldb/unittests/test_lldb.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 73 | #define SKIP_IF_ATTACH_FORBIDDEN() \ | |||
---|---|---|---|---|---|
74 | do { \ | 74 | do { \ | ||
75 | if (KDevMI::isAttachForbidden(__FILE__, __LINE__)) \ | 75 | if (KDevMI::isAttachForbidden(__FILE__, __LINE__)) \ | ||
76 | return; \ | 76 | return; \ | ||
77 | } while(0) | 77 | } while(0) | ||
78 | 78 | | |||
79 | using namespace KDevelop; | 79 | using namespace KDevelop; | ||
80 | using namespace KDevMI::LLDB; | 80 | using namespace KDevMI::LLDB; | ||
81 | using KDevMI::findExecutable; | 81 | using KDevMI::findExecutable; | ||
82 | using KDevMI::findFile; | ||||
82 | using KDevMI::findSourceFile; | 83 | using KDevMI::findSourceFile; | ||
83 | 84 | | |||
84 | namespace { | 85 | namespace { | ||
85 | class WritableEnvironmentProfileList : public EnvironmentProfileList | 86 | class WritableEnvironmentProfileList : public EnvironmentProfileList | ||
86 | { | 87 | { | ||
87 | public: | 88 | public: | ||
88 | explicit WritableEnvironmentProfileList(KConfig* config) : EnvironmentProfileList(config) {} | 89 | explicit WritableEnvironmentProfileList(KConfig* config) : EnvironmentProfileList(config) {} | ||
89 | 90 | | |||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
145 | 146 | | |||
146 | class TestDebugSession : public DebugSession | 147 | class TestDebugSession : public DebugSession | ||
147 | { | 148 | { | ||
148 | Q_OBJECT | 149 | Q_OBJECT | ||
149 | public: | 150 | public: | ||
150 | TestDebugSession() : DebugSession() | 151 | TestDebugSession() : DebugSession() | ||
151 | { | 152 | { | ||
152 | // explicit set formatter path to force use in-tree formatters, not the one installed in system. | 153 | // explicit set formatter path to force use in-tree formatters, not the one installed in system. | ||
153 | QFileInfo info(QFileInfo(__FILE__).path(), "../formatters/all.py"); | 154 | auto formatter = findFile(LLDB_SRC_DIR, "formatters/all.py"); | ||
154 | Q_ASSERT(info.exists()); | 155 | setFormatterPath(formatter); | ||
155 | setFormatterPath(info.canonicalFilePath()); | | |||
156 | 156 | | |||
157 | setSourceInitFile(false); | 157 | setSourceInitFile(false); | ||
158 | m_frameStackModel = new TestFrameStackModel(this); | 158 | m_frameStackModel = new TestFrameStackModel(this); | ||
159 | 159 | | |||
160 | KDevelop::ICore::self()->debugController()->addSession(this); | 160 | KDevelop::ICore::self()->debugController()->addSession(this); | ||
161 | } | 161 | } | ||
162 | 162 | | |||
163 | TestFrameStackModel* frameStackModel() const override | 163 | TestFrameStackModel* frameStackModel() const override | ||
▲ Show 20 Lines • Show All 581 Lines • ▼ Show 20 Line(s) | 737 | { | |||
745 | QCOMPARE(session->currentLine(), 27); | 745 | QCOMPARE(session->currentLine(), 27); | ||
746 | 746 | | |||
747 | session->run(); | 747 | session->run(); | ||
748 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 748 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
749 | } | 749 | } | ||
750 | 750 | | |||
751 | void LldbTest::testManualBreakpoint() | 751 | void LldbTest::testManualBreakpoint() | ||
752 | { | 752 | { | ||
753 | QSKIP("Skipping... lldb-mi output malformated response which breaks this"); | | |||
754 | TestDebugSession *session = new TestDebugSession; | 753 | TestDebugSession *session = new TestDebugSession; | ||
755 | TestLaunchConfiguration cfg; | 754 | TestLaunchConfiguration cfg; | ||
756 | 755 | | |||
757 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | 756 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | ||
758 | 757 | | |||
759 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 758 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
760 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 759 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
761 | QCOMPARE(session->currentLine(), 27); | 760 | QCOMPARE(session->currentLine(), 27); | ||
Show All 9 Lines | |||||
771 | auto b = breakpoints()->breakpoint(0); | 770 | auto b = breakpoints()->breakpoint(0); | ||
772 | QCOMPARE(b->line(), 22); | 771 | QCOMPARE(b->line(), 22); | ||
773 | 772 | | |||
774 | session->addCommand(MI::NonMI, QStringLiteral("break disable 2")); | 773 | session->addCommand(MI::NonMI, QStringLiteral("break disable 2")); | ||
775 | session->addCommand(MI::NonMI, QStringLiteral("break modify -c 'i == 1' 2")); | 774 | session->addCommand(MI::NonMI, QStringLiteral("break modify -c 'i == 1' 2")); | ||
776 | session->addCommand(MI::NonMI, QStringLiteral("break modify -i 1 2")); | 775 | session->addCommand(MI::NonMI, QStringLiteral("break modify -i 1 2")); | ||
777 | WAIT_FOR_A_WHILE(session, 1000); | 776 | WAIT_FOR_A_WHILE(session, 1000); | ||
778 | QCOMPARE(b->enabled(), false); | 777 | QCOMPARE(b->enabled(), false); | ||
778 | QEXPECT_FAIL("", "LLDB 4.0 does not report condition in mi response", Continue); | ||||
779 | QCOMPARE(b->condition(), QString("i == 1")); | 779 | QCOMPARE(b->condition(), QString("i == 1")); | ||
780 | QEXPECT_FAIL("", "LLDB 4.0 does not report ignore hits in mi response", Continue); | ||||
780 | QCOMPARE(b->ignoreHits(), 1); | 781 | QCOMPARE(b->ignoreHits(), 1); | ||
781 | 782 | | |||
782 | session->addCommand(MI::NonMI, QStringLiteral("break delete 2")); | 783 | session->addCommand(MI::NonMI, QStringLiteral("break delete 2")); | ||
783 | WAIT_FOR_A_WHILE(session, 100); | 784 | WAIT_FOR_A_WHILE(session, 100); | ||
785 | QEXPECT_FAIL("", "LLDB 4.0 does not report breakpoint deletion as mi notification", Continue); | ||||
784 | QCOMPARE(breakpoints()->rowCount(), 0); | 786 | QCOMPARE(breakpoints()->rowCount(), 0); | ||
785 | 787 | | |||
786 | session->run(); | 788 | session->run(); | ||
787 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 789 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
788 | } | 790 | } | ||
789 | 791 | | |||
790 | //Bug 201771 | 792 | //Bug 201771 | ||
791 | void LldbTest::testInsertAndRemoveBreakpointWhileRunning() | 793 | void LldbTest::testInsertAndRemoveBreakpointWhileRunning() | ||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 881 | { | |||
884 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | 886 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | ||
885 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(m_debugeeFileName), 29); | 887 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(m_debugeeFileName), 29); | ||
886 | b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(m_debugeeFileName), 34); | 888 | b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(m_debugeeFileName), 34); | ||
887 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | 889 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | ||
888 | 890 | | |||
889 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 891 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
890 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 892 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
891 | 893 | | |||
894 | QEXPECT_FAIL("", "See LLDB bug 28703: -d flag has no effect", Abort); | ||||
892 | QCOMPARE(session->currentLine(), 29); | 895 | QCOMPARE(session->currentLine(), 29); | ||
893 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Checked); | 896 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Checked); | ||
894 | 897 | | |||
895 | session->run(); | 898 | session->run(); | ||
896 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 899 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
897 | QCOMPARE(session->currentLine(), 34); | 900 | QCOMPARE(session->currentLine(), 34); | ||
898 | 901 | | |||
899 | session->run(); | 902 | session->run(); | ||
▲ Show 20 Lines • Show All 408 Lines • ▼ Show 20 Line(s) | 1294 | { | |||
1308 | 1311 | | |||
1309 | session->run(); | 1312 | session->run(); | ||
1310 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1313 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1311 | } | 1314 | } | ||
1312 | 1315 | | |||
1313 | void LldbTest::testCoreFile() | 1316 | void LldbTest::testCoreFile() | ||
1314 | { | 1317 | { | ||
1315 | QFileInfo f(QStringLiteral("core")); | 1318 | QFileInfo f(QStringLiteral("core")); | ||
1316 | if (f.exists()) QFile::remove(f.canonicalFilePath()); | 1319 | f.setCaching(false); // don't cache information | ||
1320 | if (f.exists()) { | ||||
1321 | QVERIFY(QFile::remove(f.canonicalFilePath())); | ||||
1322 | } | ||||
1317 | 1323 | | |||
1318 | KProcess debugeeProcess; | 1324 | KProcess debugeeProcess; | ||
1319 | debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); | 1325 | debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); | ||
1320 | debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") | 1326 | debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") | ||
1321 | << "ulimit -c unlimited; " | 1327 | << "ulimit -c unlimited; " | ||
1322 | + findExecutable(QStringLiteral("debuggee_crash")).toLocalFile(); | 1328 | + findExecutable(QStringLiteral("debuggee_crash")).toLocalFile(); | ||
1323 | debugeeProcess.start(); | 1329 | debugeeProcess.start(); | ||
1324 | debugeeProcess.waitForFinished(); | 1330 | debugeeProcess.waitForFinished(); | ||
1325 | qDebug() << debugeeProcess.readAll(); | 1331 | qDebug() << debugeeProcess.readAll(); | ||
1326 | 1332 | | |||
1327 | bool coreFileFound = f.exists(); | 1333 | bool coreFileFound = f.exists(); | ||
1328 | if (!coreFileFound) { | 1334 | if (!coreFileFound) { | ||
1329 | // Try to use coredumpctl | 1335 | // Try to use coredumpctl | ||
1336 | qDebug() << "try to use coredumpctl"; | ||||
1330 | auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); | 1337 | auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); | ||
1331 | if (!coredumpctl.isEmpty()) { | 1338 | if (!coredumpctl.isEmpty()) { | ||
1332 | KProcess::execute(coredumpctl, {"-1", "-o", f.canonicalFilePath(), "dump", "debuggee_crash"}); | 1339 | KProcess::execute(coredumpctl, {"-1", "-o", f.absoluteFilePath(), "dump", "debuggee_crash"}); | ||
1333 | coreFileFound = f.exists(); | 1340 | coreFileFound = f.exists(); | ||
1334 | } | 1341 | } | ||
1335 | } | 1342 | } | ||
1336 | if (!coreFileFound) | 1343 | if (!coreFileFound) | ||
1337 | QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); | 1344 | QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); | ||
1338 | 1345 | | |||
1339 | TestDebugSession *session = new TestDebugSession; | 1346 | TestDebugSession *session = new TestDebugSession; | ||
1340 | session->examineCoreFile(findExecutable(QStringLiteral("debuggee_crash")), | 1347 | session->examineCoreFile(findExecutable(QStringLiteral("debuggee_crash")), | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 1480 | { | |||
1487 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1494 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1488 | 1495 | | |||
1489 | variableCollection()->watches()->add(quotedTestString); //just a constant string | 1496 | variableCollection()->watches()->add(quotedTestString); //just a constant string | ||
1490 | WAIT_FOR_A_WHILE(session, 3000); | 1497 | WAIT_FOR_A_WHILE(session, 3000); | ||
1491 | 1498 | | |||
1492 | QModelIndex i = variableCollection()->index(0, 0); | 1499 | QModelIndex i = variableCollection()->index(0, 0); | ||
1493 | QCOMPARE(variableCollection()->rowCount(i), 1); | 1500 | QCOMPARE(variableCollection()->rowCount(i), 1); | ||
1494 | COMPARE_DATA(variableCollection()->index(0, 0, i), quotedTestString); | 1501 | COMPARE_DATA(variableCollection()->index(0, 0, i), quotedTestString); | ||
1502 | | ||||
1503 | QEXPECT_FAIL("", | ||||
1504 | "LLDB 4.0 cannot deal with string literal in expression when debugging, causing memory access error", | ||||
1505 | Abort); | ||||
1495 | COMPARE_DATA(variableCollection()->index(0, 1, i), quotedTestString); | 1506 | COMPARE_DATA(variableCollection()->index(0, 1, i), quotedTestString); | ||
1496 | 1507 | | |||
1497 | QModelIndex testStr = variableCollection()->index(0, 0, i); | 1508 | QModelIndex testStr = variableCollection()->index(0, 0, i); | ||
1498 | COMPARE_DATA(variableCollection()->index(0, 0, testStr), "..."); | 1509 | COMPARE_DATA(variableCollection()->index(0, 0, testStr), "..."); | ||
1499 | variableCollection()->expanded(testStr); | 1510 | variableCollection()->expanded(testStr); | ||
1500 | WAIT_FOR_A_WHILE(session, 100); | 1511 | WAIT_FOR_A_WHILE(session, 100); | ||
1501 | int len = testString.length(); | 1512 | int len = testString.length(); | ||
1502 | for (int ind = 0; ind < len; ind++) | 1513 | for (int ind = 0; ind < len; ind++) | ||
▲ Show 20 Lines • Show All 389 Lines • Show Last 20 Lines |