Skip to content

Commit

Permalink
funccount: filter bcc function count (iovisor#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
oujunli authored and 4ast committed Aug 6, 2016
1 parent 23f6b95 commit ec615af
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/funccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from time import sleep, strftime
import argparse
import signal
import os

# arguments
examples = """examples:
Expand Down Expand Up @@ -76,12 +77,12 @@ def signal_ignore(signal, frame):
return 0;
}
"""
filter_text = "u32 pid; pid = bpf_get_current_pid_tgid(); "
if args.pid:
bpf_text = bpf_text.replace('FILTER',
('u32 pid; pid = bpf_get_current_pid_tgid(); ' +
'if (pid != %s) { return 0; }') % (args.pid))
filter_text += "if (pid != %s) { return 0; }" % args.pid
else:
bpf_text = bpf_text.replace('FILTER', '')
filter_text += "if (pid == %s) { return 0; }" % os.getpid()
bpf_text = bpf_text.replace('FILTER', filter_text)
if debug:
print(bpf_text)
b = BPF(text=bpf_text)
Expand Down

0 comments on commit ec615af

Please sign in to comment.