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):
...
@@ -653,18 +653,21 @@ class BPF(object):
fields (task, pid, cpu, flags, timestamp, msg) or None if no
fields (task, pid, cpu, flags, timestamp, msg) or None if no
line was read (nonblocking=True)
line was read (nonblocking=True)
"""
"""
while
True
:
try
:
line
=
self
.
trace_readline
(
nonblocking
)
while
True
:
if
not
line
and
nonblocking
:
return
(
None
,)
*
6
line
=
self
.
trace_readline
(
nonblocking
)
# don't print messages related to lost events
if
not
line
and
nonblocking
:
return
(
None
,)
*
6
if
line
.
startswith
(
"CPU:"
):
continue
# don't print messages related to lost events
task
=
line
[:
16
].
lstrip
()
if
line
.
startswith
(
"CPU:"
):
continue
line
=
line
[
17
:]
task
=
line
[:
16
].
lstrip
()
ts_end
=
line
.
find
(
":"
)
line
=
line
[
17
:]
pid
,
cpu
,
flags
,
ts
=
line
[:
ts_end
].
split
()
ts_end
=
line
.
find
(
":"
)
cpu
=
cpu
[
1
:
-
1
]
pid
,
cpu
,
flags
,
ts
=
line
[:
ts_end
].
split
()
msg
=
line
[
ts_end
+
4
:]
cpu
=
cpu
[
1
:
-
1
]
return
(
task
,
int
(
pid
),
int
(
cpu
),
flags
,
float
(
ts
),
msg
)
msg
=
line
[
ts_end
+
4
:]
return
(
task
,
int
(
pid
),
int
(
cpu
),
flags
,
float
(
ts
),
msg
)
except
KeyboardInterrupt
:
exit
()
def
trace_readline
(
self
,
nonblocking
=
False
):
def
trace_readline
(
self
,
nonblocking
=
False
):
"""trace_readline(nonblocking=False)
"""trace_readline(nonblocking=False)
...
@@ -693,15 +696,18 @@ class BPF(object):
...
@@ -693,15 +696,18 @@ class BPF(object):
example: trace_print(fmt="pid {1}, msg = {5}")
example: trace_print(fmt="pid {1}, msg = {5}")
"""
"""
while
True
:
try
:
if
fmt
:
while
True
:
fields
=
self
.
trace_fields
(
nonblocking
=
False
)
if
fmt
:
if
not
fields
:
continue
fields
=
self
.
trace_fields
(
nonblocking
=
False
)
line
=
fmt
.
format
(
*
fields
)
if
not
fields
:
continue
else
:
line
=
fmt
.
format
(
*
fields
)
line
=
self
.
trace_readline
(
nonblocking
=
False
)
else
:
print
(
line
)
line
=
self
.
trace_readline
(
nonblocking
=
False
)
sys
.
stdout
.
flush
()
print
(
line
)
sys
.
stdout
.
flush
()
except
KeyboardInterrupt
:
exit
()
@
staticmethod
@
staticmethod
def
_load_kallsyms
():
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