Warning, file /kdevelop/kdev-python/debugger/debugjob.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2012 Sven Brauch <svenbrauch@googlemail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "debugjob.h" 0008 0009 0010 0011 #include <interfaces/idebugcontroller.h> 0012 #include <interfaces/icore.h> 0013 #include <interfaces/iplugincontroller.h> 0014 0015 #include <sublime/view.h> 0016 #include <util/processlinemaker.h> 0017 0018 #include <QDebug> 0019 #include <QStandardPaths> 0020 #include "debuggerdebug.h" 0021 0022 namespace Python { 0023 0024 0025 void DebugJob::start() 0026 { 0027 QStringList program; 0028 QString debuggerUrl = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kdevpythonsupport/debugger", QStandardPaths::LocateDirectory) + "/kdevpdb.py"; 0029 program << m_interpreter << "-u" << debuggerUrl << m_scriptUrl.toLocalFile() << m_args; 0030 // Inject environment 0031 m_session = new DebugSession(program, m_workingDirectory, m_envProfileName); 0032 0033 setStandardToolView(KDevelop::IOutputView::DebugView); 0034 setBehaviours(KDevelop::IOutputView::Behaviours(KDevelop::IOutputView::AllowUserClose) | KDevelop::IOutputView::AutoScroll); 0035 OutputModel* pyOutputModel = new KDevelop::OutputModel(); 0036 pyOutputModel->setFilteringStrategy(OutputModel::ScriptErrorFilter); 0037 setModel(pyOutputModel); 0038 setTitle(m_interpreter + m_scriptUrl.toLocalFile()); 0039 0040 setModel(new KDevelop::OutputModel(nullptr)); 0041 0042 startOutput(); 0043 0044 qCDebug(KDEV_PYTHON_DEBUGGER) << "connecting standardOutputReceived"; 0045 connect(m_session, &DebugSession::realDataReceived, this, &DebugJob::standardOutputReceived); 0046 connect(m_session, &DebugSession::stderrReceived, this, &DebugJob::standardErrorReceived); 0047 connect(m_session, &KDevelop::IDebugSession::finished, this, &DebugJob::sessionFinished); 0048 KDevelop::ICore::self()->debugController()->addSession(m_session); 0049 m_session->start(); 0050 qCDebug(KDEV_PYTHON_DEBUGGER) << "starting program:" << program; 0051 } 0052 0053 void DebugJob::sessionFinished() 0054 { 0055 emitResult(); 0056 } 0057 0058 void DebugJob::standardErrorReceived(QStringList lines) 0059 { 0060 if ( OutputModel* m = outputModel() ) { 0061 m->appendLines(lines); 0062 } 0063 } 0064 0065 void DebugJob::standardOutputReceived(QStringList lines) 0066 { 0067 qCDebug(KDEV_PYTHON_DEBUGGER) << "standard output received:" << lines << outputModel(); 0068 if ( OutputModel* m = outputModel() ) { 0069 m->appendLines(lines); 0070 } 0071 } 0072 0073 OutputModel* DebugJob::outputModel() 0074 { 0075 return dynamic_cast<OutputModel*>(model()); 0076 } 0077 0078 bool DebugJob::doKill() 0079 { 0080 qCDebug(KDEV_PYTHON_DEBUGGER) << "kill signal received"; 0081 m_session->stopDebugger(); 0082 return true; 0083 } 0084 0085 DebugJob::DebugJob() 0086 { 0087 0088 } 0089 0090 DebugJob::~DebugJob() 0091 { 0092 0093 } 0094 0095 } 0096 0097 #include "moc_debugjob.cpp"