Files
qt-creator/src/plugins/debugger/watchhandler.h

111 lines
3.0 KiB
C
Raw Normal View History

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
2008-12-02 15:08:31 +01:00
#pragma once
2008-12-02 12:01:29 +01:00
#include "watchdata.h"
#include "debuggerengine.h"
#include <QVector>
namespace Debugger {
namespace Internal {
class DebuggerCommand;
class DebuggerEngine;
class WatchModel;
using DisplayFormats = QVector<DisplayFormat>;
class WatchModelBase : public Utils::TreeModel<WatchItem, WatchItem>
{
Q_OBJECT
public:
WatchModelBase() = default;
enum { NameColumn, TimeColumn, ValueColumn, TypeColumn };
signals:
void currentIndexRequested(const QModelIndex &idx);
void itemIsExpanded(const QModelIndex &idx);
void inameIsExpanded(const QString &iname);
void updateStarted();
void updateFinished();
};
class WatchHandler
{
Q_DISABLE_COPY_MOVE(WatchHandler)
public:
explicit WatchHandler(DebuggerEngine *engine);
~WatchHandler();
WatchModelBase *model() const;
2008-12-02 12:01:29 +01:00
void cleanup();
void grabWidget(QWidget *viewParent);
void watchExpression(const QString &exp, const QString &name = QString(),
bool temporary = false);
void updateWatchExpression(WatchItem *item, const QString &newExp);
void watchVariable(const QString &exp);
2010-02-04 16:23:51 +01:00
const WatchItem *watchItem(const QModelIndex &) const;
void fetchMore(const QString &iname) const;
WatchItem *findItem(const QString &iname) const;
const WatchItem *findCppLocalVariable(const QString &name) const;
2008-12-02 12:01:29 +01:00
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>
2018-07-31 12:30:48 +02:00
void loadSessionDataForEngine();
bool isExpandedIName(const QString &iname) const;
QSet<QString> expandedINames() const;
2010-11-04 18:11:09 +01:00
static QStringList watchedExpressions();
static QMap<QString, int> watcherNames();
void appendFormatRequests(DebuggerCommand *cmd) const;
void appendWatchersAndTooltipRequests(DebuggerCommand *cmd) const;
QString typeFormatRequests() const;
QString individualFormatRequests() const;
2008-12-02 12:01:29 +01:00
int format(const QString &iname) const;
static QString nameForFormat(int format);
void addDumpers(const GdbMi &dumpers);
void addTypeFormats(const QString &type, const DisplayFormats &formats);
QString watcherName(const QString &exp);
void scheduleResetLocation();
void setCurrentItem(const QString &iname);
void updateLocalsWindow();
bool insertItem(WatchItem *item); // Takes ownership, returns whether item was added, not overwritten.
void insertItems(const GdbMi &data);
void removeItemByIName(const QString &iname);
void removeAllData(bool includeInspectData = false);
void resetValueCache();
void resetWatchers();
void notifyUpdateStarted(const UpdateParameters &updateParameters = UpdateParameters());
void notifyUpdateFinished();
void reexpandItems();
void recordTypeInfo(const GdbMi &typeInfo);
void setLocation(const Location &loc);
2008-12-02 12:01:29 +01:00
private:
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>
2018-07-31 12:30:48 +02:00
DebuggerEngine * const m_engine; // Not owned
WatchModel *m_model; // Owned.
2008-12-02 12:01:29 +01:00
};
} // namespace Internal
} // namespace Debugger
Q_DECLARE_METATYPE(Debugger::Internal::DisplayFormat)