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.
First, we should include the BPF class from the bpf module:
```python
from bpf import BPF
from bcc import BPF
```
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
to the stats BPF map. The python program could use that handle to modify the
kernel table as well.
```python
from bpf import BPF
from bcc import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
......
......@@ -96,15 +96,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
%package -n python-bpf
%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf
%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf
%{python_sitelib}/bpf*
%files -n python-bcc
%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
......
......@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
%package -n python-bpf
%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf
%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf
%{python_sitelib}/bpf*
%files -n python-bcc
%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
......
......@@ -65,15 +65,14 @@ Summary: Examples for BPF Compiler Collection (BCC)
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
%package -n python-bpf
%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
%description -n python-bpf
%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
%files -n python-bpf
%{python_sitelib}/bpf*
%files -n python-bcc
%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
......
......@@ -18,7 +18,7 @@ Architecture: any
Depends: libbcc
Description: Shared Library for BPF Compiler Collection (BCC)
Package: python-bpf
Package: python-bcc
Architecture: all
Depends: libbcc, python
Description: Python wrappers for BPF Compiler Collection (BCC)
......@@ -15,7 +15,7 @@
#
# 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 time import sleep
from sys import argv
......
......@@ -11,7 +11,7 @@
# 11-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
from bpf import BPF
from bcc import BPF
import sys
REQ_WRITE = 1 # from include/linux/blk_types.h
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
from bpf import BPF
from bcc import BPF
from builtins import input
from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
from bpf import BPF
from bcc import BPF
from builtins import input
from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler
......
......@@ -5,7 +5,7 @@
# run in project examples directory with:
# sudo ./hello_world.py"
from bpf import BPF
from bcc import BPF
prog = """
int hello(void *ctx) {
......
......@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute
ipr = IPRoute()
......
......@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF
from bcc import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
......
......@@ -25,7 +25,7 @@
# pass() |
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from simulation import Simulation
import sys
......
......@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# 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
import json
from netaddr import IPAddress
......
......@@ -15,7 +15,7 @@
#
# 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 time import sleep
from sys import argv
......
......@@ -23,7 +23,7 @@
# phys | veth |
# switch | |
from bpf import BPF
from bcc import BPF
from builtins import input
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from random import shuffle
......
......@@ -5,18 +5,17 @@ macro(symlink_file SRC DST)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC} ${DST})
endmacro()
symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf ${CMAKE_CURRENT_BINARY_DIR}/bpf)
symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf-run ${CMAKE_CURRENT_BINARY_DIR}/bpf-run)
symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bcc ${CMAKE_CURRENT_BINARY_DIR}/bcc)
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)
# build the pip installable
add_custom_command(OUTPUT ${PIP_INSTALLABLE}
COMMAND python setup.py sdist
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")
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
......
# file GENERATED by distutils, do NOT edit
setup.py
bpf/__init__.py
bpf-run
bcc/__init__.py
#!/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
if os.environ.get('DESTDIR'):
sys.argv += ['--root', os.environ['DESTDIR']]
setup(name='bpf',
setup(name='bcc',
version='@REVISION@',
description='BPF Loader Library',
author='Brenden Blanco',
author_email='bblanco@plumgrid.com',
url='http://plumgrid.com',
packages=['bpf'],
scripts=['bpf-run'],
url='https://github.com/iovisor/bcc',
packages=['bcc'],
platforms=['Linux'])
......@@ -63,7 +63,7 @@
from ctypes import c_uint
from netaddr import IPAddress, EUI
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys
from time import sleep
......
......@@ -55,7 +55,7 @@
# 9: OK
from ctypes import c_uint
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys
from time import sleep
......
......@@ -4,7 +4,7 @@
from ctypes import c_ushort, c_int, c_ulonglong
from netaddr import IPAddress
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM
import sys
......
......@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF
from bcc import BPF
from unittest import main, TestCase
class TestClang(TestCase):
......
......@@ -7,7 +7,7 @@
from ctypes import c_uint, c_ulong, Structure
from netaddr import IPAddress
from bpf import BPF
from bcc import BPF
from subprocess import check_call
import sys
from unittest import main, TestCase
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
from bpf import BPF
from bcc import BPF
import os
from time import sleep
import sys
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
from bpf import BPF
from bcc import BPF
from time import sleep
import sys
from unittest import main, TestCase
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
from bpf import BPF
from bcc import BPF
from time import sleep
import sys
from unittest import main, TestCase
......
......@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
from bpf import BPF
from bcc import BPF
import os
import sys
from unittest import main, TestCase
......
......@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from netaddr import IPAddress
from bpf import BPF
from bcc import BPF
from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM
from subprocess import call
......
......@@ -13,7 +13,7 @@
#
# 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 time import sleep, strftime
......
......@@ -12,7 +12,7 @@
# 13-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
from bpf import BPF
from bcc import BPF
import sys
# load BPF program
......
......@@ -11,7 +11,7 @@
# 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
from bpf import BPF
from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
from sys import stderr
......
......@@ -13,7 +13,7 @@
# 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
from bpf import BPF
from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
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