Skip to content

Commit ec615af

Browse files
oujunli4ast
authored andcommitted
funccount: filter bcc function count (iovisor#645)
1 parent 23f6b95 commit ec615af

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tools/funccount.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from time import sleep, strftime
2020
import argparse
2121
import signal
22+
import os
2223

2324
# arguments
2425
examples = """examples:
@@ -76,12 +77,12 @@ def signal_ignore(signal, frame):
7677
return 0;
7778
}
7879
"""
80+
filter_text = "u32 pid; pid = bpf_get_current_pid_tgid(); "
7981
if args.pid:
80-
bpf_text = bpf_text.replace('FILTER',
81-
('u32 pid; pid = bpf_get_current_pid_tgid(); ' +
82-
'if (pid != %s) { return 0; }') % (args.pid))
82+
filter_text += "if (pid != %s) { return 0; }" % args.pid
8383
else:
84-
bpf_text = bpf_text.replace('FILTER', '')
84+
filter_text += "if (pid == %s) { return 0; }" % os.getpid()
85+
bpf_text = bpf_text.replace('FILTER', filter_text)
8586
if debug:
8687
print(bpf_text)
8788
b = BPF(text=bpf_text)

0 commit comments

Comments
 (0)