Hello community,
here is the log from the commit of package bcc for openSUSE:Factory checked in at 2019-04-23 14:39:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/bcc (Old)
and /work/SRC/openSUSE:Factory/.bcc.new.5536 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bcc"
Tue Apr 23 14:39:03 2019 rev:28 rq:697025 version:0.9.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/bcc/bcc.changes 2019-03-26 15:42:29.192241730 +0100
+++ /work/SRC/openSUSE:Factory/.bcc.new.5536/bcc.changes 2019-04-23 14:39:06.105580284 +0200
@@ -1,0 +2,8 @@
+Tue Apr 23 03:44:05 UTC 2019 - Gary Ching-Pang Lin
+
+- Add upstream patches to improve python3 compatibility
+ + 0001-fix-string-re-being-used-on-bytes-for-Python-3.patch
+ + 0001-Convert-bytes-to-string-for-re-in-get_tracepoints.patch
+ + 0001-tools-don-t-mix-print-end-with-printb.patch
+
+-------------------------------------------------------------------
New:
----
0001-Convert-bytes-to-string-for-re-in-get_tracepoints.patch
0001-fix-string-re-being-used-on-bytes-for-Python-3.patch
0001-tools-don-t-mix-print-end-with-printb.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ bcc.spec ++++++
--- /var/tmp/diff_new_pack.jyQBVw/_old 2019-04-23 14:39:06.665580572 +0200
+++ /var/tmp/diff_new_pack.jyQBVw/_new 2019-04-23 14:39:06.665580572 +0200
@@ -36,6 +36,9 @@
Url: https://github.com/iovisor/bcc
Source: https://github.com/iovisor/bcc/archive/v%{version}.tar.gz
Source1: libbpf-5beb8a2ebffd.tar.gz
+Patch1: 0001-fix-string-re-being-used-on-bytes-for-Python-3.patch
+Patch2: 0001-Convert-bytes-to-string-for-re-in-get_tracepoints.patch
+Patch3: 0001-tools-don-t-mix-print-end-with-printb.patch
ExcludeArch: ppc s390
BuildRequires: bison
BuildRequires: cmake >= 2.8.7
@@ -158,6 +161,9 @@
pushd src/cc/libbpf
tar xf %{SOURCE1}
popd
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
%build
# Prevent the cpp examples from compilation and installation
++++++ 0001-Convert-bytes-to-string-for-re-in-get_tracepoints.patch ++++++
From d2a4626dacc33d3dca9a7e6ea2ef4bdaa6ef3c74 Mon Sep 17 00:00:00 2001
From: Gary Lin
Date: Wed, 17 Apr 2019 15:23:16 +0800
Subject: [PATCH] Convert bytes to string for re in get_tracepoints()
When executing funccount with python3, the following error showed.
# python3 funccount.py -D 't:block:*'
Traceback (most recent call last):
File "funccount.py", line 299, in <module>
Tool().run()
File "funccount.py", line 261, in run
self.probe.load()
File "funccount.py", line 191, in load
bpf_text += self._generate_functions(trace_count_text)
File "funccount.py", line 143, in _generate_functions
tracepoints = BPF.get_tracepoints(self.pattern)
File "/usr/lib/python3.7/site-packages/bcc/__init__.py", line 772, in get_tracepoints
if re.match(tp_re, tp):
File "/usr/lib64/python3.7/re.py", line 173, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a bytes pattern on a string-like object
This commit convert 'tp_re' from bytes to string to avoid the crash.
Signed-off-by: Gary Lin
---
src/python/bcc/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
index 6f114de8..bff5f282 100644
--- a/src/python/bcc/__init__.py
+++ b/src/python/bcc/__init__.py
@@ -769,7 +769,7 @@ class BPF(object):
evt_dir = os.path.join(cat_dir, event)
if os.path.isdir(evt_dir):
tp = ("%s:%s" % (category, event))
- if re.match(tp_re, tp):
+ if re.match(tp_re.decode(), tp):
results.append(tp)
return results
--
2.21.0
++++++ 0001-fix-string-re-being-used-on-bytes-for-Python-3.patch ++++++
From df481a4d724b407be2f30fc34a2a649c949f8171 Mon Sep 17 00:00:00 2001
From: lilydjwg
Date: Wed, 20 Mar 2019 14:42:06 +0800
Subject: [PATCH] fix string re being used on bytes for Python 3
---
src/python/bcc/table.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/python/bcc/table.py b/src/python/bcc/table.py
index d33d46eb..d32400e9 100644
--- a/src/python/bcc/table.py
+++ b/src/python/bcc/table.py
@@ -621,7 +621,7 @@ class PerfEventArray(ArrayBase):
num_fields = lib.bpf_perf_event_fields(self.bpf.module, self._name)
i = 0
while i < num_fields:
- field = lib.bpf_perf_event_field(self.bpf.module, self._name, i)
+ field = lib.bpf_perf_event_field(self.bpf.module, self._name, i).decode()
m = re.match(r"(.*)#(.*)", field)
field_name = m.group(1)
field_type = m.group(2)
--
2.21.0
++++++ 0001-tools-don-t-mix-print-end-with-printb.patch ++++++
From 6c793317dac5866db2899e62504d047a02c089b7 Mon Sep 17 00:00:00 2001
From: Gary Lin
Date: Thu, 18 Apr 2019 15:17:56 +0800
Subject: [PATCH] tools: don't mix print(end="") with printb()
While mixing print(end="") with printb(), some messages may miss due to
the underlying buffer handling in python 3.
For example:
# python3 opensnoop.py
PID COMM FD ERR PATH
/proc/18849/cmdline
4109 tmux: server 67 0 /proc/18849/cmdline
4109 tmux: server 67 0 /proc/18849/cmdline
4109 tmux: server 67 0 /proc/18849/cmdline
The PID, COMM, FD, and ERR are printed with print(end=""), and those of
the first instance was eaten by printb() which outputs PATH.
The following scripts mix print(end="") and printb() for the same line:
tools/execsnoop.py
tools/opensnoop.py
tools/tcpaccept.py
tools/tcpconnect.py
Those scripts work fine with python 2 but some messages may miss while
using python 3.
This commit converts print(end="") to printb(nl="") to avoid the
inconsistent outputs.
Signed-off-by: Gary Lin
---
tools/execsnoop.py | 2 +-
tools/opensnoop.py | 12 ++++++------
tools/tcpaccept.py | 8 ++++----
tools/tcpconnect.py | 8 ++++----
4 files changed, 15 insertions(+), 15 deletions(-)
Index: bcc-0.9.0/tools/execsnoop.py
===================================================================
--- bcc-0.9.0.orig/tools/execsnoop.py
+++ bcc-0.9.0/tools/execsnoop.py
@@ -216,7 +216,7 @@ def print_event(cpu, data, size):
if not skip:
if args.timestamp:
- print("%-8.3f" % (time.time() - start_ts), end="")
+ printb(b"%-8.3f" % (time.time() - start_ts), nl="")
ppid = event.ppid if event.ppid > 0 else get_ppid(event.pid)
ppid = b"%d" % ppid if ppid > 0 else b"?"
argv_text = b' '.join(argv[event.pid]).replace(b'\n', b'\\n')
Index: bcc-0.9.0/tools/opensnoop.py
===================================================================
--- bcc-0.9.0.orig/tools/opensnoop.py
+++ bcc-0.9.0/tools/opensnoop.py
@@ -218,17 +218,17 @@ def print_event(cpu, data, size):
if args.timestamp:
delta = event.ts - initial_ts
- print("%-14.9f" % (float(delta) / 1000000), end="")
+ printb(b"%-14.9f" % (float(delta) / 1000000), nl="")
if args.print_uid:
- print("%-6d" % event.uid, end="")
+ printb(b"%-6d" % event.uid, nl="")
- print("%-6d %-16s %4d %3d " %
- (event.id & 0xffffffff if args.tid else event.id >> 32,
- event.comm.decode('utf-8', 'replace'), fd_s, err), end="")
+ printb(b"%-6d %-16s %4d %3d " %
+ (event.id & 0xffffffff if args.tid else event.id >> 32,
+ event.comm, fd_s, err), nl="")
if args.extended_fields:
- print("%08o " % event.flags, end="")
+ printb(b"%08o " % event.flags, nl="")
printb(b'%s' % event.fname)
Index: bcc-0.9.0/tools/tcpaccept.py
===================================================================
--- bcc-0.9.0.orig/tools/tcpaccept.py
+++ bcc-0.9.0/tools/tcpaccept.py
@@ -219,7 +219,7 @@ def print_ipv4_event(cpu, data, size):
if args.timestamp:
if start_ts == 0:
start_ts = event.ts_us
- print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
+ printb(b"%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
printb(b"%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
event.task, event.ip,
inet_ntop(AF_INET, pack("I", event.daddr)).encode(),
@@ -232,7 +232,7 @@ def print_ipv6_event(cpu, data, size):
if args.timestamp:
if start_ts == 0:
start_ts = event.ts_us
- print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
+ printb(b"%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
printb(b"%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
event.task, event.ip,
inet_ntop(AF_INET6, event.daddr).encode(),
Index: bcc-0.9.0/tools/tcpconnect.py
===================================================================
--- bcc-0.9.0.orig/tools/tcpconnect.py
+++ bcc-0.9.0/tools/tcpconnect.py
@@ -193,9 +193,9 @@ def print_ipv4_event(cpu, data, size):
if args.timestamp:
if start_ts == 0:
start_ts = event.ts_us
- print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
+ printb(b"%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), nl="")
if args.print_uid:
- print("%-6d" % event.uid, end="")
+ printb(b"%-6d" % event.uid, nl="")
printb(b"%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
event.task, event.ip,
inet_ntop(AF_INET, pack("I", event.saddr)).encode(),
@@ -207,9 +207,9 @@ def print_ipv6_event(cpu, data, size):
if args.timestamp:
if start_ts == 0:
start_ts = event.ts_us
- print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
+ printb(b"%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), nl="")
if args.print_uid:
- print("%-6d" % event.uid, end="")
+ printb(b"%-6d" % event.uid, nl="")
printb(b"%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
event.task, event.ip,
inet_ntop(AF_INET6, event.saddr).encode(), inet_ntop(AF_INET6, event.daddr).encode(),