From f9634d92e3bf5c2ac4f98c629a6dcb7912786aa5 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 25 Nov 2019 17:32:04 +0300 Subject: [PATCH] BareMetal: Get rid of unused GdbServerProviderProcess class We don't need in this class, because the remote GDB servers are launches by the RunWorker. Besides, the BareMetalDevice::canCreateProcess() and the BareMetalDevice::createProcess() are not even gets called at all. Tested with the STM32 Nucleo-F767ZI board using the ST-Util GDB provider. Change-Id: I8d3770ec59738c63aa44dd39d371a1b443a81f9a Reviewed-by: hjk --- src/plugins/baremetal/CMakeLists.txt | 1 - src/plugins/baremetal/baremetal.qbs | 1 - src/plugins/baremetal/baremetaldevice.cpp | 20 --- src/plugins/baremetal/baremetaldevice.h | 3 - .../gdb/gdbserverproviderprocess.cpp | 121 ------------------ .../gdb/gdbserverproviderprocess.h | 65 ---------- .../baremetal/debugservers/gdb/gdbservers.pri | 2 - .../gdb/jlinkgdbserverprovider.cpp | 8 -- .../debugservers/gdb/jlinkgdbserverprovider.h | 5 - .../gdb/openocdgdbserverprovider.cpp | 8 -- .../gdb/openocdgdbserverprovider.h | 5 - .../gdb/stlinkutilgdbserverprovider.cpp | 8 -- .../gdb/stlinkutilgdbserverprovider.h | 5 - src/plugins/baremetal/idebugserverprovider.h | 6 - 14 files changed, 258 deletions(-) delete mode 100644 src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.cpp delete mode 100644 src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.h diff --git a/src/plugins/baremetal/CMakeLists.txt b/src/plugins/baremetal/CMakeLists.txt index fbab5c1ffec..5d91191edef 100644 --- a/src/plugins/baremetal/CMakeLists.txt +++ b/src/plugins/baremetal/CMakeLists.txt @@ -17,7 +17,6 @@ add_qtc_plugin(BareMetal debugserverproviderssettingspage.cpp debugserverproviderssettingspage.h debugservers/gdb/defaultgdbserverprovider.cpp debugservers/gdb/defaultgdbserverprovider.h debugservers/gdb/gdbserverprovider.cpp debugservers/gdb/gdbserverprovider.h - debugservers/gdb/gdbserverproviderprocess.cpp debugservers/gdb/gdbserverproviderprocess.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 ab4a9ea059b..a5cd429ce82 100644 --- a/src/plugins/baremetal/baremetal.qbs +++ b/src/plugins/baremetal/baremetal.qbs @@ -44,7 +44,6 @@ QtcPlugin { files: [ "defaultgdbserverprovider.cpp", "defaultgdbserverprovider.h", "gdbserverprovider.cpp", "gdbserverprovider.h", - "gdbserverproviderprocess.cpp", "gdbserverproviderprocess.h", "openocdgdbserverprovider.cpp", "openocdgdbserverprovider.h", "stlinkutilgdbserverprovider.cpp", "stlinkutilgdbserverprovider.h", "jlinkgdbserverprovider.cpp", "jlinkgdbserverprovider.h", diff --git a/src/plugins/baremetal/baremetaldevice.cpp b/src/plugins/baremetal/baremetaldevice.cpp index f36fec84569..0c1a47e93b6 100644 --- a/src/plugins/baremetal/baremetaldevice.cpp +++ b/src/plugins/baremetal/baremetaldevice.cpp @@ -133,26 +133,6 @@ IDeviceWidget *BareMetalDevice::createWidget() return new BareMetalDeviceConfigurationWidget(sharedFromThis()); } -bool BareMetalDevice::canCreateProcess() const -{ - if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider( - m_debugServerProviderId)) { - return provider->canCreateProcess(); - } - - return false; -} - -DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const -{ - if (IDebugServerProvider *provider = DebugServerProviderManager::findProvider( - m_debugServerProviderId)) { - return provider->createProcess(sharedFromThis(), parent); - } - - return nullptr; -} - // Factory BareMetalDeviceFactory::BareMetalDeviceFactory() diff --git a/src/plugins/baremetal/baremetaldevice.h b/src/plugins/baremetal/baremetaldevice.h index 10e0cfbbe2c..74e32b3605a 100644 --- a/src/plugins/baremetal/baremetaldevice.h +++ b/src/plugins/baremetal/baremetaldevice.h @@ -51,9 +51,6 @@ public: ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const final; - bool canCreateProcess() const final; - ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const final; - QString debugServerProviderId() const; void setDebugServerProviderId(const QString &id); void unregisterDebugServerProvider(IDebugServerProvider *provider); diff --git a/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.cpp b/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.cpp deleted file mode 100644 index d893e5fae46..00000000000 --- a/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 "gdbserverproviderprocess.h" - -#include -#include - -#include -#include -#include - -using namespace ProjectExplorer; - -namespace BareMetal { -namespace Internal { - -// GdbServerProviderProcess - -GdbServerProviderProcess::GdbServerProviderProcess( - const QSharedPointer &device, - QObject *parent) - : ProjectExplorer::DeviceProcess(device, parent) - , m_process(new Utils::QtcProcess(this)) -{ - if (Utils::HostOsInfo::isWindowsHost()) - m_process->setUseCtrlCStub(true); - - connect(m_process, &QProcess::errorOccurred, this, &GdbServerProviderProcess::error); - connect(m_process, QOverload::of(&QProcess::finished), - this, &GdbServerProviderProcess::finished); - - connect(m_process, &QProcess::readyReadStandardOutput, - this, &ProjectExplorer::DeviceProcess::readyReadStandardOutput); - connect(m_process, &QProcess::readyReadStandardError, - this, &ProjectExplorer::DeviceProcess::readyReadStandardError); - connect(m_process, &QProcess::started, - this, &ProjectExplorer::DeviceProcess::started); -} - -void GdbServerProviderProcess::start(const ProjectExplorer::Runnable &runnable) -{ - QTC_ASSERT(m_process->state() == QProcess::NotRunning, return); - m_process->setCommand(runnable.commandLine()); - m_process->start(); -} - -void GdbServerProviderProcess::interrupt() -{ - device()->signalOperation()->interruptProcess(m_process->processId()); -} - -void GdbServerProviderProcess::terminate() -{ - m_process->terminate(); -} - -void GdbServerProviderProcess::kill() -{ - m_process->kill(); -} - -QProcess::ProcessState GdbServerProviderProcess::state() const -{ - return m_process->state(); -} - -QProcess::ExitStatus GdbServerProviderProcess::exitStatus() const -{ - return m_process->exitStatus(); -} - -int GdbServerProviderProcess::exitCode() const -{ - return m_process->exitCode(); -} - -QString GdbServerProviderProcess::errorString() const -{ - return m_process->errorString(); -} - -QByteArray GdbServerProviderProcess::readAllStandardOutput() -{ - return m_process->readAllStandardOutput(); -} - -QByteArray GdbServerProviderProcess::readAllStandardError() -{ - return m_process->readAllStandardError(); -} - -qint64 GdbServerProviderProcess::write(const QByteArray &data) -{ - return m_process->write(data); -} - -} // namespace Internal -} // namespace BareMetal diff --git a/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.h b/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.h deleted file mode 100644 index bddb59fdcd8..00000000000 --- a/src/plugins/baremetal/debugservers/gdb/gdbserverproviderprocess.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 - -namespace Utils { class QtcProcess; } - -namespace BareMetal { -namespace Internal { - -// GdbServerProviderProcess - -class GdbServerProviderProcess final : public ProjectExplorer::DeviceProcess -{ - Q_OBJECT -public: - explicit GdbServerProviderProcess( - const QSharedPointer &device, - QObject *parent = nullptr); - - void start(const ProjectExplorer::Runnable &runnable) final; - void interrupt() final; - void terminate() final; - void kill() final; - - QProcess::ProcessState state() const final; - QProcess::ExitStatus exitStatus() const final; - int exitCode() const final; - QString errorString() const final; - - QByteArray readAllStandardOutput() final; - QByteArray readAllStandardError() final; - - qint64 write(const QByteArray &data) final; - -private: - Utils::QtcProcess *m_process = nullptr; -}; - -} // namespace Internal -} // namespace BareMetal diff --git a/src/plugins/baremetal/debugservers/gdb/gdbservers.pri b/src/plugins/baremetal/debugservers/gdb/gdbservers.pri index c04bd2e37db..d1371172116 100644 --- a/src/plugins/baremetal/debugservers/gdb/gdbservers.pri +++ b/src/plugins/baremetal/debugservers/gdb/gdbservers.pri @@ -1,7 +1,6 @@ HEADERS += \ $$PWD/defaultgdbserverprovider.h \ $$PWD/gdbserverprovider.h \ - $$PWD/gdbserverproviderprocess.h \ $$PWD/openocdgdbserverprovider.h \ $$PWD/stlinkutilgdbserverprovider.h \ $$PWD/jlinkgdbserverprovider.h \ @@ -9,7 +8,6 @@ HEADERS += \ SOURCES += \ $$PWD/defaultgdbserverprovider.cpp \ $$PWD/gdbserverprovider.cpp \ - $$PWD/gdbserverproviderprocess.cpp \ $$PWD/openocdgdbserverprovider.cpp \ $$PWD/stlinkutilgdbserverprovider.cpp \ $$PWD/jlinkgdbserverprovider.cpp \ diff --git a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp index d6203a24a80..39a2666599e 100644 --- a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp @@ -23,7 +23,6 @@ ** ****************************************************************************/ -#include "gdbserverproviderprocess.h" #include "jlinkgdbserverprovider.h" #include @@ -143,13 +142,6 @@ bool JLinkGdbServerProvider::isValid() const return true; } -ProjectExplorer::DeviceProcess *JLinkGdbServerProvider::createProcess( - const QSharedPointer &device, - QObject *parent) const -{ - return new GdbServerProviderProcess(device, parent); -} - GdbServerProvider *JLinkGdbServerProvider::clone() const { return new JLinkGdbServerProvider(*this); diff --git a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.h b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.h index 73afa4ed557..871f1a9b8d9 100644 --- a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.h +++ b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.h @@ -55,11 +55,6 @@ public: bool canStartupMode(StartupMode mode) const final; bool isValid() const final; - bool canCreateProcess() const final { return true; } - ProjectExplorer::DeviceProcess *createProcess( - const QSharedPointer &device, - QObject *parent = nullptr) const final; - private: explicit JLinkGdbServerProvider(); diff --git a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp index 2ba39b968ea..63fab5e3496 100644 --- a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp @@ -23,7 +23,6 @@ ** ****************************************************************************/ -#include "gdbserverproviderprocess.h" #include "openocdgdbserverprovider.h" #include @@ -150,13 +149,6 @@ bool OpenOcdGdbServerProvider::isValid() const return true; } -ProjectExplorer::DeviceProcess *OpenOcdGdbServerProvider::createProcess( - const QSharedPointer &device, - QObject *parent) const -{ - return new GdbServerProviderProcess(device, parent); -} - GdbServerProvider *OpenOcdGdbServerProvider::clone() const { return new OpenOcdGdbServerProvider(*this); diff --git a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.h b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.h index 93b57d71873..d878231b07f 100644 --- a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.h +++ b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.h @@ -55,11 +55,6 @@ public: bool canStartupMode(StartupMode mode) const final; bool isValid() const final; - bool canCreateProcess() const final { return true; } - ProjectExplorer::DeviceProcess *createProcess( - const QSharedPointer &device, - QObject *parent = nullptr) const final; - private: explicit OpenOcdGdbServerProvider(); diff --git a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp index 6e526d9228d..3f40009ab3d 100644 --- a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp @@ -23,7 +23,6 @@ ** ****************************************************************************/ -#include "gdbserverproviderprocess.h" #include "stlinkutilgdbserverprovider.h" #include @@ -143,13 +142,6 @@ bool StLinkUtilGdbServerProvider::isValid() const return true; } -ProjectExplorer::DeviceProcess *StLinkUtilGdbServerProvider::createProcess( - const QSharedPointer &device, - QObject *parent) const -{ - return new GdbServerProviderProcess(device, parent); -} - GdbServerProvider *StLinkUtilGdbServerProvider::clone() const { return new StLinkUtilGdbServerProvider(*this); diff --git a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.h b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.h index b5934e77c94..69503610d80 100644 --- a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.h +++ b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.h @@ -58,11 +58,6 @@ public: bool canStartupMode(StartupMode mode) const final; bool isValid() const final; - bool canCreateProcess() const final { return true; } - ProjectExplorer::DeviceProcess *createProcess( - const QSharedPointer &device, - QObject *parent = nullptr) const final; - private: explicit StLinkUtilGdbServerProvider(); explicit StLinkUtilGdbServerProvider(const StLinkUtilGdbServerProvider &); diff --git a/src/plugins/baremetal/idebugserverprovider.h b/src/plugins/baremetal/idebugserverprovider.h index 638b997bff3..dac8530a626 100644 --- a/src/plugins/baremetal/idebugserverprovider.h +++ b/src/plugins/baremetal/idebugserverprovider.h @@ -45,7 +45,6 @@ class DebuggerRunTool; } namespace ProjectExplorer { -class DeviceProcess; class IDevice; class RunControl; class RunWorker; @@ -87,11 +86,6 @@ public: virtual bool isValid() const = 0; - virtual bool canCreateProcess() const { return false; } - virtual ProjectExplorer::DeviceProcess *createProcess( - const QSharedPointer &, - QObject *) const { return nullptr; } - void registerDevice(BareMetalDevice *device); void unregisterDevice(BareMetalDevice *device);