Changeset View
Changeset View
Standalone View
Standalone View
debugger/debugsession.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | 14 | | |||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | 19 | | |||
20 | #include <QTimer> | 20 | #include <QTimer> | ||
21 | #include <QApplication> | 21 | #include <QApplication> | ||
22 | #include <QStringList> | ||||
22 | 23 | | |||
23 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
24 | #include <signal.h> | 25 | #include <signal.h> | ||
25 | 26 | | |||
26 | #include <debugger/framestack/framestackmodel.h> | 27 | #include <debugger/framestack/framestackmodel.h> | ||
27 | #include <interfaces/icore.h> | 28 | #include <interfaces/icore.h> | ||
28 | #include <interfaces/idocumentcontroller.h> | 29 | #include <interfaces/idocumentcontroller.h> | ||
29 | 30 | | |||
Show All 17 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 QStringList& environment) : | ||||
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_environment(environment) | ||||
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 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | ||||
apol: const | |||||
If I'm right, I'm modifying env variable later: Kebianizao: If I'm right, I'm modifying env variable later:
env.insert(key, value);
Therefore I'm not… | |||||
brauch: No, you are right, it's fine like you have it | |||||
Kebianizao: OK. | |||||
99 | for(const auto &e : m_environment) | ||||
100 | { | ||||
101 | const QString key = e.section('=',0,0); | ||||
102 | const QString value = e.section('=',1); | ||||
103 | | ||||
104 | env.insert(key, 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 |
const