Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
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
Kirill Smelkov
bcc
Commits
3dfaf983
Commit
3dfaf983
authored
Oct 06, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #262 from iovisor/bblanco_dev
Make KeyboardInterrupt catch more aggressive
parents
0b904997
d0c31819
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+27
-21
No files found.
src/python/bcc/__init__.py
View file @
3dfaf983
...
...
@@ -653,18 +653,21 @@ class BPF(object):
fields (task, pid, cpu, flags, timestamp, msg) or None if no
line was read (nonblocking=True)
"""
while
True
:
line
=
self
.
trace_readline
(
nonblocking
)
if
not
line
and
nonblocking
:
return
(
None
,)
*
6
# don't print messages related to lost events
if
line
.
startswith
(
"CPU:"
):
continue
task
=
line
[:
16
].
lstrip
()
line
=
line
[
17
:]
ts_end
=
line
.
find
(
":"
)
pid
,
cpu
,
flags
,
ts
=
line
[:
ts_end
].
split
()
cpu
=
cpu
[
1
:
-
1
]
msg
=
line
[
ts_end
+
4
:]
return
(
task
,
int
(
pid
),
int
(
cpu
),
flags
,
float
(
ts
),
msg
)
try
:
while
True
:
line
=
self
.
trace_readline
(
nonblocking
)
if
not
line
and
nonblocking
:
return
(
None
,)
*
6
# don't print messages related to lost events
if
line
.
startswith
(
"CPU:"
):
continue
task
=
line
[:
16
].
lstrip
()
line
=
line
[
17
:]
ts_end
=
line
.
find
(
":"
)
pid
,
cpu
,
flags
,
ts
=
line
[:
ts_end
].
split
()
cpu
=
cpu
[
1
:
-
1
]
msg
=
line
[
ts_end
+
4
:]
return
(
task
,
int
(
pid
),
int
(
cpu
),
flags
,
float
(
ts
),
msg
)
except
KeyboardInterrupt
:
exit
()
def
trace_readline
(
self
,
nonblocking
=
False
):
"""trace_readline(nonblocking=False)
...
...
@@ -693,15 +696,18 @@ class BPF(object):
example: trace_print(fmt="pid {1}, msg = {5}")
"""
while
True
:
if
fmt
:
fields
=
self
.
trace_fields
(
nonblocking
=
False
)
if
not
fields
:
continue
line
=
fmt
.
format
(
*
fields
)
else
:
line
=
self
.
trace_readline
(
nonblocking
=
False
)
print
(
line
)
sys
.
stdout
.
flush
()
try
:
while
True
:
if
fmt
:
fields
=
self
.
trace_fields
(
nonblocking
=
False
)
if
not
fields
:
continue
line
=
fmt
.
format
(
*
fields
)
else
:
line
=
self
.
trace_readline
(
nonblocking
=
False
)
print
(
line
)
sys
.
stdout
.
flush
()
except
KeyboardInterrupt
:
exit
()
@
staticmethod
def
_load_kallsyms
():
...
...
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