Debugger: Make most views per-engine instead of singletons

This is a step towards properly supporting multiple debugger
sessions side-by-side.

The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.

Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.

Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.

The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.

There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.

The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.

There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.

Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2018-07-31 12:30:48 +02:00
parent d6911fd10c
commit 3b5ecac238
58 changed files with 6543 additions and 6100 deletions

View File

@@ -30,28 +30,44 @@
#include <utils/fancymainwindow.h>
#include <utils/statuslabel.h>
#include <QHBoxLayout>
#include <QAction>
#include <QPointer>
#include <QSet>
#include <QToolButton>
#include <functional>
QT_BEGIN_NAMESPACE
class QComboBox;
class QToolButton;
class QStackedWidget;
QT_END_NAMESPACE
namespace Core { class Id; }
namespace Core {
class Context;
class Id;
} // Core
namespace Utils {
class DEBUGGER_EXPORT Perspective
// To be used for actions that need hideable toolbuttons.
class DEBUGGER_EXPORT OptionalAction : public QAction
{
Q_OBJECT
public:
OptionalAction(const QString &text = QString());
~OptionalAction() override;
void setVisible(bool on);
void setToolButtonStyle(Qt::ToolButtonStyle style);
public:
QPointer<QToolButton> m_toolButton;
Qt::ToolButtonStyle m_toolButtonStyle = Qt::ToolButtonIconOnly;
};
class DEBUGGER_EXPORT Perspective : public QObject
{
Q_OBJECT
public:
enum OperationType { SplitVertical, SplitHorizontal, AddToTab, Raise };
explicit Perspective(const QByteArray &id, const QString &name);
explicit Perspective(const QString &id, const QString &name);
~Perspective();
void setCentralWidget(QWidget *centralWidget);
@@ -61,54 +77,36 @@ public:
bool visibleByDefault = true,
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
QToolButton *addToolbarAction(QAction *action, const QIcon &toolbarIcon = QIcon());
void addToolbarWidget(QWidget *widget);
void addToolBarAction(QAction *action);
void addToolBarAction(OptionalAction *action);
void addToolBarWidget(QWidget *widget);
void addToolbarSeparator();
QWidget *centralWidget() const;
QString name() const;
QString id() const;
using Callback = std::function<void()>;
void setAboutToActivateCallback(const Callback &cb);
void aboutToActivate() const;
QByteArray parentPerspective() const;
void setParentPerspective(const QByteArray &parentPerspective);
void setEnabled(bool enabled);
void destroy();
void select();
static Perspective *currentPerspective();
Core::Context context() const;
void showToolBar();
void hideToolBar();
private:
Perspective(const Perspective &) = delete;
void operator=(const Perspective &) = delete;
friend class DebuggerMainWindow;
friend class DebuggerMainWindowPrivate;
class PerspectivePrivate *d = nullptr;
class Operation
{
public:
QPointer<QWidget> widget;
QByteArray anchorDockId;
OperationType operationType = Raise;
bool visibleByDefault = true;
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea;
};
class ToolbarOperation
{
public:
QPointer<QWidget> widget; // Owned by plugin if present
QPointer<QAction> action; // Owned by plugin if present
QPointer<QToolButton> toolbutton; // Owned here in case action is used
QPointer<QWidget> separator;
QIcon icon;
};
const QByteArray m_id;
QString m_name;
QByteArray m_parentPerspective;
QVector<Operation> m_operations;
QPointer<QWidget> m_centralWidget;
Callback m_aboutToActivateCallback;
QVector<ToolbarOperation> m_toolbarOperations;
};
class DEBUGGER_EXPORT DebuggerMainWindow : public FancyMainWindow
@@ -120,42 +118,18 @@ public:
~DebuggerMainWindow() override;
void registerPerspective(Perspective *perspective);
void destroyDynamicPerspective(Perspective *perspective);
void resetCurrentPerspective();
void restorePerspective(Perspective *perspective);
void finalizeSetup();
void showStatusMessage(const QString &message, int timeoutMS);
void raiseDock(const QByteArray &dockId);
QByteArray currentPerspective() const;
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
void onModeChanged(Core::Id mode);
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled);
Perspective *findPerspective(const QByteArray &perspectiveId) const;
QWidget *centralWidgetStack();
private:
void closeEvent(QCloseEvent *) final { savePerspectiveHelper(m_currentPerspective); }
void closeEvent(QCloseEvent *) final;
void loadPerspectiveHelper(Perspective *perspective, bool fromStoredSettings = true);
void savePerspectiveHelper(const Perspective *perspective);
void increaseChooserWidthIfNecessary(const QString &visibleName);
int indexInChooser(Perspective *perspective) const;
Perspective *m_currentPerspective = nullptr;
QComboBox *m_perspectiveChooser = nullptr;
QHBoxLayout *m_toolbuttonBoxLayout = nullptr;
QStackedWidget *m_centralWidgetStack = nullptr;
QWidget *m_editorPlaceHolder = nullptr;
Utils::StatusLabel *m_statusLabel = nullptr;
QDockWidget *m_toolbarDock = nullptr;
QHash<QByteArray, QDockWidget *> m_dockForDockId;
QList<Perspective *> m_perspectives;
friend class Perspective;
friend class PerspectivePrivate;
class DebuggerMainWindowPrivate *d = nullptr;
};
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow);