Skip to content

Commit

Permalink
funclatency/sslsniff: fix the TypeError when enabling pid filter on u…
Browse files Browse the repository at this point in the history
…probe

attach_uprobe() and attach_uretprobe() expect the type of pid argument
is "int" instead of "str". Fix it by specifying the type of the "-p"/"--pid"
option as "int", and updating the format string of args.pid accordingly.

Fixes: d73c58f
  • Loading branch information
htbegin committed May 24, 2017
1 parent 2631f6d commit 5ac5d6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tools/funclatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
description="Time functions and print latency as a histogram",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=examples)
parser.add_argument("-p", "--pid",
parser.add_argument("-p", "--pid", type=int,
help="trace this PID only")
parser.add_argument("-i", "--interval", default=99999999,
help="summary interval, seconds")
Expand Down Expand Up @@ -147,7 +147,7 @@ def bail(error):
# code substitutions
if args.pid:
bpf_text = bpf_text.replace('FILTER',
'if (tgid != %s) { return 0; }' % args.pid)
'if (tgid != %d) { return 0; }' % args.pid)
else:
bpf_text = bpf_text.replace('FILTER', '')
if args.milliseconds:
Expand Down
4 changes: 2 additions & 2 deletions tools/sslsniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
description="Sniff SSL data",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=examples)
parser.add_argument("-p", "--pid", help="sniff this PID only.")
parser.add_argument("-p", "--pid", type=int, help="sniff this PID only.")
parser.add_argument("-c", "--comm",
help="sniff only commands matching string.")
parser.add_argument("-o", "--no-openssl", action="store_false", dest="openssl",
Expand Down Expand Up @@ -115,7 +115,7 @@
"""

if args.pid:
prog = prog.replace('FILTER', 'if (pid != %s) { return 0; }' % args.pid)
prog = prog.replace('FILTER', 'if (pid != %d) { return 0; }' % args.pid)
else:
prog = prog.replace('FILTER', '')

Expand Down

0 comments on commit 5ac5d6e

Please sign in to comment.