From b6035b6b2272a2eccbcef3f15ff94f1c8d553bac Mon Sep 17 00:00:00 2001 From: Brendan Gregg Date: Tue, 10 Jan 2017 17:36:07 -0800 Subject: [PATCH] add a few funccount examples --- tools/funccount.py | 6 +++++- tools/funccount_example.txt | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/funccount.py b/tools/funccount.py index 66aa0118ea8d..2fd683aa4f78 100755 --- a/tools/funccount.py +++ b/tools/funccount.py @@ -43,6 +43,7 @@ def __init__(self, pattern, use_regex=False, pid=None): func -- probe a kernel function lib:func -- probe a user-space function in the library 'lib' + /path:func -- probe a user-space function in binary '/path' p::func -- same thing as 'func' p:lib:func -- same thing as 'lib:func' t:cat:event -- probe a kernel tracepoint @@ -219,8 +220,11 @@ def __init__(self): ./funccount -Ti 5 'vfs_*' # output every 5 seconds, with timestamps ./funccount -p 185 'vfs_*' # count vfs calls for PID 181 only ./funccount t:sched:sched_fork # count calls to the sched_fork tracepoint - ./funccount -p 185 u:node:gc* # count all GC USDT probes in node + ./funccount -p 185 u:node:gc* # count all GC USDT probes in node, PID 185 ./funccount c:malloc # count all malloc() calls in libc + ./funccount go:os.* # count all "os.*" calls in libgo + ./funccount -p 185 go:os.* # count all "os.*" calls in libgo, PID 185 + ./funccount ./test:read* # count "read*" calls in the ./test binary """ parser = argparse.ArgumentParser( description="Count functions, tracepoints, and USDT probes", diff --git a/tools/funccount_example.txt b/tools/funccount_example.txt index 9b090c5d9f53..16efe1ba0d17 100644 --- a/tools/funccount_example.txt +++ b/tools/funccount_example.txt @@ -169,7 +169,7 @@ Ctrl-C has been hit. User functions can be traced in executables or libraries, and per-process filtering is allowed: -# ./funccount -p 1442 contentions:* +# ./funccount -p 1442 /home/ubuntu/contentions:* Tracing 15 functions for "/home/ubuntu/contentions:*"... Hit Ctrl-C to end. ^C FUNC COUNT @@ -180,6 +180,10 @@ insert_result 87186 is_prime 1252772 Detaching... +If /home/ubuntu is in the $PATH, then the following command will also work: + +# ./funccount -p 1442 contentions:* + Counting libc write and read calls using regular expression syntax (-r): @@ -314,6 +318,8 @@ examples: ./funccount -Ti 5 'vfs_*' # output every 5 seconds, with timestamps ./funccount -p 185 'vfs_*' # count vfs calls for PID 181 only ./funccount t:sched:sched_fork # count calls to the sched_fork tracepoint - ./funccount -p 185 u:node:gc* # count all GC USDT probes in node + ./funccount -p 185 u:node:gc* # count all GC USDT probes in node, PID 185 ./funccount c:malloc # count all malloc() calls in libc - + ./funccount go:os.* # count all "os.*" calls in libgo + ./funccount -p 185 go:os.* # count all "os.*" calls in libgo, PID 185 + ./funccount ./test:read* # count "read*" calls in the ./test binary