platform/upstream/bcc.git
7 years agohello_perf_output: match the data type of pid
Gary Lin [Wed, 30 Nov 2016 09:13:37 +0000 (17:13 +0800)]
hello_perf_output: match the data type of pid

Signed-off-by: Gary Lin <glin@suse.com>
7 years agoMerge pull request #828 from palmtenor/dbgflg
4ast [Wed, 30 Nov 2016 05:48:24 +0000 (21:48 -0800)]
Merge pull request #828 from palmtenor/dbgflg

Remove debug flag override in bcc_exception.h

7 years agoRemove debug flag override in bcc_exception.h
Teng Qin [Wed, 30 Nov 2016 04:11:19 +0000 (20:11 -0800)]
Remove debug flag override in bcc_exception.h

7 years agoMerge pull request #824 from palmtenor/exception_h
4ast [Wed, 30 Nov 2016 03:13:10 +0000 (19:13 -0800)]
Merge pull request #824 from palmtenor/exception_h

Clean up bcc_exception.h

7 years agoUse StatusTuple constructor in mkstatus_
Teng Qin [Wed, 30 Nov 2016 01:09:20 +0000 (17:09 -0800)]
Use StatusTuple constructor in mkstatus_

7 years agoImplement StatusTuple class instead of using std::tuple
Teng Qin [Wed, 30 Nov 2016 00:29:08 +0000 (16:29 -0800)]
Implement StatusTuple class instead of using std::tuple

7 years agoRemove unused headers and Macro
Teng Qin [Tue, 29 Nov 2016 17:08:33 +0000 (09:08 -0800)]
Remove unused headers and Macro

7 years agoMerge pull request #825 from brendangregg/master
4ast [Tue, 29 Nov 2016 22:22:31 +0000 (14:22 -0800)]
Merge pull request #825 from brendangregg/master

biotop.py: fix compiler error on newer kernels

7 years agobiotop.py: fix compiler error on newer kernels
Brendan Gregg [Tue, 29 Nov 2016 19:11:31 +0000 (11:11 -0800)]
biotop.py: fix compiler error on newer kernels

7 years agoMerge pull request #823 from kinvolk/krnowak/kernel-dirs-at-runtime
Brenden Blanco [Tue, 29 Nov 2016 16:35:46 +0000 (08:35 -0800)]
Merge pull request #823 from kinvolk/krnowak/kernel-dirs-at-runtime

Determine kernel dirs at runtime (fix #743)

7 years agoMerge pull request #822 from iovisor/llvm_40_build
4ast [Tue, 29 Nov 2016 16:22:10 +0000 (08:22 -0800)]
Merge pull request #822 from iovisor/llvm_40_build

Add LLVMCoroutines lib for llvm>=4.0 builds

7 years agoDetermine kernel dirs at runtime (fix #743)
Krzesimir Nowak [Wed, 26 Oct 2016 11:00:09 +0000 (13:00 +0200)]
Determine kernel dirs at runtime (fix #743)

As some module build directories split headers between `source/` and
`build/` and this varies between distributions, determine the location
at runtime.

7 years agoAdd LLVMCoroutines lib for llvm>=4.0 builds
Brenden Blanco [Tue, 29 Nov 2016 15:37:30 +0000 (07:37 -0800)]
Add LLVMCoroutines lib for llvm>=4.0 builds

Building bcc against a tip of tree llvm introduces a new link failure,
which is fixed by linking against libLLVMCoroutines (which only exists
in 4.0).

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
7 years agoMerge pull request #821 from palmtenor/adjust_headers
Brenden Blanco [Tue, 29 Nov 2016 09:05:47 +0000 (01:05 -0800)]
Merge pull request #821 from palmtenor/adjust_headers

Improve the structure of exception related header files

7 years agoRename exception.h to bcc_exception.h
Teng Qin [Tue, 29 Nov 2016 05:58:46 +0000 (21:58 -0800)]
Rename exception.h to bcc_exception.h

7 years agoMove StatusTuple definition to exception.h
Teng Qin [Tue, 29 Nov 2016 05:55:32 +0000 (21:55 -0800)]
Move StatusTuple definition to exception.h

7 years agoMerge pull request #820 from brendangregg/master
4ast [Tue, 29 Nov 2016 02:44:16 +0000 (18:44 -0800)]
Merge pull request #820 from brendangregg/master

tcplife.py: Catch passive closed by server, #788

7 years agotcplife.py: Catch passive closed by server, #788
Brendan Gregg [Tue, 29 Nov 2016 01:57:20 +0000 (17:57 -0800)]
tcplife.py: Catch passive closed by server, #788

7 years agoMerge pull request #781 from palmtenor/api
4ast [Tue, 29 Nov 2016 00:30:24 +0000 (16:30 -0800)]
Merge pull request #781 from palmtenor/api

C++ helper class for BCC

7 years agoEliminate rpmlint errors and allow bcc srpm to build on Fedora koji b… (#815)
William Cohen [Mon, 28 Nov 2016 18:51:28 +0000 (13:51 -0500)]
Eliminate rpmlint errors and allow bcc srpm to build on Fedora koji b… (#815)

* Eliminate rpmlint errors and allow bcc srpm to build on Fedora koji build system

The nightly bcc srpm does not build as-is on Fedora 24. To get the
build to work the following changes were made in the bcc.spec file:

-Specify where to find luajit headers and libraries
-Correctly limit the build to the x86_64 architecture
-Add needed build requires so the srpm can build on Fedora koji
-Run ldconfig so shared library information is updated
-Follow spec conventions by putting %changelog at the end of the spec file

* Further refine the bcc.spec file

Make the following improvements to the gcc.spec file:

-Use local_clang_static variable to allow building with locally installed clang
-Adjust build requires to include nucurses-devel and make
-Put the subpackage descriptions and file list in a more logical order
-Correct the binary rpm dependencies for the subpackages

7 years agoExamples of using BCC C++ API
Teng Qin [Wed, 23 Nov 2016 20:23:03 +0000 (12:23 -0800)]
Examples of using BCC C++ API

7 years agoBasic BCC C++ API
Teng Qin [Wed, 23 Nov 2016 20:23:03 +0000 (12:23 -0800)]
Basic BCC C++ API

7 years agoAdd helper method to exception.h
Teng Qin [Wed, 23 Nov 2016 20:23:03 +0000 (12:23 -0800)]
Add helper method to exception.h

7 years agoInstall exception.h and common.h
Teng Qin [Wed, 23 Nov 2016 20:23:03 +0000 (12:23 -0800)]
Install exception.h and common.h

7 years agoUpdate .clang-format configs
Teng Qin [Wed, 23 Nov 2016 20:23:03 +0000 (12:23 -0800)]
Update .clang-format configs

7 years agoMerge pull request #817 from iovisor/clang_c_fixes
4ast [Thu, 24 Nov 2016 00:51:08 +0000 (16:51 -0800)]
Merge pull request #817 from iovisor/clang_c_fixes

Fixup test errors in clang, c api

7 years agoFixup test errors in clang, c api
Brenden Blanco [Thu, 24 Nov 2016 00:26:01 +0000 (16:26 -0800)]
Fixup test errors in clang, c api

Some errors seem to have cropped up due to updating kernels and clang
library versions.
1. test_c_api fails on kernels (seen on fedora 4.9) where startup_64
doesn't start at a particular address. Simplify the test to hopefully
work in more systems.
2. The lua and python test_clang did a dereference on a particular bio
field, which has been removed. Pick a different field that is more
uniquitous.
3. test_xlate1 was generating code where the verified pointer spilled.
Rewrite the example to store the result on the stack.

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
7 years agoMerge pull request #813 from goldshtn/trace-usdt-pid-fix
4ast [Fri, 18 Nov 2016 23:23:51 +0000 (15:23 -0800)]
Merge pull request #813 from goldshtn/trace-usdt-pid-fix

trace: Avoid passing -1 as the pid to USDT

7 years agodocs: Fix typos (#811)
4ast [Mon, 14 Nov 2016 17:31:28 +0000 (09:31 -0800)]
docs: Fix typos (#811)

7 years agodocs: Fix typos
Jakub Wilk [Mon, 14 Nov 2016 09:49:35 +0000 (10:49 +0100)]
docs: Fix typos

7 years agotrace: Avoid passing -1 as the pid to USDT
Sasha Goldshtein [Sun, 13 Nov 2016 13:07:38 +0000 (05:07 -0800)]
trace: Avoid passing -1 as the pid to USDT

When the `-p` switch is used with `trace`, it would set
the tgid to the value passed to `-p` and set the pid to
-1. The result would be incorrect logic that passed the -1
pid value to the `USDT` context constructor, which fails
for probes that require the pid to enable (because they
have a semaphore that needs a poke). This commit fixes it.

7 years agofix some typos (#810)
Taekho Nam [Fri, 11 Nov 2016 16:57:35 +0000 (01:57 +0900)]
fix some typos (#810)

7 years agoFix Tracepoint example (#809)
Teng Qin [Fri, 11 Nov 2016 16:56:58 +0000 (08:56 -0800)]
Fix Tracepoint example (#809)

7 years agoMerge pull request #808 from goldshtn/close-table-fd-fix
Brenden Blanco [Wed, 9 Nov 2016 20:04:42 +0000 (12:04 -0800)]
Merge pull request #808 from goldshtn/close-table-fd-fix

cc, python: Clean up BPF module and tables

7 years agocc, python: Clean up BPF module and tables
Sasha Goldshtein [Wed, 9 Nov 2016 23:05:50 +0000 (15:05 -0800)]
cc, python: Clean up BPF module and tables

When the `BPFModule` object is destroyed, shared tables
were closed, but non-shared tables were not. Add `close`
call to close non-shared tables in `~BPFModule`.

Make sure the `BPF.cleanup` function in the Python module
calls `bpf_module_destroy` to clean up the module. Otherwise,
we have hanging table fds that aren't destroyed.

Fixes #806. This would have been an issue for any tool
that repeatedly runs a BPF program with new maps. It's just
that most tools we have haven't exhibited this behavior.

7 years agoMerge pull request #807 from markdrayton/perf-pid-map
Brenden Blanco [Wed, 9 Nov 2016 20:04:29 +0000 (12:04 -0800)]
Merge pull request #807 from markdrayton/perf-pid-map

Make bcc_symcache_new(tid) work with symbols from /tmp/perf-pid.map

7 years agoMake bcc_symcache_new(tid) work with symbols from /tmp/perf-pid.map
Mark Drayton [Sun, 6 Nov 2016 23:35:50 +0000 (23:35 +0000)]
Make bcc_symcache_new(tid) work with symbols from /tmp/perf-pid.map

7 years agoMerge pull request #803 from dark/fix-warnings
Brenden Blanco [Tue, 8 Nov 2016 21:14:14 +0000 (22:14 +0100)]
Merge pull request #803 from dark/fix-warnings

Fix warnings covered by -Wdelete-non-virtual-dtor

7 years agoFix warnings covered by -Wdelete-non-virtual-dtor
Marco Leogrande [Tue, 8 Nov 2016 17:23:20 +0000 (09:23 -0800)]
Fix warnings covered by -Wdelete-non-virtual-dtor

The warnings were:

 src/cc/bcc_syms.cc: In function ‘void bcc_free_symcache(void*, int)’:
 src/cc/bcc_syms.cc:217:40: warning: deleting object of polymorphic class type ‘KSyms’
                            which has non-virtual destructor might cause undefined behaviour
                            [-Wdelete-non-virtual-dtor]
     delete static_cast<KSyms*>(symcache);
                                        ^
 src/cc/bcc_syms.cc:219:43: warning: deleting object of polymorphic class type ‘ProcSyms’
                            which has non-virtual destructor might cause undefined behaviour
                            [-Wdelete-non-virtual-dtor]
     delete static_cast<ProcSyms*>(symcache);
                                           ^

Fix the warnings by defining a virtual destructor for the base class SymbolCache.

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years agoRemove superfluous word (#802)
Jan-Erik Rediger [Mon, 7 Nov 2016 16:08:03 +0000 (17:08 +0100)]
Remove superfluous word (#802)

7 years agoFix argument type for increment() in documentation (#794)
Paul Chaignon [Sat, 5 Nov 2016 19:00:30 +0000 (20:00 +0100)]
Fix argument type for increment() in documentation (#794)

7 years agoFix typo in documentation (#801)
Jan-Erik Rediger [Sat, 5 Nov 2016 18:55:32 +0000 (19:55 +0100)]
Fix typo in documentation (#801)

7 years agotrace: add pid/tid filtering, fix symbolizing, misc nits (#798)
Mark Drayton [Thu, 3 Nov 2016 15:36:29 +0000 (15:36 +0000)]
trace: add pid/tid filtering, fix symbolizing, misc nits (#798)

* support filtering by process ID (-p) or thread ID (-t); previously -p
  actually filtered on thread ID (aka "pid" in kernel-speak)
* include process and thread ID in output
* flip order of user and kernel stacks to flow more naturally
* resolve symbols using process ID instead of thread ID so only one symbol
  cache is instantiated per process
* misc aesthetic fixes here and there

7 years agoMerge pull request #795 from mslusarz/install-perf_reader.h
Brenden Blanco [Wed, 2 Nov 2016 16:03:53 +0000 (17:03 +0100)]
Merge pull request #795 from mslusarz/install-perf_reader.h

perf_reader: install perf_reader.h

7 years agoMerge pull request #796 from palmtenor/sym_free
Brenden Blanco [Wed, 2 Nov 2016 05:35:30 +0000 (06:35 +0100)]
Merge pull request #796 from palmtenor/sym_free

Expose destruction of SymbolCache in libbcc

7 years agoExpose destruction of SymbolCache in libbcc
Teng Qin [Mon, 31 Oct 2016 21:20:43 +0000 (14:20 -0700)]
Expose destruction of SymbolCache in libbcc

7 years agoperf_reader: install perf_reader.h
Marcin Ślusarz [Sun, 30 Oct 2016 13:20:07 +0000 (14:20 +0100)]
perf_reader: install perf_reader.h

Ref: iovisor/bcc#778

7 years agoUse headers from BCC in installed files (#793)
Teng Qin [Sun, 30 Oct 2016 06:00:02 +0000 (23:00 -0700)]
Use headers from BCC in installed files (#793)

7 years agofunccount: Bail early if there are no matching functions (#792)
Sasha Goldshtein [Fri, 28 Oct 2016 20:45:08 +0000 (23:45 +0300)]
funccount: Bail early if there are no matching functions (#792)

funccount now bails early with an error if there are no
functions matching the specified pattern (the same applies
to tracepoints and USDT probes). For example:

```
No functions matched by pattern ^sched:sched_fork$
```

Fixes #789.

7 years agoupdate tools pic (#787)
Brendan Gregg [Thu, 27 Oct 2016 21:05:40 +0000 (14:05 -0700)]
update tools pic (#787)

7 years agoMerge pull request #780 from goldshtn/kprobe-funccount
Brenden Blanco [Wed, 26 Oct 2016 02:54:34 +0000 (19:54 -0700)]
Merge pull request #780 from goldshtn/kprobe-funccount

funccount: Fix on-CPU hang when attaching to SyS_*

7 years agoAdd installation instructions for Gentoo (#785)
Marco Leogrande [Tue, 25 Oct 2016 21:15:48 +0000 (14:15 -0700)]
Add installation instructions for Gentoo (#785)

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
7 years agopython: Grab all keys before zeroing
Sasha Goldshtein [Tue, 25 Oct 2016 14:27:38 +0000 (07:27 -0700)]
python: Grab all keys before zeroing

To avoid a potential race with the key zeroing modifying
the next hash key retrieved by the loop in `Table.zero()`,
retrieve all the keys in user space first before starting
the zeroing loop. See discussion on #780.

Tested with `funccount 'SyS_*' -i 1` while running a heavy
read/write test application (`dd`) in the background for
several minutes with no visible issues.

7 years agofunccount: Switch to BPF array instead of hash
Sasha Goldshtein [Tue, 25 Oct 2016 14:18:24 +0000 (07:18 -0700)]
funccount: Switch to BPF array instead of hash

Because we know the number of probes in advance before
attaching them, we can simply preinitialize a fixed-size
array instead of using a BPF map. This avoids potential
deadlocks/hangs/race conditions with the Python program
and internally in the kernel. See also #415, #665, #233
for more discussion.

7 years agoUpdate profile.py to use new perf support (#776)
Brendan Gregg [Fri, 21 Oct 2016 05:50:08 +0000 (22:50 -0700)]
Update profile.py to use new perf support (#776)

* profile.py to use new perf support

* Minor adjustments to llcstat docs

7 years agofix junk filenames (#775)
Brendan Gregg [Fri, 21 Oct 2016 04:46:09 +0000 (21:46 -0700)]
fix junk filenames (#775)

7 years agoMerge pull request #770 from palmtenor/pmu_api
Brenden Blanco [Fri, 21 Oct 2016 01:30:07 +0000 (18:30 -0700)]
Merge pull request #770 from palmtenor/pmu_api

Add basic support for BPF perf event

7 years agoAdd example and man file for llcstat
Teng Qin [Thu, 20 Oct 2016 23:50:06 +0000 (16:50 -0700)]
Add example and man file for llcstat

7 years agoExample for using BPF perf event
Teng Qin [Wed, 19 Oct 2016 00:22:27 +0000 (17:22 -0700)]
Example for using BPF perf event

7 years agofunccount: Do not prepopulate location cache
Sasha Goldshtein [Thu, 20 Oct 2016 23:19:12 +0000 (16:19 -0700)]
funccount: Do not prepopulate location cache

Avoiding the prepopulation of the location cache allows us
to get rid of the `zero()` call at the end of each interval,
which would hang the program at full CPU. Replaced the
prepopulation with a `lookup_or_init` and the `zero()` call
with a call to `clear()`.

7 years agopython: Filter duplicate in get_kprobe_functions
Sasha Goldshtein [Thu, 20 Oct 2016 23:18:07 +0000 (16:18 -0700)]
python: Filter duplicate in get_kprobe_functions

`BPF.get_kprobe_functions` does not filter duplicates, and
as a result may return the same function name more than
once if it appears in /sys/kernel/debug/tracing/available_filter_functions
more than once. Change the function's behavior to filter
out duplicates before returning, so we don't end up
attaching the same kprobe more than once.

7 years agoPython API for BPF perf event
Teng Qin [Tue, 18 Oct 2016 23:45:41 +0000 (16:45 -0700)]
Python API for BPF perf event

7 years agoAdd bpf_attach_perf_event in libbpf
Teng Qin [Tue, 18 Oct 2016 23:06:57 +0000 (16:06 -0700)]
Add bpf_attach_perf_event in libbpf

7 years agoAdd BPF_PROG_TYPE_PERF_EVENT to bpf_prog_type enum
Teng Qin [Tue, 18 Oct 2016 22:20:18 +0000 (15:20 -0700)]
Add BPF_PROG_TYPE_PERF_EVENT to bpf_prog_type enum

7 years agoMerge pull request #772 from goldshtn/strcmp
Brendan Gregg [Thu, 20 Oct 2016 03:06:51 +0000 (20:06 -0700)]
Merge pull request #772 from goldshtn/strcmp

trace, argdist: STRCMP helper function

7 years agoMerge branch 'master' into strcmp
Brendan Gregg [Thu, 20 Oct 2016 02:03:17 +0000 (19:03 -0700)]
Merge branch 'master' into strcmp

7 years agoadd tcplife (#773)
Brendan Gregg [Thu, 20 Oct 2016 01:55:10 +0000 (18:55 -0700)]
add tcplife (#773)

7 years agoadd reset-trace (#766)
Brendan Gregg [Thu, 20 Oct 2016 01:48:17 +0000 (18:48 -0700)]
add reset-trace (#766)

7 years agofunccount: Verify probe max limit (#771)
Sasha Goldshtein [Thu, 20 Oct 2016 01:46:37 +0000 (02:46 +0100)]
funccount: Verify probe max limit (#771)

Because `funccount` doesn't use the direct regex attach infrastructure
in the BPF module, it needs its own checking for a maximum probe
limit that would make sense. We use 1000 because that's what the
BPF module uses as well. When trying to attach to more than 1000
probes, we bail out early.

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 agoargdist: STRCMP helper function
Sasha Goldshtein [Mon, 17 Oct 2016 09:18:43 +0000 (02:18 -0700)]
argdist: STRCMP helper function

argdist filter expressions can now use the STRCMP helper
function to compare strings. The first string must be a
compile-time constant literal string, and the second string
can be determined at runtime. This is a workaround until
BPF introduces a kernel builtin for strcmp.

Example:

```
argdist -H 'r:c:open(char *file):u64:$latency:STRCMP("test.txt",file)'
```

7 years agotrace: STRCMP helper function
Sasha Goldshtein [Mon, 17 Oct 2016 08:44:56 +0000 (01:44 -0700)]
trace: STRCMP helper function

`trace` filters and print expressions can now use the
magic STRCMP helper function to compare strings. The first
string must be a compile-time constant literal string,
such as "test", and the second string can be determined at
runtime (e.g., from a function argument). The codegen for
STRCMP is on a case-by-case basis for each literal string,
and it generates an inline function with a constant-length
loop that compares the string's characters. This is a
decent workaround until we get something more reasonable
from the kernel side, such as a `bpf_strcmp` helper.

Usage example:

```
trace 'p:c:open (STRCMP("test.txt", arg1)) "%s", arg1'
``

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