.SH NAME
argdist \- Trace a function and display a histogram or frequency count of its parameter values. Uses Linux eBPF/bcc.
.SH SYNOPSIS
-.B argdist [-h] [-p PID] [-z STRING_SIZE] [-i INTERVAL] [-d DURATION] [-n COUNT] [-v] [-T TOP] [-H specifier] [-C specifier] [-I header]
+.B argdist [-h] [-p PID] [-z STRING_SIZE] [-i INTERVAL] [-d DURATION] [-n COUNT] [-v] [-T TOP] [-H specifier] [-C specifier] [-I header] [-t TID]
.SH DESCRIPTION
argdist attaches to function entry and exit points, collects specified parameter
values, and stores them in a histogram or a frequency collection that counts
\-p PID
Trace only functions in the process PID.
.TP
+\-t TID
+Trace only functions in the thread TID.
+.TP
\-z STRING_SIZE
When collecting string arguments (of type char*), collect up to STRING_SIZE
characters. Longer strings will be truncated.
#
# USAGE: argdist [-h] [-p PID] [-z STRING_SIZE] [-i INTERVAL] [-n COUNT] [-v]
# [-c] [-T TOP] [-C specifier] [-H specifier] [-I header]
+# [-t TID]
#
# Licensed under the Apache License, Version 2.0 (the "License")
# Copyright (C) 2016 Sasha Goldshtein.
u32 __pid = __pid_tgid; // lower 32 bits
u32 __tgid = __pid_tgid >> 32; // upper 32 bits
PID_FILTER
+ TID_FILTER
COLLECT
return 0;
}
text = text.replace("SIGNATURE",
"" if len(self.signature) == 0 else ", " + self.signature)
text = text.replace("PID_FILTER", self._generate_pid_filter())
+ text = text.replace("TID_FILTER", self._generate_tid_filter())
collect = ""
for pname in self.args_to_probe:
param_hash = self.hashname_prefix + pname
self.usdt_ctx = None
self.streq_functions = ""
self.pid = tool.args.pid
+ self.tid = tool.args.tid
self.cumulative = tool.args.cumulative or False
self.raw_spec = specifier
self.probe_user_list = set()
else:
return ""
+ def _generate_tid_filter(self):
+ if self.tid is not None and not self.is_user:
+ return "if (__pid != %d) { return 0; }" % self.tid
+ else:
+ return ""
+
def generate_text(self):
program = ""
probe_text = """
u32 __pid = __pid_tgid; // lower 32 bits
u32 __tgid = __pid_tgid >> 32; // upper 32 bits
PID_FILTER
+ TID_FILTER
PREFIX
KEY_EXPR
if (!(FILTER)) return 0;
program = program.replace("SIGNATURE", signature)
program = program.replace("PID_FILTER",
self._generate_pid_filter())
+ program = program.replace("TID_FILTER",
+ self._generate_tid_filter())
decl = self._generate_hash_decl()
key_expr = self._generate_key_assignment()
epilog=Tool.examples)
parser.add_argument("-p", "--pid", type=int,
help="id of the process to trace (optional)")
+ parser.add_argument("-t", "--tid", type=int,
+ help="id of the thread to trace (optional)")
parser.add_argument("-z", "--string-size", default=80,
type=int,
help="maximum string size to read from char* arguments")
optional arguments:
-h, --help show this help message and exit
-p PID, --pid PID id of the process to trace (optional)
+ -t TID, --tid TID id of the thread to trace (optional)
-z STRING_SIZE, --string-size STRING_SIZE
maximum string size to read from char* arguments
-i INTERVAL, --interval INTERVAL