Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
400eecf4
Commit
400eecf4
authored
Apr 23, 2010
by
hjk
Browse files
debugger: some work on python
parent
010b7361
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debugger.pro
View file @
400eecf4
...
...
@@ -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
src/plugins/debugger/debuggermanager.cpp
View file @
400eecf4
...
...
@@ -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
);
...
...
src/plugins/debugger/debuggermanager.h
View file @
400eecf4
...
...
@@ -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
;
...
...
src/plugins/debugger/pdb/pdb.pri
0 → 100644
View file @
400eecf4
HEADERS += \
$$PWD/pdbengine.h \
SOURCES += \
$$PWD/pdbengine.cpp \
FORMS +=
RESOURCES +=
src/plugins/debugger/pdb/pdbengine.cpp
0 → 100644
View file @
400eecf4
This diff is collapsed.
Click to expand it.
src/plugins/debugger/pdb/pdbengine.h
0 → 100644
View file @
400eecf4
/**************************************************************************
**
** 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
src/plugins/debugger/script/scriptengine.cpp
View file @
400eecf4
...
...
@@ -550,7 +550,7 @@ void ScriptEngine::setToolTipExpression(const QPoint &mousePos,
void
ScriptEngine
::
assignValueInDebugger
(
const
QString
&
expression
,
const
QString
&
value
)
{
X
SDEBUG
(
"ASSIGNING: "
<<
(
expression
+
QLatin1Char
(
'='
)
+
value
));
SDEBUG
(
"ASSIGNING: "
<<
(
expression
+
QLatin1Char
(
'='
)
+
value
));
m_scriptEngine
->
evaluate
(
expression
+
QLatin1Char
(
'='
)
+
value
);
updateLocals
();
}
...
...
tests/manual/gdbdebugger/python/math.py
0 → 100644
View file @
400eecf4
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
()
tests/manual/gdbdebugger/python/python.pro
0 → 100644
View file @
400eecf4
TEMPLATE
=
script
TARGET
=
math
.
py
SOURCES
+=
math
.
py
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment