Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
0a3d0ba6
Commit
0a3d0ba6
authored
Sep 23, 2011
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pull the ObjectInspector out of the memory-viewer and into pyrasite.inspect
parent
74675f8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
17 deletions
+40
-17
pyrasite/inspect.py
pyrasite/inspect.py
+36
-0
tools/memory-viewer.py
tools/memory-viewer.py
+4
-17
No files found.
pyrasite/inspect.py
0 → 100644
View file @
0a3d0ba6
# This file is part of pyrasite.
#
# pyrasite is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyrasite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyrasite. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2011 Red Hat, Inc.
import
subprocess
class
ObjectInspector
(
object
):
"""Inspects objects in a running Python program"""
def
__init__
(
self
,
pid
):
self
.
pid
=
pid
def
inspect
(
self
,
address
):
cmd
=
[
'gdb --quiet -p %s -batch'
%
self
.
pid
,
'-eval-command="print (PyObject *)%s"'
%
address
,
]
p
=
subprocess
.
Popen
(
' '
.
join
(
cmd
),
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
for
line
in
out
.
split
(
'
\
n
'
):
if
line
.
startswith
(
'$1 = '
):
return
line
[
5
:]
tools/memory-viewer.py
View file @
0a3d0ba6
...
@@ -26,12 +26,13 @@ the value of the object itself.
...
@@ -26,12 +26,13 @@ the value of the object itself.
__version__
=
'1.0'
__version__
=
'1.0'
import
sys
import
sys
import
subprocess
import
urwid
import
urwid
import
urwid.raw_display
import
urwid.raw_display
from
meliae
import
loader
from
meliae
import
loader
from
pyrasite.inspect
import
ObjectInspector
class
PyrasiteMemoryViewer
(
object
):
class
PyrasiteMemoryViewer
(
object
):
palette
=
[
palette
=
[
(
'body'
,
'black'
,
'light gray'
,
'standout'
),
(
'body'
,
'black'
,
'light gray'
,
'standout'
),
...
@@ -45,7 +46,7 @@ class PyrasiteMemoryViewer(object):
...
@@ -45,7 +46,7 @@ class PyrasiteMemoryViewer(object):
]
]
def
__init__
(
self
,
pid
,
objects
):
def
__init__
(
self
,
pid
,
objects
):
self
.
pid
=
pid
self
.
inspector
=
ObjectInspector
(
pid
)
self
.
objects
=
objects
self
.
objects
=
objects
self
.
summary
=
objects
.
summarize
()
self
.
summary
=
objects
.
summarize
()
...
@@ -65,21 +66,7 @@ class PyrasiteMemoryViewer(object):
...
@@ -65,21 +66,7 @@ class PyrasiteMemoryViewer(object):
def
display_object
(
self
,
w
,
state
):
def
display_object
(
self
,
w
,
state
):
if
state
:
if
state
:
cmd
=
[
value
=
self
.
inspector
.
inspect
(
w
.
obj
.
max_address
)
'gdb --quiet -p %s -batch'
%
self
.
pid
,
'-eval-command="print (PyObject *)%s"'
%
w
.
obj
.
max_address
,
]
p
=
subprocess
.
Popen
(
' '
.
join
(
cmd
),
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
if
err
:
print
"Errors:"
,
err
value
=
''
for
line
in
out
.
split
(
'
\
n
'
):
if
line
.
startswith
(
'$1 = '
):
value
+=
line
[
5
:]
self
.
object_output
.
set_text
(
value
)
self
.
object_output
.
set_text
(
value
)
def
get_object_buttons
(
self
,
group
=
[]):
def
get_object_buttons
(
self
,
group
=
[]):
...
...
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