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
a17d1e8e
Commit
a17d1e8e
authored
Sep 10, 2016
by
KarimAllah Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opensnoop: Refactor initial timestamp calculation
Signed-off-by:
KarimAllah Ahmed
<
karim.allah.ahmed@gmail.com
>
parent
0eb81fd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
19 deletions
+8
-19
tools/opensnoop.py
tools/opensnoop.py
+8
-19
No files found.
tools/opensnoop.py
View file @
a17d1e8e
...
@@ -129,9 +129,7 @@ class Data(ct.Structure):
...
@@ -129,9 +129,7 @@ class Data(ct.Structure):
(
"fname"
,
ct
.
c_char
*
NAME_MAX
)
(
"fname"
,
ct
.
c_char
*
NAME_MAX
)
]
]
start_ts
=
0
initial_ts
=
0
prev_ts
=
0
delta
=
0
# header
# header
if
args
.
timestamp
:
if
args
.
timestamp
:
...
@@ -141,9 +139,7 @@ print("%-6s %-16s %4s %3s %s" % ("PID", "COMM", "FD", "ERR", "PATH"))
...
@@ -141,9 +139,7 @@ print("%-6s %-16s %4s %3s %s" % ("PID", "COMM", "FD", "ERR", "PATH"))
# process event
# process event
def
print_event
(
cpu
,
data
,
size
):
def
print_event
(
cpu
,
data
,
size
):
event
=
ct
.
cast
(
data
,
ct
.
POINTER
(
Data
)).
contents
event
=
ct
.
cast
(
data
,
ct
.
POINTER
(
Data
)).
contents
global
start_ts
global
initial_ts
global
prev_ts
global
delta
# split return value into FD and errno columns
# split return value into FD and errno columns
if
event
.
ret
>=
0
:
if
event
.
ret
>=
0
:
...
@@ -153,26 +149,19 @@ def print_event(cpu, data, size):
...
@@ -153,26 +149,19 @@ def print_event(cpu, data, size):
fd_s
=
-
1
fd_s
=
-
1
err
=
-
event
.
ret
err
=
-
event
.
ret
if
start_ts
==
0
:
if
not
initial_ts
:
prev_ts
=
start_
ts
initial_ts
=
event
.
ts
if
start_ts
==
1
:
if
args
.
failed
and
(
event
.
ret
>=
0
):
delta
=
float
(
delta
)
+
(
event
.
ts
-
prev_ts
)
if
(
args
.
failed
and
(
event
.
ret
>=
0
)):
start_ts
=
1
prev_ts
=
event
.
ts
return
return
if
args
.
timestamp
:
if
args
.
timestamp
:
print
(
"%-14.9f"
%
(
delta
/
1000000
),
end
=
""
)
delta
=
event
.
ts
-
initial_ts
print
(
"%-14.9f"
%
(
float
(
delta
)
/
1000000
),
end
=
""
)
print
(
"%-6d %-16s %4d %3d %s"
%
(
event
.
pid
,
event
.
comm
,
print
(
"%-6d %-16s %4d %3d %s"
%
(
event
.
pid
,
event
.
comm
,
fd_s
,
err
,
event
.
fname
))
fd_s
,
err
,
event
.
fname
))
prev_ts
=
event
.
ts
start_ts
=
1
# loop with callback to print_event
# loop with callback to print_event
b
[
"events"
].
open_perf_buffer
(
print_event
)
b
[
"events"
].
open_perf_buffer
(
print_event
)
while
1
:
while
1
:
...
...
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