Commit 400eecf4 authored by hjk's avatar hjk

debugger: some work on python

parent 010b7361
......@@ -100,6 +100,7 @@ LIBS *= -lole32 \
include(cdb/cdb.pri)
include(gdb/gdb.pri)
include(script/script.pri)
include(python/python.pri)
include(shared/shared.pri)
OTHER_FILES += Debugger.pluginspec
......@@ -155,6 +155,7 @@ namespace Internal {
IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
IDebuggerEngine *createPythonEngine(DebuggerManager *parent);
// The createWinEngine function takes a list of options pages it can add to.
// This allows for having a "enabled" toggle on the page independently
......@@ -250,6 +251,7 @@ void DebuggerStartParameters::clear()
static Debugger::Internal::IDebuggerEngine *gdbEngine = 0;
static Debugger::Internal::IDebuggerEngine *scriptEngine = 0;
static Debugger::Internal::IDebuggerEngine *winEngine = 0;
static Debugger::Internal::IDebuggerEngine *pythonEngine = 0;
struct DebuggerManagerPrivate
{
......@@ -647,8 +649,14 @@ QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTy
scriptEngine->addOptionPages(&rc);
}
if (enabledTypeFlags & PythonEngineType) {
pythonEngine = createPythonEngine(this);
//pythonEngine->addOptionPages(&rc);
}
d->m_engine = 0;
STATE_DEBUG(gdbEngine << winEngine << scriptEngine << rc.size());
STATE_DEBUG(gdbEngine << winEngine << scriptEngine
<< pythonEngine << rc.size());
return rc;
}
......@@ -842,6 +850,7 @@ void DebuggerManager::shutdown()
#define doDelete(ptr) delete ptr; ptr = 0
doDelete(scriptEngine);
doDelete(pythonEngine);
doDelete(gdbEngine);
doDelete(winEngine);
......@@ -1006,6 +1015,14 @@ static IDebuggerEngine *debuggerEngineForExecutable(const QString &executable,
return scriptEngine;
}
if (executable.endsWith(_(".py"))) {
if (!pythonEngine) {
*errorMessage = msgEngineNotAvailable("Python Engine");
return 0;
}
return pythonEngine;
}
#ifndef Q_OS_WIN
Q_UNUSED(settingsIdHint)
if (!gdbEngine) {
......@@ -1080,6 +1097,8 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
if (sp->executable.endsWith(_(".js")))
d->m_engine = scriptEngine;
else if (sp->executable.endsWith(_(".py")))
d->m_engine = pythonEngine;
else
d->m_engine = debuggerEngineForToolChain(sp->toolChainType);
......
......@@ -83,6 +83,7 @@ class WatchHandler;
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class PythonEngine;
class CdbDebugEngine;
class CdbDebugEnginePrivate;
struct DebuggerManagerActions;
......@@ -138,9 +139,11 @@ enum DebuggerEngineTypeFlags
GdbEngineType = 0x01,
ScriptEngineType = 0x02,
CdbEngineType = 0x04,
PythonEngineType = 0x08,
AllEngineTypes = GdbEngineType
| ScriptEngineType
| CdbEngineType
| PythonEngineType
};
QDebug operator<<(QDebug d, DebuggerState state);
......@@ -167,6 +170,7 @@ public:
friend class Internal::CdbExceptionLoggerEventCallback;
friend class Internal::GdbEngine;
friend class Internal::ScriptEngine;
friend class Internal::PythonEngine;
friend class Internal::CdbDebugEngine;
friend class Internal::CdbDebugEnginePrivate;
friend class Internal::TrkGdbAdapter;
......
HEADERS += \
$$PWD/pdbengine.h \
SOURCES += \
$$PWD/pdbengine.cpp \
FORMS +=
RESOURCES +=
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef DEBUGGER_PDBENGINE_H
#define DEBUGGER_PDBENGINE_H
#include "idebuggerengine.h"
#include <QtCore/QProcess>
#include <QtCore/QQueue>
#include <QtCore/QVariant>
namespace Debugger {
namespace Internal {
class WatchData;
class GdbMi;
/* A debugger engine for Python using the pdb command line debugger.
*/
class PdbResponse
{
public:
QByteArray data;
QVariant cookie;
};
class PdbEngine : public IDebuggerEngine
{
Q_OBJECT
public:
PdbEngine(DebuggerManager *manager);
~PdbEngine();
private:
// IDebuggerEngine implementation
void executeStep();
void executeStepOut();
void executeNext();
void executeStepI();
void executeNextI();
void shutdown();
void setToolTipExpression(const QPoint &mousePos,
TextEditor::ITextEditor *editor, int cursorPos);
void startDebugger(const DebuggerStartParametersPtr &sp);
void exitDebugger();
void continueInferior();
Q_SLOT void runInferior();
void interruptInferior();
void executeRunToLine(const QString &fileName, int lineNumber);
void executeRunToFunction(const QString &functionName);
void executeJumpToLine(const QString &fileName, int lineNumber);
void activateFrame(int index);
void selectThread(int index);
void attemptBreakpointSynchronization();
void assignValueInDebugger(const QString &expr, const QString &value);
void executeDebuggerCommand(const QString & command);
void loadSymbols(const QString &moduleName);
void loadAllSymbols();
virtual QList<Symbol> moduleSymbols(const QString &moduleName);
void reloadModules();
void reloadRegisters() {}
void reloadSourceFiles() {}
void reloadFullStack() {}
bool supportsThreads() const { return true; }
bool isSynchroneous() const { return true; }
void updateWatchData(const WatchData &data);
private:
void debugMessage(const QString &msg);
QString errorMessage(QProcess::ProcessError error) const;
Q_SLOT void handlePdbFinished(int, QProcess::ExitStatus status);
Q_SLOT void handlePdbError(QProcess::ProcessError error);
Q_SLOT void readPdbStandardOutput();
Q_SLOT void readPdbStandardError();
void handleResponse(const QByteArray &ba);
void updateAll();
void handleUpdateAll(const PdbResponse &response);
typedef void (PdbEngine::*PdbCommandCallback)
(const PdbResponse &response);
struct PdbCommand
{
PdbCommand()
: callback(0), callbackName(0)
{}
PdbCommandCallback callback;
const char *callbackName;
QByteArray command;
QVariant cookie;
//QTime postTime;
};
void handleStop(const PdbResponse &response);
void handleBacktrace(const PdbResponse &response);
void handleListLocals(const PdbResponse &response);
void handleLoadDumper(const PdbResponse &response);
void handleBreakInsert(const PdbResponse &response);
void handleChildren(const WatchData &data0, const GdbMi &item,
QList<WatchData> *list);
void postCommand(const QByteArray &command,
//GdbCommandFlags flags = 0,
PdbCommandCallback callback = 0,
const char *callbackName = 0,
const QVariant &cookie = QVariant());
QQueue<PdbCommand> m_commands;
QByteArray m_inbuffer;
QString m_scriptFileName;
QProcess m_pdbProc;
QString m_pdb;
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_PDBENGINE_H
......@@ -550,7 +550,7 @@ void ScriptEngine::setToolTipExpression(const QPoint &mousePos,
void ScriptEngine::assignValueInDebugger(const QString &expression,
const QString &value)
{
XSDEBUG("ASSIGNING: " << (expression + QLatin1Char('=') + value));
SDEBUG("ASSIGNING: " << (expression + QLatin1Char('=') + value));
m_scriptEngine->evaluate(expression + QLatin1Char('=') + value);
updateLocals();
}
......
def square(a):
x = a * a
return a
def cube(a):
x = square(a)
x = x * a
x = x + 1
x = x - 1
return x
def main():
print cube(3)
print cube(4)
print cube(5)
if __name__ == '__main__':
main()
TEMPLATE = script
TARGET = math.py
SOURCES += math.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment