Commit 9f3662ee authored by Marko Myllynen's avatar Marko Myllynen Committed by yonghong-song

utools Tcl support (#2005)

* Add perl* utools man page links

Matches other languages, related to commit 9162be45.

* uthreads: explicitly list C as supported

uthreads supports C (pthreads) thread tracing, make this explicit.

Earlier use of -l java and -l none unchanged.

Add the corresponding man page and usage examples.

* Add Tcl support for ucalls / uflow / uobjnew / ustat

For some reason we need to use proc__args instead of proc__entry
in uflow.py to get similar results as with e.g. Python.
parent b96ebcd2
uthreads.8
\ No newline at end of file
ucalls.8
\ No newline at end of file
uflow.8
\ No newline at end of file
ustat.8
\ No newline at end of file
ucalls.8
\ No newline at end of file
uflow.8
\ No newline at end of file
uobjnew.8
\ No newline at end of file
ustat.8
\ No newline at end of file
.TH ucalls 8 "2016-11-07" "USER COMMANDS" .TH ucalls 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
ucalls, javacalls, perlcalls, phpcalls, pythoncalls, rubycalls \- Summarize method calls ucalls, javacalls, perlcalls, phpcalls, pythoncalls, rubycalls, tclcalls \- Summarize method calls
from high-level languages and Linux syscalls. from high-level languages and Linux syscalls.
.SH SYNOPSIS .SH SYNOPSIS
.B javacalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval] .B javacalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
...@@ -13,17 +13,19 @@ from high-level languages and Linux syscalls. ...@@ -13,17 +13,19 @@ from high-level languages and Linux syscalls.
.br .br
.B rubycalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval] .B rubycalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br .br
.B tclcalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br
.B ucalls [-l {java,perl,php,python,ruby}] [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval] .B ucalls [-l {java,perl,php,python,ruby}] [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.SH DESCRIPTION .SH DESCRIPTION
This tool summarizes method calls from high-level languages such as Java, Perl, This tool summarizes method calls from high-level languages such as Java, Perl,
PHP, Python, and Ruby. It can also trace Linux system calls. Whenever a method PHP, Python, Ruby, and Tcl. It can also trace Linux system calls. Whenever a method
is invoked, ucalls records the call count and optionally the method's execution is invoked, ucalls records the call count and optionally the method's execution
time (latency) and displays a summary. time (latency) and displays a summary.
This uses in-kernel eBPF maps to store per process summaries for efficiency. This uses in-kernel eBPF maps to store per process summaries for efficiency.
This tool relies on USDT probes embedded in many high-level languages, such as This tool relies on USDT probes embedded in many high-level languages, such as
Java, Perl, PHP, Python, and Ruby. It requires a runtime instrumented with these Java, Perl, PHP, Python, Ruby, and Tcl. It requires a runtime instrumented with these
probes, which in some cases requires building from source with a USDT-specific probes, which in some cases requires building from source with a USDT-specific
flag, such as "--enable-dtrace" or "--with-dtrace". For Java, method probes are flag, such as "--enable-dtrace" or "--with-dtrace". For Java, method probes are
not enabled by default, and can be turned on by running the Java process with not enabled by default, and can be turned on by running the Java process with
...@@ -35,7 +37,7 @@ Since this uses BPF, only the root user can use this tool. ...@@ -35,7 +37,7 @@ Since this uses BPF, only the root user can use this tool.
CONFIG_BPF and bcc. CONFIG_BPF and bcc.
.SH OPTIONS .SH OPTIONS
.TP .TP
\-l {java,perl,php,python,ruby} \-l {java,perl,php,python,ruby,tcl}
The language to trace. If not provided, only syscalls are traced (when the \-S The language to trace. If not provided, only syscalls are traced (when the \-S
option is used). option is used).
.TP .TP
......
.TH uflow 8 "2016-11-07" "USER COMMANDS" .TH uflow 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
uflow, javaflow, perlflow, phpflow, pythonflow, rubyflow \- Print a flow graph of method uflow, javaflow, perlflow, phpflow, pythonflow, rubyflow, tclflow \- Print a flow graph of method
calls in high-level languages. calls in high-level languages.
.SH SYNOPSIS .SH SYNOPSIS
.B javaflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid .B javaflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
...@@ -13,13 +13,15 @@ calls in high-level languages. ...@@ -13,13 +13,15 @@ calls in high-level languages.
.br .br
.B rubyflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid .B rubyflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br .br
.B uflow [-h] [-M METHOD] [-C CLAZZ] [-v] [-l {java,perl,php,python,ruby}] pid .B tclflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br
.B uflow [-h] [-M METHOD] [-C CLAZZ] [-v] [-l {java,perl,php,python,ruby,tcl}] pid
.SH DESCRIPTION .SH DESCRIPTION
uflow traces method calls and prints them in a flow graph that can facilitate uflow traces method calls and prints them in a flow graph that can facilitate
debugging and diagnostics by following the program's execution (method flow). debugging and diagnostics by following the program's execution (method flow).
This tool relies on USDT probes embedded in many high-level languages, such as This tool relies on USDT probes embedded in many high-level languages, such as
Java, Perl, PHP, Python, and Ruby. It requires a runtime instrumented with these Java, Perl, PHP, Python, Ruby, and Tcl. It requires a runtime instrumented with these
probes, which in some cases requires building from source with a USDT-specific probes, which in some cases requires building from source with a USDT-specific
flag, such as "--enable-dtrace" or "--with-dtrace". For Java processes, the flag, such as "--enable-dtrace" or "--with-dtrace". For Java processes, the
startup flag "-XX:+ExtendedDTraceProbes" is required. For PHP processes, the startup flag "-XX:+ExtendedDTraceProbes" is required. For PHP processes, the
...@@ -41,7 +43,7 @@ name interpretation strongly depends on the language. For example, in Java use ...@@ -41,7 +43,7 @@ name interpretation strongly depends on the language. For example, in Java use
\-v \-v
Print the resulting BPF program, for debugging purposes. Print the resulting BPF program, for debugging purposes.
.TP .TP
{java,perl,php,python,ruby} {java,perl,php,python,ruby,tcl}
The language to trace. The language to trace.
.TP .TP
pid pid
......
.TH ugc 8 "2016-11-07" "USER COMMANDS" .TH ugc 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
ugc, javagc, pythongc, rubygc, nodegc \- Trace garbage collection events in ugc, javagc, nodegc, pythongc, rubygc \- Trace garbage collection events in
high-level languages. high-level languages.
.SH SYNOPSIS .SH SYNOPSIS
.B javagc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid .B javagc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br .br
.B nodegc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br
.B pythongc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid .B pythongc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br .br
.B rubygc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid .B rubygc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br .br
.B nodegc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid .B ugc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] [-l {java,node,python,ruby}] pid
.br
.B ugc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] [-l {java,python,ruby,node}] pid
.SH DESCRIPTION .SH DESCRIPTION
This traces garbage collection events as they occur, including their duration This traces garbage collection events as they occur, including their duration
and any additional information (such as generation collected or type of GC) and any additional information (such as generation collected or type of GC)
provided by the respective language's runtime. provided by the respective language's runtime.
This tool relies on USDT probes embedded in many high-level languages, such as This tool relies on USDT probes embedded in many high-level languages, such as
Node, Java, Python, and Ruby. It requires a runtime instrumented with these Java, Node, Python, and Ruby. It requires a runtime instrumented with these
probes, which in some cases requires building from source with a USDT-specific probes, which in some cases requires building from source with a USDT-specific
flag, such as "--enable-dtrace" or "--with-dtrace". flag, such as "--enable-dtrace" or "--with-dtrace".
...@@ -45,7 +45,7 @@ if you have thousands of collection events, specifying this filter will not ...@@ -45,7 +45,7 @@ if you have thousands of collection events, specifying this filter will not
reduce the amount of data that has to be transferred from the BPF program to reduce the amount of data that has to be transferred from the BPF program to
the user-space script. the user-space script.
.TP .TP
{java,python,ruby,node} {java,node,python,ruby}
The language to trace. The language to trace.
.TP .TP
pid pid
......
.TH uobjnew 8 "2016-11-07" "USER COMMANDS" .TH uobjnew 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
uobjnew, javaobjnew, rubyobjnew, cobjnew \- Summarize object allocations in uobjnew, cobjnew, javaobjnew, rubyobjnew, tclobjnew \- Summarize object allocations in
high-level languages. high-level languages.
.SH SYNOPSIS .SH SYNOPSIS
.B cobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br
.B javaobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval] .B javaobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br .br
.B rubyobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval] .B rubyobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br .br
.B cobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval] .B tclobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br .br
.B uobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] [-l {java,ruby,c}] pid [interval] .B uobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] [-l {c,java,ruby,tcl}] pid [interval]
.SH DESCRIPTION .SH DESCRIPTION
uobjnew traces object allocations in high-level languages (including "malloc") uobjnew traces object allocations in high-level languages (including "malloc")
and prints summaries of the most frequently allocated types by number of and prints summaries of the most frequently allocated types by number of
objects or number of bytes. objects or number of bytes.
This tool relies on USDT probes embedded in many high-level languages, such as This tool relies on USDT probes embedded in many high-level languages, such as
Node, Java, Python, and Ruby. It requires a runtime instrumented with these C, Java, Ruby, and Tcl. It requires a runtime instrumented with these
probes, which in some cases requires building from source with a USDT-specific probes, which in some cases requires building from source with a USDT-specific
flag, such as "--enable-dtrace" or "--with-dtrace". For Java, the Java process flag, such as "--enable-dtrace" or "--with-dtrace". For Java, the Java process
must be started with the "-XX:+ExtendedDTraceProbes" flag. must be started with the "-XX:+ExtendedDTraceProbes" flag.
...@@ -35,7 +37,7 @@ Print the top object types sorted by size. ...@@ -35,7 +37,7 @@ Print the top object types sorted by size.
\-v \-v
Print the resulting BPF program, for debugging purposes. Print the resulting BPF program, for debugging purposes.
.TP .TP
{java,ruby,c} {c,java,ruby,tcl}
The language to trace. The language to trace.
.TP .TP
pid pid
......
.TH ustat 8 "2016-11-07" "USER COMMANDS" .TH ustat 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
ustat, javastat, nodestat, perlstat, phpstat, pythonstat, rubystat \- Activity stats from ustat, javastat, nodestat, perlstat, phpstat, pythonstat, rubystat, tclstat \- Activity stats from
high-level languages. high-level languages.
.SH SYNOPSIS .SH SYNOPSIS
.B javastat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]] .B javastat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
...@@ -15,7 +15,9 @@ high-level languages. ...@@ -15,7 +15,9 @@ high-level languages.
.br .br
.B rubystat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]] .B rubystat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br .br
.B ustat [-l {java,perl,python,ruby,node,php}] [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]] .B tclstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B ustat [-l {java,node,perl,php,python,ruby,tcl}] [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.SH DESCRIPTION .SH DESCRIPTION
This is "top" for high-level language events, such as garbage collections, This is "top" for high-level language events, such as garbage collections,
exceptions, thread creations, object allocations, method calls, and more. The exceptions, thread creations, object allocations, method calls, and more. The
...@@ -26,7 +28,7 @@ set of details. ...@@ -26,7 +28,7 @@ set of details.
This uses in-kernel eBPF maps to store per process summaries for efficiency. This uses in-kernel eBPF maps to store per process summaries for efficiency.
This tool relies on USDT probes embedded in many high-level languages, such as This tool relies on USDT probes embedded in many high-level languages, such as
Java, Node, Perl, PHP, Python, and Ruby. It requires a runtime instrumented with Java, Node, Perl, PHP, Python, Ruby, and Tcl. It requires a runtime instrumented with
these probes, which in some cases requires building from source with a these probes, which in some cases requires building from source with a
USDT-specific flag, such as "--enable-dtrace" or "--with-dtrace". For Java, USDT-specific flag, such as "--enable-dtrace" or "--with-dtrace". For Java,
some probes are not enabled by default, and can be turned on by running the Java some probes are not enabled by default, and can be turned on by running the Java
...@@ -43,7 +45,7 @@ Since this uses BPF, only the root user can use this tool. ...@@ -43,7 +45,7 @@ Since this uses BPF, only the root user can use this tool.
CONFIG_BPF and bcc. CONFIG_BPF and bcc.
.SH OPTIONS .SH OPTIONS
.TP .TP
\-l {java,node,perl,php,python,ruby} \-l {java,node,perl,php,python,ruby,tcl}
The language to trace. By default, all languages are traced. The language to trace. By default, all languages are traced.
.TP .TP
\-C \-C
...@@ -107,10 +109,10 @@ THR/s ...@@ -107,10 +109,10 @@ THR/s
Count of threads created during interval. Count of threads created during interval.
.SH OVERHEAD .SH OVERHEAD
When using this tool with high-frequency events, such as method calls, a very When using this tool with high-frequency events, such as method calls, a very
significant slow-down can be expected. However, many of the high-level significant slow-down can be expected. However, many of the high-level
languages covered by this tool already have a fairly high per-method invocation languages covered by this tool already have a fairly high per-method invocation
cost, especially when running in interpreted mode. For the lower-frequency cost, especially when running in interpreted mode. For the lower-frequency
events, such as garbage collections or thread creations, the overhead should events, such as garbage collections or thread creations, the overhead should
not be significant. Specifically, when probing Java processes and not using the not be significant. Specifically, when probing Java processes and not using the
"-XX:+ExtendedDTraceProbes" flag, the most expensive probes are not emitted, "-XX:+ExtendedDTraceProbes" flag, the most expensive probes are not emitted,
and the overhead should be acceptable. and the overhead should be acceptable.
......
.TH uthreads 8 "2016-11-07" "USER COMMANDS" .TH uthreads 8 "2018-10-09" "USER COMMANDS"
.SH NAME .SH NAME
uthreads, javathreads \- Trace thread creation events in Java or pthreads. uthreads, cthreads, javathreads \- Trace thread creation events in Java or pthreads.
.SH SYNOPSIS .SH SYNOPSIS
.B cthreads [-h] [-v] pid
.BR
.B javathreads [-h] [-v] pid .B javathreads [-h] [-v] pid
.BR .BR
.B uthreads [-h] [-l {java}] [-v] pid .B uthreads [-h] [-l {c,java,none}] [-v] pid
.SH DESCRIPTION .SH DESCRIPTION
This traces thread creation events in Java processes, or pthread creation This traces thread creation events in Java processes, or pthread creation
events in any process. When a thread is created, its name or start address events in any process. When a thread is created, its name or start address
...@@ -15,9 +17,9 @@ Since this uses BPF, only the root user can use this tool. ...@@ -15,9 +17,9 @@ Since this uses BPF, only the root user can use this tool.
CONFIG_BPF and bcc. CONFIG_BPF and bcc.
.SH OPTIONS .SH OPTIONS
.TP .TP
\-l {java} \-l {c,java,none}
The language to trace (currently only Java is supported). When no language is The language to trace. C and none select tracing pthreads only, regardless
specified, only pthread creations are traced. of the runtime being traced.
.TP .TP
\-v \-v
Print the resulting BPF program, for debugging purposes. Print the resulting BPF program, for debugging purposes.
......
lib/uthreads_example.txt
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# ucalls Summarize method calls in high-level languages and/or system calls. # ucalls Summarize method calls in high-level languages and/or system calls.
# For Linux, uses BCC, eBPF. # For Linux, uses BCC, eBPF.
# #
# USAGE: ucalls [-l {java,perl,php,python,ruby}] [-h] [-T TOP] [-L] [-S] [-v] [-m] # USAGE: ucalls [-l {java,perl,php,python,ruby,tcl}] [-h] [-T TOP] [-L] [-S] [-v] [-m]
# pid [interval] # pid [interval]
# #
# Copyright 2016 Sasha Goldshtein # Copyright 2016 Sasha Goldshtein
...@@ -18,7 +18,7 @@ from bcc import BPF, USDT, utils ...@@ -18,7 +18,7 @@ from bcc import BPF, USDT, utils
from time import sleep from time import sleep
import os import os
languages = ["java", "perl", "php", "python", "ruby"] languages = ["java", "perl", "php", "python", "ruby", "tcl"]
examples = """examples: examples = """examples:
./ucalls -l java 185 # trace Java calls and print statistics on ^C ./ucalls -l java 185 # trace Java calls and print statistics on ^C
...@@ -94,6 +94,12 @@ elif language == "ruby": ...@@ -94,6 +94,12 @@ elif language == "ruby":
return_probe = "method__return" return_probe = "method__return"
read_class = "bpf_usdt_readarg(1, ctx, &clazz);" read_class = "bpf_usdt_readarg(1, ctx, &clazz);"
read_method = "bpf_usdt_readarg(2, ctx, &method);" read_method = "bpf_usdt_readarg(2, ctx, &method);"
elif language == "tcl":
# TODO Also consider probe cmd__entry and cmd__return with same arguments
entry_probe = "proc__entry"
return_probe = "proc__return"
read_class = "" # no class/file info available
read_method = "bpf_usdt_readarg(1, ctx, &method);"
elif not language or language == "none": elif not language or language == "none":
if not args.syscalls: if not args.syscalls:
print("Nothing to do; use -S to trace syscalls.") print("Nothing to do; use -S to trace syscalls.")
......
...@@ -2,8 +2,8 @@ Demonstrations of ucalls. ...@@ -2,8 +2,8 @@ Demonstrations of ucalls.
ucalls summarizes method calls in various high-level languages, including Java, ucalls summarizes method calls in various high-level languages, including Java,
Perl, PHP, Python, Ruby, and Linux system calls. It displays statistics on the Perl, PHP, Python, Ruby, Tcl, and Linux system calls. It displays statistics on
most frequently called methods, as well as the latency (duration) of these the most frequently called methods, as well as the latency (duration) of these
methods. methods.
Through the syscalls support, ucalls can provide basic information on a Through the syscalls support, ucalls can provide basic information on a
...@@ -61,7 +61,7 @@ METHOD # CALLS ...@@ -61,7 +61,7 @@ METHOD # CALLS
USAGE message: USAGE message:
# ./ucalls.py -h # ./ucalls.py -h
usage: ucalls.py [-h] [-l {java,perl,php,python,ruby,none}] [-T TOP] [-L] [-S] [-v] usage: ucalls.py [-h] [-l {java,perl,php,python,ruby,tcl,none}] [-T TOP] [-L] [-S] [-v]
[-m] [-m]
pid [interval] pid [interval]
...@@ -73,7 +73,7 @@ positional arguments: ...@@ -73,7 +73,7 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-l {java,perl,php,python,ruby,none}, --language {java,perl,php,python,ruby,none} -l {java,perl,php,python,ruby,tcl,none}, --language {java,perl,php,python,ruby,tcl,none}
language to trace (if none, trace syscalls only) language to trace (if none, trace syscalls only)
-T TOP, --top TOP number of most frequent/slow calls to print -T TOP, --top TOP number of most frequent/slow calls to print
-L, --latency record method latency from enter to exit (except -L, --latency record method latency from enter to exit (except
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# uflow Trace method execution flow in high-level languages. # uflow Trace method execution flow in high-level languages.
# For Linux, uses BCC, eBPF. # For Linux, uses BCC, eBPF.
# #
# USAGE: uflow [-C CLASS] [-M METHOD] [-v] {java,perl,php,python,ruby} pid # USAGE: uflow [-C CLASS] [-M METHOD] [-v] {java,perl,php,python,ruby,tcl} pid
# #
# Copyright 2016 Sasha Goldshtein # Copyright 2016 Sasha Goldshtein
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
...@@ -18,7 +18,7 @@ import ctypes as ct ...@@ -18,7 +18,7 @@ import ctypes as ct
import time import time
import os import os
languages = ["java", "perl", "php", "python", "ruby"] languages = ["java", "perl", "php", "python", "ruby", "tcl"]
examples = """examples: examples = """examples:
./uflow -l java 185 # trace Java method calls in process 185 ./uflow -l java 185 # trace Java method calls in process 185
...@@ -161,6 +161,13 @@ elif language == "ruby": ...@@ -161,6 +161,13 @@ elif language == "ruby":
enable_probe("cmethod__return", "ruby_creturn", enable_probe("cmethod__return", "ruby_creturn",
"bpf_usdt_readarg(1, ctx, &clazz);", "bpf_usdt_readarg(1, ctx, &clazz);",
"bpf_usdt_readarg(2, ctx, &method);", is_return=True) "bpf_usdt_readarg(2, ctx, &method);", is_return=True)
elif language == "tcl":
enable_probe("proc__args", "tcl_entry",
"", # no class/file info available
"bpf_usdt_readarg(1, ctx, &method);", is_return=False)
enable_probe("proc__return", "tcl_return",
"", # no class/file info available
"bpf_usdt_readarg(1, ctx, &method);", is_return=True)
else: else:
print("No language detected; use -l to trace a language.") print("No language detected; use -l to trace a language.")
exit(1) exit(1)
......
...@@ -4,7 +4,7 @@ Demonstrations of uflow. ...@@ -4,7 +4,7 @@ Demonstrations of uflow.
uflow traces method entry and exit events and prints a visual flow graph that uflow traces method entry and exit events and prints a visual flow graph that
shows how methods are entered and exited, similar to a tracing debugger with shows how methods are entered and exited, similar to a tracing debugger with
breakpoints. This can be useful for understanding program flow in high-level breakpoints. This can be useful for understanding program flow in high-level
languages such as Java, Perl, PHP, Python, and Ruby, which provide USDT languages such as Java, Perl, PHP, Python, Ruby, and Tcl which provide USDT
probes for method invocations. probes for method invocations.
...@@ -88,7 +88,7 @@ thread running on the same CPU. ...@@ -88,7 +88,7 @@ thread running on the same CPU.
USAGE message: USAGE message:
# ./uflow -h # ./uflow -h
usage: uflow.py [-h] [-l {java,perl,php,python,ruby}] [-M METHOD] [-C CLAZZ] [-v] usage: uflow.py [-h] [-l {java,perl,php,python,ruby,tcl}] [-M METHOD] [-C CLAZZ] [-v]
pid pid
Trace method execution flow in high-level languages. Trace method execution flow in high-level languages.
...@@ -98,7 +98,7 @@ positional arguments: ...@@ -98,7 +98,7 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-l {java,perl,php,python,ruby}, --language {java,perl,php,python,ruby} -l {java,perl,php,python,ruby,tcl}, --language {java,perl,php,python,ruby,tcl}
language to trace language to trace
-M METHOD, --method METHOD -M METHOD, --method METHOD
trace only calls to methods starting with this prefix trace only calls to methods starting with this prefix
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# uobjnew Summarize object allocations in high-level languages. # uobjnew Summarize object allocations in high-level languages.
# For Linux, uses BCC, eBPF. # For Linux, uses BCC, eBPF.
# #
# USAGE: uobjnew [-h] [-T TOP] [-v] {c,java,ruby} pid [interval] # USAGE: uobjnew [-h] [-T TOP] [-v] {c,java,ruby,tcl} pid [interval]
# #
# Copyright 2016 Sasha Goldshtein # Copyright 2016 Sasha Goldshtein
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
...@@ -18,7 +18,7 @@ from time import sleep ...@@ -18,7 +18,7 @@ from time import sleep
import os import os
# C needs to be the last language. # C needs to be the last language.
languages = ["c", "java", "ruby"] languages = ["c", "java", "ruby", "tcl"]
examples = """examples: examples = """examples:
./uobjnew -l java 145 # summarize Java allocations in process 145 ./uobjnew -l java 145 # summarize Java allocations in process 145
...@@ -137,7 +137,20 @@ int object_alloc_entry(struct pt_regs *ctx) { ...@@ -137,7 +137,20 @@ int object_alloc_entry(struct pt_regs *ctx) {
program += create_template.replace("THETHING", thing) program += create_template.replace("THETHING", thing)
usdt.enable_probe_or_bail("%s__create" % thing, usdt.enable_probe_or_bail("%s__create" % thing,
"%s_alloc_entry" % thing) "%s_alloc_entry" % thing)
#
# Tcl
#
elif language == "tcl":
program += """
int alloc_entry(struct pt_regs *ctx) {
struct key_t key = { .name = "<ALL>" };
struct val_t *valp, zero = {};
valp = allocs.lookup_or_init(&key, &zero);
valp->num_allocs += 1;
return 0;
}
"""
usdt.enable_probe_or_bail("obj__create", "alloc_entry")
else: else:
print("No language detected; use -l to trace a language.") print("No language detected; use -l to trace a language.")
exit(1) exit(1)
...@@ -173,7 +186,7 @@ while True: ...@@ -173,7 +186,7 @@ while True:
data = data[-args.top_size:] data = data[-args.top_size:]
else: else:
data = sorted(data.items(), key=lambda kv: kv[1].total_size) data = sorted(data.items(), key=lambda kv: kv[1].total_size)
print("%-30s %8s %12s" % ("TYPE", "# ALLOCS", "# BYTES")) print("%-30s %8s %12s" % ("NAME/TYPE", "# ALLOCS", "# BYTES"))
for key, value in data: for key, value in data:
if language == "c": if language == "c":
obj_type = "block size %d" % key.size obj_type = "block size %d" % key.size
......
...@@ -48,7 +48,7 @@ block size 80 569 45520 ...@@ -48,7 +48,7 @@ block size 80 569 45520
USAGE message: USAGE message:
# ./uobjnew -h # ./uobjnew -h
usage: uobjnew.py [-h] [-l {java,ruby,c}] [-C TOP_COUNT] [-S TOP_SIZE] [-v] usage: uobjnew.py [-h] [-l {c,java,ruby,tcl}] [-C TOP_COUNT] [-S TOP_SIZE] [-v]
pid [interval] pid [interval]
Summarize object allocations in high-level languages. Summarize object allocations in high-level languages.
...@@ -59,7 +59,7 @@ positional arguments: ...@@ -59,7 +59,7 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-l {java,ruby,c}, --language {java,ruby,c} -l {c,java,ruby,tcl}, --language {c,java,ruby,tcl}
language to trace language to trace
-C TOP_COUNT, --top-count TOP_COUNT -C TOP_COUNT, --top-count TOP_COUNT
number of most frequently allocated types to print number of most frequently allocated types to print
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# method calls, class loads, garbage collections, and more. # method calls, class loads, garbage collections, and more.
# For Linux, uses BCC, eBPF. # For Linux, uses BCC, eBPF.
# #
# USAGE: ustat [-l {java,node,perl,php,python,ruby}] [-C] # USAGE: ustat [-l {java,node,perl,php,python,ruby,tcl}] [-C]
# [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] # [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d]
# [interval [count]] # [interval [count]]
# #
...@@ -132,7 +132,7 @@ class Tool(object): ...@@ -132,7 +132,7 @@ class Tool(object):
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=examples) epilog=examples)
parser.add_argument("-l", "--language", parser.add_argument("-l", "--language",
choices=["java", "node", "perl", "php", "python", "ruby"], choices=["java", "node", "perl", "php", "python", "ruby", "tcl"],
help="language to trace (default: all languages)") help="language to trace (default: all languages)")
parser.add_argument("-C", "--noclear", action="store_true", parser.add_argument("-C", "--noclear", action="store_true",
help="don't clear the screen") help="don't clear the screen")
...@@ -190,6 +190,10 @@ class Tool(object): ...@@ -190,6 +190,10 @@ class Tool(object):
"load__entry": Category.CLOAD, "load__entry": Category.CLOAD,
"raise": Category.EXCP "raise": Category.EXCP
}), }),
"tcl": Probe("tcl", ["tclsh", "wish"], {
"proc__entry": Category.METHOD,
"obj__create": Category.OBJNEW
}),
} }
if self.args.language: if self.args.language:
......
...@@ -4,7 +4,7 @@ Demonstrations of ustat. ...@@ -4,7 +4,7 @@ Demonstrations of ustat.
ustat is a "top"-like tool for monitoring events in high-level languages. It ustat is a "top"-like tool for monitoring events in high-level languages. It
prints statistics about garbage collections, method calls, object allocations, prints statistics about garbage collections, method calls, object allocations,
and various other events for every process that it recognizes with a Java, and various other events for every process that it recognizes with a Java,
Node, Perl, PHP, Python, and Ruby runtime. Node, Perl, PHP, Python, Ruby, and Tcl runtime.
For example: For example:
...@@ -48,7 +48,7 @@ PID CMDLINE METHOD/s GC/s OBJNEW/s CLOAD/s EXC/s THR/s ...@@ -48,7 +48,7 @@ PID CMDLINE METHOD/s GC/s OBJNEW/s CLOAD/s EXC/s THR/s
USAGE message: USAGE message:
# ./ustat.py -h # ./ustat.py -h
usage: ustat.py [-h] [-l {java,node,perl,php,python,ruby}] [-C] usage: ustat.py [-h] [-l {java,node,perl,php,python,ruby,tcl}] [-C]
[-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d]
[interval] [count] [interval] [count]
...@@ -60,7 +60,7 @@ positional arguments: ...@@ -60,7 +60,7 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-l {{java,node,perl,php,python,ruby}}, --language {java,node,perl,php,python,ruby} -l {java,node,perl,php,python,ruby,tcl}, --language {java,node,perl,php,python,ruby,tcl}
language to trace (default: all languages) language to trace (default: all languages)
-C, --noclear don't clear the screen -C, --noclear don't clear the screen
-S {cload,excp,gc,method,objnew,thread}, --sort {cload,excp,gc,method,objnew,thread} -S {cload,excp,gc,method,objnew,thread}, --sort {cload,excp,gc,method,objnew,thread}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# uthreads Trace thread creation/destruction events in high-level languages. # uthreads Trace thread creation/destruction events in high-level languages.
# For Linux, uses BCC, eBPF. # For Linux, uses BCC, eBPF.
# #
# USAGE: uthreads [-l {java}] [-v] pid # USAGE: uthreads [-l {c,java,none}] [-v] pid
# #
# Copyright 2016 Sasha Goldshtein # Copyright 2016 Sasha Goldshtein
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
...@@ -18,11 +18,11 @@ import ctypes as ct ...@@ -18,11 +18,11 @@ import ctypes as ct
import time import time
import os import os
languages = ["java"] languages = ["c", "java"]
examples = """examples: examples = """examples:
./uthreads -l java 185 # trace Java threads in process 185 ./uthreads -l java 185 # trace Java threads in process 185
./uthreads 12245 # trace only pthreads in process 12245 ./uthreads -l none 12245 # trace only pthreads in process 12245
""" """
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Trace thread creation/destruction events in " + description="Trace thread creation/destruction events in " +
...@@ -68,7 +68,10 @@ language = args.language ...@@ -68,7 +68,10 @@ language = args.language
if not language: if not language:
language = utils.detect_language(languages, args.pid) language = utils.detect_language(languages, args.pid)
if language == "java": if language == "c":
# Nothing to add
pass
elif language == "java":
template = """ template = """
int %s(struct pt_regs *ctx) { int %s(struct pt_regs *ctx) {
char type[] = "%s"; char type[] = "%s";
......
Demonstrations of uthreads. Demonstrations of uthreads.
uthreads traces thread creation events in Java or raw pthreads, and prints uthreads traces thread creation events in Java or raw (C) pthreads, and prints
details about the newly created thread. For Java threads, the thread name is details about the newly created thread. For Java threads, the thread name is
printed; for pthreads, the thread's start function is printed, if there is printed; for pthreads, the thread's start function is printed, if there is
symbol information to resolve it. symbol information to resolve it.
...@@ -23,7 +23,7 @@ runtime. ...@@ -23,7 +23,7 @@ runtime.
Next, trace only pthread creation events in some native application: Next, trace only pthread creation events in some native application:
# ./uthreads 27450 # ./uthreads 27450
Tracing thread events in process 27450 (language: none)... Ctrl-C to quit. Tracing thread events in process 27450 (language: c)... Ctrl-C to quit.
TIME ID TYPE DESCRIPTION TIME ID TYPE DESCRIPTION
0.924 27462 pthread primes_thread [primes] 0.924 27462 pthread primes_thread [primes]
0.927 27463 pthread primes_thread [primes] 0.927 27463 pthread primes_thread [primes]
...@@ -39,7 +39,7 @@ instead. ...@@ -39,7 +39,7 @@ instead.
USAGE message: USAGE message:
# ./uthreads -h # ./uthreads -h
usage: uthreads.py [-h] [-l {java,none}] [-v] pid usage: uthreads.py [-h] [-l {c,java,none}] [-v] pid
Trace thread creation/destruction events in high-level languages. Trace thread creation/destruction events in high-level languages.
...@@ -48,11 +48,11 @@ positional arguments: ...@@ -48,11 +48,11 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-l {java,none}, --language {java,none} -l {c,java,none}, --language {c,java,none}
language to trace (none for pthreads only) language to trace (none for pthreads only)
-v, --verbose verbose mode: print the BPF program (for debugging -v, --verbose verbose mode: print the BPF program (for debugging
purposes) purposes)
examples: examples:
./uthreads -l java 185 # trace Java threads in process 185 ./uthreads -l java 185 # trace Java threads in process 185
./uthreads 12245 # trace only pthreads in process 12245 ./uthreads -l none 12245 # trace only pthreads in process 12245
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ucalls.py -l tcl "$@"
lib/ucalls_example.txt
\ No newline at end of file
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uflow.py -l tcl "$@"
lib/uflow_example.txt
\ No newline at end of file
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uobjnew.py -l tcl "$@"
lib/uobjnew_example.txt
\ No newline at end of file
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ustat.py -l tcl "$@"
lib/ustat_example.txt
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment