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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
298ea966
Commit
298ea966
authored
Mar 25, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debugger: Added 'cy set' command
parent
4e603550
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Cython/Debugger/Tests/test_libcython_in_gdb.py
Cython/Debugger/Tests/test_libcython_in_gdb.py
+10
-0
Cython/Debugger/libcython.py
Cython/Debugger/libcython.py
+24
-0
No files found.
Cython/Debugger/Tests/test_libcython_in_gdb.py
View file @
298ea966
...
...
@@ -379,6 +379,16 @@ class TestExec(DebugTestCase):
self
.
assertEqual
(
'14'
,
self
.
eval_command
(
'some_random_var'
))
class
CySet
(
DebugTestCase
):
def
test_cyset
(
self
):
self
.
break_and_run
(
'os.path.join("foo", "bar")'
)
gdb
.
execute
(
'cy set a = $cy_eval("{None: []}")'
)
stringvalue
=
self
.
read_var
(
"a"
,
cast_to
=
str
)
self
.
assertEqual
(
stringvalue
,
"{None: []}"
)
class
TestCyEval
(
DebugTestCase
):
"Test the $cy_eval() gdb function."
...
...
Cython/Debugger/libcython.py
View file @
298ea966
...
...
@@ -625,6 +625,7 @@ class CyCy(CythonCommand):
globals
=
CyGlobals
.
register
(),
exec_
=
libpython
.
FixGdbCommand
(
'cy exec'
,
'-cy-exec'
),
_exec
=
CyExec
.
register
(),
set
=
CySet
.
register
(),
# GDB functions
cy_cname
=
CyCName
(
'cy_cname'
),
...
...
@@ -1284,6 +1285,29 @@ class CyExec(CythonCommand, libpython.PyExec, EvaluateOrExecuteCodeMixin):
executor
.
xdecref
(
self
.
evalcode
(
expr
,
executor
.
Py_single_input
))
class
CySet
(
CythonCommand
):
"""
Set a Cython variable to a certain value
cy set my_cython_c_variable = 10
cy set my_cython_py_variable = $cy_eval("{'doner': 'kebab'}")
"""
name
=
'cy set'
command_class
=
gdb
.
COMMAND_DATA
completer_class
=
gdb
.
COMPLETE_NONE
@
require_cython_frame
def
invoke
(
self
,
expr
,
from_tty
):
name_and_expr
=
expr
.
split
(
'='
,
1
)
if
len
(
name_and_expr
)
!=
2
:
raise
gdb
.
GdbError
(
"Invalid expression. Use 'cy set var = expr'."
)
varname
,
expr
=
name_and_expr
cname
=
self
.
cy
.
cy_cname
.
invoke
(
varname
.
strip
())
gdb
.
execute
(
"set %s = %s"
%
(
cname
,
expr
))
# Functions
class
CyCName
(
gdb
.
Function
,
CythonBase
):
...
...
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