1 parent 23f6b95 commit ec615afCopy full SHA for ec615af
1 file changed
tools/funccount.py
@@ -19,6 +19,7 @@
19
from time import sleep, strftime
20
import argparse
21
import signal
22
+import os
23
24
# arguments
25
examples = """examples:
@@ -76,12 +77,12 @@ def signal_ignore(signal, frame):
76
77
return 0;
78
}
79
"""
80
+filter_text = "u32 pid; pid = bpf_get_current_pid_tgid(); "
81
if args.pid:
- bpf_text = bpf_text.replace('FILTER',
- ('u32 pid; pid = bpf_get_current_pid_tgid(); ' +
82
- 'if (pid != %s) { return 0; }') % (args.pid))
+ filter_text += "if (pid != %s) { return 0; }" % args.pid
83
else:
84
- bpf_text = bpf_text.replace('FILTER', '')
+ filter_text += "if (pid == %s) { return 0; }" % os.getpid()
85
+bpf_text = bpf_text.replace('FILTER', filter_text)
86
if debug:
87
print(bpf_text)
88
b = BPF(text=bpf_text)
0 commit comments