Changeset View
Changeset View
Standalone View
Standalone View
debugger/debugsession.cpp
Show All 20 Lines | |||||
21 | #include <QApplication> | 21 | #include <QApplication> | ||
22 | 22 | | |||
23 | #include <KLocalizedString> | 23 | #include <KLocalizedString> | ||
24 | #include <signal.h> | 24 | #include <signal.h> | ||
25 | 25 | | |||
26 | #include <debugger/framestack/framestackmodel.h> | 26 | #include <debugger/framestack/framestackmodel.h> | ||
27 | #include <interfaces/icore.h> | 27 | #include <interfaces/icore.h> | ||
28 | #include <interfaces/idocumentcontroller.h> | 28 | #include <interfaces/idocumentcontroller.h> | ||
29 | #include <util/environmentprofilelist.h> | ||||
29 | 30 | | |||
30 | #include "debugsession.h" | 31 | #include "debugsession.h" | ||
31 | #include "pdbframestackmodel.h" | 32 | #include "pdbframestackmodel.h" | ||
32 | #include "variablecontroller.h" | 33 | #include "variablecontroller.h" | ||
33 | #include "variable.h" | 34 | #include "variable.h" | ||
34 | #include "breakpointcontroller.h" | 35 | #include "breakpointcontroller.h" | ||
35 | 36 | | |||
36 | #include <QDebug> | 37 | #include <QDebug> | ||
Show All 10 Lines | |||||
47 | using namespace KDevelop; | 48 | using namespace KDevelop; | ||
48 | 49 | | |||
49 | static QByteArray debuggerPrompt = "__KDEVPYTHON_DEBUGGER_PROMPT"; | 50 | static QByteArray debuggerPrompt = "__KDEVPYTHON_DEBUGGER_PROMPT"; | ||
50 | static QByteArray debuggerOutputBegin = "__KDEVPYTHON_BEGIN_DEBUGGER_OUTPUT>>>"; | 51 | static QByteArray debuggerOutputBegin = "__KDEVPYTHON_BEGIN_DEBUGGER_OUTPUT>>>"; | ||
51 | static QByteArray debuggerOutputEnd = "<<<__KDEVPYTHON_END___DEBUGGER_OUTPUT"; | 52 | static QByteArray debuggerOutputEnd = "<<<__KDEVPYTHON_END___DEBUGGER_OUTPUT"; | ||
52 | 53 | | |||
53 | namespace Python { | 54 | namespace Python { | ||
54 | 55 | | |||
55 | DebugSession::DebugSession(QStringList program, const QUrl &workingDirectory) : | 56 | DebugSession::DebugSession(QStringList program, const QUrl &workingDirectory, | ||
57 | const QString& envProfileName) : | ||||
56 | IDebugSession() | 58 | IDebugSession() | ||
57 | , m_breakpointController(nullptr) | 59 | , m_breakpointController(nullptr) | ||
58 | , m_variableController(nullptr) | 60 | , m_variableController(nullptr) | ||
59 | , m_frameStackModel(nullptr) | 61 | , m_frameStackModel(nullptr) | ||
60 | , m_workingDirectory(workingDirectory) | 62 | , m_workingDirectory(workingDirectory) | ||
63 | , m_envProfileName(envProfileName) | ||||
61 | , m_nextNotifyMethod(nullptr) | 64 | , m_nextNotifyMethod(nullptr) | ||
62 | , m_inDebuggerData(0) | 65 | , m_inDebuggerData(0) | ||
63 | { | 66 | { | ||
64 | qCDebug(KDEV_PYTHON_DEBUGGER) << "creating debug session"; | 67 | qCDebug(KDEV_PYTHON_DEBUGGER) << "creating debug session"; | ||
65 | m_program = program; | 68 | m_program = program; | ||
66 | m_breakpointController = new Python::BreakpointController(this); | 69 | m_breakpointController = new Python::BreakpointController(this); | ||
67 | m_variableController = new VariableController(this); | 70 | m_variableController = new VariableController(this); | ||
68 | m_frameStackModel = new PdbFrameStackModel(this); | 71 | m_frameStackModel = new PdbFrameStackModel(this); | ||
Show All 17 Lines | |||||
86 | void DebugSession::start() | 89 | void DebugSession::start() | ||
87 | { | 90 | { | ||
88 | setState(StartingState); | 91 | setState(StartingState); | ||
89 | m_debuggerProcess = new KProcess(this); | 92 | m_debuggerProcess = new KProcess(this); | ||
90 | m_debuggerProcess->setProgram(m_program); | 93 | m_debuggerProcess->setProgram(m_program); | ||
91 | m_debuggerProcess->setOutputChannelMode(KProcess::SeparateChannels); | 94 | m_debuggerProcess->setOutputChannelMode(KProcess::SeparateChannels); | ||
92 | m_debuggerProcess->blockSignals(true); | 95 | m_debuggerProcess->blockSignals(true); | ||
93 | m_debuggerProcess->setWorkingDirectory(m_workingDirectory.path()); | 96 | m_debuggerProcess->setWorkingDirectory(m_workingDirectory.path()); | ||
97 | | ||||
98 | const KDevelop::EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig()); | ||||
99 | const auto environment = environmentProfiles.variables(m_envProfileName); | ||||
100 | | ||||
101 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | ||||
102 | for(auto i = environment.cbegin(); i != environment.cend(); i++ ) | ||||
103 | { | ||||
104 | env.insert(i.key(), i.value()); | ||||
105 | } | ||||
106 | m_debuggerProcess->setProcessEnvironment(env); | ||||
107 | | ||||
94 | connect(m_debuggerProcess, &QProcess::readyReadStandardOutput, this, &DebugSession::dataAvailable); | 108 | connect(m_debuggerProcess, &QProcess::readyReadStandardOutput, this, &DebugSession::dataAvailable); | ||
95 | connect(m_debuggerProcess, SIGNAL(finished(int)), this, SLOT(debuggerQuit(int))); | 109 | connect(m_debuggerProcess, SIGNAL(finished(int)), this, SLOT(debuggerQuit(int))); | ||
96 | connect(this, &DebugSession::debuggerReady, this, &DebugSession::checkCommandQueue); | 110 | connect(this, &DebugSession::debuggerReady, this, &DebugSession::checkCommandQueue); | ||
97 | connect(this, &DebugSession::commandAdded, this, &DebugSession::checkCommandQueue); | 111 | connect(this, &DebugSession::commandAdded, this, &DebugSession::checkCommandQueue); | ||
98 | m_debuggerProcess->start(); | 112 | m_debuggerProcess->start(); | ||
99 | m_debuggerProcess->waitForStarted(); | 113 | m_debuggerProcess->waitForStarted(); | ||
100 | auto dir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 114 | auto dir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
101 | "kdevpythonsupport/debugger/", QStandardPaths::LocateDirectory); | 115 | "kdevpythonsupport/debugger/", QStandardPaths::LocateDirectory); | ||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |