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 "lldbdebugger.h" 0008 0009 #include "dbgglobal.h" 0010 #include "debuglog.h" 0011 0012 #include <interfaces/icore.h> 0013 #include <interfaces/iruntime.h> 0014 #include <interfaces/iruntimecontroller.h> 0015 #include <util/environmentprofilelist.h> 0016 0017 #include <KConfigGroup> 0018 #include <KLocalizedString> 0019 #include <KShell> 0020 0021 #include <QUrl> 0022 0023 using namespace KDevelop; 0024 using namespace KDevMI::LLDB; 0025 using namespace KDevMI::MI; 0026 0027 LldbDebugger::LldbDebugger(QObject* parent) 0028 : MIDebugger(parent) 0029 { 0030 } 0031 0032 LldbDebugger::~LldbDebugger() 0033 { 0034 } 0035 0036 bool LldbDebugger::start(KConfigGroup& config, const QStringList& extraArguments) 0037 { 0038 // Get path to executable 0039 QUrl lldbUrl = config.readEntry(Config::LldbExecutableEntry, QUrl()); 0040 if (!lldbUrl.isValid() || !lldbUrl.isLocalFile()) { 0041 m_debuggerExecutable = QStringLiteral("lldb-mi"); 0042 } else { 0043 m_debuggerExecutable = lldbUrl.toLocalFile(); 0044 } 0045 0046 // Get arguments 0047 QStringList arguments = extraArguments; 0048 //arguments << "-quiet"; 0049 arguments.append(KShell::splitArgs(config.readEntry(Config::LldbArgumentsEntry, QString()))); 0050 0051 // Get environment 0052 const EnvironmentProfileList egl(config.config()); 0053 const auto &envs = egl.variables(config.readEntry(Config::LldbEnvironmentEntry, egl.defaultProfileName())); 0054 QProcessEnvironment processEnv; 0055 if (config.readEntry(Config::LldbInheritSystemEnvEntry, true)) { 0056 processEnv = QProcessEnvironment::systemEnvironment(); 0057 } 0058 for (auto it = envs.begin(), ite = envs.end(); it != ite; ++it) { 0059 processEnv.insert(it.key(), it.value()); 0060 } 0061 0062 // Start! 0063 m_process->setProcessEnvironment(processEnv); 0064 m_process->setProgram(m_debuggerExecutable, arguments); 0065 ICore::self()->runtimeController()->currentRuntime()->startProcess(m_process); 0066 0067 qCDebug(DEBUGGERLLDB) << "Starting LLDB with command" << m_debuggerExecutable + QLatin1Char(' ') + arguments.join(QLatin1Char(' ')); 0068 qCDebug(DEBUGGERLLDB) << "LLDB process pid:" << m_process->processId(); 0069 emit userCommandOutput(m_debuggerExecutable + QLatin1Char(' ') + arguments.join(QLatin1Char(' ')) + QLatin1Char('\n')); 0070 0071 return true; 0072 } 0073 0074 #include "moc_lldbdebugger.cpp"