Files
qt-creator/src/plugins/baremetal/idebugserverprovider.h

152 lines
4.0 KiB
C
Raw Normal View History

BareMetal: Minimize dependency from GDB engine The problem is that this plugin was originally developed only for working with the GDB debugging engine. This hard dependency penetrates to all plugin logic, that excludes an easy addition of other types of a debugger engines. This patch tries to minimize the GDB dependency and improves code a bit in the following way: * A code that belongs to the GDB engine moved to the separate debugservers/gdb directory. * A classes having a common functionality are renamed with 'Debug' suffixes instead of 'Gdb' suffixes. * Introduced a new interface IDebugServerProvider{Factory|ConfigWidget} whih are used as a base for all derived debug servers providers (e.g. for the OpenOCD, STLink and etc). * The IDebugServerProvider interface has a new virtual engineType() method to show a supported debugger engine by a specific debugger server provider. This method is used in BareMetalDebugSupport class to detect a provider engine for an additional initialization (which depends on an used debugger engine). * The IDebugServerProvider interface has a new virtual hasProcess() method. E.g. this is required for a future debug server providers which has not a remote processes. In this case the BareMetalDevice::canCreateProcess() will report about that in a right way. Thus, this approach allowed us to preserve a previous behavior of an already implemented GDB providers. Also it makes possible to add a new providers in a future with a minimized costs. Change-Id: I1be84b9178d4aa78c3ef5108a9e6b381e245f36f Reviewed-by: hjk <hjk@qt.io>
2019-11-04 00:51:58 +03:00
/****************************************************************************
**
** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
** 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 <QObject>
#include <QSet>
#include <QVariantMap>
#include <QWidget>
#include <coreplugin/id.h>
#include <debugger/debuggerconstants.h>
#include <utils/fileutils.h>
QT_BEGIN_NAMESPACE
class QFormLayout;
class QLabel;
class QLineEdit;
QT_END_NAMESPACE
namespace BareMetal {
namespace Internal {
class BareMetalDevice;
class IDebugServerProviderConfigWidget;
// IDebugServerProvider
class IDebugServerProvider
{
public:
virtual ~IDebugServerProvider();
QString displayName() const;
void setDisplayName(const QString &name);
QString id() const;
QString typeDisplayName() const;
virtual bool operator==(const IDebugServerProvider &other) const;
virtual IDebugServerProviderConfigWidget *configurationWidget() = 0;
virtual IDebugServerProvider *clone() const = 0;
virtual QVariantMap toMap() const;
virtual bool isValid() const = 0;
virtual bool hasProcess() const { return false; }
virtual Debugger::DebuggerEngineType engineType() const = 0;
void registerDevice(BareMetalDevice *device);
void unregisterDevice(BareMetalDevice *device);
protected:
explicit IDebugServerProvider(const QString &id);
explicit IDebugServerProvider(const IDebugServerProvider &provider);
void setTypeDisplayName(const QString &typeDisplayName);
void providerUpdated();
virtual bool fromMap(const QVariantMap &data);
QString m_id;
mutable QString m_displayName;
QString m_typeDisplayName;
QSet<BareMetalDevice *> m_devices;
friend class IDebugServerProviderConfigWidget;
};
// IDebugServerProviderFactory
class IDebugServerProviderFactory : public QObject
{
Q_OBJECT
public:
QString id() const;
QString displayName() const;
virtual IDebugServerProvider *create() = 0;
virtual bool canRestore(const QVariantMap &data) const = 0;
virtual IDebugServerProvider *restore(const QVariantMap &data) = 0;
static QString idFromMap(const QVariantMap &data);
static void idToMap(QVariantMap &data, const QString &id);
protected:
void setId(const QString &id);
void setDisplayName(const QString &name);
private:
QString m_displayName;
QString m_id;
};
// IDebugServerProviderConfigWidget
class IDebugServerProviderConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit IDebugServerProviderConfigWidget(IDebugServerProvider *provider);
virtual void apply();
virtual void discard();
signals:
void dirty();
protected:
void setErrorMessage(const QString &);
void clearErrorMessage();
void addErrorLabel();
void setFromProvider();
IDebugServerProvider *m_provider = nullptr;
QFormLayout *m_mainLayout = nullptr;
QLineEdit *m_nameLineEdit = nullptr;
QLabel *m_errorLabel = nullptr;
};
} // namespace Internal
} // namespace BareMetal