Commit 07f3ba94 authored by Peifeng Yu's avatar Peifeng Yu
Browse files

Lldb config page and launcher

parent e0fdc4fc
......@@ -69,8 +69,13 @@ static const char AllowForcedBPEntry[] = "Allow Forced Breakpoint Set";
}
namespace LLDB { namespace Config {
static const char LldbPathEntry[] = "LLDB Path";
static const char ldbConfigScriptEntry[] = "LLDB Config Script";
static const char LldbExecutableEntry[] = "LLDB Executable";
static const char LldbArgumentsEntry[] = "LLDB Arguments";
static const char LldbEnvironmentEntry[] = "LLDB Environment";
static const char LldbConfigScriptEntry[] = "LLDB Config Script";
static const char LldbRemoteDebuggingEntry[] = "LLDB Remote Debugging";
static const char LldbRemoteServerEntry[] = "LLDB Remote Server";
static const char LldbRemoteAttachEntry[] = "LLDB Remote Attach";
}
}
......
......@@ -9,9 +9,12 @@ set(kdevlldb_SRCS
controllers/variablecontroller.cpp
controllers/variable.cpp
controllers/framestackmodel.cpp
widgets/lldbconfigpage.cpp
lldblauncher.cpp
)
set(kdevlldb_UI
widgets/lldbconfigpage.ui
)
ki18n_wrap_ui(kdevlldb_SRCS ${kdevlldb_UI})
......@@ -23,8 +26,12 @@ target_link_libraries(kdevlldb_static
PUBLIC
kdevdebuggercommon
KDev::Debugger
KDev::Interfaces
PRIVATE
Qt5::Core
Qt5::Gui
KF5::KIOWidgets
KDev::Shell
)
# The actual plugin
......
......@@ -125,7 +125,7 @@ void DebugSession::configure(ILaunchConfiguration *cfg, IExecutePlugin *)
{
// Read Configuration values
KConfigGroup grp = cfg->config();
QUrl configLldbScript = grp.readEntry(Config::ldbConfigScriptEntry, QUrl());
QUrl configLldbScript = grp.readEntry(Config::LldbConfigScriptEntry, QUrl());
// break on start: can't use "-exec-run --start" because in lldb-mi
// the inferior stops without any notification
......
......@@ -50,7 +50,7 @@ LldbDebugger::~LldbDebugger()
bool LldbDebugger::start(KConfigGroup& config, const QStringList& extraArguments)
{
QUrl lldbUrl = config.readEntry(Config::LldbPathEntry, QUrl());
QUrl lldbUrl = config.readEntry(Config::LldbExecutableEntry, QUrl());
if (!lldbUrl.isValid() || !lldbUrl.isLocalFile()) {
debuggerBinary_ = "lldb-mi";
} else {
......
/*
* LLDB Debugger Support
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "lldblauncher.h"
#include "debuggerplugin.h"
#include "debuglog.h"
#include "midebugjobs.h"
#include "widgets/lldbconfigpage.h"
#include <execute/iexecuteplugin.h>
#include <interfaces/icore.h>
#include <interfaces/idebugcontroller.h>
#include <interfaces/ilaunchconfiguration.h>
#include <interfaces/iruncontroller.h>
#include <util/executecompositejob.h>
#include <KLocalizedString>
#include <KMessageBox>
#include <QApplication>
using namespace KDevelop;
using namespace KDevMI;
using namespace KDevMI::LLDB;
KDevMI::LLDB::LldbLauncher::LldbLauncher(CppDebuggerPlugin *plugin, IExecutePlugin *iexec)
: m_plugin(plugin)
, m_iexec(iexec)
{
m_factoryList << new LldbConfigPageFactory();
}
QString LldbLauncher::id()
{
return QStringLiteral("lldb");
}
QString LldbLauncher::name() const
{
return i18n("LLDB");
}
QString LldbLauncher::description() const
{
return i18n("Debug a native application in LLDB");
}
QStringList LldbLauncher::supportedModes() const
{
return {"debug"};
}
QList< KDevelop::LaunchConfigurationPageFactory * > LldbLauncher::configPages() const
{
return m_factoryList;
}
KJob *LldbLauncher::start(const QString &launchMode, KDevelop::ILaunchConfiguration *cfg)
{
if (!cfg) {
qCWarning(DEBUGGERLLDB) << "LldbLauncher: can't start with null configuration";
return nullptr;
}
if (launchMode == "debug") {
if (ICore::self()->debugController()->currentSession()) {
auto ans = KMessageBox::warningYesNo(qApp->activeWindow(),
i18n("A program is already being debugged. Do you want to abort the "
"currently running debug session and continue with the launch?"));
if (ans == KMessageBox::No)
return nullptr;
}
QList<KJob*> l;
auto depJob = m_iexec->dependencyJob(cfg);
if (depJob)
l << depJob;
// l << new MIDebugJob(m_plugin, cfg, m_iexec);
return new ExecuteCompositeJob(ICore::self()->runController(), l);
}
qCWarning(DEBUGGERLLDB) << "Unknown launch mode" << launchMode << "for config:" << cfg->name();
return nullptr;
}
/*
* LLDB Debugger Support
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LLDBLAUNCHER_H
#define LLDBLAUNCHER_H
#include <interfaces/ilauncher.h>
class IExecutePlugin;
namespace KDevMI { namespace LLDB {
class CppDebuggerPlugin;
class LldbLauncher : public KDevelop::ILauncher
{
public:
LldbLauncher(CppDebuggerPlugin *plugin, IExecutePlugin *iexec);
QList<KDevelop::LaunchConfigurationPageFactory*> configPages() const override;
QString description() const override;
QString id() override;
QString name() const override;
KJob* start(const QString &launchMode, KDevelop::ILaunchConfiguration *cfg) override;
QStringList supportedModes() const override;
private:
QList<KDevelop::LaunchConfigurationPageFactory*> m_factoryList;
CppDebuggerPlugin *m_plugin;
IExecutePlugin *m_iexec;
};
} // end of namespace LLDB
} // end of namespace KDevMI
#endif // LLDBLAUNCHER_H
......@@ -832,7 +832,7 @@ void LldbTest::testPickupManuallyInsertedBreakpointOnlyOnce()
TestLaunchConfiguration cfg;
KConfigGroup grp = cfg.config();
grp.writeEntry(Config::ldbConfigScriptEntry, QUrl::fromLocalFile(configScript.fileName()));
grp.writeEntry(Config::LldbConfigScriptEntry, QUrl::fromLocalFile(configScript.fileName()));
breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile("debugee.cpp"), 31);
......@@ -1736,7 +1736,7 @@ void LldbTest::testRunLldbScript()
TestLaunchConfiguration cfg;
KConfigGroup grp = cfg.config();
grp.writeEntry(Config::ldbConfigScriptEntry, QUrl::fromLocalFile(runScript.fileName()));
grp.writeEntry(Config::LldbConfigScriptEntry, QUrl::fromLocalFile(runScript.fileName()));
QVERIFY(session->startDebugging(&cfg, m_iface));
......
/*
* LLDB Debugger Support
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "lldbconfigpage.h"
#include "ui_lldbconfigpage.h"
#include "dbgglobal.h"
#include <util/environmentselectionwidget.h>
#include <KConfigGroup>
#include <KUrlRequester>
#include <QComboBox>
#include <QGroupBox>
#include <QLineEdit>
using namespace KDevelop;
namespace Config = KDevMI::LLDB::Config;
LldbConfigPage::LldbConfigPage(QWidget* parent)
: LaunchConfigurationPage(parent)
, ui(new Ui::LldbConfigPage)
{
ui->setupUi(this);
ui->lineDebuggerExec->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
ui->lineConfigScript->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
ui->lineRemoteServer->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
ui->lineAttachScript->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly);
ui->comboStartWith->setItemData(0, "ApplicationOutput");
ui->comboStartWith->setItemData(1, "GdbConsole");
ui->comboStartWith->setItemData(2, "FrameStack");
connect(ui->lineDebuggerExec, &KUrlRequester::textChanged, this, &LldbConfigPage::changed);
connect(ui->lineDebuggerArgs, &QLineEdit::textChanged, this, &LldbConfigPage::changed);
connect(ui->comboEnv, &EnvironmentSelectionWidget::currentProfileChanged,
this, &LldbConfigPage::changed);
connect(ui->lineConfigScript, &KUrlRequester::textChanged, this, &LldbConfigPage::changed);
connect(ui->comboStartWith, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &LldbConfigPage::changed);
connect(ui->groupRemote, &QGroupBox::clicked, this, &LldbConfigPage::changed);
connect(ui->lineRemoteServer, &KUrlRequester::textChanged, this, &LldbConfigPage::changed);
connect(ui->lineAttachScript, &KUrlRequester::textChanged, this, &LldbConfigPage::changed);
}
LldbConfigPage::~LldbConfigPage()
{
delete ui;
}
QIcon LldbConfigPage::icon() const
{
return {};
}
QString LldbConfigPage::title() const
{
return i18n("LLDB Configuration");
}
void LldbConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject *proj)
{
bool block = blockSignals(true);
ui->lineDebuggerExec->setUrl(cfg.readEntry(Config::LldbExecutableEntry, QUrl()));
ui->lineDebuggerArgs->setText(cfg.readEntry(Config::LldbArgumentsEntry, QString()));
ui->comboEnv->setCurrentProfile(cfg.readEntry(Config::LldbEnvironmentEntry, QString()));
ui->lineConfigScript->setUrl(cfg.readEntry(Config::LldbConfigScriptEntry, QUrl()));
ui->comboStartWith->setCurrentIndex(ui->comboStartWith->findData(
cfg.readEntry(KDevMI::Config::StartWithEntry, "ApplicationOutput")));
ui->groupRemote->setCheckable(cfg.readEntry(Config::LldbRemoteDebuggingEntry, false));
ui->lineRemoteServer->setUrl(cfg.readEntry(Config::LldbRemoteServerEntry, QUrl()));
ui->lineAttachScript->setUrl(cfg.readEntry(Config::LldbRemoteAttachEntry, QUrl()));
blockSignals(block);
}
void LldbConfigPage::saveToConfiguration(KConfigGroup cfg, KDevelop::IProject *proj) const
{
cfg.writeEntry(Config::LldbExecutableEntry, ui->lineDebuggerExec->url());
cfg.writeEntry(Config::LldbArgumentsEntry, ui->lineDebuggerArgs->text());
cfg.writeEntry(Config::LldbEnvironmentEntry, ui->comboEnv->currentProfile());
cfg.writeEntry(Config::LldbConfigScriptEntry, ui->lineConfigScript->url());
cfg.writeEntry(KDevMI::Config::StartWithEntry, ui->comboStartWith->currentData().toString());
cfg.writeEntry(Config::LldbRemoteDebuggingEntry, ui->groupRemote->isChecked());
cfg.writeEntry(Config::LldbRemoteServerEntry, ui->lineRemoteServer->url());
cfg.writeEntry(Config::LldbRemoteAttachEntry, ui->lineAttachScript->url());
}
KDevelop::LaunchConfigurationPage * LldbConfigPageFactory::createWidget(QWidget* parent)
{
return new LldbConfigPage(parent);
}
/*
* LLDB Debugger Support
* Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LLDBCONFIGPAGE_H
#define LLDBCONFIGPAGE_H
#include <interfaces/launchconfigurationpage.h>
namespace Ui
{
class LldbConfigPage;
}
class LldbConfigPage : public KDevelop::LaunchConfigurationPage
{
Q_OBJECT
public:
LldbConfigPage( QWidget* parent = 0 );
~LldbConfigPage() override;
QIcon icon() const override;
QString title() const override;
void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject *proj = nullptr) override;
void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject *proj = nullptr) const override;
private:
Ui::LldbConfigPage* ui;
};
class LldbConfigPageFactory : public KDevelop::LaunchConfigurationPageFactory
{
public:
KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override;
};
#endif // LLDBCONFIGPAGE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LldbConfigPage</class>
<widget class="QWidget" name="LldbConfigPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>535</height>
</rect>
</property>
<property name="windowTitle">
<string>Debugger Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupDebugger">
<property name="title">
<string>Debugger</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Debugger executable:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KUrlRequester" name="lineDebuggerExec"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Arguments:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineDebuggerArgs"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Environment:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="KDevelop::EnvironmentSelectionWidget" name="comboEnv">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="KDevelop::EnvironmentConfigureButton" name="btnEditEnv">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupOptions">
<property name="title">
<string>Options</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Config script:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KUrlRequester" name="lineConfigScript"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Start debugger with:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboStartWith">
<item>
<property name="text">
<string>Application Output</string>
</property>
</item>
<item>
<property name="text">
<string>LLDB Console</string>
</property>
</item>
<item>
<property name="text">
<string>Frame Stack</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupRemote">
<property name="title">
<string>Re&amp;mote Debugging</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Remote server script:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KUrlRequester" name="lineRemoteServer"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Attach command script:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KUrlRequester" name="lineAttachScript"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>149</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KDevelop::EnvironmentConfigureButton</class>
<extends>QToolButton</extends>
<header>shell/environmentconfigurebutton.h</header>
</customwidget>
<customwidget>
<class>KDevelop::EnvironmentSelectionWidget</class>
<extends>QComboBox</extends>
<header>util/environmentselectionwidget.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QLineEdit</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment