platform/upstream/bcc.git
7 years agoMerge pull request #763 from goldshtn/enhanced-funccount
Brendan Gregg [Wed, 19 Oct 2016 08:22:18 +0000 (01:22 -0700)]
Merge pull request #763 from goldshtn/enhanced-funccount

funccount: Generalized for uprobes, tracepoints, and USDT

7 years agopython: Fix kprobe quota test breakage, add uprobes
Sasha Goldshtein [Wed, 19 Oct 2016 08:04:44 +0000 (01:04 -0700)]
python: Fix kprobe quota test breakage, add uprobes

As part of the funccount work, the kprobe quota test doesn't fail
early when adding multiple kprobes at once (with `event_re`), but
rather only when the 1000th probe is being added. Revert to the old
behavior, which fixes the `test_probe_quota` test. Add similar test
for uprobes, `test_uprobe_quota`, which tests the recently-added
uprobe regex support.

7 years agofunccount: Generalize for uprobes, tracepoints, and USDT
Sasha Goldshtein [Sat, 8 Oct 2016 14:01:21 +0000 (07:01 -0700)]
funccount: Generalize for uprobes, tracepoints, and USDT

This commit updates `funccount` to support attaching to a set of
user functions, kernel tracepoints, or USDT probes using familiar
syntax. Along the way, the implementation has been updated to use
a separate BPF function for each target function, because using
the instruction pointer to determine the function name doesn't
work for anything other than kprobes. Even though the BPF program
can now be potentially larger, testing with 40-50 attach points
shows no significant overhead compared to the previous version.

Examples of what's now possible:

```
funccount t:block:*
funccount u:node:gc*
funccount -r 'c:(read|write)$'
funccount -p 142 u:ruby:object__create
```

7 years agobcc: Make regex helpers publicly accessible
Sasha Goldshtein [Sat, 8 Oct 2016 14:00:18 +0000 (07:00 -0700)]
bcc: Make regex helpers publicly accessible

Make the `get_user_functions`, `get_kprobe_functions`, and
`get_tracepoints` methods publicly accessible from the BPF class.
These can then be used by tools that need to do their own work
before attaching programs to a set of functions or tracepoints.

7 years agostackcount: Style fixes for linter (pep8)
Sasha Goldshtein [Sat, 8 Oct 2016 13:59:37 +0000 (06:59 -0700)]
stackcount: Style fixes for linter (pep8)

7 years agofix profile.py page_offset_base breakage (#768)
Brendan Gregg [Wed, 19 Oct 2016 03:17:04 +0000 (20:17 -0700)]
fix profile.py page_offset_base breakage (#768)

7 years agoadd output notes to doc (#765)
Brendan Gregg [Tue, 18 Oct 2016 22:15:33 +0000 (15:15 -0700)]
add output notes to doc (#765)

7 years agoTools lint cleanup (#764)
Sasha Goldshtein [Tue, 18 Oct 2016 22:14:30 +0000 (01:14 +0300)]
Tools lint cleanup (#764)

* argdist: linter cleanup

* cpudist: linter cleanup

* execsnoop: linter cleanup

* funclatency: linter cleanup

* gethostlatency: linter cleanup

* hardirqs: linter cleanup

* memleak: linter cleanup

* mountsnoop: linter cleanup

* offcputime: linter cleanup

* softirqs: linter cleanup

* solisten: linter cleanup and u+x mode

* stacksnoop: linter cleanup

* tplist: linter cleanup

* trace: linter cleanup

7 years agoMerge pull request #752 from goldshtn/mysqld-slower-fix
Brenden Blanco [Tue, 18 Oct 2016 20:13:51 +0000 (13:13 -0700)]
Merge pull request #752 from goldshtn/mysqld-slower-fix

mysqld_slower: Fix breakage after USDT API change

7 years agoadd slabratetop (#759)
Brendan Gregg [Tue, 18 Oct 2016 19:10:24 +0000 (12:10 -0700)]
add slabratetop (#759)

7 years agotrace, argdist: -I switch for trace and miscellaneous fixes (#761)
Sasha Goldshtein [Tue, 18 Oct 2016 17:54:47 +0000 (20:54 +0300)]
trace, argdist: -I switch for trace and miscellaneous fixes (#761)

* trace: Additional include files support

Similarly to `argdist`, `trace` now has a `-I` option for adding
include files that can be used in filter and print expressions.
This also required a slight modification to `argdist`'s syntax
for consistency: where previously we would allow `-I header1 header2`,
we now require `-I header1 -I header2` to avoid any mixups with
which argument is a header file and which is a probe for `trace`.

This is very unlikely to break anyone, because I haven't seen the
`-I` option used at all, not to mention extensively with multiple
headers.

Also made sure the man and example pages are up to date.

* argdist: Update -C and -H switches for consistency

This commit updates `argdist`'s `-H` and `-C` switches for consistency
with the `-I` switch and `trace`'s switches. Specifically, each probe
needs an explicit `-C` or `-H` specifier in front of it. This also
allows safe and understandable mixing of histogram and counting probes,
for example:

```
argdist -C 'p:c:write()' -H 'p::vfs__write(int fd, const void *buf, size_t size):size_t:size#write sizes'
```

* trace: Fix stack trace support for tracepoints

Tracepoint probes don't have a `ctx` argument, it's called `args`
instead. The recently-added stack trace support code didn't take
this into account, and consequently didn't work for tracepoints.
This commit fixes the issue, so we can now do things like
`trace -K t:block:block_rq_complete`.

7 years agoMerge pull request #701 from dkronst/master
Brenden Blanco [Tue, 18 Oct 2016 00:34:51 +0000 (17:34 -0700)]
Merge pull request #701 from dkronst/master

Making selection of kernel headers type automatic

7 years agocc: Support glob+offset format in USDT arguments (#753)
Sasha Goldshtein [Tue, 18 Oct 2016 00:21:54 +0000 (03:21 +0300)]
cc: Support glob+offset format in USDT arguments (#753)

Modern versions of USDT probes (such as what's found in
PostgreSQL when compiled with `--enable-dtrace`) may have
the offset listed after the global symbol for USDT
arguments of the format `4@symbol+8(%rip)`. This commit
extends the argument parser to support these cases, adds
tests for these cases, and makes sure that in case of a
parse error, the parser always moves forward and consumes
at least one character. Presently, the parser would get
stuck on the problematic position and enter an infinite
loop.

7 years agoMerge pull request #754 from iovisor/dkalani_dev
Brenden Blanco [Tue, 18 Oct 2016 00:03:28 +0000 (17:03 -0700)]
Merge pull request #754 from iovisor/dkalani_dev

Add vxlan gbp header

7 years agoSupport filtering by process ID in the filesystem slower tools (#756)
Dina Goldshtein [Tue, 18 Oct 2016 00:01:05 +0000 (03:01 +0300)]
Support filtering by process ID in the filesystem slower tools (#756)

* Filter by process ID in ex4slower

* Updated the rest of the tools to filter by process ID

7 years agoUpdate examples and docs to use the new USDT API
Sasha Goldshtein [Fri, 7 Oct 2016 00:52:09 +0000 (17:52 -0700)]
Update examples and docs to use the new USDT API

The BPF class constructor now accepts an array of USDT
contexts instead of just one object. Update the examples
in **examples/tracing** and docs in **docs** to reflect
this change.

7 years agomysqld_slower: Fix breakage after USDT API change
Sasha Goldshtein [Thu, 6 Oct 2016 23:12:14 +0000 (16:12 -0700)]
mysqld_slower: Fix breakage after USDT API change

A recent PR to the USDT infrastructure changed the BPF
module constructor to accept an array of USDT contexts.
This commit updates `mysqld_slower` to use that new
constructor.

7 years agoadd ttysnoop (#755)
Brendan Gregg [Sun, 16 Oct 2016 19:33:50 +0000 (12:33 -0700)]
add ttysnoop (#755)

7 years agoAdd new mountsnoop tool (#750)
Omar Sandoval [Sun, 16 Oct 2016 19:31:32 +0000 (12:31 -0700)]
Add new mountsnoop tool (#750)

Filesystem mounting and unmounting affects an entire system, so this is
a great candidate for system-wide tracing. mountsnoop.py watches all
mounts and unmounts and is also mount namespace-aware, which is a
requirement for working with containers.

Signed-off-by: Omar Sandoval <osandov@fb.com>
7 years agoAdd vxlan gbp header
Deepa Kalani [Fri, 14 Oct 2016 17:09:55 +0000 (10:09 -0700)]
Add vxlan gbp header

Signed-off-by: Deepa Kalani <dkalani@plumgrid.com>
7 years agotrace: Add %K and %U format specifiers (#742)
Sasha Goldshtein [Tue, 11 Oct 2016 14:56:13 +0000 (07:56 -0700)]
trace: Add %K and %U format specifiers (#742)

The %K and %U format specifiers can be used in a trace
format string to resolve kernel and user symbols,
respectively. For example, the pthread_create USDT probe
has an argument pointing to the new thread's function.
To trace pthread_create and print the symbolic name of
the new thread's function, use:

```
trace 'u:pthread:pthread_create "%U", arg3'
```

The %U specifier resolves addresses in the event's process,
while the %K specifier resolves kernel addresses.

7 years agoUpdate opensnoop to filter by PID and TID (#739)
Dina Goldshtein [Mon, 10 Oct 2016 18:37:36 +0000 (21:37 +0300)]
Update opensnoop to filter by PID and TID (#739)

* Use real PID instead of TID in opensnoop

* Replaced -t for timestamp with -T

* Support TID as well as PID

* Update opensnoop example

* Update man

* Added missing documentation re -n option

* Minor: styling

7 years agoMerge pull request #741 from brontide/patch-1
Brenden Blanco [Mon, 10 Oct 2016 17:42:25 +0000 (10:42 -0700)]
Merge pull request #741 from brontide/patch-1

Update INSTALL.md

7 years agoUpdate INSTALL.md
Eric W [Sun, 9 Oct 2016 17:10:03 +0000 (13:10 -0400)]
Update INSTALL.md

Quickstart leaves out installing the examples.

7 years agoFix #735 (#736)
Marco Leogrande [Thu, 6 Oct 2016 19:28:40 +0000 (12:28 -0700)]
Fix #735 (#736)

GCC 6 behaves slightly differently when using -isystem, and our use of
that parameter is causing a build failure. Avoid using -isystem on
gcc6+ for now, until that compiler becomes a bit more mainstream and
we can debug further.

Failure had been introuced in d19e0cb.

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years agofunclatency: user functions support (#733)
Sasha Goldshtein [Thu, 6 Oct 2016 18:17:59 +0000 (21:17 +0300)]
funclatency: user functions support (#733)

* bcc: Allow custom bucket formatting for histogram keys

When histogram keys are complex structures (`ct.Structure`
created from C struct), they can't be used as dictionary keys
for counting purposes without a custom hashing function.
Allow the user to provide such hashing function when calling
`print_log_hist` to print the histogram.

* bcc: Allow regular expression in attach_uretprobe

Similarly to `attach_uprobe`, `attach_uretprobe` now supports
taking a regular expression.

* funclatency: Support user functions

funclatency now supports user functions (including regular
expressions) in addition to kernel functions. When multiple
processes are traced, the output is always per-function, per-
process. When a single process is traced, the output can be
combined for all traced functions (as with kernel functions).

Usage examples:

```
funclatency pthread:*mutex* -p 6449 -F
funclatency c:read
funclatency dd:* -p $(pidof dd) -uF
```

7 years agoUpdate Clang download in INSTALL.md for FC (#732)
Sasha Goldshtein [Thu, 6 Oct 2016 17:20:18 +0000 (20:20 +0300)]
Update Clang download in INSTALL.md for FC (#732)

FC23 and FC24 need Clang 3.9.0 because of ABI changes in the C++
runtime library. Split the installation instructions to FC22 and
FC23/24.

7 years agotplist: Print USDT locations and arguments (#734)
Sasha Goldshtein [Thu, 6 Oct 2016 15:18:18 +0000 (18:18 +0300)]
tplist: Print USDT locations and arguments (#734)

* cc: Add USDT location and argument reporting

libbcc now exposes USDT location and argument information using
two new APIs: `bcc_usdt_get_location` and `bcc_usdt_get_argument`.

* python: Retrieve USDT locations and arguments

Add wrappers in the libbcc.py file to access the new APIs for
retrieving USDT location and argument information. Also add
high-level classes in usdt.py to access this information and
format arguments and locations in a shape suitable for display.

* tplist: Print USDT locations and arguments

Add super-verbose mode (-vv) to tplist where it prints USDT locations
and arguments including full detail on registers, offsets, and global
identifier offsets.

7 years agosrc/lua: LuaJIT BPF compiler, examples, tests (#652)
Marek Vavruša [Thu, 6 Oct 2016 00:08:25 +0000 (17:08 -0700)]
src/lua: LuaJIT BPF compiler, examples, tests (#652)

this is initial commit of LuaJIT bytecode to BPF
compiler project that enables writing both kernel
and user-part of the code as Lua

7 years agostackcount: Support uprobes, tracepoints, and USDT (#730)
Sasha Goldshtein [Wed, 5 Oct 2016 22:11:55 +0000 (01:11 +0300)]
stackcount: Support uprobes, tracepoints, and USDT (#730)

* stackcount: Support user-space functions

Add support for user-space functions in `stackcount` by taking an additional
`-l` command-line parameter specifying the name of the user-space library.
When a user-space library is specified, `stackcount` attaches to a specific
process and traces a user-space function with user-space stacks only.
Regex support for uprobes (similar to what is available for kprobes) is
not currently provided.

Also add a couple of functions to the `BPF` object for consistency.

* bcc: Support regex in attach_uprobe

attach_kprobe allows a regular expression for the function name,
while attach_uprobe does not. Add support in libccc for enumerating
all the function symbols in a binary, and use that in the BPF module
to attach uprobes according to a regular expression. For example:

```python
bpf = BPF(text="...")
bpf.attach_uprobe(name="c", sym_re=".*write$", fn_name="probe")
```

* python: Support regex in attach_tracepoint

Modify attach_tracepoint to take a regex argument, in which case
it enumerates all tracepoints matching that regex and attaches to
all of them. The logic for enumerating tracepoints should eventually
belong in libccc and be shared across all the tools (tplist, trace
and so on).

* cc: Fix termination condition bug in symbol enumeration

bcc_elf would not terminate the enumeration correctly when the
user-provided callback returned -1 but there were still more
sections remaining in the ELF to be enumerated.

* stackcount: Support uprobes and tracepoints

Refactored stackcount and added support for uprobes and tracepoints,
which also required changes to the BPF module. USDT support still
pending.

* bcc: Refactor symbol listing to use foreach-style

Refactor symbol listing from paging style to foreach-style with a
callback function per-symbol. Even though we're now performing a
callback from C to Python for each symbol, this is preferable to the
paging approach because we need all the symbols in the current use
case.

Also refactored `stackcount` slightly; only missing support for USDT
probes now.

* stackcount: Support per-process displays

For user-space functions, or when requested for kernel-space
functions or tracepoints, group the output by process. Toggled
with the -P switch, off by default (except for user-space).

* Fix rebase issues, print pid only when there is one

* stackcount: Add USDT support

Now, stackcount supports USDT tracepoints in addition to
kernel functions, user functions, and kernel tracepoints.
The format is the same as with the other general-purpose
tools (argdist, trace):

```
stackcount -p $(pidof node) u:node:gc*
stackcount -p 185 u:pthread:pthread_create
```

* stackcount: Update examples and man page

Add examples and man page documentation for kernel
tracepoints, USDT tracepoints, and other features.

* stackcount: Change printing format slightly

When -p is specified, don't print the comm and pid. Also,
when -P is specified for kernel probes (kprobes and
tracepoints), use -1 for symbol resolution so that we
don't try to resolve kernel functions as user symbols.
Finally, print the comm and pid at the end of the stack
output and not at the beginning.

7 years agoMerge branch 'master' into master
Dror Kronstein [Wed, 5 Oct 2016 10:32:16 +0000 (13:32 +0300)]
Merge branch 'master' into master

7 years agofix filelife missing output (#729)
Brendan Gregg [Wed, 5 Oct 2016 01:17:16 +0000 (18:17 -0700)]
fix filelife missing output (#729)

7 years agoupdate tools map (#727)
Brendan Gregg [Tue, 4 Oct 2016 22:41:04 +0000 (15:41 -0700)]
update tools map (#727)

7 years agotcptop (#726)
Brendan Gregg [Tue, 4 Oct 2016 22:18:11 +0000 (15:18 -0700)]
tcptop (#726)

7 years agotrace: Initialize USDT arguments to 0 before reading (#725)
Sasha Goldshtein [Tue, 4 Oct 2016 16:50:50 +0000 (19:50 +0300)]
trace: Initialize USDT arguments to 0 before reading (#725)

Fixes #722, in which a USDT probe that has more than
one location and the type of the argument is a string
caused trace to potentially access an uninitialized
stack variable, thereby not passing BPF program
verification at load time.

7 years agoargdist, trace: Native tracepoint support (#724)
Sasha Goldshtein [Tue, 4 Oct 2016 16:49:57 +0000 (19:49 +0300)]
argdist, trace: Native tracepoint support (#724)

* Remove tracepoint.py

The `Tracepoint` class which implements the necessary
support for the tracepoint kprobe-based hack is no
longer needed and can be removed.

* argdist: Native tracepoint support

This commit migrates argdist to use the native bcc/BPF
tracepoint support instead of the hackish kprobe-
based approach. The resulting programs are cleaner
and likely more efficient.

As a result of this change, there is a slight API
change in how argdist is used with tracepoints. To
access fields from the tracepoint structure, the user
is expected to use `args->field` directly. This
leverages most of the built-in bcc support for
generating the tracepoint probe function.

* trace: Native tracepoint support

This commit migrates trace to use the native bcc/BPF
tracepoint support instead of the hackish kprobe-
based approach. The resulting programs are cleaner
and likely more efficient.

As with argdist, users are now expected to use the
`args` structure pointer to access the tracepoint's
arguments.

For example:

```
trace 't:irq:irq_handler_entry (args->irq != 27) "irq %d", args->irq'
```

7 years agoargdist: Cumulative mode (-c) (#719)
Sasha Goldshtein [Tue, 4 Oct 2016 15:40:15 +0000 (18:40 +0300)]
argdist: Cumulative mode (-c) (#719)

By default, argdist now clears the histograms or freq
count maps after each display interval. The new `-c`
option enables cumulative mode, where maps are not
cleared at each interval. This fixes #718.

7 years agotrace: Print USDT arg helpers in verbose mode (#723)
Sasha Goldshtein [Tue, 4 Oct 2016 15:39:01 +0000 (18:39 +0300)]
trace: Print USDT arg helpers in verbose mode (#723)

When verbose mode is enabled, ask all USDT helper
objects to print out the argument helper functions,
which help retrieve the argument values for each
individual probe location. This can be useful for
debugging probes; the helper functions are part of
the loaded BPF program, so they need to be printed
in verbose mode.

7 years agoargdist, trace: Support naked executable names in probes (#720)
Sasha Goldshtein [Tue, 4 Oct 2016 15:33:36 +0000 (18:33 +0300)]
argdist, trace: Support naked executable names in probes (#720)

Fixes the error message from `BPF._find_exe` which would
occur if argdist or trace had a naked executable name
not qualified with a path, such as:

```
trace 'r:bash:readline "%s", retval'
```

This is now supported again.

7 years agodocs: Update eBPF features list by kernel version (#717)
Quentin Monnet [Mon, 3 Oct 2016 15:06:37 +0000 (17:06 +0200)]
docs: Update eBPF features list by kernel version (#717)

Following brendangregg's suggestion
(https://github.com/iovisor/bcc/pull/577#issuecomment-251052371), this
commit replaces the former list with a new one: more features are
listed, along with commit ids and references (but no comments detailing
the features, though).

7 years agofixup the issue in which distributed_bridge example (#716)
zaafar [Sat, 1 Oct 2016 16:31:18 +0000 (21:31 +0500)]
fixup the issue in which distributed_bridge example (#716)

wasn't working for kernel ver less than 4.5.

7 years agoFix bpf_common.cc include style (#715)
Teng Qin [Fri, 30 Sep 2016 20:13:13 +0000 (13:13 -0700)]
Fix bpf_common.cc include style (#715)

7 years agoMove libbpf.h to src/cc (#714)
Teng Qin [Fri, 30 Sep 2016 19:52:45 +0000 (12:52 -0700)]
Move libbpf.h to src/cc (#714)

7 years agoAdd stack trace to trace.py (#712)
Teng Qin [Fri, 30 Sep 2016 04:30:13 +0000 (21:30 -0700)]
Add stack trace to trace.py (#712)

7 years agoFix trace.py USDT argument filtering (#710)
Teng Qin [Wed, 28 Sep 2016 15:19:40 +0000 (08:19 -0700)]
Fix trace.py USDT argument filtering (#710)

7 years agocmake: fix build when LLVM_INCLUDE_DIRS includes multiple directories (#709)
Marco Leogrande [Wed, 28 Sep 2016 02:17:02 +0000 (19:17 -0700)]
cmake: fix build when LLVM_INCLUDE_DIRS includes multiple directories (#709)

If LLVM_INCLUDE_DIRS includes multiple directories, separated by
semicolon, the string would be incorrectly propagated all the way down
to the shell, that would interpret such semicolon as a command
separator. E.g. we would have:

 c++ ... -isystem /w/llvm/include;/w/llvm/bld/include ...

Instead, we need to parse the string as a CMake list (that are defined
as strings composed by semicolon-separated tokens) and build a string
in the form:

 c++ ... -isystem /w/llvm/include -isystem /w/llvm/bld/include ...

This bug was introduced in d19e0cb.
This commit fixes #707.

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years agoFix or hide a few warnings (#695)
Marco Leogrande [Tue, 27 Sep 2016 16:41:32 +0000 (09:41 -0700)]
Fix or hide a few warnings (#695)

* Flag ${LLVM_INCLUDE_DIRS} as a system include directory

g++ supports a -isystem switch, that can be used to mark a given
directory as a system include directory. Warnings generated by system
include directories are ignored by default.

This commit hides a long list of warnings, like the following one,
generated by llvm header files included from ${LLVM_INCLUDE_DIRS}:

 /usr/lib/llvm-3.7/include/clang/AST/APValue.h:373:44: warning:
   dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
* Fix 'defined but not used' warning

Remove unused function from the USDT probes test.

The warning was:

 tests/cc/test_usdt_probes.cc:59:15: warning:
   ‘size_t countsubs(const string&, const string&)’ defined but not used [-Wunused-function]

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years agoFix argdist, trace, tplist to use the libbcc USDT support (#698)
Sasha Goldshtein [Tue, 27 Sep 2016 16:40:00 +0000 (19:40 +0300)]
Fix argdist, trace, tplist to use the libbcc USDT support (#698)

* Allow argdist to enable USDT probes without a pid

The current code would only pass the pid to the USDT
class, thereby not allowing USDT probes to be enabled
from the binary path only. If the probe doesn't have
a semaphore, it can actually be enabled for all
processes in a uniform fashion -- which is now
supported.

* Reintroduce USDT support into tplist

To print USDT probe information, tplist needs an API
to return the probe data, including the number of
arguments and locations for each probe. This commit
introduces this API, called bcc_usdt_foreach, and
invokes it from the revised tplist implementation.

Although the result is not 100% identical to the
original tplist, which could also print the probe
argument information, this is not strictly required
for users of the argdist and trace tools, which is
why it was omitted for now.

* Fix trace.py tracepoint support

Somehow, the import of the Perf class was omitted
from tracepoint.py, which would cause failures when
trace enables kernel tracepoints.

* trace: Native bcc USDT support

trace now works again by using the new bcc USDT support
instead of the home-grown Python USDT parser. This
required an additional change in the BPF Python API
to allow multiple USDT context objects to be passed to
the constructor in order to support multiple USDT
probes in a single invocation of trace. Otherwise, the
USDT-related code in trace was greatly simplified, and
uses the `bpf_usdt_readarg` macros to obtain probe
argument values.

One minor inconvenience that was introduced in the bcc
USDT API is that USDT probes with multiple locations
that reside in a shared object *must* have a pid
specified to enable, even if they don't have an
associated semaphore. The reason is that the bcc USDT
code figures out which location invoked the probe by
inspecting `ctx->ip`, which, for shared objects, can
only be determined when the specific process context is
available to figure out where the shared object was
loaded. This limitation did not previously exist,
because instead of looking at `ctx->ip`, the Python
USDT reader generated separate code for each probe
location with an incrementing identifier. It's not a
very big deal because it only means that some probes
can't be enabled without specifying a process id, which
is almost always desired anyway for USDT probes.

argdist has not yet been retrofitted with support for
multiple USDT probes, and needs to be updated in a
separate commit.

* argdist: Support multiple USDT probes

argdist now supports multiple USDT probes, as it did
before the transition to the native bcc USDT support.
This requires aggregating the USDT objects from each
probe and passing them together to the BPF constructor
when the probes are initialized and attached.

Also add a more descriptive exception message to the
USDT class when it fails to enable a probe.

7 years agofilelife: use d_name.name and d_name.len instead of d_iname (#700)
Marco Leogrande [Mon, 26 Sep 2016 22:59:51 +0000 (15:59 -0700)]
filelife: use d_name.name and d_name.len instead of d_iname (#700)

This is similar in spirit to what was done in PR #677 to fix the
problem reported in #609.

filelife.py is now converted to use the right struct field.

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years ago[offcputime] allow for the speficication of a threshold for collection (#697)
Glauber Costa [Mon, 26 Sep 2016 19:59:32 +0000 (12:59 -0700)]
[offcputime] allow for the speficication of a threshold for collection (#697)

There are situations, specially when using non-folded mode, where we are
interested only in very high latencies that happen due to blocking.

While we can certainly filter out the very small ones out of the output, it is a
lot more convenient to do this from the tool itself, as it would be difficult
from an external filter to do this in one pass.

But if we are to discard unused measurements, we can do even better: we can
change the bpf code itself not to grab those traces, and gain a bit of
efficiency in scenarios in which we are only concerned about peak latencies.

This scheme can be easily extended to also allow a maximum cap in the latencies
we are interested in.

After this patch is applied, the options -m and -M can be used to set those
limits respectively.

Fixes: #588

7 years agodo no install CMakeLists.txt in tools/doc (#683)
Jörg Thalheim [Mon, 26 Sep 2016 17:37:11 +0000 (19:37 +0200)]
do no install CMakeLists.txt in tools/doc (#683)

7 years agochange the file name, bitehist.* to vfsreadlat.* (#702)
Taekho Nam [Mon, 26 Sep 2016 17:34:16 +0000 (02:34 +0900)]
change the file name, bitehist.* to vfsreadlat.* (#702)

7 years agoMaking selection of kernel headers type automatic
Dror Kronstein [Sun, 25 Sep 2016 13:17:21 +0000 (16:17 +0300)]
Making selection of kernel headers type automatic

7 years agoMerge pull request #689 from chantra/tcpconnect_port
Brendan Gregg [Fri, 16 Sep 2016 18:35:09 +0000 (11:35 -0700)]
Merge pull request #689 from chantra/tcpconnect_port

[tcpconnect] filter traced connection based on destination ports

7 years ago[tcpconnect] filter traced connection based on destination ports
chantra [Sat, 10 Sep 2016 16:44:50 +0000 (09:44 -0700)]
[tcpconnect] filter traced connection based on destination ports

Test:
While running:
while [ 1 ]; do nc -w 1 100.127.0.1 80; nc -w 1 100.127.0.1 81; done

root@vagrant:/mnt/bcc# ./tools/tcpconnect.py
PID    COMM         IP SADDR            DADDR            DPORT
19978  nc           4  10.0.2.15        100.127.0.1      80
19979  nc           4  10.0.2.15        100.127.0.1      81
19980  nc           4  10.0.2.15        100.127.0.1      80
19981  nc           4  10.0.2.15        100.127.0.1      81
root@vagrant:/mnt/bcc# ./tools/tcpconnect.py  -P 80
PID    COMM         IP SADDR            DADDR            DPORT
19987  nc           4  10.0.2.15        100.127.0.1      80
19989  nc           4  10.0.2.15        100.127.0.1      80
19991  nc           4  10.0.2.15        100.127.0.1      80
19993  nc           4  10.0.2.15        100.127.0.1      80
19995  nc           4  10.0.2.15        100.127.0.1      80
root@vagrant:/mnt/bcc# ./tools/tcpconnect.py  -P 80,81
PID    COMM         IP SADDR            DADDR            DPORT
8725   nc           4  10.0.2.15        100.127.0.1      80
8726   nc           4  10.0.2.15        100.127.0.1      81
8727   nc           4  10.0.2.15        100.127.0.1      80
8728   nc           4  10.0.2.15        100.127.0.1      81
8729   nc           4  10.0.2.15        100.127.0.1      80

Fixes #681

7 years agonew tool: capable (#690)
Brendan Gregg [Wed, 14 Sep 2016 15:15:09 +0000 (08:15 -0700)]
new tool: capable (#690)

* add new tool: capable

* refactor a little, remove extra bpf_get_current_pid_tgid()

7 years agoFix bpf log buffer for large bpf program: (#680)
davidefdl [Mon, 12 Sep 2016 19:00:37 +0000 (12:00 -0700)]
Fix bpf log buffer for large bpf program: (#680)

Use tempfile module to create a temp file

Fix some review input

Fix style check

Style

Style check

Remove builtin module from python test to run fedora ctest

Let the program calling bpf_prog_load to handle the log buffer

Check max instruction before the syscall. Fix other review comment

7 years agoMerge pull request #688 from KarimAllah/opensnoop-re
Brendan Gregg [Sun, 11 Sep 2016 04:37:53 +0000 (21:37 -0700)]
Merge pull request #688 from KarimAllah/opensnoop-re

minor cleanup + process partial name matching

7 years agoopensnoop: Introduce process name filtering
KarimAllah Ahmed [Sat, 10 Sep 2016 10:01:07 +0000 (12:01 +0200)]
opensnoop: Introduce process name filtering

Signed-off-by: KarimAllah Ahmed <karim.allah.ahmed@gmail.com>
7 years agoopensnoop: Refactor initial timestamp calculation
KarimAllah Ahmed [Sat, 10 Sep 2016 10:00:32 +0000 (12:00 +0200)]
opensnoop: Refactor initial timestamp calculation

Signed-off-by: KarimAllah Ahmed <karim.allah.ahmed@gmail.com>
7 years agoopensnoop: Remove 'delta' and 'cont' variables
KarimAllah Ahmed [Sat, 10 Sep 2016 09:53:46 +0000 (11:53 +0200)]
opensnoop: Remove 'delta' and 'cont' variables

... since they are unused.

Signed-off-by: KarimAllah Ahmed <karim.allah.ahmed@gmail.com>
7 years agoMerge pull request #686 from iovisor/tag_v0.2.0 v0.2.0
Brenden Blanco [Fri, 9 Sep 2016 00:58:25 +0000 (20:58 -0400)]
Merge pull request #686 from iovisor/tag_v0.2.0

Prepare debian changelog for v0.2.0 tag

7 years agoPrepare debian changelog for v0.2.0 tag
Brenden Blanco [Fri, 9 Sep 2016 00:15:55 +0000 (17:15 -0700)]
Prepare debian changelog for v0.2.0 tag

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
7 years agoMerge pull request #685 from kinvolk/iaguis/fix-indentation
Brendan Gregg [Thu, 8 Sep 2016 23:03:43 +0000 (16:03 -0700)]
Merge pull request #685 from kinvolk/iaguis/fix-indentation

examples: fix indentation in tracing/tcpv4connect

7 years agoexamples: fix indentation in tracing/tcpv4connect
Iago López Galeiras [Thu, 8 Sep 2016 14:45:11 +0000 (16:45 +0200)]
examples: fix indentation in tracing/tcpv4connect

Python doesn't like mixing spaces and tabs.

7 years agoMerge pull request #677 from markdrayton/fileslower
Brendan Gregg [Tue, 30 Aug 2016 19:18:57 +0000 (12:18 -0700)]
Merge pull request #677 from markdrayton/fileslower

fileslower: use de->d_name.name, add filtering

7 years agofileslower/filetop: use de->d_name.name, add filtering
Mark Drayton [Thu, 25 Aug 2016 19:46:35 +0000 (20:46 +0100)]
fileslower/filetop: use de->d_name.name, add filtering

7 years agoMerge pull request #675 from brendangregg/master
Brenden Blanco [Thu, 25 Aug 2016 04:01:02 +0000 (00:01 -0400)]
Merge pull request #675 from brendangregg/master

fix biosnoop after kernel change

7 years agofix biosnoop after kernel change
Brendan Gregg [Wed, 24 Aug 2016 22:10:05 +0000 (15:10 -0700)]
fix biosnoop after kernel change

7 years agoMerge pull request #674 from markdrayton/offcputime
Brendan Gregg [Wed, 24 Aug 2016 21:56:09 +0000 (14:56 -0700)]
Merge pull request #674 from markdrayton/offcputime

offcputime improvements: use less RAM, add PID/TID support

7 years agooffcputime: one symbol cache per process, improve pid/tid handling
Mark Drayton [Sun, 31 Jul 2016 21:47:07 +0000 (22:47 +0100)]
offcputime: one symbol cache per process, improve pid/tid handling

7 years agoMerge pull request #670 from iamkafai/perf_submit_skb
Brenden Blanco [Wed, 24 Aug 2016 04:21:53 +0000 (00:21 -0400)]
Merge pull request #670 from iamkafai/perf_submit_skb

Add perf_submit_skb

7 years agoAdd perf_submit_skb
Martin KaFai Lau [Fri, 19 Aug 2016 22:34:18 +0000 (15:34 -0700)]
Add perf_submit_skb

For BPF_PROG_TYPE_SCHED_CLS/ACT, the upstream kernel has recently added a
feature to efficiently output skb + meta data:
commit 555c8a8623a3 ("bpf: avoid stack copy and use skb ctx for event output")

This patch adds perf_submit_skb to BPF_PERF_OUTPUT macro.  It takes
an extra u32 argument.  perf_submit_skb will then be expanded to
bpf_perf_event_output properly to consider the newly added
u32 argument as the skb's len.

Other than the above described changes, perf_submit_skb is almost
a carbon copy of the perf_submit except the removal of the 'string name'
variable since I cannot find a specific use of it.

Note that the 3rd param type of bpf_perf_event_output has also been
changed from u32 to u64.

Added a sample program tc_perf_event.py.  Here is how the output
looks like:
[root@arch-fb-vm1 networking]# ./tc_perf_event.py
Try: "ping -6 ff02::1%me"

CPU SRC IP                           DST IP       Magic
0   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c
0   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c
0   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c
1   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c
1   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c
1   fe80::982f:5dff:fec1:e52b        ff02::1      0xfaceb00c

7 years agoMerge pull request #671 from pchaigno/fix-doc
Brendan Gregg [Sun, 21 Aug 2016 03:20:12 +0000 (20:20 -0700)]
Merge pull request #671 from pchaigno/fix-doc

Minor adjustments to the documentation

7 years agoMention that tracepoint support requires Linux 4.7
Paul Chaignon [Sat, 20 Aug 2016 12:24:03 +0000 (14:24 +0200)]
Mention that tracepoint support requires Linux 4.7

7 years agoAdjustments to the documentation
Paul Chaignon [Sat, 20 Aug 2016 12:15:07 +0000 (14:15 +0200)]
Adjustments to the documentation

Fix a few typos
Add missing link
Reword update() description sentence

7 years agoMerge pull request #668 from iovisor/ast_dev
Brenden Blanco [Fri, 19 Aug 2016 20:02:53 +0000 (13:02 -0700)]
Merge pull request #668 from iovisor/ast_dev

fix build with 4.0 llvm trunk

7 years agofix build with 4.0 llvm trunk
Alexei Starovoitov [Fri, 19 Aug 2016 02:52:57 +0000 (22:52 -0400)]
fix build with 4.0 llvm trunk

Signed-off-by: Alexei Starovoitov <ast@fb.com>
7 years agofrontends/clang: Safety check for invalid opLoc in ProbeVisitor (#667)
Brenden Blanco [Thu, 18 Aug 2016 21:33:29 +0000 (14:33 -0700)]
frontends/clang: Safety check for invalid opLoc in ProbeVisitor (#667)

As reported in #664:
In cases where the AST contains a MemberExpr with an invalid opLoc,
rewrite will fail but prior to this change would segfault. Fail a little
more gracefully, even though the program will still be rejected.

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
7 years agoMerge pull request #663 from adrianlzt/sniff_ssl_tool
Brendan Gregg [Thu, 18 Aug 2016 20:22:35 +0000 (13:22 -0700)]
Merge pull request #663 from adrianlzt/sniff_ssl_tool

Tool to sniff data contents before encrypted with OpenSSL

7 years agoAdd capture for GnuTLS and argparse options
Adrian Lopez [Wed, 17 Aug 2016 12:08:08 +0000 (14:08 +0200)]
Add capture for GnuTLS and argparse options

Now it also captures gnutls_record_send and gnutls_record_recv calls.
Added options to filter by pid or command name, or just one lib.

7 years agoTool to sniff data contents before encrypted with OpenSSL
Adrian Lopez [Tue, 16 Aug 2016 15:49:49 +0000 (17:49 +0200)]
Tool to sniff data contents before encrypted with OpenSSL

Add tool as talked in iovisor-dev 'BCC: bpf_probe_read read function arguments'

7 years agoTypo writting BPF (#659)
Adrián López [Mon, 15 Aug 2016 18:58:40 +0000 (20:58 +0200)]
Typo writting BPF (#659)

7 years agoRevert "debian packaging: Build with -DBCC_KERNEL_HAS_SOURCE_DIR=1" (#662)
Brenden Blanco [Mon, 15 Aug 2016 18:58:16 +0000 (11:58 -0700)]
Revert "debian packaging: Build with -DBCC_KERNEL_HAS_SOURCE_DIR=1" (#662)

This reverts commit c6688dda4e856be43b8651afe92d7e32e63faea9.

7 years agoMerge pull request #661 from oujunli/ojl_dev
Brendan Gregg [Sun, 14 Aug 2016 06:57:01 +0000 (23:57 -0700)]
Merge pull request #661 from oujunli/ojl_dev

killsnoop: use current time replace timestamp and default output

7 years agokillsnoop: use current time replace timestamp and default output
Junli Ou [Sat, 13 Aug 2016 09:12:45 +0000 (17:12 +0800)]
killsnoop: use current time replace timestamp and default output

7 years agoupdate debian packaging (#657)
Brenden Blanco [Thu, 11 Aug 2016 21:02:40 +0000 (14:02 -0700)]
update debian packaging (#657)

* debian packaging: Add missing Build-dependencies

* Add clang-format-3.7 to build-depends

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
* debian packaging: Build with -DBCC_KERNEL_HAS_SOURCE_DIR=1

This is required to use the distro-provided includes on Debian/Ubuntu

7 years agoMerge pull request #655 from markdrayton/dcsnoop
Brendan Gregg [Thu, 11 Aug 2016 17:10:55 +0000 (10:10 -0700)]
Merge pull request #655 from markdrayton/dcsnoop

dcsnoop: use PERF_EVENT_OUTPUT

7 years agoMerge branch 'master' into dcsnoop
Mark Drayton [Thu, 11 Aug 2016 09:39:03 +0000 (10:39 +0100)]
Merge branch 'master' into dcsnoop

7 years agodcsnoop: use PERF_EVENT_OUTPUT
Mark Drayton [Wed, 13 Jul 2016 17:15:05 +0000 (18:15 +0100)]
dcsnoop: use PERF_EVENT_OUTPUT

7 years agoMerge pull request #654 from palmtenor/docs
Brendan Gregg [Thu, 11 Aug 2016 01:04:32 +0000 (18:04 -0700)]
Merge pull request #654 from palmtenor/docs

Add some explanation for functions in BPF program in Tutorial

7 years agoImprove tutorial
Teng Qin [Thu, 11 Aug 2016 00:35:28 +0000 (17:35 -0700)]
Improve tutorial

7 years agoMotivate delete() before update() in tutorial (#651)
Paul Chaignon [Tue, 9 Aug 2016 16:38:05 +0000 (18:38 +0200)]
Motivate delete() before update() in tutorial (#651)

This delete() is required because of a kernel bug:
https://git.kernel.org/cgit/linux/kernel/git/davem/net.git/commit/?id=a6ed3ea65d9868fdf9eff84e6fe4f666b8d14b02

7 years agoAdd bpf_get_current_task() helper definition (#650)
Omar Sandoval [Sat, 6 Aug 2016 03:43:35 +0000 (20:43 -0700)]
Add bpf_get_current_task() helper definition (#650)

Signed-off-by: Omar Sandoval <osandov@fb.com>
7 years agofunccount: filter bcc function count (#645)
Junli Ou [Sat, 6 Aug 2016 03:43:20 +0000 (11:43 +0800)]
funccount: filter bcc function count (#645)

7 years agoMerge pull request #649 from iovisor/ast_dev
Brenden Blanco [Fri, 5 Aug 2016 04:44:14 +0000 (21:44 -0700)]
Merge pull request #649 from iovisor/ast_dev

fix build with llvm 4.0

7 years agofix build with llvm 4.0
Alexei Starovoitov [Fri, 5 Aug 2016 04:01:11 +0000 (00:01 -0400)]
fix build with llvm 4.0

Signed-off-by: Alexei Starovoitov <ast@fb.com>
7 years agoAdd bcc_syms.h to C++ install (#648)
Teng Qin [Fri, 5 Aug 2016 03:14:13 +0000 (20:14 -0700)]
Add bcc_syms.h to C++ install (#648)

7 years agoDisable static-libstdc++ when clang is linked dynamically (#647)
Brenden Blanco [Fri, 5 Aug 2016 03:13:19 +0000 (20:13 -0700)]
Disable static-libstdc++ when clang is linked dynamically (#647)

Based on the bug report in
https://bugs.gentoo.org/show_bug.cgi?id=582770, mixing static+non-static
libstdc++ can lead to crashes. Disable such combinations. Choosing to
leave out the llvm check, since in practice clang is less likely to be
provided statically, so the check should cover both cases.

Fixes: #633
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
7 years agostyle nits (#646)
Brendan Gregg [Wed, 3 Aug 2016 22:15:41 +0000 (15:15 -0700)]
style nits (#646)