Changeset View
Changeset View
Standalone View
Standalone View
debuggers/common/midebuggerplugin.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Common code for MI debugger support | ||||
3 | * | ||||
4 | * Copyright 1999-2001 John Birch <jbb@kdevelop.org> | ||||
5 | * Copyright 2001 by Bernd Gehrmann <bernd@kdevelop.org> | ||||
6 | * Copyright 2007 Hamish Rodda <rodda@kde.org> | ||||
7 | * Copyright 2016 Aetf <aetf@unlimitedcodeworks.xyz> | ||||
8 | * | ||||
9 | * This program is free software; you can redistribute it and/or | ||||
10 | * modify it under the terms of the GNU General Public License as | ||||
11 | * published by the Free Software Foundation; either version 2 of | ||||
12 | * the License or (at your option) version 3 or any later version | ||||
13 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
14 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
15 | * defined in Section 14 of version 3 of the license. | ||||
16 | * | ||||
17 | * This program is distributed in the hope that it will be useful, | ||||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
20 | * GNU General Public License for more details. | ||||
21 | * | ||||
22 | * You should have received a copy of the GNU General Public License | ||||
23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
24 | * | ||||
25 | */ | ||||
26 | | ||||
27 | #ifndef MIDEBUGGERPLUGIN_H | ||||
28 | #define MIDEBUGGERPLUGIN_H | ||||
29 | | ||||
30 | #include <interfaces/iplugin.h> | ||||
31 | #include <interfaces/istatus.h> | ||||
32 | #include <interfaces/iuicontroller.h> | ||||
33 | #include <sublime/view.h> | ||||
34 | | ||||
35 | #include <QHash> | ||||
36 | | ||||
37 | class QDBusInterface; | ||||
38 | class QSignalMapper; | ||||
39 | class QUrl; | ||||
40 | | ||||
41 | namespace KDevelop { | ||||
42 | class Context; | ||||
43 | } | ||||
44 | | ||||
45 | namespace KDevMI { | ||||
46 | class MIDebugSession; | ||||
47 | class MIDebuggerPlugin : public KDevelop::IPlugin, public KDevelop::IStatus | ||||
48 | { | ||||
49 | Q_OBJECT | ||||
50 | Q_INTERFACES(KDevelop::IStatus) | ||||
51 | | ||||
52 | public: | ||||
53 | MIDebuggerPlugin(const QString& componentName, QObject *parent); | ||||
54 | ~MIDebuggerPlugin() override; | ||||
55 | | ||||
56 | void unload() override; | ||||
57 | KDevelop::ContextMenuExtension contextMenuExtension( KDevelop::Context* ) override; | ||||
58 | | ||||
59 | virtual MIDebugSession *createSession() const = 0; | ||||
60 | | ||||
61 | //BEGIN IStatus | ||||
62 | public: | ||||
63 | QString statusName() const override; | ||||
64 | | ||||
65 | Q_SIGNALS: | ||||
66 | void clearMessage(KDevelop::IStatus*) override; | ||||
67 | void showMessage(KDevelop::IStatus*, const QString & message, int timeout = 0) override; | ||||
68 | void hideProgress(KDevelop::IStatus*) override; | ||||
69 | void showProgress(KDevelop::IStatus*, int minimum, int maximum, int value) override; | ||||
70 | void showErrorMessage(const QString&, int) override; | ||||
71 | //END IStatus | ||||
72 | | ||||
73 | Q_SIGNALS: | ||||
74 | void reset(); | ||||
75 | void stopDebugger(); | ||||
76 | void attachTo(int pid); | ||||
77 | void coreFile(const QString& core); | ||||
78 | void runUntil(const QUrl &url, int line); | ||||
79 | void jumpTo(const QUrl &url, int line); | ||||
80 | void addWatchVariable(const QString& var); | ||||
81 | void evaluateExpression(const QString& expr); | ||||
82 | void raiseDebuggerConsoleViews(); | ||||
83 | | ||||
84 | protected Q_SLOTS: | ||||
85 | | ||||
86 | void slotDebugExternalProcess(QObject* interface); | ||||
87 | void slotExamineCore(); | ||||
88 | #ifdef KDEV_ENABLE_DBG_ATTACH_DIALOG | ||||
89 | void slotAttachProcess(); | ||||
90 | #endif | ||||
91 | | ||||
92 | void slotDBusServiceRegistered(const QString& service); | ||||
93 | void slotDBusServiceUnregistered(const QString& service); | ||||
94 | void slotCloseDrKonqi(); | ||||
95 | | ||||
96 | protected: | ||||
97 | void setupToolviews(); | ||||
98 | void setupActions(); | ||||
99 | void setupDBus(); | ||||
100 | | ||||
101 | void attachProcess(int pid); | ||||
102 | void showStatusMessage(const QString& msg, int timeout); | ||||
103 | | ||||
104 | private: | ||||
105 | QHash<QString, QDBusInterface*> m_drkonqis; | ||||
106 | QSignalMapper* m_drkonqiMap; | ||||
107 | QString m_drkonqi; | ||||
108 | }; | ||||
109 | | ||||
110 | template<class T, class Plugin = MIDebuggerPlugin> | ||||
111 | class DebuggerToolFactory : public KDevelop::IToolViewFactory | ||||
112 | { | ||||
113 | public: | ||||
114 | DebuggerToolFactory(Plugin * plugin, const QString &id, Qt::DockWidgetArea defaultArea) | ||||
115 | : m_plugin(plugin), m_id(id), m_defaultArea(defaultArea) | ||||
116 | {} | ||||
117 | | ||||
118 | QWidget* create(QWidget *parent = 0) override | ||||
119 | { | ||||
120 | return new T(m_plugin, parent); | ||||
121 | } | ||||
122 | | ||||
123 | QString id() const override | ||||
124 | { | ||||
125 | return m_id; | ||||
126 | } | ||||
127 | | ||||
128 | Qt::DockWidgetArea defaultPosition() override | ||||
129 | { | ||||
130 | return m_defaultArea; | ||||
131 | } | ||||
132 | | ||||
133 | void viewCreated(Sublime::View* view) override | ||||
134 | { | ||||
135 | if (view->widget()->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("requestRaise()")) != -1) | ||||
136 | QObject::connect(view->widget(), SIGNAL(requestRaise()), view, SLOT(requestRaise())); | ||||
137 | } | ||||
138 | | ||||
139 | /* At present, some debugger widgets (e.g. breakpoint) contain actions so that shortcuts | ||||
140 | work, but they don't need any toolbar. So, suppress toolbar action. */ | ||||
141 | QList<QAction*> toolBarActions(QWidget* viewWidget) const override | ||||
142 | { | ||||
143 | Q_UNUSED(viewWidget); | ||||
144 | return QList<QAction*>(); | ||||
145 | } | ||||
146 | | ||||
147 | private: | ||||
148 | Plugin * m_plugin; | ||||
149 | QString m_id; | ||||
150 | Qt::DockWidgetArea m_defaultArea; | ||||
151 | }; | ||||
152 | | ||||
153 | } // end of namespace KDevMI | ||||
154 | | ||||
155 | #endif // MIDEBUGGERPLUGIN_H |