OSDN Git Service

774026e2b27bcf644a58bb9f5f9344131e321d05
[qt-creator-jp/qt-creator-jp.git] / src / plugins / debugger / pdb / pdbengine.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef DEBUGGER_PDBENGINE_H
35 #define DEBUGGER_PDBENGINE_H
36
37 #include "debuggerengine.h"
38
39 #include <QtCore/QProcess>
40 #include <QtCore/QQueue>
41 #include <QtCore/QVariant>
42
43
44 namespace Debugger {
45 namespace Internal {
46
47 class WatchData;
48 class GdbMi;
49
50 /* A debugger engine for Python using the pdb command line debugger.
51  */
52
53 class PdbResponse
54 {
55 public:
56     QByteArray data;
57     QVariant cookie;
58 };
59
60 class PdbEngine : public DebuggerEngine
61 {
62     Q_OBJECT
63
64 public:
65     explicit PdbEngine(const DebuggerStartParameters &startParameters);
66     ~PdbEngine();
67
68 private:
69     // DebuggerEngine implementation
70     void executeStep();
71     void executeStepOut();
72     void executeNext();
73     void executeStepI();
74     void executeNextI();
75
76     void setupEngine();
77     void setupInferior();
78     void runEngine();
79     void shutdownInferior();
80     void shutdownEngine();
81
82     bool setToolTipExpression(const QPoint &mousePos,
83         TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
84
85     void continueInferior();
86     void interruptInferior();
87
88     void executeRunToLine(const ContextData &data);
89     void executeRunToFunction(const QString &functionName);
90     void executeJumpToLine(const ContextData &data);
91
92     void activateFrame(int index);
93     void selectThread(int index);
94
95     bool acceptsBreakpoint(BreakpointId id) const;
96     void insertBreakpoint(BreakpointId id);
97     void removeBreakpoint(BreakpointId id);
98
99     void assignValueInDebugger(const WatchData *data,
100         const QString &expr, const QVariant &value);
101     void executeDebuggerCommand(const QString &command);
102
103     void loadSymbols(const QString &moduleName);
104     void loadAllSymbols();
105     void requestModuleSymbols(const QString &moduleName);
106     void reloadModules();
107     void reloadRegisters() {}
108     void reloadSourceFiles() {}
109     void reloadFullStack() {}
110
111     bool supportsThreads() const { return true; }
112     bool isSynchronous() const { return true; }
113     void updateWatchData(const WatchData &data, const WatchUpdateFlags &flags);
114
115 signals:
116     void outputReady(const QByteArray &data);
117
118 private:
119     QString errorMessage(QProcess::ProcessError error) const;
120     unsigned debuggerCapabilities() const;
121
122     Q_SLOT void handlePdbFinished(int, QProcess::ExitStatus status);
123     Q_SLOT void handlePdbError(QProcess::ProcessError error);
124     Q_SLOT void readPdbStandardOutput();
125     Q_SLOT void readPdbStandardError();
126     Q_SLOT void handleOutput2(const QByteArray &data);
127     void handleResponse(const QByteArray &ba);
128     void handleOutput(const QByteArray &data);
129     void updateAll();
130     void updateLocals();
131     void handleUpdateAll(const PdbResponse &response);
132     void handleFirstCommand(const PdbResponse &response);
133     void handleExecuteDebuggerCommand(const PdbResponse &response);
134
135     typedef void (PdbEngine::*PdbCommandCallback)
136         (const PdbResponse &response);
137
138     struct PdbCommand
139     {
140         PdbCommand()
141             : callback(0), callbackName(0)
142         {}
143
144         PdbCommandCallback callback;
145         const char *callbackName;
146         QByteArray command;
147         QVariant cookie;
148         //QTime postTime;
149     };
150
151     void handleStop(const PdbResponse &response);
152     void handleBacktrace(const PdbResponse &response);
153     void handleListLocals(const PdbResponse &response);
154     void handleListModules(const PdbResponse &response);
155     void handleListSymbols(const PdbResponse &response);
156     void handleBreakInsert(const PdbResponse &response);
157
158     void handleChildren(const WatchData &data0, const GdbMi &item,
159         QList<WatchData> *list);
160     void postCommand(const QByteArray &command,
161                      //GdbCommandFlags flags = 0,
162                      PdbCommandCallback callback = 0,
163                      const char *callbackName = 0,
164                      const QVariant &cookie = QVariant());
165     void postDirectCommand(const QByteArray &command);
166
167     QQueue<PdbCommand> m_commands;
168
169     QByteArray m_inbuffer; 
170     QString m_scriptFileName;
171     QProcess m_pdbProc;
172     QString m_pdb;
173 };
174
175 } // namespace Internal
176 } // namespace Debugger
177
178 #endif // DEBUGGER_PDBENGINE_H