platform/upstream/bcc.git
7 years agoFix for test_log_buf to work with python3
Brenden Blanco [Thu, 9 Feb 2017 19:11:23 +0000 (11:11 -0800)]
Fix for test_log_buf to work with python3

In python3, output needs to be converted from ascii to str before the
"error_msg in str" test will succeed. This change should be backwards
compatible with python2.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoStyle fixes for loader.cc
Brenden Blanco [Thu, 9 Feb 2017 18:59:16 +0000 (10:59 -0800)]
Style fixes for loader.cc

Diff generated by clang-format

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoUse builtin clang::CompilerInvocation object
Brenden Blanco [Thu, 9 Feb 2017 18:56:03 +0000 (10:56 -0800)]
Use builtin clang::CompilerInvocation object

Recent llvm changed the calling convention of setInvocation, breaking
3.9/4.0 compatibility. This new approach works for both.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoExplicitly mark b functions as nounwind
Brenden Blanco [Thu, 9 Feb 2017 18:53:29 +0000 (10:53 -0800)]
Explicitly mark b functions as nounwind

Without marking as nounwind, recent llvm started generating .eh_frame
section, which is invalid for bpf target jit.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMark additional helper function as inline
Brenden Blanco [Thu, 9 Feb 2017 18:52:40 +0000 (10:52 -0800)]
Mark additional helper function as inline

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMerge pull request #916 from pchaigno/use-pid-to-resolve-lib
Brenden Blanco [Thu, 9 Feb 2017 18:21:03 +0000 (10:21 -0800)]
Merge pull request #916 from pchaigno/use-pid-to-resolve-lib

Use PID to resolve path of target libraries

7 years agoMerge pull request #951 from r4f4/fix-trace-py3
Brenden Blanco [Thu, 9 Feb 2017 18:18:20 +0000 (10:18 -0800)]
Merge pull request #951 from r4f4/fix-trace-py3

trace: fix for python3

7 years agoMerge pull request #952 from ColinIanKing/master
Brenden Blanco [Thu, 9 Feb 2017 18:13:23 +0000 (10:13 -0800)]
Merge pull request #952 from ColinIanKing/master

snapcraft: add in some missing tools from the snapcraft apps list

7 years agoMerge pull request #955 from r4f4/fix-tplist
4ast [Thu, 9 Feb 2017 17:02:03 +0000 (09:02 -0800)]
Merge pull request #955 from r4f4/fix-tplist

tplist: don't fail if no verbosity is supplied

7 years agoMerge pull request #954 from brendangregg/master
Brenden Blanco [Thu, 9 Feb 2017 15:58:00 +0000 (07:58 -0800)]
Merge pull request #954 from brendangregg/master

update tools pic

7 years agotplist: don't fail if no verbosity is supplied
Rafael Fonseca [Thu, 9 Feb 2017 15:20:24 +0000 (16:20 +0100)]
tplist: don't fail if no verbosity is supplied

Initialise the verbosity argument to 0, so that when no verbosity is
provided we don't fail with

$ tplist
kvmmmu:kvm_mmu_pagetable_walk
unorderable types: NoneType() > int()

7 years agoupdate tools pic
Brendan Gregg [Thu, 9 Feb 2017 07:49:21 +0000 (23:49 -0800)]
update tools pic

7 years agotrace: fix for python3
Rafael Fonseca [Wed, 8 Feb 2017 15:14:31 +0000 (16:14 +0100)]
trace: fix for python3

xrange does not exist in py3.

7 years agosnapcraft: add in some missing tools from the snapcraft apps list
Colin Ian King [Wed, 8 Feb 2017 18:29:05 +0000 (18:29 +0000)]
snapcraft: add in some missing tools from the snapcraft apps list

Add in capable, deadlock-detector, llcstat, mountsnoop, profile,
runqlen, solisten, tplist, ucalls, uflow, ugc, uobjnew, ustat
and uthreads. Includes some re-ordering as well.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
7 years agoMerge pull request #948 from shodoco/master
4ast [Wed, 8 Feb 2017 16:37:11 +0000 (08:37 -0800)]
Merge pull request #948 from shodoco/master

bcc: add support for lpm trie map type

7 years agobcc: update kernel-versions.md for lpm trie change
Huapeng Zhou [Wed, 8 Feb 2017 07:27:20 +0000 (23:27 -0800)]
bcc: update kernel-versions.md for lpm trie change

7 years agobcc: add support for lpm trie map type
Huapeng Zhou [Tue, 7 Feb 2017 23:03:32 +0000 (15:03 -0800)]
bcc: add support for lpm trie map type

7 years agoMerge pull request #946 from goldshtn/install-fc2425
Brenden Blanco [Tue, 7 Feb 2017 20:08:39 +0000 (12:08 -0800)]
Merge pull request #946 from goldshtn/install-fc2425

Update installation instructions for FC24 and FC25

7 years agoMerge pull request #947 from rnav/powerpc64-doc-update
4ast [Tue, 7 Feb 2017 16:33:44 +0000 (08:33 -0800)]
Merge pull request #947 from rnav/powerpc64-doc-update

docs/kernel-versions: add reference to powerpc64 constant blinding support

7 years agodocs/kernel-versions: add reference to powerpc64 constant blinding support
Naveen N. Rao [Tue, 7 Feb 2017 14:53:50 +0000 (20:23 +0530)]
docs/kernel-versions: add reference to powerpc64 constant blinding support

... introduced in v4.9

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 years agoUpdate installation instructions for FC24 and FC25
Sasha Goldshtein [Tue, 7 Feb 2017 10:09:07 +0000 (05:09 -0500)]
Update installation instructions for FC24 and FC25

It turns out that for FC24 and FC25, there is a sufficiently recent
version of Clang in the official package sources, so we don't need
to fetch it from llvm.org using wget. Tested manually on a pair of
fresh FC24 and FC25 VMs, and confirmed that BCC builds and runs OK.

7 years agoMerge pull request #936 from kennyyu/kennyyu-deadlock-detector
4ast [Tue, 7 Feb 2017 04:56:12 +0000 (20:56 -0800)]
Merge pull request #936 from kennyyu/kennyyu-deadlock-detector

tools: add tool to detect potential deadlocks in running programs

7 years agoMerge pull request #944 from derek0883/mybcc
4ast [Tue, 7 Feb 2017 04:54:43 +0000 (20:54 -0800)]
Merge pull request #944 from derek0883/mybcc

switch bcc to use single instance per bcc process, fixed issue #940

7 years agoswitch bcc to use single instance per bcc process,
Derek [Tue, 7 Feb 2017 03:34:11 +0000 (19:34 -0800)]
switch bcc to use single instance per bcc process,
instance dir is bcc_pid, fixed issue #940

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Mon, 6 Feb 2017 20:41:44 +0000 (12:41 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoMerge pull request #943 from edwardshao/topic/fix-docs-commit-link
4ast [Mon, 6 Feb 2017 18:26:31 +0000 (10:26 -0800)]
Merge pull request #943 from edwardshao/topic/fix-docs-commit-link

docs: fix "BPF attached to sockets" commit link

7 years agodocs: fix "BPF attached to sockets" commit link
Edward Shao [Mon, 6 Feb 2017 17:27:27 +0000 (01:27 +0800)]
docs: fix "BPF attached to sockets" commit link

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Sun, 5 Feb 2017 23:31:22 +0000 (15:31 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoMerge pull request #937 from netoptimizer/for_upstream01
4ast [Sun, 5 Feb 2017 16:24:37 +0000 (08:24 -0800)]
Merge pull request #937 from netoptimizer/for_upstream01

docs: keep track of when prealloc of map elements were introduced

7 years agoAddress round 2 of comments in https://github.com/iovisor/bcc/pull/936
Kenny Yu [Sat, 4 Feb 2017 02:50:33 +0000 (18:50 -0800)]
Address round 2 of comments in https://github.com/iovisor/bcc/pull/936

- Specify when `--binary` is needed (statically vs dynamically-linked
  binaries).

- Make `-h`, `_examples.txt`, and man page have concrete examples and
  be more user-friendly.

7 years agoMerge branch 'master' into kennyyu-deadlock-detector
Kenny Yu [Fri, 3 Feb 2017 22:24:40 +0000 (14:24 -0800)]
Merge branch 'master' into kennyyu-deadlock-detector

7 years agoFix a few small typos
Kenny Yu [Fri, 3 Feb 2017 21:33:20 +0000 (13:33 -0800)]
Fix a few small typos

7 years agoAddress comments from https://github.com/iovisor/bcc/pull/936
Kenny Yu [Fri, 3 Feb 2017 17:39:39 +0000 (09:39 -0800)]
Address comments from https://github.com/iovisor/bcc/pull/936

- Remove dependency on networkx. I did this by copying only the parts I needed
  from networkx, and adapting it to only use what I needed. These include:
  `DiGraph`, `strongly_connected_components`, `simple_cyles`

- Symbolize global and static mutexes. In order to do this, I subshell out to
  `subshell`. This isn't very efficient, but this only happens at the end of
  the program if a deadlock is found, so it's not too bad.

- `--verbose` mode to print graph statistics

- Make `--binary` flag optional. Not needed by default, However, this is needed
  on kernels without this recent kernel patch
  (https://lkml.org/lkml/2017/1/13/585, submitted 2 weeks ago): we can't attach
  a uprobe on a binary that has `:` in the path name. Instead, we can create a
  symlink without `:` in the path and pass that to the `--binary` argument
  instead.

7 years agodocs: keep track of when prealloc of map elements were introduced
Jesper Dangaard Brouer [Fri, 3 Feb 2017 07:46:48 +0000 (08:46 +0100)]
docs: keep track of when prealloc of map elements were introduced

Kernel v4.6-rc1~91^2~108^2~6
 commit 6c9059817432 ("bpf: pre-allocate hash map elements")

Introduced default preallocation of mem elements to solve a deadlock
(when kprobe'ing the memory allocator itself).

This change is also a performance enhancement.

The commit also introduced a map_flags on BPF_MAP_CREATE, which can disable
this preallocation again BPF_F_NO_PREALLOC.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
7 years agotools: add tool to detect potential deadlocks in running programs
Kenny Yu [Thu, 2 Feb 2017 18:05:31 +0000 (10:05 -0800)]
tools: add tool to detect potential deadlocks in running programs

`deadlock_detector` is a new tool to detect potential deadlocks (lock order
inversions) in a running process. The program attaches uprobes on
`pthread_mutex_lock` and `pthread_mutex_unlock` to build a mutex wait directed
graph, and then looks for a cycle in this graph. This graph has the following
properties:

- Nodes in the graph represent mutexes.
- Edge (A, B) exists if there exists some thread T where lock(A) was called
  and lock(B) was called before unlock(A) was called.

If there is a cycle in this graph, this indicates that there is a lock order
inversion (potential deadlock). If the program finds a lock order inversion, the
program will dump the cycle of mutexes, dump the stack traces where each mutex
was acquired, and then exit.

The format of the output uses a similar output as ThreadSanitizer (See example:
https://github.com/google/sanitizers/wiki/ThreadSanitizerDeadlockDetector)

This program can only find potential deadlocks that occur while the program is
tracing the process. It cannot find deadlocks that may have occurred before the
program was attached to the process.

If the traced process has many mutexes and threads, this program will add a
very large overhead because every mutex lock/unlock and clone call will be
traced. This tool is meant for debugging only, and you should run this tool
only on programs where the slowdown is acceptable.

Note: This tool adds a dependency on `networkx` for the graph libraries
(building a directed graph and cycle detection).

Note: This tool does not work for shared mutexes or recursive mutexes.

For shared (read-write) mutexes, a deadlock requires a cycle in the wait
graph where at least one of the mutexes in the cycle is acquiring exclusive
(write) ownership.

For recursive mutexes, lock() is called multiple times on the same mutex.
However, there is no way to determine if a mutex is a recursive mutex
after the mutex has been created. As a result, this tool will not find
potential deadlocks that involve only one mutex.

7 years agoMerge pull request #935 from wcohen/wcohen/lua_opt
Brenden Blanco [Fri, 3 Feb 2017 00:55:51 +0000 (16:55 -0800)]
Merge pull request #935 from wcohen/wcohen/lua_opt

Allow RPMS to be built on ppc64 and aarch64 by making luajit optional

7 years agoAllow RPMS to be built on ppc64 and aarch64 by making luajit optional
William Cohen [Thu, 2 Feb 2017 22:24:32 +0000 (17:24 -0500)]
Allow RPMS to be built on ppc64 and aarch64 by making luajit optional

Not all architectures have luajit supported.  The bcc configure and
build were already was set up to make the luajit dependent parts
optional.  The bcc.spec now makes the luajit dependent parts optional
too allowing Fedora 25 builds on ppc64, ppc64le, and aarch64.  This
change has been tested and allows the resulting srpm to build on the
Fedora koji build system for the newly added architectures.

Signed-off-by: William Cohen <wcohen@redhat.com>
7 years agoMerge pull request #928 from goldshtn/tp-data-loc
4ast [Wed, 1 Feb 2017 18:21:16 +0000 (10:21 -0800)]
Merge pull request #928 from goldshtn/tp-data-loc

Support for __data_loc tracepoint fields

7 years agotplist: Don't ignore __data_loc fields
Sasha Goldshtein [Wed, 1 Feb 2017 09:57:01 +0000 (09:57 +0000)]
tplist: Don't ignore __data_loc fields

7 years agotests: Add test for TP_DATA_LOC_READ_CONST
Sasha Goldshtein [Wed, 1 Feb 2017 09:39:12 +0000 (09:39 +0000)]
tests: Add test for TP_DATA_LOC_READ_CONST

7 years agocc: Support for __data_loc tracepoint fields
Sasha Goldshtein [Wed, 1 Feb 2017 06:58:59 +0000 (06:58 +0000)]
cc: Support for __data_loc tracepoint fields

`__data_loc` fields are dynamically sized by the kernel at
runtime. The field data follows the tracepoint structure entry,
and needs to be extracted in a special way. The `__data_loc` field
itself is a 32-bit value that consists of two 16-bit parts: the
high 16 bits are the length of the data, and the low 16 bits are
the offset of the data from the beginning of the tracepoint
structure. From a cursory look, there are >200 tracepoints in
recent kernels that have this kind of field.

This patch fixes `tp_frontend_action.cc` to recognize and emit
`__data_loc` fields correctly, as 32-bit opaque fields. Then, it
introduces two helper macros:

`TP_DATA_LOC_READ(dst, field)` reads from `args->field` by finding
the right offset and length and emitting the `bpf_probe_read`
required to fetch the data. This will only work with new kernels.

`TP_DATA_LOC_READ_CONST(dst, field, length)` takes a user-specified
length rather than finding it from `args->field`. This will work
on older kernels, where the BPF verifier doesn't allow non-constant
sizes to be passed to `bpf_probe_read`.

7 years agoMerge pull request #918 from derek0883/mybcc
4ast [Wed, 1 Feb 2017 04:39:09 +0000 (20:39 -0800)]
Merge pull request #918 from derek0883/mybcc

Handling multiple concurrent probe users.

7 years agoenum bpf_probe_attach_type to CAPITAL
Derek [Wed, 1 Feb 2017 03:28:10 +0000 (19:28 -0800)]
enum bpf_probe_attach_type to CAPITAL

7 years agoundo rebase
Derek [Wed, 1 Feb 2017 02:22:24 +0000 (18:22 -0800)]
undo rebase

7 years agoMerge pull request #927 from rnav/powerpc-fixes
4ast [Tue, 31 Jan 2017 17:59:34 +0000 (09:59 -0800)]
Merge pull request #927 from rnav/powerpc-fixes

powerpc: update the build triplet

7 years agopowerpc: update the build triplet
Naveen N. Rao [Tue, 31 Jan 2017 11:49:17 +0000 (17:19 +0530)]
powerpc: update the build triplet

The more commonly used triplet on ppc64le happens to be
powerpc64le-unknown-linux-gnu. The existing one causes problems in
certain build environments. Change this.

While at it, also include support for building on big endian.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 years agoMerge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc
Derek [Tue, 31 Jan 2017 05:16:55 +0000 (21:16 -0800)]
Merge branch 'mybcc' of https://github.com/derek0883/bcc into mybcc

7 years agokeep 'enum bpf_attach_type' inside libbpf.h, renamed it to bpf_probe_attach_type
Derek [Tue, 31 Jan 2017 05:03:02 +0000 (21:03 -0800)]
keep 'enum bpf_attach_type' inside libbpf.h, renamed it to bpf_probe_attach_type
using static buf size in libbpf.c. for uprobe, set buf size to PATH_MAX

7 years agoFixed test case test_trace4.py error
Derek [Sun, 29 Jan 2017 01:43:15 +0000 (17:43 -0800)]
Fixed test case test_trace4.py error

7 years ago Handling multiple concurrent probe users.
Derek [Sun, 29 Jan 2017 00:11:28 +0000 (16:11 -0800)]
Handling multiple concurrent probe users.
    remove event_desc from front-end, handle it inside libbpf
    Event naming pattern changed to $(eventname)_bcc_$(pid)

7 years agorename event_name for lua
Derek [Thu, 26 Jan 2017 02:01:16 +0000 (18:01 -0800)]
rename event_name for lua

7 years agorename event name in detach_uprobe/detach_uretprobe
Derek [Tue, 24 Jan 2017 04:46:35 +0000 (20:46 -0800)]
rename event name in detach_uprobe/detach_uretprobe

7 years agorename event name in detach_kprobe/detach_kretprobe
Derek [Tue, 24 Jan 2017 04:32:59 +0000 (20:32 -0800)]
rename event name in detach_kprobe/detach_kretprobe

7 years agoHandling multiple concurrent probe users.
Derek [Mon, 23 Jan 2017 04:58:23 +0000 (20:58 -0800)]
Handling multiple concurrent probe users.
Event naming pattern changed to $(eventname)_bcc_$(pid)
Detect /sys/kernel/debug/tracing/instances in bpf_attach_probe,
if it exist, then will per-instance event, if failed the make global
event instance as same as before.

7 years agoMerge pull request #926 from goldshtn/argdist-pid-fix
4ast [Mon, 30 Jan 2017 16:07:05 +0000 (08:07 -0800)]
Merge pull request #926 from goldshtn/argdist-pid-fix

argdist: Fix -p behavior to filter tgid and not pid

7 years agoMerge pull request #925 from goldshtn/cpudist-import-fix
4ast [Mon, 30 Jan 2017 16:05:13 +0000 (08:05 -0800)]
Merge pull request #925 from goldshtn/cpudist-import-fix

cpudist: remove unused Tracepoint import

7 years agoargdist: Fix -p behavior to filter tgid and not pid
Sasha Goldshtein [Mon, 30 Jan 2017 11:08:12 +0000 (11:08 +0000)]
argdist: Fix -p behavior to filter tgid and not pid

argdist remained one of the last holdouts to use the `-p` switch
inconsistently with other tools, filtering for kernel pid (thread
id from user space perspective) and not kernel tgid (process id
from user space perspective). This is now fixed.

Additionally, minor nits around generating pid filters were fixed,
and a potential collision with user-provided argument names was
fixed too (in general, script-generated arguments/locals should
probably stick to reserved identifiers, such as `__whatever` rather
than `whatever`).

7 years agocpudist: remove unused Tracepoint import
Sasha Goldshtein [Mon, 30 Jan 2017 07:40:42 +0000 (07:40 +0000)]
cpudist: remove unused Tracepoint import

7 years agoFixed test case test_trace4.py error
Derek [Sun, 29 Jan 2017 01:43:15 +0000 (17:43 -0800)]
Fixed test case test_trace4.py error

7 years ago Handling multiple concurrent probe users.
Derek [Sun, 29 Jan 2017 00:11:28 +0000 (16:11 -0800)]
Handling multiple concurrent probe users.
    remove event_desc from front-end, handle it inside libbpf
    Event naming pattern changed to $(eventname)_bcc_$(pid)

7 years agorename event_name for lua
Derek [Thu, 26 Jan 2017 02:01:16 +0000 (18:01 -0800)]
rename event_name for lua

7 years agorename event name in detach_uprobe/detach_uretprobe
Derek [Tue, 24 Jan 2017 04:46:35 +0000 (20:46 -0800)]
rename event name in detach_uprobe/detach_uretprobe

7 years agorename event name in detach_kprobe/detach_kretprobe
Derek [Tue, 24 Jan 2017 04:32:59 +0000 (20:32 -0800)]
rename event name in detach_kprobe/detach_kretprobe

7 years agoUse PID to resolve path of target libraries
Paul Chaignon [Sat, 21 Jan 2017 13:25:41 +0000 (14:25 +0100)]
Use PID to resolve path of target libraries

Leverage commit 690b7e6d

7 years agoHandling multiple concurrent probe users.
Derek [Mon, 23 Jan 2017 04:58:23 +0000 (20:58 -0800)]
Handling multiple concurrent probe users.
Event naming pattern changed to $(eventname)_bcc_$(pid)
Detect /sys/kernel/debug/tracing/instances in bpf_attach_probe,
if it exist, then will per-instance event, if failed the make global
event instance as same as before.

7 years agoMerge pull request #913 from iovisor/python23_percpu
4ast [Sun, 22 Jan 2017 17:34:21 +0000 (09:34 -0800)]
Merge pull request #913 from iovisor/python23_percpu

Fix python2/3 incompatible percpu helpers

7 years agoSkip percpu testing on unsupported kernels
Brenden Blanco [Fri, 20 Jan 2017 23:35:36 +0000 (15:35 -0800)]
Skip percpu testing on unsupported kernels

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoSupport for hotplug cpu cases in percpu array sizing
Brenden Blanco [Fri, 20 Jan 2017 23:34:36 +0000 (15:34 -0800)]
Support for hotplug cpu cases in percpu array sizing

The kernel uses number of possible cpus to size the leaf, not the num of
online cpus. Fixup the python side appropriately.
Update: use num_possible_cpus() helper instead

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoFix python2/3 incompatible percpu helpers
Brenden Blanco [Wed, 18 Jan 2017 17:02:59 +0000 (09:02 -0800)]
Fix python2/3 incompatible percpu helpers

The python3 version of the percpu helpers (average, sum, etc.) were
using a python2 function that has since moved to functools (reduce).

Worse, the test case for percpu functionality was not enabled in the
cmake file. Better turn that on and make it work.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
7 years agoMerge pull request #914 from mkacik/master
4ast [Fri, 20 Jan 2017 17:33:46 +0000 (09:33 -0800)]
Merge pull request #914 from mkacik/master

[tools][memleak.py] add parameter for specifying object to load malloc/free from

7 years ago[memleak] add parameter for specifying object to load malloc/free from
Maria Kacik [Thu, 19 Jan 2017 05:43:41 +0000 (21:43 -0800)]
[memleak] add parameter for specifying object to load malloc/free from

7 years agoMerge pull request #911 from goldshtn/trace-params-signature
4ast [Tue, 17 Jan 2017 19:06:38 +0000 (11:06 -0800)]
Merge pull request #911 from goldshtn/trace-params-signature

trace: Allow function signatures in uprobes and kprobes

7 years agoMerge pull request #909 from goldshtn/tp-str-fixes
4ast [Tue, 17 Jan 2017 19:04:41 +0000 (11:04 -0800)]
Merge pull request #909 from goldshtn/tp-str-fixes

trace, tplist, argdist: UDST probe miscellaneous fixes

7 years agotrace: Allow function signatures in uprobes and kprobes
Sasha Goldshtein [Tue, 17 Jan 2017 08:49:36 +0000 (08:49 +0000)]
trace: Allow function signatures in uprobes and kprobes

§`trace` now allows uprobes and kprobes to have function signatures,
which means function parameters can be named and typed, rather than
relying on the positional arg1, arg2, etc. arguments. This also
enables structure field access, which is impossible with the unnamed
arguments due to rewriter limitations.

The example requested by @brendangregg, which now works, is the
following:

§Â```
PID    TID    COMM         FUNC             -
777    785    automount    SyS_nanosleep    sleep for 500000000 ns
777    785    automount    SyS_nanosleep    sleep for 500000000 ns
777    785    automount    SyS_nanosleep    sleep for 500000000 ns
777    785    automount    SyS_nanosleep    sleep for 500000000 ns
^C
```

7 years agotrace, argdist: Fix code formatting nits
Sasha Goldshtein [Tue, 17 Jan 2017 07:40:57 +0000 (07:40 +0000)]
trace, argdist: Fix code formatting nits

7 years agotrace: Use correct argument index and tgid for filters
Sasha Goldshtein [Mon, 16 Jan 2017 18:43:11 +0000 (18:43 +0000)]
trace: Use correct argument index and tgid for filters

`trace` would use the incorrect argument index for USDT probes when
filtering specifically, e.g. `trace u:lib:tp (arg1 != 0) ...` would
actually use the type of the 2nd argument, and not the 1st argument
for the type of the filter variable in the generated program. This
could cause compilation errors or subtle bugs where the data would
be either extended or contracted to fit the wrong argument's type.

Additionally, `trace` would use the pid (thread id, `-L`) filter
with the `attach_uprobe` API, which expects a tgid (process id).
As a result, incorrect filtering would happen.

7 years agotrace: Generated streq-helper to ignore null terminator
Sasha Goldshtein [Mon, 16 Jan 2017 18:41:22 +0000 (18:41 +0000)]
trace: Generated streq-helper to ignore null terminator

7 years agoargdist: Generated streq-helper to ignore null terminator
Sasha Goldshtein [Mon, 16 Jan 2017 18:38:30 +0000 (18:38 +0000)]
argdist: Generated streq-helper to ignore null terminator

Oftentimes we want to use the STRCMP helper to compare strings that
are not null-terminated, e.g. in USDT probes this often happens.
Ignore the null terminator (i.e. loop until the last character
excluding the null terminator).

7 years agotplist: Print one-based location and argument indices
Sasha Goldshtein [Mon, 16 Jan 2017 18:36:52 +0000 (18:36 +0000)]
tplist: Print one-based location and argument indices

The `trace` and `argdist` tools expect location and argument indices
to start at 1 -- the first argument is arg1, and so on. The `tplist`
tool now prints UDST argument indices (and location indices, for
consistency) as 1-based as well.

7 years agoMerge pull request #875 from pchaigno/target-process-library
4ast [Tue, 17 Jan 2017 01:24:17 +0000 (17:24 -0800)]
Merge pull request #875 from pchaigno/target-process-library

Use targeted process to resolve library names

7 years agoMerge pull request #908 from Catalysts/cpu-iteration
4ast [Mon, 16 Jan 2017 21:35:04 +0000 (13:35 -0800)]
Merge pull request #908 from Catalysts/cpu-iteration

fix iteration over CPUs

7 years agofix iteration over CPUs
Andreas Gerstmayr [Mon, 16 Jan 2017 15:35:58 +0000 (16:35 +0100)]
fix iteration over CPUs

Since kernel version 4.9.0 BPF stopped working in a KVM guest.
The problem are calls to perf_event_open with CPU identifiers which do
not exist (ENODEV). The root cause for this is that the current code
assumes ascending numbered CPUs. However, this is not always the case
(e.g. CPU hotplugging).

This patch introduces the get_online_cpus() and get_possible_cpus()
helper functions and uses the appropriate function for iterations over
CPUs. The BPF_MAP_TYPE_PERF_EVENT_ARRAY map contains now an entry for
each possible CPU instead of for each online CPU.

Fixes: #893
Signed-off-by: Andreas Gerstmayr <andreas.gerstmayr@catalysts.cc>
7 years agoMerge pull request #906 from goldshtn/valid-idents
Brendan Gregg [Mon, 16 Jan 2017 11:13:39 +0000 (03:13 -0800)]
Merge pull request #906 from goldshtn/valid-idents

argdist, trace: Support non-C identifier names

7 years agocc: Dynamically allocate memory for library path
Paul Chaignon [Sun, 15 Jan 2017 09:11:42 +0000 (10:11 +0100)]
cc: Dynamically allocate memory for library path

7 years agocc: Use PID to detach uprobes
Paul Chaignon [Fri, 13 Jan 2017 22:37:28 +0000 (23:37 +0100)]
cc: Use PID to detach uprobes

We need the PID when detaching uprobes to resolve library names
to the same path as when attaching

7 years agocc: Resolve library names using loaded libraries
Paul Chaignon [Sun, 25 Dec 2016 18:43:41 +0000 (19:43 +0100)]
cc: Resolve library names using loaded libraries

To resolve library names, bcc_procutils_which_so leverages mapped
libraries of the targeted process, if one is given. Uses the kernel's
/proc/$pid/maps

7 years agoargdist, trace: Support non-C identifier names
Sasha Goldshtein [Sat, 14 Jan 2017 11:17:40 +0000 (11:17 +0000)]
argdist, trace: Support non-C identifier names

When argdist or trace face a function that has characters
in its name that are not valid in C identifier, they now
replace these characters with an underscore (`_`) when
generating function names and structure names to include
in the BPF program. As a result, it is now possible to
trace functions that have these identifiers in their names,
such as Golang functions like `fmt.Println`.

7 years agoMerge pull request #904 from brendangregg/master
4ast [Fri, 13 Jan 2017 23:36:53 +0000 (15:36 -0800)]
Merge pull request #904 from brendangregg/master

add some error hints

7 years agoadd some error hints
Brendan Gregg [Fri, 13 Jan 2017 22:02:02 +0000 (14:02 -0800)]
add some error hints

7 years agoMerge pull request #899 from brendangregg/tool2
4ast [Wed, 11 Jan 2017 18:47:47 +0000 (10:47 -0800)]
Merge pull request #899 from brendangregg/tool2

profile: increase unique stack default to 10k

7 years agoMerge pull request #896 from brendangregg/tool1
4ast [Wed, 11 Jan 2017 18:40:47 +0000 (10:40 -0800)]
Merge pull request #896 from brendangregg/tool1

trace: allow tracing of functions containing a dot (golang)

7 years agoMerge pull request #897 from brendangregg/master
4ast [Wed, 11 Jan 2017 18:40:19 +0000 (10:40 -0800)]
Merge pull request #897 from brendangregg/master

statsnoop: refactor

7 years agoprofile: increase unique stack default to 10k
Brendan Gregg [Wed, 11 Jan 2017 17:40:49 +0000 (09:40 -0800)]
profile: increase unique stack default to 10k

7 years agostatsnoop: refactor
Brendan Gregg [Wed, 11 Jan 2017 06:31:30 +0000 (22:31 -0800)]
statsnoop: refactor

7 years agoMerge pull request #895 from brendangregg/master
4ast [Wed, 11 Jan 2017 05:28:55 +0000 (21:28 -0800)]
Merge pull request #895 from brendangregg/master

gethostlatency: remove unused code

7 years agotrace: allow tracing of functions containing a dot (golang)
Brendan Gregg [Wed, 11 Jan 2017 04:39:07 +0000 (20:39 -0800)]
trace: allow tracing of functions containing a dot (golang)

7 years agogethostlatency: remove unused code
Brendan Gregg [Wed, 11 Jan 2017 04:31:06 +0000 (20:31 -0800)]
gethostlatency: remove unused code

7 years agoMerge pull request #894 from brendangregg/master
4ast [Wed, 11 Jan 2017 02:04:41 +0000 (18:04 -0800)]
Merge pull request #894 from brendangregg/master

add a few funccount examples

7 years agoadd a few funccount examples
Brendan Gregg [Wed, 11 Jan 2017 01:36:07 +0000 (17:36 -0800)]
add a few funccount examples

7 years agoMerge pull request #883 from ColinIanKing/master
4ast [Mon, 9 Jan 2017 20:40:46 +0000 (12:40 -0800)]
Merge pull request #883 from ColinIanKing/master

snapcraft: add cpuunclaimed to snapcraft wrapper rules