Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
59b75c3b
Commit
59b75c3b
authored
Nov 13, 2010
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'cy exec' and 'py-exec' multiline code support
parent
4f208e13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
Cython/Debugger/libcython.py
Cython/Debugger/libcython.py
+3
-2
Cython/Debugger/libpython.py
Cython/Debugger/libpython.py
+24
-3
No files found.
Cython/Debugger/libcython.py
View file @
59b75c3b
...
...
@@ -1099,7 +1099,7 @@ class CyGlobals(CyLocals):
prefix
=
' '
)
class
CyExec
(
CythonCommand
):
class
CyExec
(
CythonCommand
,
libpython
.
PyExec
):
name
=
'-cy-exec'
command_class
=
gdb
.
COMMAND_STACK
completer_class
=
gdb
.
COMPLETE_NONE
...
...
@@ -1153,6 +1153,7 @@ class CyExec(CythonCommand):
libpython
.
py_exec
.
invoke
(
expr
,
from_tty
)
return
expr
,
input_type
=
self
.
readcode
(
expr
)
executor
=
libpython
.
PythonCodeExecutor
()
# get the dict of Cython globals and construct a dict in the inferior
...
...
@@ -1163,7 +1164,7 @@ class CyExec(CythonCommand):
try
:
self
.
_fill_locals_dict
(
executor
,
libpython
.
pointervalue
(
local_dict
))
executor
.
evalcode
(
expr
,
global_dict
,
local_dict
)
executor
.
evalcode
(
expr
,
input_type
,
global_dict
,
local_dict
)
finally
:
executor
.
decref
(
libpython
.
pointervalue
(
local_dict
))
...
...
Cython/Debugger/libpython.py
View file @
59b75c3b
...
...
@@ -1901,6 +1901,7 @@ py_cont = PyCont('py-cont')
py_step.init_breakpoints()
Py_single_input = 256
Py_file_input = 257
Py_eval_input = 258
def pointervalue(gdbval):
...
...
@@ -1961,7 +1962,7 @@ class PythonCodeExecutor(object):
# Python strings.
gdb.parse_and_eval('Py_DecRef((PyObject *) %d)' % pointer)
def evalcode(self, code, global_dict=None, local_dict=None):
def evalcode(self, code,
input_type,
global_dict=None, local_dict=None):
"""
Evaluate
python
code
`code`
given
as
a
string
in
the
inferior
and
return
the
result
as
a
gdb
.
Value
.
Returns
a
new
reference
in
the
...
...
@@ -1989,7 +1990,7 @@ class PythonCodeExecutor(object):
(
int
)
%
(
start
)
d
,
(
PyObject
*
)
%
(
globals
)
s
,
(
PyObject
*
)
%
(
locals
)
d
)
""" % dict(code=pointer, start=
Py_single_input
,
""" % dict(code=pointer, start=
input_type
,
globals=globalsp, locals=localsp)
with FetchAndRestoreError():
...
...
@@ -2077,7 +2078,27 @@ class FixGdbCommand(gdb.Command):
class PyExec(gdb.Command):
def readcode(self, expr):
if expr:
return expr, Py_single_input
else:
lines = []
while True:
try:
line = raw_input('>')
except EOFError:
break
else:
if line.rstrip() == 'end':
break
lines.append(line)
return '
\
n
'.join(lines), Py_file_input
def invoke(self, expr, from_tty):
expr, input_type = self.readcode(expr)
executor = PythonCodeExecutor()
global_dict = gdb.parse_and_eval('PyEval_GetGlobals()')
local_dict = gdb.parse_and_eval('PyEval_GetLocals()')
...
...
@@ -2087,7 +2108,7 @@ class PyExec(gdb.Command):
"most recent Python function (relative to the "
"selected frame).")
executor.evalcode(expr, global_dict, local_dict)
executor.evalcode(expr,
input_type,
global_dict, local_dict)
py_exec = FixGdbCommand('py-exec', '-py-exec')
_py_exec = PyExec("-py-exec", gdb.COMMAND_DATA, gdb.COMPLETE_NONE)
\ No newline at end of file
Write
Preview
Markdown
is supported
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