%else
%{!?with_lua: %global with_lua 1}
%endif
+
+# use --with shared to only link against libLLVM.so
+%if 0%{?fedora} >= 28 || 0%{?rhel} > 7
+%bcond_without llvm_shared
+%else
+%bcond_with llvm_shared
+%endif
+
+# Build python3 support for distributions that have it
+%if 0%{?fedora} >= 28 || 0%{?rhel} > 7
+%bcond_without python3
+%else
+%bcond_with python3
+%endif
+
+%if %{with python3}
+%global __python %{__python3}
+%global python_bcc python3-bcc
+%global python_cmds python2;python3
+%else
+%global __python %{__python2}
+%global python_bcc python2-bcc
+%global python_cmds python2
+%endif
+
%define debug_package %{nil}
Name: bcc
ExclusiveArch: x86_64 ppc64 aarch64 ppc64le
BuildRequires: bison cmake >= 2.8.7 flex make
BuildRequires: gcc gcc-c++ python2-devel elfutils-libelf-devel-static
+%if %{with python3}
+BuildRequires: python3-devel
+%endif
%if %{with_lua}
BuildRequires: luajit luajit-devel
%endif
%if %{without local_clang_static}
-BuildRequires: llvm-devel llvm-static
+BuildRequires: llvm-devel
BuildRequires: clang-devel
+%if %{without llvm_shared}
+BuildRequires: llvm-static
+%endif
%endif
BuildRequires: pkgconfig ncurses-devel
pushd build
cmake .. -DREVISION_LAST=%{version} -DREVISION=%{version} \
-DCMAKE_INSTALL_PREFIX=/usr \
- %{?lua_config}
+ %{?lua_config} \
+ -DPYTHON_CMD="%{python_cmds}" \
+ %{?with_llvm_shared:-DENABLE_LLVM_SHARED=1}
make %{?_smp_mflags}
popd
%install
pushd build
make install/strip DESTDIR=%{buildroot}
+# mangle shebangs
+find %{buildroot}/usr/share/bcc/{tools,examples} -type f -exec \
+ sed -i -e '1 s|^#!/usr/bin/python$|#!'%{__python}'|' \
+ -e '1 s|^#!/usr/bin/env python$|#!'%{__python}'|' {} \;
%package -n libbcc
Summary: Shared Library for BPF Compiler Collection (BCC)
%description -n libbcc
Shared Library for BPF Compiler Collection (BCC)
-%package -n python-bcc
-Summary: Python bindings for BPF Compiler Collection (BCC)
+%package -n python2-bcc
+Summary: Python2 bindings for BPF Compiler Collection (BCC)
Requires: libbcc = %{version}-%{release}
-%description -n python-bcc
+%{?python_provide:%python_provide python2-bcc}
+%description -n python2-bcc
Python bindings for BPF Compiler Collection (BCC)
+%if %{with python3}
+%package -n python3-bcc
+Summary: Python3 bindings for BPF Compiler Collection (BCC)
+Requires: libbcc = %{version}-%{release}
+%{?python_provide:%python_provide python3-bcc}
+%description -n python3-bcc
+Python bindings for BPF Compiler Collection (BCC)
+%endif
+
%if %{with_lua}
%package -n bcc-lua
Summary: Standalone tool to run BCC tracers written in Lua
%package -n libbcc-examples
Summary: Examples for BPF Compiler Collection (BCC)
-Requires: python-bcc = %{version}-%{release}
+Requires: %{python_bcc} = %{version}-%{release}
%if %{with_lua}
Requires: bcc-lua = %{version}-%{release}
%endif
%package -n bcc-tools
Summary: Command line tools for BPF Compiler Collection (BCC)
-Requires: python-bcc = %{version}-%{release}
+Requires: %{python_bcc} = %{version}-%{release}
%description -n bcc-tools
Command line tools for BPF Compiler Collection (BCC)
/usr/lib64/*
/usr/include/bcc/*
-%files -n python-bcc
-%{python_sitelib}/bcc*
+%files -n python2-bcc
+%{python2_sitelib}/bcc*
+
+%if %{with python3}
+%files -n python3-bcc
+%{python3_sitelib}/bcc*
+%endif
%if %{with_lua}
%files -n bcc-lua
%postun -n libbcc -p /sbin/ldconfig
%changelog
+* Wed Jul 18 2018 Brenden Blanco <bblanco@gmail.com> - 0.6.0-1
+- Make python3 the default when possible
+- Add with llvm_shared conditional
+- Add python2/python3 package targets
+
* Mon Nov 21 2016 William Cohen <wcohen@redhat.com> - 0.2.0-1
- Revise bcc.spec to address rpmlint issues and build properly in Fedora koji.
from __future__ import print_function
from bcc import BPF
+from bcc.utils import ArgString, printb
import argparse
from time import strftime
import ctypes as ct
if (args.failed and (event.ret >= 0)):
return
- print("%-9s %-6d %-16s %-4d %-6d %d" % (strftime("%H:%M:%S"),
- event.pid, event.comm.decode(), event.sig, event.tpid, event.ret))
+ printb(b"%-9s %-6d %-16s %-4d %-6d %d" % (strftime("%H:%M:%S"),
+ event.pid, event.comm, event.sig, event.tpid, event.ret))
# loop with callback to print_event
b["events"].open_perf_buffer(print_event)
from __future__ import print_function
from bcc import BPF
+from bcc.utils import printb
from time import sleep, strftime
import argparse
import signal
if folded:
# print folded stack output
line = \
- [k.waker.decode()] + \
+ [k.waker] + \
[b.ksym(addr)
for addr in reversed(list(waker_kernel_stack))] + \
- [k.target.decode()]
- print("%s %d" % (";".join(line), v.value))
+ [k.target]
+ printb(b"%s %d" % (b";".join(line), v.value))
else:
# print default multi-line stack output
- print(" %-16s %s" % ("target:", k.target.decode()))
+ printb(b" %-16s %s" % (b"target:", k.target))
for addr in waker_kernel_stack:
- print(" %-16x %s" % (addr, b.ksym(addr)))
- print(" %-16s %s" % ("waker:", k.waker.decode()))
+ printb(b" %-16x %s" % (addr, b.ksym(addr)))
+ printb(b" %-16s %s" % (b"waker:", k.waker))
print(" %d\n" % v.value)
counts.clear()