Changeset View
Changeset View
Standalone View
Standalone View
debuggers/gdb/unittests/test_gdb.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #include "test_gdb.h" | 20 | #include "test_gdb.h" | ||
21 | 21 | | |||
22 | #include "debugsession.h" | 22 | #include "debugsession.h" | ||
23 | #include "gdbframestackmodel.h" | 23 | #include "gdbframestackmodel.h" | ||
24 | #include "mi/micommand.h" | 24 | #include "mi/micommand.h" | ||
25 | #include "mi/milexer.h" | 25 | #include "mi/milexer.h" | ||
26 | #include "mi/miparser.h" | 26 | #include "mi/miparser.h" | ||
27 | #include "tests/debuggers-tests-config.h" | ||||
28 | #include "tests/testhelper.h" | ||||
27 | 29 | | |||
28 | #include <execute/iexecuteplugin.h> | 30 | #include <execute/iexecuteplugin.h> | ||
29 | #include <debugger/breakpoint/breakpoint.h> | 31 | #include <debugger/breakpoint/breakpoint.h> | ||
30 | #include <debugger/breakpoint/breakpointmodel.h> | 32 | #include <debugger/breakpoint/breakpointmodel.h> | ||
31 | #include <debugger/framestack/framestackmodel.h> | 33 | #include <debugger/framestack/framestackmodel.h> | ||
32 | #include <debugger/interfaces/ivariablecontroller.h> | 34 | #include <debugger/interfaces/ivariablecontroller.h> | ||
33 | #include <debugger/variable/variablecollection.h> | 35 | #include <debugger/variable/variablecollection.h> | ||
34 | #include <interfaces/idebugcontroller.h> | 36 | #include <interfaces/idebugcontroller.h> | ||
Show All 12 Lines | |||||
47 | #include <QDebug> | 49 | #include <QDebug> | ||
48 | #include <QDir> | 50 | #include <QDir> | ||
49 | #include <QFileInfo> | 51 | #include <QFileInfo> | ||
50 | #include <QStandardPaths> | 52 | #include <QStandardPaths> | ||
51 | #include <QSignalSpy> | 53 | #include <QSignalSpy> | ||
52 | #include <QTest> | 54 | #include <QTest> | ||
53 | #include <QTemporaryFile> | 55 | #include <QTemporaryFile> | ||
54 | 56 | | |||
55 | using KDevelop::AutoTestShell; | | |||
56 | | ||||
57 | namespace KDevMI { namespace GDB { | | |||
58 | | ||||
59 | QUrl findExecutable(const QString& name) | | |||
60 | { | | |||
61 | QFileInfo info(qApp->applicationDirPath() + "/unittests/" + name); | | |||
62 | Q_ASSERT(info.exists()); | | |||
63 | Q_ASSERT(info.isExecutable()); | | |||
64 | return QUrl::fromLocalFile(info.canonicalFilePath()); | | |||
65 | } | | |||
66 | | ||||
67 | QString findSourceFile(const QString& name) | | |||
68 | { | | |||
69 | QFileInfo info(QFileInfo(__FILE__).dir().absoluteFilePath(name)); | | |||
70 | Q_ASSERT(info.exists()); | | |||
71 | return info.canonicalFilePath(); | | |||
72 | } | | |||
73 | | ||||
74 | static bool isAttachForbidden(const char * file, int line) | | |||
75 | { | | |||
76 | // if on linux, ensure we can actually attach | | |||
77 | QFile canRun(QStringLiteral("/proc/sys/kernel/yama/ptrace_scope")); | | |||
78 | if (canRun.exists()) { | | |||
79 | if (!canRun.open(QIODevice::ReadOnly)) { | | |||
80 | QTest::qFail("Something is wrong: /proc/sys/kernel/yama/ptrace_scope exists but cannot be read", file, line); | | |||
81 | return true; | | |||
82 | } | | |||
83 | if (canRun.read(1).toInt() != 0) { | | |||
84 | QTest::qSkip("ptrace attaching not allowed, skipping test. To enable it, set /proc/sys/kernel/yama/ptrace_scope to 0.", file, line); | | |||
85 | return true; | | |||
86 | } | | |||
87 | } | | |||
88 | | ||||
89 | return false; | | |||
90 | } | | |||
91 | | ||||
92 | #define SKIP_IF_ATTACH_FORBIDDEN() \ | 57 | #define SKIP_IF_ATTACH_FORBIDDEN() \ | ||
93 | do { \ | 58 | do { \ | ||
94 | if (isAttachForbidden(__FILE__, __LINE__)) \ | 59 | if (KDevMI::isAttachForbidden(__FILE__, __LINE__)) \ | ||
95 | return; \ | 60 | return; \ | ||
96 | } while(0) | 61 | } while(0) | ||
97 | 62 | | |||
63 | using KDevelop::AutoTestShell; | ||||
64 | using KDevMI::findExecutable; | ||||
65 | using KDevMI::findSourceFile; | ||||
66 | | ||||
67 | namespace KDevMI { namespace GDB { | ||||
68 | | ||||
98 | void GdbTest::initTestCase() | 69 | void GdbTest::initTestCase() | ||
99 | { | 70 | { | ||
100 | AutoTestShell::init(); | 71 | AutoTestShell::init(); | ||
101 | KDevelop::TestCore::initialize(KDevelop::Core::NoUi); | 72 | KDevelop::TestCore::initialize(KDevelop::Core::NoUi); | ||
102 | 73 | | |||
103 | m_iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecutePlugin"), QStringLiteral("kdevexecute"))->extension<IExecutePlugin>(); | 74 | m_iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecutePlugin"), QStringLiteral("kdevexecute"))->extension<IExecutePlugin>(); | ||
104 | Q_ASSERT(m_iface); | 75 | Q_ASSERT(m_iface); | ||
105 | } | 76 | } | ||
Show All 28 Lines | 102 | public: | |||
134 | using EnvironmentProfileList::variables; | 105 | using EnvironmentProfileList::variables; | ||
135 | using EnvironmentProfileList::saveSettings; | 106 | using EnvironmentProfileList::saveSettings; | ||
136 | using EnvironmentProfileList::removeProfile; | 107 | using EnvironmentProfileList::removeProfile; | ||
137 | }; | 108 | }; | ||
138 | 109 | | |||
139 | class TestLaunchConfiguration : public KDevelop::ILaunchConfiguration | 110 | class TestLaunchConfiguration : public KDevelop::ILaunchConfiguration | ||
140 | { | 111 | { | ||
141 | public: | 112 | public: | ||
142 | explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("debugee")), | 113 | explicit TestLaunchConfiguration(const QUrl& executable = findExecutable(QStringLiteral("debuggee_debugee")), | ||
143 | const QUrl& workingDirectory = QUrl()) { | 114 | const QUrl& workingDirectory = QUrl()) { | ||
144 | qDebug() << "FIND" << executable; | 115 | qDebug() << "FIND" << executable; | ||
145 | c = new KConfig(); | 116 | c = new KConfig(); | ||
146 | c->deleteGroup("launch"); | 117 | c->deleteGroup("launch"); | ||
147 | cfg = c->group("launch"); | 118 | cfg = c->group("launch"); | ||
148 | cfg.writeEntry("isExecutable", true); | 119 | cfg.writeEntry("isExecutable", true); | ||
149 | cfg.writeEntry("Executable", executable); | 120 | cfg.writeEntry("Executable", executable); | ||
150 | cfg.writeEntry("Working Directory", workingDirectory); | 121 | cfg.writeEntry("Working Directory", workingDirectory); | ||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 272 | { | |||
304 | QCOMPARE(arguments.count(), 1); | 275 | QCOMPARE(arguments.count(), 1); | ||
305 | QCOMPARE(arguments.first().toStringList(), QStringList() << "Hello, world!" << "Hello"); | 276 | QCOMPARE(arguments.first().toStringList(), QStringList() << "Hello, world!" << "Hello"); | ||
306 | } | 277 | } | ||
307 | } | 278 | } | ||
308 | 279 | | |||
309 | void GdbTest::testEnvironmentSet() | 280 | void GdbTest::testEnvironmentSet() | ||
310 | { | 281 | { | ||
311 | TestDebugSession *session = new TestDebugSession; | 282 | TestDebugSession *session = new TestDebugSession; | ||
312 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeechoenv"))); | 283 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeechoenv"))); | ||
313 | 284 | | |||
314 | cfg.config().writeEntry("EnvironmentGroup", "GdbTestGroup"); | 285 | cfg.config().writeEntry("EnvironmentGroup", "GdbTestGroup"); | ||
315 | 286 | | |||
316 | WritableEnvironmentProfileList envProfiles(cfg.rootConfig()); | 287 | WritableEnvironmentProfileList envProfiles(cfg.rootConfig()); | ||
317 | envProfiles.removeProfile(QStringLiteral("GdbTestGroup")); | 288 | envProfiles.removeProfile(QStringLiteral("GdbTestGroup")); | ||
318 | auto &envs = envProfiles.variables(QStringLiteral("GdbTestGroup")); | 289 | auto &envs = envProfiles.variables(QStringLiteral("GdbTestGroup")); | ||
319 | envs[QStringLiteral("VariableA")] = QStringLiteral("-A' \" complex --value"); | 290 | envs[QStringLiteral("VariableA")] = QStringLiteral("-A' \" complex --value"); | ||
320 | envs[QStringLiteral("VariableB")] = QStringLiteral("-B' \" complex --value"); | 291 | envs[QStringLiteral("VariableB")] = QStringLiteral("-B' \" complex --value"); | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | |||||
466 | 437 | | |||
467 | void GdbTest::testPendingBreakpoint() | 438 | void GdbTest::testPendingBreakpoint() | ||
468 | { | 439 | { | ||
469 | TestDebugSession *session = new TestDebugSession; | 440 | TestDebugSession *session = new TestDebugSession; | ||
470 | TestLaunchConfiguration cfg; | 441 | TestLaunchConfiguration cfg; | ||
471 | 442 | | |||
472 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 28); | 443 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 28); | ||
473 | 444 | | |||
474 | KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("test_gdb.cpp"))), 10); | 445 | KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("debugeeqt.cpp"))), 10); | ||
475 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | 446 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | ||
476 | 447 | | |||
477 | session->startDebugging(&cfg, m_iface); | 448 | session->startDebugging(&cfg, m_iface); | ||
478 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 449 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
479 | QCOMPARE(b->state(), KDevelop::Breakpoint::PendingState); | 450 | QCOMPARE(b->state(), KDevelop::Breakpoint::PendingState); | ||
480 | session->run(); | 451 | session->run(); | ||
481 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 452 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
482 | } | 453 | } | ||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Line(s) | 630 | { | |||
684 | 655 | | |||
685 | session->run(); | 656 | session->run(); | ||
686 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 657 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
687 | } | 658 | } | ||
688 | 659 | | |||
689 | void GdbTest::testInsertBreakpointWhileRunning() | 660 | void GdbTest::testInsertBreakpointWhileRunning() | ||
690 | { | 661 | { | ||
691 | TestDebugSession *session = new TestDebugSession; | 662 | TestDebugSession *session = new TestDebugSession; | ||
692 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); | 663 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); | ||
693 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | 664 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | ||
694 | 665 | | |||
695 | session->startDebugging(&cfg, m_iface); | 666 | session->startDebugging(&cfg, m_iface); | ||
696 | 667 | | |||
697 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | 668 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | ||
698 | QTest::qWait(2000); | 669 | QTest::qWait(2000); | ||
699 | qDebug() << "adding breakpoint"; | 670 | qDebug() << "adding breakpoint"; | ||
700 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | 671 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | ||
701 | QTest::qWait(500); | 672 | QTest::qWait(500); | ||
702 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 673 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
703 | QTest::qWait(500); | 674 | QTest::qWait(500); | ||
704 | QCOMPARE(session->line(), 25); | 675 | QCOMPARE(session->line(), 25); | ||
705 | b->setDeleted(); | 676 | b->setDeleted(); | ||
706 | session->run(); | 677 | session->run(); | ||
707 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 678 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
708 | } | 679 | } | ||
709 | 680 | | |||
710 | void GdbTest::testInsertBreakpointWhileRunningMultiple() | 681 | void GdbTest::testInsertBreakpointWhileRunningMultiple() | ||
711 | { | 682 | { | ||
712 | TestDebugSession *session = new TestDebugSession; | 683 | TestDebugSession *session = new TestDebugSession; | ||
713 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); | 684 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); | ||
714 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | 685 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | ||
715 | 686 | | |||
716 | session->startDebugging(&cfg, m_iface); | 687 | session->startDebugging(&cfg, m_iface); | ||
717 | 688 | | |||
718 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | 689 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | ||
719 | QTest::qWait(2000); | 690 | QTest::qWait(2000); | ||
720 | qDebug() << "adding breakpoint"; | 691 | qDebug() << "adding breakpoint"; | ||
721 | KDevelop::Breakpoint *b1 = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 24); | 692 | KDevelop::Breakpoint *b1 = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 24); | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 795 | { | |||
858 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 829 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
859 | session->run(); | 830 | session->run(); | ||
860 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 831 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
861 | } | 832 | } | ||
862 | 833 | | |||
863 | void GdbTest::testStackFetchMore() | 834 | void GdbTest::testStackFetchMore() | ||
864 | { | 835 | { | ||
865 | TestDebugSession *session = new TestDebugSession; | 836 | TestDebugSession *session = new TestDebugSession; | ||
866 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeerecursion"))); | 837 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeerecursion"))); | ||
867 | QString fileName = findSourceFile(QStringLiteral("debugeerecursion.cpp")); | 838 | QString fileName = findSourceFile(QStringLiteral("debugeerecursion.cpp")); | ||
868 | 839 | | |||
869 | TestFrameStackModel *stackModel = session->frameStackModel(); | 840 | TestFrameStackModel *stackModel = session->frameStackModel(); | ||
870 | 841 | | |||
871 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | 842 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | ||
872 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 843 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
873 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 844 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
874 | QCOMPARE(session->frameStackModel()->fetchFramesCalled, 1); | 845 | QCOMPARE(session->frameStackModel()->fetchFramesCalled, 1); | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 906 | { | |||
957 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 928 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
958 | session->run(); | 929 | session->run(); | ||
959 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 930 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
960 | } | 931 | } | ||
961 | 932 | | |||
962 | void GdbTest::testStackSwitchThread() | 933 | void GdbTest::testStackSwitchThread() | ||
963 | { | 934 | { | ||
964 | TestDebugSession *session = new TestDebugSession; | 935 | TestDebugSession *session = new TestDebugSession; | ||
965 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeethreads"))); | 936 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeethreads"))); | ||
966 | QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); | 937 | QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); | ||
967 | 938 | | |||
968 | TestFrameStackModel *stackModel = session->frameStackModel(); | 939 | TestFrameStackModel *stackModel = session->frameStackModel(); | ||
969 | 940 | | |||
970 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 38); | 941 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 38); | ||
971 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 942 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
972 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 943 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
973 | 944 | | |||
Show All 19 Lines | |||||
993 | 964 | | |||
994 | void GdbTest::testAttach() | 965 | void GdbTest::testAttach() | ||
995 | { | 966 | { | ||
996 | SKIP_IF_ATTACH_FORBIDDEN(); | 967 | SKIP_IF_ATTACH_FORBIDDEN(); | ||
997 | 968 | | |||
998 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | 969 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | ||
999 | 970 | | |||
1000 | KProcess debugeeProcess; | 971 | KProcess debugeeProcess; | ||
1001 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debugeeslow")).toLocalFile(); | 972 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); | ||
1002 | debugeeProcess.start(); | 973 | debugeeProcess.start(); | ||
1003 | QVERIFY(debugeeProcess.waitForStarted()); | 974 | QVERIFY(debugeeProcess.waitForStarted()); | ||
1004 | QTest::qWait(100); | 975 | QTest::qWait(100); | ||
1005 | 976 | | |||
1006 | TestDebugSession *session = new TestDebugSession; | 977 | TestDebugSession *session = new TestDebugSession; | ||
1007 | session->attachToProcess(debugeeProcess.pid()); | 978 | session->attachToProcess(debugeeProcess.pid()); | ||
1008 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 979 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1009 | 980 | | |||
Show All 12 Lines | |||||
1022 | 993 | | |||
1023 | void GdbTest::testManualAttach() | 994 | void GdbTest::testManualAttach() | ||
1024 | { | 995 | { | ||
1025 | SKIP_IF_ATTACH_FORBIDDEN(); | 996 | SKIP_IF_ATTACH_FORBIDDEN(); | ||
1026 | 997 | | |||
1027 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | 998 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | ||
1028 | 999 | | |||
1029 | KProcess debugeeProcess; | 1000 | KProcess debugeeProcess; | ||
1030 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debugeeslow")).toLocalFile(); | 1001 | debugeeProcess << QStringLiteral("nice") << findExecutable(QStringLiteral("debuggee_debugeeslow")).toLocalFile(); | ||
1031 | debugeeProcess.start(); | 1002 | debugeeProcess.start(); | ||
1032 | QVERIFY(debugeeProcess.waitForStarted()); | 1003 | QVERIFY(debugeeProcess.waitForStarted()); | ||
1033 | 1004 | | |||
1034 | TestDebugSession *session = new TestDebugSession; | 1005 | TestDebugSession *session = new TestDebugSession; | ||
1035 | 1006 | | |||
1036 | TestLaunchConfiguration cfg; | 1007 | TestLaunchConfiguration cfg; | ||
1037 | cfg.config().writeEntry(Config::RemoteGdbRunEntry, QUrl::fromLocalFile(findSourceFile(QStringLiteral("gdb_script_empty")))); | 1008 | cfg.config().writeEntry(Config::RemoteGdbRunEntry, QUrl::fromLocalFile(findSourceFile(QStringLiteral("gdb_script_empty")))); | ||
1038 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 1009 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
1039 | 1010 | | |||
1040 | session->addCommand(MI::NonMI, QStringLiteral("attach %0").arg(debugeeProcess.pid())); | 1011 | session->addCommand(MI::NonMI, QStringLiteral("attach %0").arg(debugeeProcess.pid())); | ||
1041 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1012 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1042 | 1013 | | |||
1043 | session->run(); | 1014 | session->run(); | ||
1044 | QTest::qWait(2000); // give the slow inferior some extra time to run | 1015 | QTest::qWait(2000); // give the slow inferior some extra time to run | ||
1045 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1016 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1046 | } | 1017 | } | ||
1047 | 1018 | | |||
1048 | void GdbTest::testCoreFile() | 1019 | void GdbTest::testCoreFile() | ||
1049 | { | 1020 | { | ||
1050 | QFile f(QStringLiteral("core")); | 1021 | QFileInfo f(QStringLiteral("core")); | ||
1051 | if (f.exists()) f.remove(); | 1022 | if (f.exists()) QFile::remove(f.canonicalFilePath()); | ||
1052 | 1023 | | |||
1053 | KProcess debugeeProcess; | 1024 | KProcess debugeeProcess; | ||
1054 | debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); | 1025 | debugeeProcess.setOutputChannelMode(KProcess::MergedChannels); | ||
1055 | debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") << "ulimit -c unlimited; " + findExecutable(QStringLiteral("debugeecrash")).toLocalFile(); | 1026 | debugeeProcess << QStringLiteral("bash") << QStringLiteral("-c") | ||
1027 | << "ulimit -c unlimited; " | ||||
1028 | + findExecutable(QStringLiteral("debuggee_crash")).toLocalFile(); | ||||
1056 | debugeeProcess.start(); | 1029 | debugeeProcess.start(); | ||
1057 | debugeeProcess.waitForFinished(); | 1030 | debugeeProcess.waitForFinished(); | ||
1058 | qDebug() << debugeeProcess.readAll(); | 1031 | qDebug() << debugeeProcess.readAll(); | ||
1059 | 1032 | | |||
1060 | bool coreFileFound = QFile::exists(QStringLiteral("core")); | 1033 | bool coreFileFound = f.exists(); | ||
1061 | if (!coreFileFound) { | 1034 | if (!coreFileFound) { | ||
1062 | // Try to use coredumpctl | 1035 | // Try to use coredumpctl | ||
1063 | auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); | 1036 | auto coredumpctl = QStandardPaths::findExecutable(QStringLiteral("coredumpctl")); | ||
1064 | if (!coredumpctl.isEmpty()) { | 1037 | if (!coredumpctl.isEmpty()) { | ||
1065 | QFileInfo fi(QStringLiteral("core")); | 1038 | KProcess::execute(coredumpctl, {"-1", "-o", f.canonicalFilePath(), "dump", "debugeecrash"}); | ||
1066 | KProcess::execute(coredumpctl, {"-1", "-o", fi.absoluteFilePath(), "dump", "debugeecrash"}); | 1039 | coreFileFound = f.exists(); | ||
1067 | coreFileFound = fi.exists(); | | |||
1068 | } | 1040 | } | ||
1069 | } | 1041 | } | ||
1070 | if (!coreFileFound) | 1042 | if (!coreFileFound) | ||
1071 | QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); | 1043 | QSKIP("no core dump found, check your system configuration (see /proc/sys/kernel/core_pattern).", SkipSingle); | ||
1072 | 1044 | | |||
1073 | TestDebugSession *session = new TestDebugSession; | 1045 | TestDebugSession *session = new TestDebugSession; | ||
1074 | session->examineCoreFile(findExecutable(QStringLiteral("debugeecrash")), QUrl::fromLocalFile(QDir::currentPath()+"/core")); | 1046 | session->examineCoreFile(findExecutable(QStringLiteral("debuggee_crash")), | ||
1047 | QUrl::fromLocalFile(f.canonicalFilePath())); | ||||
1075 | 1048 | | |||
1076 | TestFrameStackModel *stackModel = session->frameStackModel(); | 1049 | TestFrameStackModel *stackModel = session->frameStackModel(); | ||
1077 | 1050 | | |||
1078 | WAIT_FOR_STATE(session, DebugSession::StoppedState); | 1051 | WAIT_FOR_STATE(session, DebugSession::StoppedState); | ||
1079 | 1052 | | |||
1080 | QModelIndex tIdx = stackModel->index(0,0); | 1053 | QModelIndex tIdx = stackModel->index(0,0); | ||
1081 | QCOMPARE(stackModel->rowCount(QModelIndex()), 1); | 1054 | QCOMPARE(stackModel->rowCount(QModelIndex()), 1); | ||
1082 | QCOMPARE(stackModel->columnCount(QModelIndex()), 3); | 1055 | QCOMPARE(stackModel->columnCount(QModelIndex()), 3); | ||
▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Line(s) | 1360 | { | |||
1428 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1401 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1429 | } | 1402 | } | ||
1430 | 1403 | | |||
1431 | 1404 | | |||
1432 | void GdbTest::testSegfaultDebugee() | 1405 | void GdbTest::testSegfaultDebugee() | ||
1433 | { | 1406 | { | ||
1434 | TestDebugSession *session = new TestDebugSession; | 1407 | TestDebugSession *session = new TestDebugSession; | ||
1435 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); | 1408 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); | ||
1436 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeecrash"))); | 1409 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_crash"))); | ||
1437 | QString fileName = findSourceFile(QStringLiteral("debugeecrash.cpp")); | 1410 | QString fileName = findSourceFile(QStringLiteral("debugeecrash.cpp")); | ||
1438 | 1411 | | |||
1439 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 23); | 1412 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 23); | ||
1440 | 1413 | | |||
1441 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 1414 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
1442 | 1415 | | |||
1443 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 1416 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
1444 | QCOMPARE(session->line(), 23); | 1417 | QCOMPARE(session->line(), 23); | ||
Show All 29 Lines | 1428 | { | |||
1474 | QCOMPARE(stackModel->currentFrame(), 1); | 1447 | QCOMPARE(stackModel->currentFrame(), 1); | ||
1475 | 1448 | | |||
1476 | } | 1449 | } | ||
1477 | 1450 | | |||
1478 | //Bug 201771 | 1451 | //Bug 201771 | ||
1479 | void GdbTest::testInsertAndRemoveBreakpointWhileRunning() | 1452 | void GdbTest::testInsertAndRemoveBreakpointWhileRunning() | ||
1480 | { | 1453 | { | ||
1481 | TestDebugSession *session = new TestDebugSession; | 1454 | TestDebugSession *session = new TestDebugSession; | ||
1482 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeslow"))); | 1455 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeslow"))); | ||
1483 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | 1456 | QString fileName = findSourceFile(QStringLiteral("debugeeslow.cpp")); | ||
1484 | 1457 | | |||
1485 | session->startDebugging(&cfg, m_iface); | 1458 | session->startDebugging(&cfg, m_iface); | ||
1486 | 1459 | | |||
1487 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | 1460 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | ||
1488 | QTest::qWait(2000); | 1461 | QTest::qWait(2000); | ||
1489 | qDebug() << "adding breakpoint"; | 1462 | qDebug() << "adding breakpoint"; | ||
1490 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | 1463 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 25); | ||
1491 | b->setDeleted(); | 1464 | b->setDeleted(); | ||
1492 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1465 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1493 | } | 1466 | } | ||
1494 | 1467 | | |||
1495 | //Bug 274390 | 1468 | //Bug 274390 | ||
1496 | void GdbTest::testCommandOrderFastStepping() | 1469 | void GdbTest::testCommandOrderFastStepping() | ||
1497 | { | 1470 | { | ||
1498 | TestDebugSession *session = new TestDebugSession; | 1471 | TestDebugSession *session = new TestDebugSession; | ||
1499 | 1472 | | |||
1500 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeqt"))); | 1473 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeqt"))); | ||
1501 | 1474 | | |||
1502 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | 1475 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | ||
1503 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 1476 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
1504 | for(int i=0; i<20; i++) { | 1477 | for(int i=0; i<20; i++) { | ||
1505 | session->stepInto(); | 1478 | session->stepInto(); | ||
1506 | } | 1479 | } | ||
1507 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1480 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1508 | session->run(); | 1481 | session->run(); | ||
Show All 23 Lines | |||||
1532 | //Bug 270970 | 1505 | //Bug 270970 | ||
1533 | void GdbTest::testPickupManuallyInsertedBreakpointOnlyOnce() | 1506 | void GdbTest::testPickupManuallyInsertedBreakpointOnlyOnce() | ||
1534 | { | 1507 | { | ||
1535 | TestDebugSession *session = new TestDebugSession; | 1508 | TestDebugSession *session = new TestDebugSession; | ||
1536 | 1509 | | |||
1537 | //inject here, so it behaves similar like a command from .gdbinit | 1510 | //inject here, so it behaves similar like a command from .gdbinit | ||
1538 | QTemporaryFile configScript; | 1511 | QTemporaryFile configScript; | ||
1539 | configScript.open(); | 1512 | configScript.open(); | ||
1540 | configScript.write(QStringLiteral("file %0\n").arg(findExecutable(QStringLiteral("debugee")).toLocalFile()).toLocal8Bit()); | 1513 | configScript.write(QStringLiteral("file %0\n").arg(findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile()).toLocal8Bit()); | ||
1541 | configScript.write("break debugee.cpp:32\n"); | 1514 | configScript.write("break debugee.cpp:32\n"); | ||
1542 | configScript.close(); | 1515 | configScript.close(); | ||
1543 | 1516 | | |||
1544 | TestLaunchConfiguration cfg; | 1517 | TestLaunchConfiguration cfg; | ||
1545 | KConfigGroup grp = cfg.config(); | 1518 | KConfigGroup grp = cfg.config(); | ||
1546 | grp.writeEntry(Config::RemoteGdbConfigEntry, QUrl::fromLocalFile(configScript.fileName())); | 1519 | grp.writeEntry(Config::RemoteGdbConfigEntry, QUrl::fromLocalFile(configScript.fileName())); | ||
1547 | 1520 | | |||
1548 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(QStringLiteral("debugee.cpp")), 31); | 1521 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(QStringLiteral("debugee.cpp")), 31); | ||
Show All 29 Lines | |||||
1578 | 1551 | | |||
1579 | void GdbTest::testRunGdbScript() | 1552 | void GdbTest::testRunGdbScript() | ||
1580 | { | 1553 | { | ||
1581 | TestDebugSession *session = new TestDebugSession; | 1554 | TestDebugSession *session = new TestDebugSession; | ||
1582 | 1555 | | |||
1583 | QTemporaryFile runScript; | 1556 | QTemporaryFile runScript; | ||
1584 | runScript.open(); | 1557 | runScript.open(); | ||
1585 | 1558 | | |||
1586 | runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); | 1559 | runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); | ||
1587 | runScript.write("break main\n"); | 1560 | runScript.write("break main\n"); | ||
1588 | runScript.write("run\n"); | 1561 | runScript.write("run\n"); | ||
1589 | runScript.close(); | 1562 | runScript.close(); | ||
1590 | 1563 | | |||
1591 | TestLaunchConfiguration cfg; | 1564 | TestLaunchConfiguration cfg; | ||
1592 | KConfigGroup grp = cfg.config(); | 1565 | KConfigGroup grp = cfg.config(); | ||
1593 | grp.writeEntry(Config::RemoteGdbRunEntry, QUrl::fromLocalFile(runScript.fileName())); | 1566 | grp.writeEntry(Config::RemoteGdbRunEntry, QUrl::fromLocalFile(runScript.fileName())); | ||
1594 | 1567 | | |||
Show All 13 Lines | 1579 | { | |||
1608 | if (gdbserverExecutable.isEmpty()) { | 1581 | if (gdbserverExecutable.isEmpty()) { | ||
1609 | QSKIP("Skipping, gdbserver not available", SkipSingle); | 1582 | QSKIP("Skipping, gdbserver not available", SkipSingle); | ||
1610 | } | 1583 | } | ||
1611 | 1584 | | |||
1612 | TestDebugSession *session = new TestDebugSession; | 1585 | TestDebugSession *session = new TestDebugSession; | ||
1613 | 1586 | | |||
1614 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | 1587 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | ||
1615 | shellScript.open(); | 1588 | shellScript.open(); | ||
1616 | shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); | 1589 | shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); | ||
1617 | shellScript.close(); | 1590 | shellScript.close(); | ||
1618 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | 1591 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | ||
1619 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | 1592 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | ||
1620 | 1593 | | |||
1621 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | 1594 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | ||
1622 | runScript.open(); | 1595 | runScript.open(); | ||
1623 | runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); | 1596 | runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); | ||
1624 | runScript.write("target remote localhost:2345\n"); | 1597 | runScript.write("target remote localhost:2345\n"); | ||
1625 | runScript.write("break debugee.cpp:30\n"); | 1598 | runScript.write("break debugee.cpp:30\n"); | ||
1626 | runScript.write("continue\n"); | 1599 | runScript.write("continue\n"); | ||
1627 | runScript.close(); | 1600 | runScript.close(); | ||
1628 | 1601 | | |||
1629 | TestLaunchConfiguration cfg; | 1602 | TestLaunchConfiguration cfg; | ||
1630 | KConfigGroup grp = cfg.config(); | 1603 | KConfigGroup grp = cfg.config(); | ||
1631 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile((shellScript.fileName()+"-copy"))); | 1604 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile((shellScript.fileName()+"-copy"))); | ||
Show All 20 Lines | 1620 | { | |||
1652 | 1625 | | |||
1653 | TestDebugSession *session = new TestDebugSession; | 1626 | TestDebugSession *session = new TestDebugSession; | ||
1654 | 1627 | | |||
1655 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 29); | 1628 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 29); | ||
1656 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 35); | 1629 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 35); | ||
1657 | 1630 | | |||
1658 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | 1631 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | ||
1659 | shellScript.open(); | 1632 | shellScript.open(); | ||
1660 | shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + "\n"); | 1633 | shellScript.write("gdbserver localhost:2345 " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + "\n"); | ||
1661 | shellScript.close(); | 1634 | shellScript.close(); | ||
1662 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | 1635 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | ||
1663 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | 1636 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | ||
1664 | 1637 | | |||
1665 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | 1638 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | ||
1666 | runScript.open(); | 1639 | runScript.open(); | ||
1667 | runScript.write("file " + findExecutable(QStringLiteral("debugee")).toLocalFile().toUtf8() + '\n'); | 1640 | runScript.write("file " + findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toUtf8() + '\n'); | ||
1668 | runScript.write("target remote localhost:2345\n"); | 1641 | runScript.write("target remote localhost:2345\n"); | ||
1669 | runScript.write("break debugee.cpp:30\n"); | 1642 | runScript.write("break debugee.cpp:30\n"); | ||
1670 | runScript.write("continue\n"); | 1643 | runScript.write("continue\n"); | ||
1671 | runScript.close(); | 1644 | runScript.close(); | ||
1672 | 1645 | | |||
1673 | TestLaunchConfiguration cfg; | 1646 | TestLaunchConfiguration cfg; | ||
1674 | KConfigGroup grp = cfg.config(); | 1647 | KConfigGroup grp = cfg.config(); | ||
1675 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile(shellScript.fileName()+"-copy")); | 1648 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile(shellScript.fileName()+"-copy")); | ||
Show All 27 Lines | 1672 | { | |||
1703 | } | 1676 | } | ||
1704 | 1677 | | |||
1705 | TestDebugSession *session = new TestDebugSession; | 1678 | TestDebugSession *session = new TestDebugSession; | ||
1706 | 1679 | | |||
1707 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 35); | 1680 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 35); | ||
1708 | 1681 | | |||
1709 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | 1682 | QTemporaryFile shellScript(QDir::currentPath()+"/shellscript"); | ||
1710 | shellScript.open(); | 1683 | shellScript.open(); | ||
1711 | shellScript.write("gdbserver localhost:2345 "+findExecutable(QStringLiteral("debugee")).toLocalFile().toLatin1()+"\n"); | 1684 | shellScript.write("gdbserver localhost:2345 "+findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toLatin1()+"\n"); | ||
1712 | shellScript.close(); | 1685 | shellScript.close(); | ||
1713 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | 1686 | shellScript.setPermissions(shellScript.permissions() | QFile::ExeUser); | ||
1714 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | 1687 | QFile::copy(shellScript.fileName(), shellScript.fileName()+"-copy"); //to avoid "Text file busy" on executing (why?) | ||
1715 | 1688 | | |||
1716 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | 1689 | QTemporaryFile runScript(QDir::currentPath()+"/runscript"); | ||
1717 | runScript.open(); | 1690 | runScript.open(); | ||
1718 | runScript.write("file "+findExecutable(QStringLiteral("debugee")).toLocalFile().toLatin1()+"\n"); | 1691 | runScript.write("file "+findExecutable(QStringLiteral("debuggee_debugee")).toLocalFile().toLatin1()+"\n"); | ||
1719 | runScript.write("target remote localhost:2345\n"); | 1692 | runScript.write("target remote localhost:2345\n"); | ||
1720 | runScript.write("break debugee.cpp:30\n"); | 1693 | runScript.write("break debugee.cpp:30\n"); | ||
1721 | runScript.write("continue\n"); | 1694 | runScript.write("continue\n"); | ||
1722 | runScript.close(); | 1695 | runScript.close(); | ||
1723 | 1696 | | |||
1724 | TestLaunchConfiguration cfg; | 1697 | TestLaunchConfiguration cfg; | ||
1725 | KConfigGroup grp = cfg.config(); | 1698 | KConfigGroup grp = cfg.config(); | ||
1726 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile((shellScript.fileName()+"-copy"))); | 1699 | grp.writeEntry(Config::RemoteGdbShellEntry, QUrl::fromLocalFile((shellScript.fileName()+"-copy"))); | ||
Show All 35 Lines | |||||
1762 | 1735 | | |||
1763 | QFile::remove(shellScript.fileName()+"-copy"); | 1736 | QFile::remove(shellScript.fileName()+"-copy"); | ||
1764 | } | 1737 | } | ||
1765 | 1738 | | |||
1766 | void GdbTest::testBreakpointWithSpaceInPath() | 1739 | void GdbTest::testBreakpointWithSpaceInPath() | ||
1767 | { | 1740 | { | ||
1768 | TestDebugSession *session = new TestDebugSession; | 1741 | TestDebugSession *session = new TestDebugSession; | ||
1769 | 1742 | | |||
1770 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeespace"))); | 1743 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeespace"))); | ||
1771 | KConfigGroup grp = cfg.config(); | 1744 | KConfigGroup grp = cfg.config(); | ||
1772 | QString fileName = findSourceFile(QStringLiteral("debugee space.cpp")); | 1745 | QString fileName = findSourceFile(QStringLiteral("debugee space.cpp")); | ||
1773 | 1746 | | |||
1774 | KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 20); | 1747 | KDevelop::Breakpoint * b = breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 20); | ||
1775 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | 1748 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | ||
1776 | 1749 | | |||
1777 | session->startDebugging(&cfg, m_iface); | 1750 | session->startDebugging(&cfg, m_iface); | ||
1778 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 1751 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
Show All 25 Lines | 1758 | { | |||
1804 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1777 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1805 | } | 1778 | } | ||
1806 | 1779 | | |||
1807 | void GdbTest::testCatchpoint() | 1780 | void GdbTest::testCatchpoint() | ||
1808 | { | 1781 | { | ||
1809 | TestDebugSession *session = new TestDebugSession; | 1782 | TestDebugSession *session = new TestDebugSession; | ||
1810 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); | 1783 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateLocals); | ||
1811 | 1784 | | |||
1812 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeeexception"))); | 1785 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeeexception"))); | ||
1813 | 1786 | | |||
1814 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("debugeeexception.cpp"))), 29); | 1787 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(findSourceFile(QStringLiteral("debugeeexception.cpp"))), 29); | ||
1815 | 1788 | | |||
1816 | session->startDebugging(&cfg, m_iface); | 1789 | session->startDebugging(&cfg, m_iface); | ||
1817 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1790 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1818 | QTest::qWait(1000); | 1791 | QTest::qWait(1000); | ||
1819 | TestFrameStackModel* fsModel = session->frameStackModel(); | 1792 | TestFrameStackModel* fsModel = session->frameStackModel(); | ||
1820 | QCOMPARE(fsModel->currentFrame(), 0); | 1793 | QCOMPARE(fsModel->currentFrame(), 0); | ||
Show All 18 Lines | |||||
1839 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1812 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1840 | } | 1813 | } | ||
1841 | 1814 | | |||
1842 | void GdbTest::testThreadAndFrameInfo() | 1815 | void GdbTest::testThreadAndFrameInfo() | ||
1843 | { | 1816 | { | ||
1844 | // Check if --thread is added to user commands | 1817 | // Check if --thread is added to user commands | ||
1845 | 1818 | | |||
1846 | TestDebugSession *session = new TestDebugSession; | 1819 | TestDebugSession *session = new TestDebugSession; | ||
1847 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeethreads"))); | 1820 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeethreads"))); | ||
1848 | QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); | 1821 | QString fileName = findSourceFile(QStringLiteral("debugeethreads.cpp")); | ||
1849 | 1822 | | |||
1850 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 38); | 1823 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(fileName), 38); | ||
1851 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 1824 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
1852 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 1825 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
1853 | 1826 | | |||
1854 | QSignalSpy outputSpy(session, &TestDebugSession::debuggerUserCommandOutput); | 1827 | QSignalSpy outputSpy(session, &TestDebugSession::debuggerUserCommandOutput); | ||
1855 | 1828 | | |||
Show All 40 Lines | 1846 | { | |||
1896 | std::unique_ptr<MI::Record> record(parser.parse(&file)); | 1869 | std::unique_ptr<MI::Record> record(parser.parse(&file)); | ||
1897 | QVERIFY(record.get() != nullptr); | 1870 | QVERIFY(record.get() != nullptr); | ||
1898 | } | 1871 | } | ||
1899 | 1872 | | |||
1900 | void GdbTest::testMultipleLocationsBreakpoint() | 1873 | void GdbTest::testMultipleLocationsBreakpoint() | ||
1901 | { | 1874 | { | ||
1902 | TestDebugSession *session = new TestDebugSession; | 1875 | TestDebugSession *session = new TestDebugSession; | ||
1903 | 1876 | | |||
1904 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debugeemultilocbreakpoint"))); | 1877 | TestLaunchConfiguration cfg(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); | ||
1905 | 1878 | | |||
1906 | breakpoints()->addCodeBreakpoint(QStringLiteral("aPlusB")); | 1879 | breakpoints()->addCodeBreakpoint(QStringLiteral("aPlusB")); | ||
1907 | 1880 | | |||
1908 | //TODO check if the additional location breakpoint is added | 1881 | //TODO check if the additional location breakpoint is added | ||
1909 | 1882 | | |||
1910 | session->startDebugging(&cfg, m_iface); | 1883 | session->startDebugging(&cfg, m_iface); | ||
1911 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 1884 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
1912 | QCOMPARE(session->line(), 19); | 1885 | QCOMPARE(session->line(), 19); | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 1896 | { | |||
1960 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1933 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1961 | } | 1934 | } | ||
1962 | 1935 | | |||
1963 | void GdbTest::testMultipleBreakpoint() | 1936 | void GdbTest::testMultipleBreakpoint() | ||
1964 | { | 1937 | { | ||
1965 | TestDebugSession *session = new TestDebugSession; | 1938 | TestDebugSession *session = new TestDebugSession; | ||
1966 | 1939 | | |||
1967 | //there'll be about 3-4 breakpoints, but we treat it like one. | 1940 | //there'll be about 3-4 breakpoints, but we treat it like one. | ||
1968 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeemultiplebreakpoint"))); | 1941 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultiplebreakpoint"))); | ||
1969 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeemultiplebreakpoint.cpp:52")); | 1942 | KDevelop::Breakpoint *b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeemultiplebreakpoint.cpp:52")); | ||
1970 | session->startDebugging(&c, m_iface); | 1943 | session->startDebugging(&c, m_iface); | ||
1971 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1944 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1972 | QCOMPARE(breakpoints()->breakpoints().count(), 1); | 1945 | QCOMPARE(breakpoints()->breakpoints().count(), 1); | ||
1973 | 1946 | | |||
1974 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | 1947 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | ||
1975 | session->run(); | 1948 | session->run(); | ||
1976 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1949 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1977 | } | 1950 | } | ||
1978 | 1951 | | |||
1979 | void GdbTest::testRegularExpressionBreakpoint() | 1952 | void GdbTest::testRegularExpressionBreakpoint() | ||
1980 | { | 1953 | { | ||
1981 | TestDebugSession *session = new TestDebugSession; | 1954 | TestDebugSession *session = new TestDebugSession; | ||
1982 | 1955 | | |||
1983 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeemultilocbreakpoint"))); | 1956 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeemultilocbreakpoint"))); | ||
1984 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | 1957 | breakpoints()->addCodeBreakpoint(QStringLiteral("main")); | ||
1985 | session->startDebugging(&c, m_iface); | 1958 | session->startDebugging(&c, m_iface); | ||
1986 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1959 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1987 | session->addCommand(MI::NonMI, QStringLiteral("rbreak .*aPl.*B")); | 1960 | session->addCommand(MI::NonMI, QStringLiteral("rbreak .*aPl.*B")); | ||
1988 | QTest::qWait(100); | 1961 | QTest::qWait(100); | ||
1989 | session->run(); | 1962 | session->run(); | ||
1990 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1963 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
1991 | QCOMPARE(breakpoints()->breakpoints().count(), 3); | 1964 | QCOMPARE(breakpoints()->breakpoints().count(), 3); | ||
1992 | 1965 | | |||
1993 | session->addCommand(MI::BreakDelete, QLatin1String("")); | 1966 | session->addCommand(MI::BreakDelete, QLatin1String("")); | ||
1994 | session->run(); | 1967 | session->run(); | ||
1995 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1968 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1996 | } | 1969 | } | ||
1997 | 1970 | | |||
1998 | void GdbTest::testChangeBreakpointWhileRunning() { | 1971 | void GdbTest::testChangeBreakpointWhileRunning() { | ||
1999 | 1972 | | |||
2000 | TestDebugSession *session = new TestDebugSession; | 1973 | TestDebugSession *session = new TestDebugSession; | ||
2001 | 1974 | | |||
2002 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debugeeslow"))); | 1975 | TestLaunchConfiguration c(findExecutable(QStringLiteral("debuggee_debugeeslow"))); | ||
2003 | KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeeslow.cpp:25")); | 1976 | KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("debugeeslow.cpp:25")); | ||
2004 | session->startDebugging(&c, m_iface); | 1977 | session->startDebugging(&c, m_iface); | ||
2005 | 1978 | | |||
2006 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | 1979 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
2007 | QVERIFY(session->currentLine() >= 24 && session->currentLine() <= 26 ); | 1980 | QVERIFY(session->currentLine() >= 24 && session->currentLine() <= 26 ); | ||
2008 | session->run(); | 1981 | session->run(); | ||
2009 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | 1982 | WAIT_FOR_STATE(session, DebugSession::ActiveState); | ||
2010 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | 1983 | b->setData(KDevelop::Breakpoint::EnableColumn, Qt::Unchecked); | ||
Show All 39 Lines | |||||
2050 | } | 2023 | } | ||
2051 | 2024 | | |||
2052 | // see: https://bugs.kde.org/show_bug.cgi?id=339231 | 2025 | // see: https://bugs.kde.org/show_bug.cgi?id=339231 | ||
2053 | void GdbTest::testPathWithSpace() | 2026 | void GdbTest::testPathWithSpace() | ||
2054 | { | 2027 | { | ||
2055 | #ifdef HAVE_PATH_WITH_SPACES_TEST | 2028 | #ifdef HAVE_PATH_WITH_SPACES_TEST | ||
2056 | TestDebugSession* session = new TestDebugSession; | 2029 | TestDebugSession* session = new TestDebugSession; | ||
2057 | 2030 | | |||
2058 | auto debugee = findExecutable(QStringLiteral("path with space/spacedebugee")); | 2031 | auto debugee = findExecutable(QStringLiteral("path with space/debuggee_spacedebugee")); | ||
2059 | TestLaunchConfiguration c(debugee, KIO::upUrl(debugee)); | 2032 | TestLaunchConfiguration c(debugee, KIO::upUrl(debugee)); | ||
2060 | KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("spacedebugee.cpp:30")); | 2033 | KDevelop::Breakpoint* b = breakpoints()->addCodeBreakpoint(QStringLiteral("spacedebugee.cpp:30")); | ||
2061 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | 2034 | QCOMPARE(b->state(), KDevelop::Breakpoint::NotStartedState); | ||
2062 | session->startDebugging(&c, m_iface); | 2035 | session->startDebugging(&c, m_iface); | ||
2063 | 2036 | | |||
2064 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 2037 | WAIT_FOR_STATE(session, DebugSession::PausedState); | ||
2065 | QCOMPARE(b->state(), KDevelop::Breakpoint::CleanState); | 2038 | QCOMPARE(b->state(), KDevelop::Breakpoint::CleanState); | ||
2066 | session->run(); | 2039 | session->run(); | ||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |