File indexing completed on 2024-04-28 04:38:57
0001 /* 0002 SPDX-FileCopyrightText: 2016 Aetf <aetf@unlimitedcodeworks.xyz> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "lldblauncher.h" 0008 0009 #include "debuggerplugin.h" 0010 #include "debuglog.h" 0011 #include "midebugjobs.h" 0012 #include "widgets/lldbconfigpage.h" 0013 0014 #include <execute/iexecuteplugin.h> 0015 #include <interfaces/icore.h> 0016 #include <interfaces/idebugcontroller.h> 0017 #include <interfaces/ilaunchconfiguration.h> 0018 #include <interfaces/iruncontroller.h> 0019 #include <util/executecompositejob.h> 0020 0021 #include <KLocalizedString> 0022 #include <KMessageBox> 0023 #include <KMessageBox_KDevCompat> 0024 0025 #include <QApplication> 0026 0027 using namespace KDevelop; 0028 using namespace KDevMI; 0029 using namespace KDevMI::LLDB; 0030 0031 KDevMI::LLDB::LldbLauncher::LldbLauncher(LldbDebuggerPlugin *plugin, IExecutePlugin *iexec) 0032 : m_plugin(plugin) 0033 , m_iexec(iexec) 0034 { 0035 m_factoryList << new LldbConfigPageFactory(); 0036 } 0037 0038 QString LldbLauncher::id() 0039 { 0040 return QStringLiteral("lldb"); 0041 } 0042 0043 QString LldbLauncher::name() const 0044 { 0045 return i18n("LLDB"); 0046 } 0047 0048 QString LldbLauncher::description() const 0049 { 0050 return i18n("Debug a native application in LLDB"); 0051 } 0052 0053 QStringList LldbLauncher::supportedModes() const 0054 { 0055 return {QStringLiteral("debug")}; 0056 } 0057 0058 QList< KDevelop::LaunchConfigurationPageFactory * > LldbLauncher::configPages() const 0059 { 0060 return m_factoryList; 0061 } 0062 0063 KJob *LldbLauncher::start(const QString &launchMode, KDevelop::ILaunchConfiguration *cfg) 0064 { 0065 qCDebug(DEBUGGERLLDB) << "LldbLauncher: starting debugging"; 0066 if (!cfg) { 0067 qCWarning(DEBUGGERLLDB) << "LldbLauncher: can't start with null configuration"; 0068 return nullptr; 0069 } 0070 0071 if (launchMode == QLatin1String("debug")) { 0072 if (ICore::self()->debugController()->currentSession()) { 0073 auto ans = KMessageBox::warningTwoActions( 0074 qApp->activeWindow(), 0075 i18n("A program is already being debugged. Do you want to abort the " 0076 "currently running debug session and continue with the launch?"), 0077 {}, KGuiItem(i18nc("@action:button", "Abort Current Session"), QStringLiteral("application-exit")), 0078 KStandardGuiItem::cancel()); 0079 if (ans == KMessageBox::SecondaryAction) 0080 return nullptr; 0081 } 0082 0083 QList<KJob*> l; 0084 auto depJob = m_iexec->dependencyJob(cfg); 0085 if (depJob) 0086 l << depJob; 0087 l << new MIDebugJob(m_plugin, cfg, m_iexec); 0088 return new ExecuteCompositeJob(ICore::self()->runController(), l); 0089 } 0090 0091 qCWarning(DEBUGGERLLDB) << "Unknown launch mode" << launchMode << "for config:" << cfg->name(); 0092 return nullptr; 0093 }