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
5f354e5a
Commit
5f354e5a
authored
Feb 15, 2017
by
Brenden Blanco
Committed by
GitHub
Feb 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #974 from r4f4/fix-undo
Revert "undo rebase"
parents
a46c36ae
af236e7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
tools/argdist.py
tools/argdist.py
+12
-10
tools/cpudist.py
tools/cpudist.py
+1
-1
No files found.
tools/argdist.py
View file @
5f354e5a
...
...
@@ -20,7 +20,7 @@ import sys
class
Probe
(
object
):
next_probe_index
=
0
streq_index
=
0
aliases
=
{
"$PID"
:
"
bpf_get_current_pid_tgid(
)"
}
aliases
=
{
"$PID"
:
"
(bpf_get_current_pid_tgid() >> 32
)"
}
def
_substitute_aliases
(
self
,
expr
):
if
expr
is
None
:
...
...
@@ -47,7 +47,9 @@ class Probe(object):
text
=
"""
int PROBENAME(struct pt_regs *ctx SIGNATURE)
{
u32 pid = bpf_get_current_pid_tgid();
u64 __pid_tgid = bpf_get_current_pid_tgid();
u32 __pid = __pid_tgid; // lower 32 bits
u32 __tgid = __pid_tgid >> 32; // upper 32 bits
PID_FILTER
COLLECT
return 0;
...
...
@@ -56,19 +58,17 @@ int PROBENAME(struct pt_regs *ctx SIGNATURE)
text
=
text
.
replace
(
"PROBENAME"
,
self
.
entry_probe_func
)
text
=
text
.
replace
(
"SIGNATURE"
,
""
if
len
(
self
.
signature
)
==
0
else
", "
+
self
.
signature
)
pid_filter
=
""
if
self
.
is_user
or
self
.
pid
is
None
\
else
"if (pid != %d) { return 0; }"
%
self
.
pid
text
=
text
.
replace
(
"PID_FILTER"
,
pid_filter
)
text
=
text
.
replace
(
"PID_FILTER"
,
self
.
_generate_pid_filter
())
collect
=
""
for
pname
in
self
.
args_to_probe
:
param_hash
=
self
.
hashname_prefix
+
pname
if
pname
==
"__latency"
:
collect
+=
"""
u64 __time = bpf_ktime_get_ns();
%s.update(&pid, &__time);
%s.update(&
__
pid, &__time);
"""
%
param_hash
else
:
collect
+=
"%s.update(&pid, &%s);
\
n
"
%
\
collect
+=
"%s.update(&
__
pid, &%s);
\
n
"
%
\
(
param_hash
,
pname
)
text
=
text
.
replace
(
"COLLECT"
,
collect
)
return
text
...
...
@@ -108,7 +108,7 @@ u64 __time = bpf_ktime_get_ns();
# argument we needed to probe using $entry(name), and they all
# have values (which isn't necessarily the case if we missed
# the method entry probe).
text = "
u32
__pid
=
bpf_get_current_pid_tgid
();
\
n
"
text = ""
self.param_val_names = {}
for pname in self.args_to_probe:
val_name = "
__
%
s_val
" % pname
...
...
@@ -345,8 +345,7 @@ static inline bool %s(char const *ignored, char const *str) {
# Kernel probes need to explicitly filter pid, because the
# attach interface doesn't support pid filtering
if
self
.
pid
is
not
None
and
not
self
.
is_user
:
return
"u32 pid = bpf_get_current_pid_tgid();
\
n
"
+
\
"if (pid != %d) { return 0; }"
%
self
.
pid
return
"if (__tgid != %d) { return 0; }"
%
self
.
pid
else
:
return
""
...
...
@@ -360,6 +359,9 @@ DATA_DECL
if
self
.
probe_type
==
"t"
else
"int PROBENAME(struct pt_regs *ctx SIGNATURE)"
)
+
"""
{
u64 __pid_tgid = bpf_get_current_pid_tgid();
u32 __pid = __pid_tgid; // lower 32 bits
u32 __tgid = __pid_tgid >> 32; // upper 32 bits
PID_FILTER
PREFIX
if (!(FILTER)) return 0;
...
...
tools/cpudist.py
View file @
5f354e5a
...
...
@@ -12,7 +12,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from
__future__
import
print_function
from
bcc
import
BPF
,
Tracepoint
from
bcc
import
BPF
from
time
import
sleep
,
strftime
import
argparse
...
...
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