Commit c35989dd authored by Brenden Blanco's avatar Brenden Blanco

Rename python module name to 'bcc' from 'bpf'

* Rename python module to bcc
* Rename python-bpf (deb,rpm) package to python-bcc
* Pending this change, I will likely re-tag 0.1.6, and upload the bcc
  package to pypi.python.org
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent fb180271
...@@ -55,7 +55,7 @@ detail of how this all works. ...@@ -55,7 +55,7 @@ detail of how this all works.
First, we should include the BPF class from the bpf module: First, we should include the BPF class from the bpf module:
```python ```python
from bpf import BPF from bcc import BPF
``` ```
Since the C code is so short, we will embed it inside the python script. Since the C code is so short, we will embed it inside the python script.
...@@ -158,7 +158,7 @@ argument). The `get_table` API returns an object that gives dict-style access ...@@ -158,7 +158,7 @@ argument). The `get_table` API returns an object that gives dict-style access
to the stats BPF map. The python program could use that handle to modify the to the stats BPF map. The python program could use that handle to modify the
kernel table as well. kernel table as well.
```python ```python
from bpf import BPF from bcc import BPF
from time import sleep from time import sleep
b = BPF(src_file="task_switch.c") b = BPF(src_file="task_switch.c")
......
...@@ -96,15 +96,14 @@ Summary: Examples for BPF Compiler Collection (BCC) ...@@ -96,15 +96,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples %description -n libbcc-examples
Examples for BPF Compiler Collection (BCC) Examples for BPF Compiler Collection (BCC)
%package -n python-bpf %package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC) Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf %description -n python-bcc
Python bindings for BPF Compiler Collection (BCC) Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf %files -n python-bcc
%{python_sitelib}/bpf* %{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info %exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc %files -n libbcc
/usr/lib64/* /usr/lib64/*
......
...@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC) ...@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples %description -n libbcc-examples
Examples for BPF Compiler Collection (BCC) Examples for BPF Compiler Collection (BCC)
%package -n python-bpf %package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC) Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf %description -n python-bcc
Python bindings for BPF Compiler Collection (BCC) Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf %files -n python-bcc
%{python_sitelib}/bpf* %{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info %exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc %files -n libbcc
/usr/lib64/* /usr/lib64/*
......
...@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC) ...@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples %description -n libbcc-examples
Examples for BPF Compiler Collection (BCC) Examples for BPF Compiler Collection (BCC)
%package -n python-bpf %package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC) Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf %description -n python-bcc
Python bindings for BPF Compiler Collection (BCC) Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf %files -n python-bcc
%{python_sitelib}/bpf* %{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info %exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc %files -n libbcc
/usr/lib64/* /usr/lib64/*
......
...@@ -18,7 +18,7 @@ Architecture: any ...@@ -18,7 +18,7 @@ Architecture: any
Depends: libbcc Depends: libbcc
Description: Shared Library for BPF Compiler Collection (BCC) Description: Shared Library for BPF Compiler Collection (BCC)
Package: python-bpf Package: python-bcc
Architecture: all Architecture: all
Depends: libbcc, python Depends: libbcc, python
Description: Python wrappers for BPF Compiler Collection (BCC) Description: Python wrappers for BPF Compiler Collection (BCC)
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# #
# 15-Aug-2015 Brendan Gregg Created this. # 15-Aug-2015 Brendan Gregg Created this.
from bpf import BPF from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep from time import sleep
from sys import argv from sys import argv
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# 11-Aug-2015 Brendan Gregg Created this. # 11-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function from __future__ import print_function
from bpf import BPF from bcc import BPF
import sys import sys
REQ_WRITE = 1 # from include/linux/blk_types.h REQ_WRITE = 1 # from include/linux/blk_types.h
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv from sys import argv
from bpf import BPF from bcc import BPF
from builtins import input from builtins import input
from ctypes import c_int, c_uint from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler from http.server import HTTPServer, SimpleHTTPRequestHandler
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv from sys import argv
from bpf import BPF from bcc import BPF
from builtins import input from builtins import input
from ctypes import c_int, c_uint from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler from http.server import HTTPServer, SimpleHTTPRequestHandler
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# run in project examples directory with: # run in project examples directory with:
# sudo ./hello_world.py" # sudo ./hello_world.py"
from bpf import BPF from bcc import BPF
prog = """ prog = """
int hello(void *ctx) { int hello(void *ctx) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute from pyroute2 import IPRoute
ipr = IPRoute() ipr = IPRoute()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF from bcc import BPF
from time import sleep from time import sleep
b = BPF(src_file="task_switch.c") b = BPF(src_file="task_switch.c")
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# pass() | # pass() |
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from simulation import Simulation from simulation import Simulation
import sys import sys
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF from bcc import BPF
from ctypes import c_uint, c_int, c_ulonglong, Structure from ctypes import c_uint, c_int, c_ulonglong, Structure
import json import json
from netaddr import IPAddress from netaddr import IPAddress
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# #
# 15-Aug-2015 Brendan Gregg Created this. # 15-Aug-2015 Brendan Gregg Created this.
from bpf import BPF from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep from time import sleep
from sys import argv from sys import argv
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
# phys | veth | # phys | veth |
# switch | | # switch | |
from bpf import BPF from bcc import BPF
from builtins import input from builtins import input
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from random import shuffle from random import shuffle
......
...@@ -5,18 +5,17 @@ macro(symlink_file SRC DST) ...@@ -5,18 +5,17 @@ macro(symlink_file SRC DST)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC} ${DST}) execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC} ${DST})
endmacro() endmacro()
symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf ${CMAKE_CURRENT_BINARY_DIR}/bpf) symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bcc ${CMAKE_CURRENT_BINARY_DIR}/bcc)
symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf-run ${CMAKE_CURRENT_BINARY_DIR}/bpf-run)
set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist/bpf-${REVISION}.tar.gz") set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist/bcc-${REVISION}.tar.gz")
configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY) configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY)
# build the pip installable # build the pip installable
add_custom_command(OUTPUT ${PIP_INSTALLABLE} add_custom_command(OUTPUT ${PIP_INSTALLABLE}
COMMAND python setup.py sdist COMMAND python setup.py sdist
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bpf/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bcc/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py
) )
add_custom_target(bpf_py ALL DEPENDS ${PIP_INSTALLABLE}) add_custom_target(bcc_py ALL DEPENDS ${PIP_INSTALLABLE})
if(EXISTS "/etc/debian_version") if(EXISTS "/etc/debian_version")
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb") set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
......
# file GENERATED by distutils, do NOT edit # file GENERATED by distutils, do NOT edit
setup.py setup.py
bpf/__init__.py bcc/__init__.py
bpf-run
#!/usr/bin/env python
import sys
USAGE = """\
usage: {argv0} <opts> -p probe_func -c cmd
-c cmd contents of the program to run, omitting prototype (required)
-d name dump table <name> upon exit
-f format format string to apply to trace output (see python str.format())
-n sec run for <sec> seconds and then exit (default=-1)
-p probe kernel entry point to trace (required)
-t attach to kernel trace output
-v increase verbosity
example:
{argv0} -p sys_clone -c 'bpf_trace_printk("Hello, World!\\n");' -t\
"""
wrapper = """
int run(void *ctx) {
%s
return 0;
}
"""
def print_usage_and_exit(rc, msg=None):
if rc != 0:
sys.stdout = sys.stderr
if msg:
print(msg)
print(USAGE.format(argv0=sys.argv[0]))
sys.exit(rc)
def main():
import getopt
import os
import signal
try:
opts, args = getopt.getopt(sys.argv[1:], "c:d:f:hn:p:tv")
except getopt.error, msg:
print_usage_and_exit(2, msg)
runcmd = None
probe_fn = None
trace = 0
dump_tables = []
verbose = 0
nsec = 0
format_str = None
for o, a in opts:
if o == "-c": runcmd = a
if o == "-d": dump_tables.append(a)
if o == "-f": format_str = a
if o == "-h": print_usage_and_exit(0)
if o == "-n": nsec = int(a)
if o == "-p": probe_fn = a
if o == "-t": trace = 1
if o == "-v": verbose += 1
if not runcmd or not probe_fn:
print_usage_and_exit(2, "Error: -p and -c arguments are required")
from bpf import BPF
b = BPF(text=wrapper % runcmd, debug=verbose)
fn = b.load_func("run", BPF.KPROBE)
BPF.attach_kprobe(fn, probe_fn)
if nsec:
def receive_alarm(signo, stack):
os.kill(os.getpid(), signal.SIGINT)
signal.signal(signal.SIGALRM, receive_alarm)
signal.alarm(nsec)
try:
if trace:
with open("/sys/kernel/debug/tracing/trace_pipe") as f:
while True:
line = f.readline(128)
line = line.rstrip()
if format_str:
args=line.split(None, 5)
line = format_str.format(*args)
print(line)
sys.stdout.flush()
elif nsec:
signal.pause()
except KeyboardInterrupt:
pass
if dump_tables:
print("Table dump not yet implemented")
if __name__ == "__main__":
main()
...@@ -7,12 +7,11 @@ import sys ...@@ -7,12 +7,11 @@ import sys
if os.environ.get('DESTDIR'): if os.environ.get('DESTDIR'):
sys.argv += ['--root', os.environ['DESTDIR']] sys.argv += ['--root', os.environ['DESTDIR']]
setup(name='bpf', setup(name='bcc',
version='@REVISION@', version='@REVISION@',
description='BPF Loader Library', description='BPF Loader Library',
author='Brenden Blanco', author='Brenden Blanco',
author_email='bblanco@plumgrid.com', author_email='bblanco@plumgrid.com',
url='http://plumgrid.com', url='https://github.com/iovisor/bcc',
packages=['bpf'], packages=['bcc'],
scripts=['bpf-run'],
platforms=['Linux']) platforms=['Linux'])
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
from ctypes import c_uint from ctypes import c_uint
from netaddr import IPAddress, EUI from netaddr import IPAddress, EUI
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys import sys
from time import sleep from time import sleep
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
# 9: OK # 9: OK
from ctypes import c_uint from ctypes import c_uint
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys import sys
from time import sleep from time import sleep
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from netaddr import IPAddress from netaddr import IPAddress
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM from socket import socket, AF_INET, SOCK_DGRAM
import sys import sys
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF from bcc import BPF
from unittest import main, TestCase from unittest import main, TestCase
class TestClang(TestCase): class TestClang(TestCase):
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
from ctypes import c_uint, c_ulong, Structure from ctypes import c_uint, c_ulong, Structure
from netaddr import IPAddress from netaddr import IPAddress
from bpf import BPF from bcc import BPF
from subprocess import check_call from subprocess import check_call
import sys import sys
from unittest import main, TestCase from unittest import main, TestCase
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure from ctypes import c_uint, c_ulong, Structure
from bpf import BPF from bcc import BPF
import os import os
from time import sleep from time import sleep
import sys import sys
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure from ctypes import c_uint, c_ulong, Structure
from bpf import BPF from bcc import BPF
from time import sleep from time import sleep
import sys import sys
from unittest import main, TestCase from unittest import main, TestCase
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure from ctypes import c_uint, c_ulong, Structure
from bpf import BPF from bcc import BPF
from time import sleep from time import sleep
import sys import sys
from unittest import main, TestCase from unittest import main, TestCase
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF from bcc import BPF
import os import os
import sys import sys
from unittest import main, TestCase from unittest import main, TestCase
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from netaddr import IPAddress from netaddr import IPAddress
from bpf import BPF from bcc import BPF
from pyroute2 import IPRoute from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM from socket import socket, AF_INET, SOCK_DGRAM
from subprocess import call from subprocess import call
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# #
# 11-Aug-2015 Brendan Gregg Created this. # 11-Aug-2015 Brendan Gregg Created this.
from bpf import BPF from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime from time import sleep, strftime
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# 13-Aug-2015 Brendan Gregg Created this. # 13-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function from __future__ import print_function
from bpf import BPF from bcc import BPF
import sys import sys
# load BPF program # load BPF program
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# 14-Aug-2015 Brendan Gregg Created this. # 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function from __future__ import print_function
from bpf import BPF from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime from time import sleep, strftime
from sys import stderr from sys import stderr
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# 14-Aug-2015 Brendan Gregg Created this. # 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function from __future__ import print_function
from bpf import BPF from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime from time import sleep, strftime
from sys import argv from sys import argv
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment