diff --git a/src/plugins/baremetal/CMakeLists.txt b/src/plugins/baremetal/CMakeLists.txt index 0a6721c4e76..046e0531c33 100644 --- a/src/plugins/baremetal/CMakeLists.txt +++ b/src/plugins/baremetal/CMakeLists.txt @@ -14,6 +14,7 @@ add_qtc_plugin(BareMetal debugserverprovidermanager.cpp debugserverprovidermanager.h debugserverproviderssettingspage.cpp debugserverproviderssettingspage.h debugservers/gdb/gdbserverprovider.cpp debugservers/gdb/gdbserverprovider.h + debugservers/gdb/genericgdbserverprovider.cpp debugservers/gdb/genericgdbserverprovider.h debugservers/gdb/openocdgdbserverprovider.cpp debugservers/gdb/openocdgdbserverprovider.h debugservers/gdb/stlinkutilgdbserverprovider.cpp debugservers/gdb/stlinkutilgdbserverprovider.h debugservers/gdb/jlinkgdbserverprovider.cpp debugservers/gdb/jlinkgdbserverprovider.h diff --git a/src/plugins/baremetal/baremetal.qbs b/src/plugins/baremetal/baremetal.qbs index c1942018002..f9631304500 100644 --- a/src/plugins/baremetal/baremetal.qbs +++ b/src/plugins/baremetal/baremetal.qbs @@ -42,6 +42,7 @@ QtcPlugin { prefix: "debugservers/gdb/" files: [ "gdbserverprovider.cpp", "gdbserverprovider.h", + "genericgdbserverprovider.cpp", "genericgdbserverprovider.h", "openocdgdbserverprovider.cpp", "openocdgdbserverprovider.h", "stlinkutilgdbserverprovider.cpp", "stlinkutilgdbserverprovider.h", "jlinkgdbserverprovider.cpp", "jlinkgdbserverprovider.h", diff --git a/src/plugins/baremetal/baremetalconstants.h b/src/plugins/baremetal/baremetalconstants.h index 816aa0a51a2..e446d77ed27 100644 --- a/src/plugins/baremetal/baremetalconstants.h +++ b/src/plugins/baremetal/baremetalconstants.h @@ -39,6 +39,7 @@ const char DEBUG_SERVER_PROVIDERS_SETTINGS_ID[] = "EE.BareMetal.DebugServerProvi // GDB Debugger Server Provider Ids. const char GDBSERVER_OPENOCD_PROVIDER_ID[] = "BareMetal.GdbServerProvider.OpenOcd"; const char GDBSERVER_JLINK_PROVIDER_ID[] = "BareMetal.GdbServerProvider.JLink"; +const char GDBSERVER_GENERIC_PROVIDER_ID[] = "BareMetal.GdbServerProvider.Generic"; const char GDBSERVER_STLINK_UTIL_PROVIDER_ID[] = "BareMetal.GdbServerProvider.STLinkUtil"; const char GDBSERVER_EBLINK_PROVIDER_ID[] = "BareMetal.GdbServerProvider.EBlink"; diff --git a/src/plugins/baremetal/debugserverprovidermanager.cpp b/src/plugins/baremetal/debugserverprovidermanager.cpp index 5081588783a..d594e2eb8f5 100644 --- a/src/plugins/baremetal/debugserverprovidermanager.cpp +++ b/src/plugins/baremetal/debugserverprovidermanager.cpp @@ -27,6 +27,7 @@ #include "idebugserverprovider.h" // GDB debug servers. +#include "debugservers/gdb/genericgdbserverprovider.h" #include "debugservers/gdb/openocdgdbserverprovider.h" #include "debugservers/gdb/stlinkutilgdbserverprovider.h" #include "debugservers/gdb/jlinkgdbserverprovider.h" @@ -61,7 +62,8 @@ static DebugServerProviderManager *m_instance = nullptr; DebugServerProviderManager::DebugServerProviderManager() : m_configFile(Utils::FilePath::fromString(Core::ICore::userResourcePath() + fileNameKeyC)) - , m_factories({new JLinkGdbServerProviderFactory, + , m_factories({new GenericGdbServerProviderFactory, + new JLinkGdbServerProviderFactory, new OpenOcdGdbServerProviderFactory, new StLinkUtilGdbServerProviderFactory, new EBlinkGdbServerProviderFactory, diff --git a/src/plugins/baremetal/debugservers/gdb/gdbservers.pri b/src/plugins/baremetal/debugservers/gdb/gdbservers.pri index 3d6d4c31807..cd7e4c88717 100644 --- a/src/plugins/baremetal/debugservers/gdb/gdbservers.pri +++ b/src/plugins/baremetal/debugservers/gdb/gdbservers.pri @@ -1,13 +1,15 @@ HEADERS += \ $$PWD/eblinkgdbserverprovider.h \ $$PWD/gdbserverprovider.h \ + $$PWD/genericgdbserverprovider.h \ + $$PWD/jlinkgdbserverprovider.h \ $$PWD/openocdgdbserverprovider.h \ $$PWD/stlinkutilgdbserverprovider.h \ - $$PWD/jlinkgdbserverprovider.h \ SOURCES += \ $$PWD/eblinkgdbserverprovider.cpp \ $$PWD/gdbserverprovider.cpp \ + $$PWD/genericgdbserverprovider.cpp \ + $$PWD/jlinkgdbserverprovider.cpp \ $$PWD/openocdgdbserverprovider.cpp \ $$PWD/stlinkutilgdbserverprovider.cpp \ - $$PWD/jlinkgdbserverprovider.cpp \ diff --git a/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.cpp new file mode 100644 index 00000000000..3a95e07e705 --- /dev/null +++ b/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "genericgdbserverprovider.h" + +#include +#include + +#include +#include + +#include +#include +#include + +namespace BareMetal { +namespace Internal { + +// GenericGdbServerProvider + +GenericGdbServerProvider::GenericGdbServerProvider() + : GdbServerProvider(Constants::GDBSERVER_GENERIC_PROVIDER_ID) +{ + setChannel("localhost", 3333); + setSettingsKeyBase("BareMetal.GenericGdbServerProvider"); + setTypeDisplayName(GdbServerProvider::tr("Generic")); + setConfigurationWidgetCreator([this] { return new GenericGdbServerProviderConfigWidget(this); }); +} + +QSet GenericGdbServerProvider::supportedStartupModes() const +{ + return {StartupOnNetwork}; +} + +// GenericGdbServerProviderFactory + +GenericGdbServerProviderFactory::GenericGdbServerProviderFactory() +{ + setId(Constants::GDBSERVER_GENERIC_PROVIDER_ID); + setDisplayName(GdbServerProvider::tr("Generic")); + setCreator([] { return new GenericGdbServerProvider; }); +} + +// GdbServerProviderConfigWidget + +GenericGdbServerProviderConfigWidget::GenericGdbServerProviderConfigWidget( + GenericGdbServerProvider *provider) + : GdbServerProviderConfigWidget(provider) +{ + Q_ASSERT(provider); + + m_hostWidget = new HostWidget(this); + m_mainLayout->addRow(tr("Host:"), m_hostWidget); + + m_useExtendedRemoteCheckBox = new QCheckBox(this); + m_useExtendedRemoteCheckBox->setToolTip("Use GDB target extended-remote"); + m_mainLayout->addRow(tr("Extended mode:"), m_useExtendedRemoteCheckBox); + m_initCommandsTextEdit = new QPlainTextEdit(this); + m_initCommandsTextEdit->setToolTip(defaultInitCommandsTooltip()); + m_mainLayout->addRow(tr("Init commands:"), m_initCommandsTextEdit); + m_resetCommandsTextEdit = new QPlainTextEdit(this); + m_resetCommandsTextEdit->setToolTip(defaultResetCommandsTooltip()); + m_mainLayout->addRow(tr("Reset commands:"), m_resetCommandsTextEdit); + + addErrorLabel(); + setFromProvider(); + + const auto chooser = new Utils::VariableChooser(this); + chooser->addSupportedWidget(m_initCommandsTextEdit); + chooser->addSupportedWidget(m_resetCommandsTextEdit); + + connect(m_hostWidget, &HostWidget::dataChanged, + this, &GdbServerProviderConfigWidget::dirty); + connect(m_useExtendedRemoteCheckBox, &QCheckBox::stateChanged, + this, &GdbServerProviderConfigWidget::dirty); + connect(m_initCommandsTextEdit, &QPlainTextEdit::textChanged, + this, &GdbServerProviderConfigWidget::dirty); + connect(m_resetCommandsTextEdit, &QPlainTextEdit::textChanged, + this, &GdbServerProviderConfigWidget::dirty); +} + +void GenericGdbServerProviderConfigWidget::apply() +{ + const auto p = static_cast(m_provider); + Q_ASSERT(p); + + p->setChannel(m_hostWidget->channel()); + p->setUseExtendedRemote(m_useExtendedRemoteCheckBox->isChecked()); + p->setInitCommands(m_initCommandsTextEdit->toPlainText()); + p->setResetCommands(m_resetCommandsTextEdit->toPlainText()); + IDebugServerProviderConfigWidget::apply(); +} + +void GenericGdbServerProviderConfigWidget::discard() +{ + setFromProvider(); + IDebugServerProviderConfigWidget::discard(); +} + +void GenericGdbServerProviderConfigWidget::setFromProvider() +{ + const auto p = static_cast(m_provider); + Q_ASSERT(p); + + const QSignalBlocker blocker(this); + m_hostWidget->setChannel(p->channel()); + m_useExtendedRemoteCheckBox->setChecked(p->useExtendedRemote()); + m_initCommandsTextEdit->setPlainText(p->initCommands()); + m_resetCommandsTextEdit->setPlainText(p->resetCommands()); +} + +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.h b/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.h new file mode 100644 index 00000000000..90d75496dc0 --- /dev/null +++ b/src/plugins/baremetal/debugservers/gdb/genericgdbserverprovider.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "gdbserverprovider.h" + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QPlainTextEdit; +QT_END_NAMESPACE + +namespace BareMetal { +namespace Internal { + +// GenericGdbServerProvider + +class GenericGdbServerProvider final : public GdbServerProvider +{ +private: + GenericGdbServerProvider(); + QSet supportedStartupModes() const final; + + friend class GenericGdbServerProviderConfigWidget; + friend class GenericGdbServerProviderFactory; + friend class BareMetalDevice; +}; + +// GenericGdbServerProviderFactory + +class GenericGdbServerProviderFactory final : public IDebugServerProviderFactory +{ +public: + GenericGdbServerProviderFactory(); +}; + +// GenericGdbServerProviderConfigWidget + +class GenericGdbServerProviderConfigWidget final + : public GdbServerProviderConfigWidget +{ + Q_OBJECT + +public: + explicit GenericGdbServerProviderConfigWidget( + GenericGdbServerProvider *provider); + +private: + void apply() final; + void discard() final; + + void setFromProvider(); + + HostWidget *m_hostWidget = nullptr; + QCheckBox *m_useExtendedRemoteCheckBox = nullptr; + QPlainTextEdit *m_initCommandsTextEdit = nullptr; + QPlainTextEdit *m_resetCommandsTextEdit = nullptr; +}; + +} // namespace Internal +} // namespace BareMetal