File indexing completed on 2024-04-14 04:31:24

0001 /*
0002  * XDebug Debugger Support
0003  *
0004  * Copyright 2006 Vladimir Prus <ghost@cs.msu.su>
0005  * Copyright 2007 Hamish Rodda <rodda@kde.org>
0006  * Copyright 2009 Andreas Pakulat <apaku@gmx.de>
0007  * Copyright 2009 Niko Sams <niko.sams@gmail.com>
0008  *
0009  * This program is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License as
0011  * published by the Free Software Foundation; either version 2 of the
0012  * License, or (at your option) any later version.
0013  *
0014  * This program is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  * GNU General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU General Public
0020  * License along with this program; if not, write to the
0021  * Free Software Foundation, Inc.,
0022  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0023  */
0024 
0025 #include "launchconfig.h"
0026 
0027 #include <KLocalizedString>
0028 
0029 #include <outputview/outputmodel.h>
0030 #include <interfaces/ilaunchconfiguration.h>
0031 #include <execute/iexecuteplugin.h>
0032 #include <interfaces/iproject.h>
0033 #include <project/interfaces/iprojectbuilder.h>
0034 #include <project/builderjob.h>
0035 #include <interfaces/iuicontroller.h>
0036 #include <project/interfaces/ibuildsystemmanager.h>
0037 #include <util/executecompositejob.h>
0038 #include <interfaces/iplugincontroller.h>
0039 #include <interfaces/icore.h>
0040 #include <util/processlinemaker.h>
0041 #include <executescript/iexecutescriptplugin.h>
0042 
0043 #include "debugsession.h"
0044 #include "xdebugplugin.h"
0045 #include "debugjob.h"
0046 #include "launchconfigurationpage.h"
0047 #include "debuggerdebug.h"
0048 
0049 namespace XDebug {
0050 XDebugLauncher::XDebugLauncher(XDebugPlugin* p) : m_plugin(p)
0051 {
0052     m_factoryList << new ConfigPageFactory();
0053 }
0054 
0055 QList<KDevelop::LaunchConfigurationPageFactory*> XDebugLauncher::configPages() const
0056 {
0057     return m_factoryList;;
0058 }
0059 
0060 QString XDebugLauncher::id()
0061 {
0062     return "xdebug";
0063 }
0064 
0065 QString XDebugLauncher::name() const
0066 {
0067     return i18n("XDebug");
0068 }
0069 
0070 KJob* XDebugLauncher::start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg)
0071 {
0072     Q_ASSERT(cfg);
0073     if (!cfg) {
0074         return nullptr;
0075     }
0076     if (launchMode == "debug") {
0077         return new XDebugJob(m_plugin->createSession(), cfg);
0078     }
0079     qCWarning(KDEV_PHP_DEBUGGER) << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
0080     return nullptr;
0081 }
0082 
0083 QStringList XDebugLauncher::supportedModes() const
0084 {
0085     return QStringList() << "debug";
0086 }
0087 
0088 QString XDebugLauncher::description() const
0089 {
0090     return i18n("Executes a PHP script with XDebug enabled");
0091 }
0092 
0093 XDebugBrowserLauncher::XDebugBrowserLauncher(XDebugPlugin* plugin)
0094     : XDebugLauncher(plugin)
0095 {
0096 }
0097 
0098 KJob* XDebugBrowserLauncher::start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg)
0099 {
0100     Q_ASSERT(cfg);
0101     if (!cfg) {
0102         return nullptr;
0103     }
0104 
0105     if (launchMode == "debug") {
0106         return new XDebugBrowserJob(m_plugin->createSession(), cfg);
0107     }
0108     qCWarning(KDEV_PHP_DEBUGGER) << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
0109     return nullptr;
0110 }
0111 }