Skip to content

Commit

Permalink
u* tools: per-language wrappers (iovisor#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
pchaigno authored and goldshtn committed Apr 2, 2017
1 parent a4ad687 commit caa14ed
Show file tree
Hide file tree
Showing 86 changed files with 245 additions and 28 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ pair of .c and .py files, and some are directories of files.
- tools/[tplist](tools/tplist.py): Display kernel tracepoints or USDT probes and their formats. [Examples](tools/tplist_example.txt).
- tools/[trace](tools/trace.py): Trace arbitrary functions, with filters. [Examples](tools/trace_example.txt).
- tools/[ttysnoop](tools/ttysnoop.py): Watch live output from a tty or pts device. [Examples](tools/ttysnoop_example.txt).
- tools/[ucalls](tools/ucalls.py): Summarize method calls or Linux syscalls in high-level languages. [Examples](tools/ucalls_example.txt).
- tools/[uflow](tools/uflow.py): Print a method flow graph in high-level languages. [Examples](tools/uflow_example.txt).
- tools/[ugc](tools/ugc.py): Trace garbage collection events in high-level languages. [Examples](tools/ugc_example.txt).
- tools/[uobjnew](tools/uobjnew.py): Summarize object allocation events by object type and number of bytes allocated. [Examples](tools/uobjnew_example.txt).
- tools/[ustat](tools/ustat.py): Collect events such as GCs, thread creations, object allocations, exceptions and more in high-level languages. [Examples](tools/ustat_example.txt).
- tools/[uthreads](tools/uthreads.py): Trace thread creation events in Java and raw pthreads. [Examples](tools/uthreads_example.txt).
- tools/[ucalls](tools/lib/ucalls.py): Summarize method calls or Linux syscalls in high-level languages. [Examples](tools/lib/ucalls_example.txt).
- tools/[uflow](tools/lib/uflow.py): Print a method flow graph in high-level languages. [Examples](tools/lib/uflow_example.txt).
- tools/[ugc](tools/lib/ugc.py): Trace garbage collection events in high-level languages. [Examples](tools/lib/ugc_example.txt).
- tools/[uobjnew](tools/lib/uobjnew.py): Summarize object allocation events by object type and number of bytes allocated. [Examples](tools/lib/uobjnew_example.txt).
- tools/[ustat](tools/lib/ustat.py): Collect events such as GCs, thread creations, object allocations, exceptions and more in high-level languages. [Examples](tools/lib/ustat_example.txt).
- tools/[uthreads](tools/lib/uthreads.py): Trace thread creation events in Java and raw pthreads. [Examples](tools/lib/uthreads_example.txt).
- tools/[vfscount](tools/vfscount.py) tools/[vfscount.c](tools/vfscount.c): Count VFS calls. [Examples](tools/vfscount_example.txt).
- tools/[vfsstat](tools/vfsstat.py) tools/[vfsstat.c](tools/vfsstat.c): Count some VFS calls, with column output. [Examples](tools/vfsstat_example.txt).
- tools/[wakeuptime](tools/wakeuptime.py): Summarize sleep to wakeup time by waker kernel stack. [Examples](tools/wakeuptime_example.txt).
Expand Down
1 change: 1 addition & 0 deletions man/man8/cobjnew.8
1 change: 1 addition & 0 deletions man/man8/javacalls.8
1 change: 1 addition & 0 deletions man/man8/javaflow.8
1 change: 1 addition & 0 deletions man/man8/javagc.8
1 change: 1 addition & 0 deletions man/man8/javaobjnew.8
1 change: 1 addition & 0 deletions man/man8/javastat.8
1 change: 1 addition & 0 deletions man/man8/javathreads.8
1 change: 1 addition & 0 deletions man/man8/nodegc.8
1 change: 1 addition & 0 deletions man/man8/nodestat.8
1 change: 1 addition & 0 deletions man/man8/phpcalls.8
1 change: 1 addition & 0 deletions man/man8/phpflow.8
1 change: 1 addition & 0 deletions man/man8/phpstat.8
1 change: 1 addition & 0 deletions man/man8/pythoncalls.8
1 change: 1 addition & 0 deletions man/man8/pythonflow.8
1 change: 1 addition & 0 deletions man/man8/pythongc.8
1 change: 1 addition & 0 deletions man/man8/pythonstat.8
1 change: 1 addition & 0 deletions man/man8/rubycalls.8
1 change: 1 addition & 0 deletions man/man8/rubyflow.8
1 change: 1 addition & 0 deletions man/man8/rubygc.8
1 change: 1 addition & 0 deletions man/man8/rubyobjnew.8
1 change: 1 addition & 0 deletions man/man8/rubystat.8
11 changes: 10 additions & 1 deletion man/man8/ucalls.8
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
.TH ucalls 8 "2016-11-07" "USER COMMANDS"
.SH NAME
ucalls \- Summarize method calls from high-level languages and Linux syscalls.
ucalls, javacalls, pythoncalls, rubycalls, phpcalls \- Summarize method calls
from high-level languages and Linux syscalls.
.SH SYNOPSIS
.B javacalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br
.B pythoncalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br
.B rubycalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br
.B phpcalls [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.br
.B ucalls [-l {java,python,ruby,php}] [-h] [-T TOP] [-L] [-S] [-v] [-m] pid [interval]
.SH DESCRIPTION
This tool summarizes method calls from high-level languages such as Python,
Expand Down
13 changes: 11 additions & 2 deletions man/man8/uflow.8
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.TH uflow 8 "2016-11-07" "USER COMMANDS"
.SH NAME
uflow \- Print a flow graph of method calls in high-level languages.
uflow, javaflow, pythonflow, rubyflow, phpflow \- Print a flow graph of method
calls in high-level languages.
.SH SYNOPSIS
.B uflow [-h] [-M METHOD] [-C CLAZZ] [-v] {java,python,ruby,php} pid
.B javaflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br
.B pythonflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br
.B rubyflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br
.B phpflow [-h] [-M METHOD] [-C CLAZZ] [-v] pid
.br
.B uflow [-h] [-M METHOD] [-C CLAZZ] [-v] [-l {java,python,ruby,php}] pid
.SH DESCRIPTION
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).
Expand Down
13 changes: 11 additions & 2 deletions man/man8/ugc.8
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.TH ugc 8 "2016-11-07" "USER COMMANDS"
.SH NAME
ugc \- Trace garbage collection events in high-level languages.
ugc, javagc, pythongc, rubygc, nodegc \- Trace garbage collection events in
high-level languages.
.SH SYNOPSIS
.B ugc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] {java,python,ruby,node} pid
.B javagc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br
.B pythongc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br
.B rubygc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br
.B nodegc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] pid
.br
.B ugc [-h] [-v] [-m] [-M MINIMUM] [-F FILTER] [-l {java,python,ruby,node}] pid
.SH DESCRIPTION
This traces garbage collection events as they occur, including their duration
and any additional information (such as generation collected or type of GC)
Expand Down
11 changes: 9 additions & 2 deletions man/man8/uobjnew.8
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
.TH uobjnew 8 "2016-11-07" "USER COMMANDS"
.SH NAME
uobjnew \- Summarize object allocations in high-level languages.
uobjnew, javaobjnew, rubyobjnew, cobjnew \- Summarize object allocations in
high-level languages.
.SH SYNOPSIS
.B uobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] {java,ruby,c} pid [interval]
.B javaobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br
.B rubyobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br
.B cobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] pid [interval]
.br
.B uobjnew [-h] [-C TOP_COUNT] [-S TOP_SIZE] [-v] [-l {java,ruby,c}] pid [interval]
.SH DESCRIPTION
uobjnew traces object allocations in high-level languages (including "malloc")
and prints summaries of the most frequently allocated types by number of
Expand Down
13 changes: 12 additions & 1 deletion man/man8/ustat.8
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
.TH ustat 8 "2016-11-07" "USER COMMANDS"
.SH NAME
ustat \- Activity stats from high-level languages.
ustat, javastat, pythonstat, rubystat, nodestat, phpstat \- Activity stats from
high-level languages.
.SH SYNOPSIS
.B javastat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B pythonstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B rubystat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B nodestat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B phpstat [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.br
.B ustat [-l {java,python,ruby,node,php}] [-C] [-S {cload,excp,gc,method,objnew,thread}] [-r MAXROWS] [-d] [interval [count]]
.SH DESCRIPTION
This is "top" for high-level language events, such as garbage collections,
Expand Down
4 changes: 3 additions & 1 deletion man/man8/uthreads.8
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.TH uthreads 8 "2016-11-07" "USER COMMANDS"
.SH NAME
uthreads \- Trace thread creation events in Java or pthreads.
uthreads, javathreads \- Trace thread creation events in Java or pthreads.
.SH SYNOPSIS
.B javathreads [-h] [-v] pid
.BR
.B uthreads [-h] [-l {java}] [-v] pid
.SH DESCRIPTION
This traces thread creation events in Java processes, or pthread creation
Expand Down
56 changes: 49 additions & 7 deletions snapcraft/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
name: bcc
version: 0.3.0-20170322-1719-aaab74e
version: 0.3.0-20170401-1747-c5f48c9
summary: BPF Compiler Collection (BCC)
description: A toolkit for creating efficient kernel tracing and manipulation programs
confinement: strict
Expand Down Expand Up @@ -149,17 +149,59 @@ apps:
ttysnoop:
command: wrapper ttysnoop
ucalls:
command: wrapper ucalls
command: wrapper lib/ucalls
uflow:
command: wrapper uflow
command: wrapper lib/uflow
ugc:
command: wrapper ugc
command: wrapper lib/ugc
uobjnew:
command: wrapper uobjnew
command: wrapper lib/uobjnew
ustat:
command: wrapper ustat
command: wrapper lib/ustat
uthreads:
command: wrapper uthreads
command: wrapper lib/uthreads
cobjnew:
command: wrapper cobjnew
javacalls:
command: wrapper javacalls
javaflow:
command: wrapper javaflow
javagc:
command: wrapper javagc
javaobjnew:
command: wrapper javaobjnew
javastat:
command: wrapper javastat
javathreads:
command: wrapper javathreads
nodegc:
command: wrapper nodegc
nodestat:
command: wrapper nodestat
phpcalls:
command: wrapper phpcalls
phpflow:
command: wrapper phpflow
phpstat:
command: wrapper phpstat
pythoncalls:
command: wrapper pythoncalls
pythonflow:
command: wrapper pythonflow
pythongc:
command: wrapper pythongc
pythonstat:
command: wrapper pythonstat
rubycalls:
command: wrapper rubycalls
rubyflow:
command: wrapper rubyflow
rubygc:
command: wrapper rubygc
rubyobjnew:
command: wrapper rubyobjnew
rubystat:
command: wrapper rubystat
vfscount:
command: wrapper vfscount
vfsstat:
Expand Down
10 changes: 5 additions & 5 deletions tests/python/test_tools_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ def test_ttysnoop(self):
def test_ucalls(self):
# This attaches a large number (300+) kprobes, which can be slow,
# so use an increased timeout value.
self.run_with_int("ucalls.py -l none -S %d" % os.getpid(),
self.run_with_int("lib/ucalls.py -l none -S %d" % os.getpid(),
timeout=30, kill_timeout=30)

@skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
def test_uflow(self):
# The Python installed on the Ubuntu buildbot doesn't have USDT
# probes, so we can't run uflow.
# self.run_with_int("uflow.py -l python %d" % os.getpid())
# self.run_with_int("pythonflow.py %d" % os.getpid())
pass

@skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
Expand All @@ -325,15 +325,15 @@ def test_ugc(self):

@skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
def test_uobjnew(self):
self.run_with_int("uobjnew.py -l c %d" % os.getpid())
self.run_with_int("cobjnew.sh %d" % os.getpid())

@skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
def test_ustat(self):
self.run_with_duration("ustat.py 1 1")
self.run_with_duration("lib/ustat.py 1 1")

@skipUnless(kernel_version_ge(4,4), "requires kernel >= 4.4")
def test_uthreads(self):
self.run_with_int("uthreads.py %d" % os.getpid())
self.run_with_int("lib/uthreads.py %d" % os.getpid())

def test_vfscount(self):
self.run_with_int("vfscount.py")
Expand Down
17 changes: 16 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
file(GLOB C_FILES *.c)
file(GLOB PY_FILES *.py)
file(GLOB SH_FILES *.sh)
file(GLOB TXT_FILES *.txt)
list(REMOVE_ITEM TXT_FILES "CMakeLists.txt")
list(REMOVE_ITEM TXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
foreach(FIL ${PY_FILES})
get_filename_component(FIL_WE ${FIL} NAME_WE)
install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
endforeach()
foreach(FIL ${SH_FILES})
if(${FIL} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/reset-trace.sh)
get_filename_component(FIL_WE ${FIL} NAME_WE)
install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
else()
file(READ ${FIL} CONTENT)
string(REPLACE ".py -l" " -l" CONTENT_WE ${CONTENT})
string(REPLACE "\"" "\\\"" CONTENT_WE ${CONTENT_WE})
get_filename_component(FIL_WE ${FIL} NAME_WE)
install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
install(CODE "file(WRITE \"\$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}/share/bcc/tools/${FIL_WE}\" \"${CONTENT_WE}\")")
endif()
endforeach()
install(FILES ${C_FILES} DESTINATION share/bcc/tools)
install(FILES ${TXT_FILES} DESTINATION share/bcc/tools/doc)
add_subdirectory(lib)
add_subdirectory(old)
3 changes: 3 additions & 0 deletions tools/cobjnew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uobjnew.py -l c "$@"
1 change: 1 addition & 0 deletions tools/cobjnew_example.txt
3 changes: 3 additions & 0 deletions tools/javacalls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ucalls.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javacalls_example.txt
3 changes: 3 additions & 0 deletions tools/javaflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uflow.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javaflow_example.txt
3 changes: 3 additions & 0 deletions tools/javagc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ugc.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javagc_example.txt
3 changes: 3 additions & 0 deletions tools/javaobjnew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uobjnew.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javaobjnew_example.txt
3 changes: 3 additions & 0 deletions tools/javastat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ustat.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javastat_example.txt
3 changes: 3 additions & 0 deletions tools/javathreads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/uthreads.py -l java "$@"
1 change: 1 addition & 0 deletions tools/javathreads_example.txt
8 changes: 8 additions & 0 deletions tools/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
file(GLOB PY_FILES *.py)
file(GLOB TXT_FILES *.txt)
list(REMOVE_ITEM TXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
foreach(FIL ${PY_FILES})
get_filename_component(FIL_WE ${FIL} NAME_WE)
install(PROGRAMS ${FIL} DESTINATION share/bcc/tools/lib RENAME ${FIL_WE})
endforeach()
install(FILES ${TXT_FILES} DESTINATION share/bcc/tools/doc/lib)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions tools/nodegc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ugc.py -l node "$@"
1 change: 1 addition & 0 deletions tools/nodegc_example.txt
3 changes: 3 additions & 0 deletions tools/nodestat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
lib=$(dirname $0)/lib
$lib/ustat.py -l node "$@"
1 change: 1 addition & 0 deletions tools/nodestat_example.txt
Loading

0 comments on commit caa14ed

Please sign in to comment.