diff --git a/tools/stackcount.py b/tools/stackcount.py index a58f9e3162249e3456603aa60f1e30cbe959eff3..2afb91ff875a936f838bd08e3510ae4844468ee6 100755 --- a/tools/stackcount.py +++ b/tools/stackcount.py @@ -275,6 +275,12 @@ class Tool(object): self.kernel_stack = self.args.kernel_stacks_only self.user_stack = self.args.user_stacks_only + # For tracing single processes in isolation, explicitly set perpid + # to True, if not already set. This is required to generate the correct + # BPF program that can store pid in the tgid field of the key_t object. + if self.args.pid is not None and self.args.pid > 0: + self.args.perpid = True + self.probe = Probe(self.args.pattern, self.kernel_stack, self.user_stack, self.args.regexp, self.args.pid, self.args.perpid, self.args.cpu) diff --git a/tools/stackcount_example.txt b/tools/stackcount_example.txt index 26233d798b426c241d06da30f167731fef921e98..805aff36f600413cdb4f08be3470c856a2927267 100644 --- a/tools/stackcount_example.txt +++ b/tools/stackcount_example.txt @@ -487,7 +487,7 @@ User-space functions can also be traced if a library name is provided. For example, to quickly identify code locations that allocate heap memory for PID 4902 (using -p), by tracing malloc from libc ("c:malloc"): -# ./stackcount -P -p 4902 c:malloc +# ./stackcount -p 4902 c:malloc Tracing 1 functions for "malloc"... Hit Ctrl-C to end. ^C malloc