import bcc-0.8.0-4.el8

This commit is contained in:
CentOS Sources 2019-11-05 13:16:40 -05:00 committed by Andrew Lukoshko
parent 991f78baef
commit fd182cb1cb
18 changed files with 1668 additions and 1300 deletions

View File

@ -1 +1 @@
d5a11c0da3483cad478f6971cbfc9b0eb1bdc932 SOURCES/bcc-0.7.0.tar.gz 168b517240fd27aaa48f480d2470907fe1875dac SOURCES/bcc-0.8.0.tar.gz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/bcc-0.7.0.tar.gz SOURCES/bcc-0.8.0.tar.gz

View File

@ -1,791 +0,0 @@
From b96ebcd2f328cd694101d657341faeb5869556a9 Mon Sep 17 00:00:00 2001
From: jeromemarchand <38073585+jeromemarchand@users.noreply.github.com>
Date: Wed, 10 Oct 2018 01:58:15 +0200
Subject: [PATCH] Bytes/string encoding (#2004)
* tools: uses 'replace' error handler by default in decode()
Tools might encouter characters from non utf-8 charset (e.g. a file
name). When this happen, it's better to replace the unexpected
character by a question mark than crash the tool when all we do is
to print the string.
* tools: fix a bytes/string issue in attach_perf_event()
---
tools/bashreadline.py | 2 +-
tools/biosnoop.py | 4 ++--
tools/biotop.py | 4 ++--
tools/btrfsslower.py | 10 ++++++----
tools/cachetop.py | 2 +-
tools/capable.py | 4 ++--
tools/dcsnoop.py | 5 +++--
tools/ext4slower.py | 10 ++++++----
tools/filelife.py | 3 ++-
tools/fileslower.py | 6 +++---
tools/filetop.py | 7 ++++---
tools/funcslower.py | 4 ++--
tools/gethostlatency.py | 4 ++--
tools/hardirqs.py | 2 +-
tools/llcstat.py | 2 +-
tools/mdflush.py | 3 ++-
tools/mountsnoop.py | 4 ++--
tools/nfsslower.py | 4 ++--
tools/offcputime.py | 4 ++--
tools/offwaketime.py | 8 ++++----
tools/old/offcputime.py | 2 +-
tools/old/oomkill.py | 4 ++--
tools/old/profile.py | 2 +-
tools/old/wakeuptime.py | 8 ++++----
tools/oomkill.py | 4 ++--
tools/opensnoop.py | 3 ++-
tools/profile.py | 8 ++++----
tools/sslsniff.py | 5 +++--
tools/stackcount.py | 2 +-
tools/statsnoop.py | 5 +++--
tools/tcpaccept.py | 7 ++++---
tools/tcpconnect.py | 7 ++++---
tools/tcpconnlat.py | 8 ++++----
tools/tcplife.py | 4 ++--
tools/tcpstates.py | 4 ++--
tools/tcptracer.py | 4 ++--
tools/trace.py | 3 ++-
tools/ttysnoop.py | 2 +-
tools/zfsslower.py | 10 ++++++----
39 files changed, 100 insertions(+), 84 deletions(-)
diff --git a/tools/bashreadline.py b/tools/bashreadline.py
index aaf6fc7..89c37c3 100755
--- a/tools/bashreadline.py
+++ b/tools/bashreadline.py
@@ -57,7 +57,7 @@ print("%-9s %-6s %s" % ("TIME", "PID", "COMMAND"))
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
print("%-9s %-6d %s" % (strftime("%H:%M:%S"), event.pid,
- event.str.decode()))
+ event.str.decode('utf-8', 'replace')))
b["events"].open_perf_buffer(print_event)
while 1:
diff --git a/tools/biosnoop.py b/tools/biosnoop.py
index 7f61180..2b1e77d 100755
--- a/tools/biosnoop.py
+++ b/tools/biosnoop.py
@@ -176,8 +176,8 @@ delta = 0
delta = float(delta) + (event.ts - prev_ts)
print("%-14.9f %-14.14s %-6s %-7s %-2s %-9s %-7s %7.2f" % (
- delta / 1000000, event.name.decode(), event.pid,
- event.disk_name.decode(), rwflg, val,
+ delta / 1000000, event.name.decode('utf-8', 'replace'), event.pid,
+ event.disk_name.decode('utf-8', 'replace'), rwflg, val,
event.len, float(event.delta) / 1000000))
prev_ts = event.ts
diff --git a/tools/biotop.py b/tools/biotop.py
index 63d6642..c6e1ca2 100755
--- a/tools/biotop.py
+++ b/tools/biotop.py
@@ -221,8 +221,8 @@ exiting = 0
# print line
avg_ms = (float(v.us) / 1000) / v.io
print("%-6d %-16s %1s %-3d %-3d %-8s %5s %7s %6.2f" % (k.pid,
- k.name.decode(), "W" if k.rwflag else "R", k.major, k.minor,
- diskname, v.io, v.bytes / 1024, avg_ms))
+ k.name.decode('utf-8', 'replace'), "W" if k.rwflag else "R",
+ k.major, k.minor, diskname, v.io, v.bytes / 1024, avg_ms))
line += 1
if line >= maxrows:
diff --git a/tools/btrfsslower.py b/tools/btrfsslower.py
index 644cb22..d48e04c 100755
--- a/tools/btrfsslower.py
+++ b/tools/btrfsslower.py
@@ -316,12 +316,14 @@ TASK_COMM_LEN = 16 # linux/sched.h
if (csv):
print("%d,%s,%d,%s,%d,%d,%d,%s" % (
- event.ts_us, event.task.decode(), event.pid, type, event.size,
- event.offset, event.delta_us, event.file.decode()))
+ event.ts_us, event.task.decode('utf-8', 'replace'), event.pid,
+ type, event.size, event.offset, event.delta_us,
+ event.file.decode('utf-8', 'replace')))
return
print("%-8s %-14.14s %-6s %1s %-7s %-8d %7.2f %s" % (strftime("%H:%M:%S"),
- event.task.decode(), event.pid, type, event.size, event.offset / 1024,
- float(event.delta_us) / 1000, event.file.decode()))
+ event.task.decode('utf-8', 'replace'), event.pid, type, event.size,
+ event.offset / 1024, float(event.delta_us) / 1000,
+ event.file.decode('utf-8', 'replace')))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/cachetop.py b/tools/cachetop.py
index 0e08af9..1013675 100755
--- a/tools/cachetop.py
+++ b/tools/cachetop.py
@@ -72,7 +72,7 @@ def get_processes_stats(
counts = bpf.get_table("counts")
stats = defaultdict(lambda: defaultdict(int))
for k, v in counts.items():
- stats["%d-%d-%s" % (k.pid, k.uid, k.comm.decode())][k.ip] = v.value
+ stats["%d-%d-%s" % (k.pid, k.uid, k.comm.decode('utf-8', 'replace'))][k.ip] = v.value
stats_list = []
for pid, count in sorted(stats.items(), key=lambda stat: stat[0]):
diff --git a/tools/capable.py b/tools/capable.py
index 3e032e9..efcff4d 100755
--- a/tools/capable.py
+++ b/tools/capable.py
@@ -148,8 +148,8 @@ print("%-9s %-6s %-6s %-16s %-4s %-20s %s" % (
else:
name = "?"
print("%-9s %-6d %-6d %-16s %-4d %-20s %d" % (strftime("%H:%M:%S"),
- event.uid, event.pid, event.comm.decode(), event.cap, name,
- event.audit))
+ event.uid, event.pid, event.comm.decode('utf-8', 'replace'),
+ event.cap, name, event.audit))
# loop with callback to print_event
b["events"].open_perf_buffer(print_event)
diff --git a/tools/dcsnoop.py b/tools/dcsnoop.py
index 070c87a..13152c2 100755
--- a/tools/dcsnoop.py
+++ b/tools/dcsnoop.py
@@ -153,8 +153,9 @@ start_ts = time.time()
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
print("%-11.6f %-6d %-16s %1s %s" % (
- time.time() - start_ts, event.pid, event.comm.decode(),
- mode_s[event.type], event.filename.decode()))
+ time.time() - start_ts, event.pid,
+ event.comm.decode('utf-8', 'replace'), mode_s[event.type],
+ event.filename.decode('utf-8', 'replace')))
# header
print("%-11s %-6s %-16s %1s %s" % ("TIME(s)", "PID", "COMM", "T", "FILE"))
diff --git a/tools/ext4slower.py b/tools/ext4slower.py
index eb6430e..88db831 100755
--- a/tools/ext4slower.py
+++ b/tools/ext4slower.py
@@ -314,12 +314,14 @@ TASK_COMM_LEN = 16 # linux/sched.h
if (csv):
print("%d,%s,%d,%s,%d,%d,%d,%s" % (
- event.ts_us, event.task.decode(), event.pid, type, event.size,
- event.offset, event.delta_us, event.file.decode()))
+ event.ts_us, event.task.decode('utf-8', 'replace'), event.pid,
+ type, event.size, event.offset, event.delta_us,
+ event.file.decode('utf-8', 'replace')))
return
print("%-8s %-14.14s %-6s %1s %-7s %-8d %7.2f %s" % (strftime("%H:%M:%S"),
- event.task.decode(), event.pid, type, event.size, event.offset / 1024,
- float(event.delta_us) / 1000, event.file.decode()))
+ event.task.decode('utf-8', 'replace'), event.pid, type, event.size,
+ event.offset / 1024, float(event.delta_us) / 1000,
+ event.file.decode('utf-8', 'replace')))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/filelife.py b/tools/filelife.py
index 0f4e269..410659d 100755
--- a/tools/filelife.py
+++ b/tools/filelife.py
@@ -136,7 +136,8 @@ print("%-8s %-6s %-16s %-7s %s" % ("TIME", "PID", "COMM", "AGE(s)", "FILE"))
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
print("%-8s %-6d %-16s %-7.2f %s" % (strftime("%H:%M:%S"), event.pid,
- event.comm.decode(), float(event.delta) / 1000, event.fname.decode()))
+ event.comm.decode('utf-8', 'replace'), float(event.delta) / 1000,
+ event.fname.decode('utf-8', 'replace')))
b["events"].open_perf_buffer(print_event)
while 1:
diff --git a/tools/fileslower.py b/tools/fileslower.py
index 5caa4ca..25443a2 100755
--- a/tools/fileslower.py
+++ b/tools/fileslower.py
@@ -240,13 +240,13 @@ start_ts = time.time()
event = ct.cast(data, ct.POINTER(Data)).contents
ms = float(event.delta_us) / 1000
- name = event.name.decode()
+ name = event.name.decode('utf-8', 'replace')
if event.name_len > DNAME_INLINE_LEN:
name = name[:-3] + "..."
print("%-8.3f %-14.14s %-6s %1s %-7s %7.2f %s" % (
- time.time() - start_ts, event.comm.decode(), event.pid,
- mode_s[event.mode], event.sz, ms, name))
+ time.time() - start_ts, event.comm.decode('utf-8', 'replace'),
+ event.pid, mode_s[event.mode], event.sz, ms, name))
b["events"].open_perf_buffer(print_event, page_cnt=64)
while 1:
diff --git a/tools/filetop.py b/tools/filetop.py
index 454dfd8..4c7a28a 100755
--- a/tools/filetop.py
+++ b/tools/filetop.py
@@ -190,14 +190,15 @@ exiting = 0
for k, v in reversed(sorted(counts.items(),
key=lambda counts:
getattr(counts[1], args.sort))):
- name = k.name.decode()
+ name = k.name.decode('utf-8', 'replace')
if k.name_len > DNAME_INLINE_LEN:
name = name[:-3] + "..."
# print line
print("%-6d %-16s %-6d %-6d %-7d %-7d %1s %s" % (k.pid,
- k.comm.decode(), v.reads, v.writes, v.rbytes / 1024,
- v.wbytes / 1024, k.type.decode(), name))
+ k.comm.decode('utf-8', 'replace'), v.reads, v.writes,
+ v.rbytes / 1024, v.wbytes / 1024,
+ k.type.decode('utf-8', 'replace'), name))
line += 1
if line >= maxrows:
diff --git a/tools/funcslower.py b/tools/funcslower.py
index 93fb846..261869e 100755
--- a/tools/funcslower.py
+++ b/tools/funcslower.py
@@ -306,7 +306,7 @@ earliest_ts = 0
# print folded stack output
user_stack = list(user_stack)
kernel_stack = list(kernel_stack)
- line = [event.comm.decode()] + \
+ line = [event.comm.decode('utf-8', 'replace')] + \
[b.sym(addr, event.tgid_pid) for addr in reversed(user_stack)] + \
(do_delimiter and ["-"] or []) + \
[b.ksym(addr) for addr in reversed(kernel_stack)]
@@ -323,7 +323,7 @@ earliest_ts = 0
ts = float(event.duration_ns) / time_multiplier
if not args.folded:
print((time_str(event) + "%-14.14s %-6s %7.2f %16x %s %s") %
- (event.comm.decode(), event.tgid_pid >> 32,
+ (event.comm.decode('utf-8', 'replace'), event.tgid_pid >> 32,
ts, event.retval, args.functions[event.id], args_str(event)))
if args.user_stack or args.kernel_stack:
print_stack(event)
diff --git a/tools/gethostlatency.py b/tools/gethostlatency.py
index f1d7dea..3a967ae 100755
--- a/tools/gethostlatency.py
+++ b/tools/gethostlatency.py
@@ -129,8 +129,8 @@ print("%-9s %-6s %-16s %10s %s" % ("TIME", "PID", "COMM", "LATms", "HOST"))
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
print("%-9s %-6d %-16s %10.2f %s" % (strftime("%H:%M:%S"), event.pid,
- event.comm.decode(), (float(event.delta) / 1000000),
- event.host.decode()))
+ event.comm.decode('utf-8', 'replace'), (float(event.delta) / 1000000),
+ event.host.decode('utf-8', 'replace')))
# loop with callback to print_event
b["events"].open_perf_buffer(print_event)
diff --git a/tools/hardirqs.py b/tools/hardirqs.py
index 3835d63..589a890 100755
--- a/tools/hardirqs.py
+++ b/tools/hardirqs.py
@@ -172,7 +172,7 @@ dist = b.get_table("dist")
else:
print("%-26s %11s" % ("HARDIRQ", "TOTAL_" + label))
for k, v in sorted(dist.items(), key=lambda dist: dist[1].value):
- print("%-26s %11d" % (k.name.decode(), v.value / factor))
+ print("%-26s %11d" % (k.name.decode('utf-8', 'replace'), v.value / factor))
dist.clear()
countdown -= 1
diff --git a/tools/llcstat.py b/tools/llcstat.py
index fe8bdd9..ec2c1f8 100755
--- a/tools/llcstat.py
+++ b/tools/llcstat.py
@@ -113,7 +113,7 @@ tot_miss = 0
# This happens on some PIDs due to missed counts caused by sampling
hit = (v.value - miss) if (v.value >= miss) else 0
print('{:<8d} {:<16s} {:<4d} {:>12d} {:>12d} {:>6.2f}%'.format(
- k.pid, k.name.decode(), k.cpu, v.value, miss,
+ k.pid, k.name.decode('utf-8', 'replace'), k.cpu, v.value, miss,
(float(hit) / float(v.value)) * 100.0))
print('Total References: {} Total Misses: {} Hit Rate: {:.2f}%'.format(
tot_ref, tot_miss, (float(tot_ref - tot_miss) / float(tot_ref)) * 100.0))
diff --git a/tools/mdflush.py b/tools/mdflush.py
index 1d29bf1..70afc4d 100755
--- a/tools/mdflush.py
+++ b/tools/mdflush.py
@@ -72,7 +72,8 @@ print("%-8s %-6s %-16s %s" % ("TIME", "PID", "COMM", "DEVICE"))
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
print("%-8s %-6d %-16s %s" % (strftime("%H:%M:%S"), event.pid,
- event.comm.decode(), event.disk.decode()))
+ event.comm.decode('utf-8', 'replace'),
+ event.disk.decode('utf-8', 'replace')))
# read events
b["events"].open_perf_buffer(print_event)
diff --git a/tools/mountsnoop.py b/tools/mountsnoop.py
index 2d0fa1a..e9b5865 100755
--- a/tools/mountsnoop.py
+++ b/tools/mountsnoop.py
@@ -382,8 +382,8 @@ _escape_chars = {
flags=decode_umount_flags(syscall['flags']),
retval=decode_errno(event.union.retval))
print('{:16} {:<7} {:<7} {:<11} {}'.format(
- syscall['comm'].decode(), syscall['tgid'], syscall['pid'],
- syscall['mnt_ns'], call))
+ syscall['comm'].decode('utf-8', 'replace'), syscall['tgid'],
+ syscall['pid'], syscall['mnt_ns'], call))
except KeyError:
# This might happen if we lost an event.
pass
diff --git a/tools/nfsslower.py b/tools/nfsslower.py
index 0f836af..2f92c90 100755
--- a/tools/nfsslower.py
+++ b/tools/nfsslower.py
@@ -280,13 +280,13 @@ TASK_COMM_LEN = 16 # linux/sched.h
return
print("%-8s %-14.14s %-6s %1s %-7s %-8d %7.2f %s" %
(strftime("%H:%M:%S"),
- event.task.decode(),
+ event.task.decode('utf-8', 'replace'),
event.pid,
type,
event.size,
event.offset / 1024,
float(event.delta_us) / 1000,
- event.file.decode()))
+ event.file.decode('utf-8', 'replace')))
# Currently specifically works for NFSv4, the other kprobes are generic
diff --git a/tools/offcputime.py b/tools/offcputime.py
index de77fb4..d84ae52 100755
--- a/tools/offcputime.py
+++ b/tools/offcputime.py
@@ -281,7 +281,7 @@ stack_traces = b.get_table("stack_traces")
# print folded stack output
user_stack = list(user_stack)
kernel_stack = list(kernel_stack)
- line = [k.name.decode()]
+ line = [k.name.decode('utf-8', 'replace')]
# if we failed to get the stack is, such as due to no space (-ENOMEM) or
# hash collision (-EEXIST), we still print a placeholder for consistency
if not args.kernel_stacks_only:
@@ -312,7 +312,7 @@ stack_traces = b.get_table("stack_traces")
else:
for addr in user_stack:
print(" %s" % b.sym(addr, k.tgid))
- print(" %-16s %s (%d)" % ("-", k.name.decode(), k.pid))
+ print(" %-16s %s (%d)" % ("-", k.name.decode('utf-8', 'replace'), k.pid))
print(" %d\n" % v.value)
if missing_stacks > 0:
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
index 01961ee..674be22 100755
--- a/tools/offwaketime.py
+++ b/tools/offwaketime.py
@@ -316,7 +316,7 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
if folded:
# print folded stack output
- line = [k.target.decode()]
+ line = [k.target.decode('utf-8', 'replace')]
if not args.kernel_stacks_only:
if stack_id_err(k.t_u_stack_id):
line.append("[Missed User Stack]")
@@ -344,11 +344,11 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
else:
line.extend([b.sym(addr, k.w_tgid)
for addr in reversed(list(waker_user_stack))])
- line.append(k.waker.decode())
+ line.append(k.waker.decode('utf-8', 'replace'))
print("%s %d" % (";".join(line), v.value))
else:
# print wakeup name then stack in reverse order
- print(" %-16s %s %s" % ("waker:", k.waker.decode(), k.t_pid))
+ print(" %-16s %s %s" % ("waker:", k.waker.decode('utf-8', 'replace'), k.t_pid))
if not args.kernel_stacks_only:
if stack_id_err(k.w_u_stack_id):
print(" [Missed User Stack]")
@@ -381,7 +381,7 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
else:
for addr in target_user_stack:
print(" %s" % b.sym(addr, k.t_tgid))
- print(" %-16s %s %s" % ("target:", k.target.decode(), k.w_pid))
+ print(" %-16s %s %s" % ("target:", k.target.decode('utf-8', 'replace'), k.w_pid))
print(" %d\n" % v.value)
if missing_stacks > 0:
diff --git a/tools/old/offcputime.py b/tools/old/offcputime.py
index 680d924..38d12a2 100755
--- a/tools/old/offcputime.py
+++ b/tools/old/offcputime.py
@@ -185,7 +185,7 @@ matched = b.num_open_kprobes()
for k, v in sorted(counts.items(), key=lambda counts: counts[1].value):
if folded:
# print folded stack output
- line = k.name.decode() + ";"
+ line = k.name.decode('utf-8', 'replace') + ";"
for i in reversed(range(0, maxdepth)):
if k.ret[i] == 0:
continue
diff --git a/tools/old/oomkill.py b/tools/old/oomkill.py
index e8e0321..b99f852 100755
--- a/tools/old/oomkill.py
+++ b/tools/old/oomkill.py
@@ -68,8 +68,8 @@ TASK_COMM_LEN = 16 # linux/sched.h
avgline = stats.read().rstrip()
print(("%s Triggered by PID %d (\"%s\"), OOM kill of PID %d (\"%s\")"
", %d pages, loadavg: %s") % (strftime("%H:%M:%S"), event.fpid,
- event.fcomm.decode(), event.tpid, event.tcomm.decode(), event.pages,
- avgline))
+ event.fcomm.decode('utf-8', 'replace'), event.tpid,
+ event.tcomm.decode('utf-8', 'replace'), event.pages, avgline))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/old/profile.py b/tools/old/profile.py
index 04ca13a..e308208 100755
--- a/tools/old/profile.py
+++ b/tools/old/profile.py
@@ -339,7 +339,7 @@ stack_traces = b.get_table("stack_traces")
# print folded stack output
user_stack = list(user_stack)
kernel_stack = list(kernel_stack)
- line = [k.name.decode()] + \
+ line = [k.name.decode('utf-8', 'replace')] + \
[b.sym(addr, k.pid) for addr in reversed(user_stack)] + \
(do_delimiter and ["-"] or []) + \
[aksym(addr) for addr in reversed(kernel_stack)]
diff --git a/tools/old/wakeuptime.py b/tools/old/wakeuptime.py
index e09840a..783c7ff 100644
--- a/tools/old/wakeuptime.py
+++ b/tools/old/wakeuptime.py
@@ -199,23 +199,23 @@ matched = b.num_open_kprobes()
for k, v in sorted(counts.items(), key=lambda counts: counts[1].value):
if folded:
# print folded stack output
- line = k.waker.decode() + ";"
+ line = k.waker.decode('utf-8', 'replace') + ";"
for i in reversed(range(0, maxdepth)):
if k.ret[i] == 0:
continue
line = line + b.ksym(k.ret[i])
if i != 0:
line = line + ";"
- print("%s;%s %d" % (line, k.target.decode(), v.value))
+ print("%s;%s %d" % (line, k.target.decode('utf-8', 'replace'), v.value))
else:
# print default multi-line stack output
- print(" %-16s %s" % ("target:", k.target.decode()))
+ print(" %-16s %s" % ("target:", k.target.decode('utf-8', 'replace')))
for i in range(0, maxdepth):
if k.ret[i] == 0:
break
print(" %-16x %s" % (k.ret[i],
b.ksym(k.ret[i])))
- print(" %-16s %s" % ("waker:", k.waker.decode()))
+ print(" %-16s %s" % ("waker:", k.waker.decode('utf-8', 'replace')))
print(" %d\n" % v.value)
counts.clear()
diff --git a/tools/oomkill.py b/tools/oomkill.py
index e831d44..0677e49 100755
--- a/tools/oomkill.py
+++ b/tools/oomkill.py
@@ -69,8 +69,8 @@ TASK_COMM_LEN = 16 # linux/sched.h
avgline = stats.read().rstrip()
print(("%s Triggered by PID %d (\"%s\"), OOM kill of PID %d (\"%s\")"
", %d pages, loadavg: %s") % (strftime("%H:%M:%S"), event.fpid,
- event.fcomm.decode(), event.tpid, event.tcomm.decode(), event.pages,
- avgline))
+ event.fcomm.decode('utf-8', 'replace'), event.tpid,
+ event.tcomm.decode('utf-8', 'replace'), event.pages, avgline))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/opensnoop.py b/tools/opensnoop.py
index a0657d4..418d47b 100755
--- a/tools/opensnoop.py
+++ b/tools/opensnoop.py
@@ -184,7 +184,8 @@ print("%-6s %-16s %4s %3s %s" %
print("%-6d %-16s %4d %3d %s" %
(event.id & 0xffffffff if args.tid else event.id >> 32,
- event.comm.decode(), fd_s, err, event.fname.decode()))
+ event.comm.decode('utf-8', 'replace'), fd_s, err,
+ event.fname.decode('utf-8', 'replace')))
# loop with callback to print_event
b["events"].open_perf_buffer(print_event, page_cnt=64)
diff --git a/tools/profile.py b/tools/profile.py
index 1530b98..d1d3d26 100755
--- a/tools/profile.py
+++ b/tools/profile.py
@@ -268,7 +268,7 @@ b.attach_perf_event(ev_type=PerfType.SOFTWARE,
def aksym(addr):
if args.annotations:
- return b.ksym(addr) + "_[k]"
+ return b.ksym(addr) + "_[k]".encode()
else:
return b.ksym(addr)
@@ -320,7 +320,7 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
line.append("[Missed Kernel Stack]")
else:
line.extend([b.ksym(addr) for addr in reversed(kernel_stack)])
- print("%s %d" % (b";".join(line).decode(), v.value))
+ print("%s %d" % (b";".join(line).decode('utf-8', 'replace'), v.value))
else:
# print default multi-line stack output
if not args.user_stacks_only:
@@ -336,8 +336,8 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
print(" [Missed User Stack]")
else:
for addr in user_stack:
- print(" %s" % b.sym(addr, k.pid).decode())
- print(" %-16s %s (%d)" % ("-", k.name.decode(), k.pid))
+ print(" %s" % b.sym(addr, k.pid).decode('utf-8', 'replace'))
+ print(" %-16s %s (%d)" % ("-", k.name.decode('utf-8', 'replace'), k.pid))
print(" %d\n" % v.value)
# check missing
diff --git a/tools/sslsniff.py b/tools/sslsniff.py
index 2e74fba..0c9f976 100755
--- a/tools/sslsniff.py
+++ b/tools/sslsniff.py
@@ -221,8 +221,9 @@ start = 0
" bytes lost) " + "-" * 5
fmt = "%-12s %-18.9f %-16s %-6d %-6d\n%s\n%s\n%s\n\n"
- print(fmt % (rw, time_s, event.comm.decode(), event.pid, event.len, s_mark,
- event.v0.decode(), e_mark))
+ print(fmt % (rw, time_s, event.comm.decode('utf-8', 'replace'),
+ event.pid, event.len, s_mark,
+ event.v0.decode('utf-8', 'replace'), e_mark))
b["perf_SSL_write"].open_perf_buffer(print_event_write)
b["perf_SSL_read"].open_perf_buffer(print_event_read)
diff --git a/tools/stackcount.py b/tools/stackcount.py
index 8781879..5554014 100755
--- a/tools/stackcount.py
+++ b/tools/stackcount.py
@@ -339,7 +339,7 @@ BPF_STACK_TRACE(stack_traces, 1024);
# print folded stack output
user_stack = list(user_stack)
kernel_stack = list(kernel_stack)
- line = [k.name.decode()] + \
+ line = [k.name.decode('utf-8', 'replace')] + \
[b.sym(addr, k.tgid) for addr in
reversed(user_stack)] + \
(self.need_delimiter and ["-"] or []) + \
diff --git a/tools/statsnoop.py b/tools/statsnoop.py
index 6fd8049..4e62ebd 100755
--- a/tools/statsnoop.py
+++ b/tools/statsnoop.py
@@ -172,8 +172,9 @@ print("%-6s %-16s %4s %3s %s" % ("PID", "COMM", "FD", "ERR", "PATH"))
if args.timestamp:
print("%-14.9f" % (float(event.ts_ns - start_ts) / 1000000000), end="")
- print("%-6d %-16s %4d %3d %s" % (event.pid, event.comm.decode(),
- fd_s, err, event.fname.decode()))
+ print("%-6d %-16s %4d %3d %s" % (event.pid,
+ event.comm.decode('utf-8', 'replace'), fd_s, err,
+ event.fname.decode('utf-8', 'replace')))
# loop with callback to print_event
b["events"].open_perf_buffer(print_event, page_cnt=64)
diff --git a/tools/tcpaccept.py b/tools/tcpaccept.py
index 044f15c..884b0c5 100755
--- a/tools/tcpaccept.py
+++ b/tools/tcpaccept.py
@@ -239,7 +239,7 @@ TASK_COMM_LEN = 16 # linux/sched.h
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
- event.task.decode(), event.ip,
+ event.task.decode('utf-8', 'replace'), event.ip,
inet_ntop(AF_INET, pack("I", event.daddr)),
inet_ntop(AF_INET, pack("I", event.saddr)), event.lport))
@@ -251,8 +251,9 @@ TASK_COMM_LEN = 16 # linux/sched.h
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
- event.task.decode(), event.ip, inet_ntop(AF_INET6, event.daddr),
- inet_ntop(AF_INET6, event.saddr), event.lport))
+ event.task.decode('utf-8', 'replace'), event.ip,
+ inet_ntop(AF_INET6, event.daddr),inet_ntop(AF_INET6, event.saddr),
+ event.lport))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/tcpconnect.py b/tools/tcpconnect.py
index f0b23b0..ac84326 100755
--- a/tools/tcpconnect.py
+++ b/tools/tcpconnect.py
@@ -202,7 +202,7 @@ TASK_COMM_LEN = 16 # linux/sched.h
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
- event.task.decode(), event.ip,
+ event.task.decode('utf-8', 'replace'), event.ip,
inet_ntop(AF_INET, pack("I", event.saddr)),
inet_ntop(AF_INET, pack("I", event.daddr)), event.dport))
@@ -214,8 +214,9 @@ TASK_COMM_LEN = 16 # linux/sched.h
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-4d" % (event.pid,
- event.task.decode(), event.ip, inet_ntop(AF_INET6, event.saddr),
- inet_ntop(AF_INET6, event.daddr), event.dport))
+ event.task.decode('utf-8', 'replace'), event.ip,
+ inet_ntop(AF_INET6, event.saddr), inet_ntop(AF_INET6, event.daddr),
+ event.dport))
# initialize BPF
b = BPF(text=bpf_text)
diff --git a/tools/tcpconnlat.py b/tools/tcpconnlat.py
index 233612b..0d21b83 100755
--- a/tools/tcpconnlat.py
+++ b/tools/tcpconnlat.py
@@ -237,7 +237,7 @@ start_ts = 0
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-5d %.2f" % (event.pid,
- event.task.decode(), event.ip,
+ event.task.decode('utf-8', 'replace'), event.ip,
inet_ntop(AF_INET, pack("I", event.saddr)),
inet_ntop(AF_INET, pack("I", event.daddr)), event.dport,
float(event.delta_us) / 1000))
@@ -250,9 +250,9 @@ start_ts = 0
start_ts = event.ts_us
print("%-9.3f" % ((float(event.ts_us) - start_ts) / 1000000), end="")
print("%-6d %-12.12s %-2d %-16s %-16s %-5d %.2f" % (event.pid,
- event.task.decode(), event.ip, inet_ntop(AF_INET6, event.saddr),
- inet_ntop(AF_INET6, event.daddr), event.dport,
- float(event.delta_us) / 1000))
+ event.task.decode('utf-8', 'replace'), event.ip,
+ inet_ntop(AF_INET6, event.saddr), inet_ntop(AF_INET6, event.daddr),
+ event.dport, float(event.delta_us) / 1000))
# header
if args.timestamp:
diff --git a/tools/tcplife.py b/tools/tcplife.py
index f8bab43..51ed7ae 100755
--- a/tools/tcplife.py
+++ b/tools/tcplife.py
@@ -454,7 +454,7 @@ format_string = "%-5d %-10.10s %s%-15s %-5d %-15s %-5d %5d %5d %.2f"
print("%.6f," % delta_s, end="")
else:
print("%-9.6f " % delta_s, end="")
- print(format_string % (event.pid, event.task.decode(),
+ print(format_string % (event.pid, event.task.decode('utf-8', 'replace'),
"4" if args.wide or args.csv else "",
inet_ntop(AF_INET, pack("I", event.saddr)), event.ports >> 32,
inet_ntop(AF_INET, pack("I", event.daddr)), event.ports & 0xffffffff,
@@ -476,7 +476,7 @@ format_string = "%-5d %-10.10s %s%-15s %-5d %-15s %-5d %5d %5d %.2f"
print("%.6f," % delta_s, end="")
else:
print("%-9.6f " % delta_s, end="")
- print(format_string % (event.pid, event.task.decode(),
+ print(format_string % (event.pid, event.task.decode('utf-8', 'replace'),
"6" if args.wide or args.csv else "",
inet_ntop(AF_INET6, event.saddr), event.ports >> 32,
inet_ntop(AF_INET6, event.daddr), event.ports & 0xffffffff,
diff --git a/tools/tcpstates.py b/tools/tcpstates.py
index ec758d2..381a6d5 100755
--- a/tools/tcpstates.py
+++ b/tools/tcpstates.py
@@ -276,7 +276,7 @@ format_string = ("%-16x %-5d %-10.10s %s%-15s %-5d %-15s %-5d %-11s " +
print("%.6f," % delta_s, end="")
else:
print("%-9.6f " % delta_s, end="")
- print(format_string % (event.skaddr, event.pid, event.task.decode(),
+ print(format_string % (event.skaddr, event.pid, event.task.decode('utf-8', 'replace'),
"4" if args.wide or args.csv else "",
inet_ntop(AF_INET, pack("I", event.saddr)), event.ports >> 32,
inet_ntop(AF_INET, pack("I", event.daddr)), event.ports & 0xffffffff,
@@ -299,7 +299,7 @@ format_string = ("%-16x %-5d %-10.10s %s%-15s %-5d %-15s %-5d %-11s " +
print("%.6f," % delta_s, end="")
else:
print("%-9.6f " % delta_s, end="")
- print(format_string % (event.skaddr, event.pid, event.task.decode(),
+ print(format_string % (event.skaddr, event.pid, event.task.decode('utf-8', 'replace'),
"6" if args.wide or args.csv else "",
inet_ntop(AF_INET6, event.saddr), event.ports >> 32,
inet_ntop(AF_INET6, event.daddr), event.ports & 0xffffffff,
diff --git a/tools/tcptracer.py b/tools/tcptracer.py
index 5e97ee6..16bb4b1 100755
--- a/tools/tcptracer.py
+++ b/tools/tcptracer.py
@@ -556,7 +556,7 @@ verbose_types = {"C": "connect", "A": "accept",
print("%-2s " % (type_str), end="")
print("%-6d %-16s %-2d %-16s %-16s %-6d %-6d" %
- (event.pid, event.comm.decode('utf-8'),
+ (event.pid, event.comm.decode('utf-8', 'replace'),
event.ip,
inet_ntop(AF_INET, pack("I", event.saddr)),
inet_ntop(AF_INET, pack("I", event.daddr)),
@@ -593,7 +593,7 @@ verbose_types = {"C": "connect", "A": "accept",
print("%-2s " % (type_str), end="")
print("%-6d %-16s %-2d %-16s %-16s %-6d %-6d" %
- (event.pid, event.comm.decode('utf-8'),
+ (event.pid, event.comm.decode('utf-8', 'replace'),
event.ip,
"[" + inet_ntop(AF_INET6, event.saddr) + "]",
"[" + inet_ntop(AF_INET6, event.daddr) + "]",
diff --git a/tools/trace.py b/tools/trace.py
index 16e9b6b..2233305 100755
--- a/tools/trace.py
+++ b/tools/trace.py
@@ -558,7 +558,8 @@ BPF_PERF_OUTPUT(%s);
if Probe.print_cpu:
print("%-3s " % event.cpu, end="")
print("%-7d %-7d %-15s %-16s %s" %
- (event.tgid, event.pid, event.comm.decode(),
+ (event.tgid, event.pid,
+ event.comm.decode('utf-8', 'replace'),
self._display_function(), msg))
if self.kernel_stack:
diff --git a/tools/ttysnoop.py b/tools/ttysnoop.py
index e934486..9780518 100755
--- a/tools/ttysnoop.py
+++ b/tools/ttysnoop.py
@@ -115,7 +115,7 @@ BUFSIZE = 256
# process event
def print_event(cpu, data, size):
event = ct.cast(data, ct.POINTER(Data)).contents
- print("%s" % event.buf[0:event.count].decode(), end="")
+ print("%s" % event.buf[0:event.count].decode('utf-8', 'replace'), end="")
sys.stdout.flush()
# loop with callback to print_event
diff --git a/tools/zfsslower.py b/tools/zfsslower.py
index 6de4606..8ab283a 100755
--- a/tools/zfsslower.py
+++ b/tools/zfsslower.py
@@ -265,12 +265,14 @@ TASK_COMM_LEN = 16 # linux/sched.h
if (csv):
print("%d,%s,%d,%s,%d,%d,%d,%s" % (
- event.ts_us, event.task.decode(), event.pid, type, event.size,
- event.offset, event.delta_us, event.file.decode()))
+ event.ts_us, event.task.decode('utf-8', 'replace'), event.pid,
+ type, event.size, event.offset, event.delta_us,
+ event.file.decode('utf-8', 'replace')))
return
print("%-8s %-14.14s %-6s %1s %-7s %-8d %7.2f %s" % (strftime("%H:%M:%S"),
- event.task.decode(), event.pid, type, event.size, event.offset / 1024,
- float(event.delta_us) / 1000, event.file.decode()))
+ event.task.decode('utf-8', 'replace'), event.pid, type, event.size,
+ event.offset / 1024, float(event.delta_us) / 1000,
+ event.file.decode('utf-8', 'replace')))
# initialize BPF
b = BPF(text=bpf_text)
--
2.17.2

View File

@ -1,28 +0,0 @@
From b3faa19c61a5a5385899a80bdd0d6a3052f1415a Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Thu, 24 May 2018 16:11:30 +0200
Subject: [PATCH] Disable tests/cc
Some files in tests/cc/ don't compile on s390x. We can just disable
them until a better fix is available: the build target are not
installed anyway.
---
tests/CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 86abec9..48e9029 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,7 +8,6 @@ add_test(NAME style-check COMMAND ${CMAKE_SOURCE_DIR}/scripts/style-check.sh)
set_tests_properties(style-check PROPERTIES PASS_REGULAR_EXPRESSION ".*")
if(ENABLE_CLANG_JIT)
-add_subdirectory(cc)
add_subdirectory(python)
add_subdirectory(lua)
endif()
--
2.13.6

View File

@ -1,69 +0,0 @@
From 09f9d3c8dd016ee10dc8b57057763dc25b0d2208 Mon Sep 17 00:00:00 2001
From: jeromemarchand <38073585+jeromemarchand@users.noreply.github.com>
Date: Sat, 13 Oct 2018 01:01:22 +0200
Subject: [PATCH] Tools fixes (#2009)
* tools: the argument of get_kprobe_functions() should be a bytes object
It fixes the following error:
Traceback (most recent call last):
File "/usr/share/bcc/tools/ext4dist", line 189, in <module>
if BPF.get_kprobe_functions('ext4_file_read_iter'):
File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 519, in get_kprobe_functions
if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \
File "/usr/lib64/python3.6/re.py", line 172, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object
* tools: fix freeze in offwaketime
Since commit 47cecb65ce6e, the sigint signal is ignored
unconditionally which prevents offwaketime to be stopped by
pressing Ctrl-C when run without a specified duration.
---
tools/ext4dist.py | 4 ++--
tools/offwaketime.py | 10 ++++++----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/ext4dist.py b/tools/ext4dist.py
index 1806953..bc797fb 100755
--- a/tools/ext4dist.py
+++ b/tools/ext4dist.py
@@ -183,10 +183,10 @@ b = BPF(text=bpf_text)
# Comment by Joe Yin
# From Linux 4.10, the function .read_iter at the ext4_file_operations has
# changed to ext4_file_read_iter.
-# So, I add get_kprobe_functions('ext4_file_read_iter'),it will first to attach ext4_file_read_iter,
+# So, I add get_kprobe_functions(b'ext4_file_read_iter'),it will first to attach ext4_file_read_iter,
# if fails and will attach the generic_file_read_iter which used to pre-4.10.
-if BPF.get_kprobe_functions('ext4_file_read_iter'):
+if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_entry")
else:
b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
index 674be22..0e4f35e 100755
--- a/tools/offwaketime.py
+++ b/tools/offwaketime.py
@@ -277,11 +277,13 @@ matched = b.num_open_kprobes()
else:
print("... Hit Ctrl-C to end.")
-# as cleanup can take many seconds, trap Ctrl-C:
-# print a newline for folded output on Ctrl-C
-signal.signal(signal.SIGINT, signal_ignore)
+try:
+ sleep(duration)
+except KeyboardInterrupt:
+ # as cleanup can take many seconds, trap Ctrl-C:
+ # print a newline for folded output on Ctrl-C
+ signal.signal(signal.SIGINT, signal_ignore)
-sleep(duration)
if not folded:
print()
--
2.17.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
From 0f5849187972a50adf0d9eaa8788c11f9fd926ea Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
Date: Thu, 28 Feb 2019 11:18:04 -0800
Subject: [PATCH] fix b.support_raw_tracepoint for 5.0 kernel
Fix issue #2240.
In 5.0, the following commit
commit a38d1107f937ca95dcf820161ef44ea683d6a0b1
Author: Matt Mullins <mmullins@fb.com>
Date: Wed Dec 12 16:42:37 2018 -0800
bpf: support raw tracepoints in modules
renamed the function bpf_find_raw_tracepoint() to
bpf_get_raw_tracepoint(). The bcc relies on checking
bpf_find_raw_tracepoint() in /proc/kallsyms to detect
whether raw_tracepoint is supported in kernel or not.
We do not have better mechanism to detect raw_tracepoint
support without additional syscalls. So tentatively,
let us just check bpf_get_raw_tracepoint() ksym as well
for raw_tracepoint support.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
src/python/bcc/__init__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
index 01d5604b..69a048f3 100644
--- a/src/python/bcc/__init__.py
+++ b/src/python/bcc/__init__.py
@@ -858,7 +858,8 @@ DEBUG_BTF = 0x20
@staticmethod
def support_raw_tracepoint():
# kernel symbol "bpf_find_raw_tracepoint" indicates raw_tracepint support
- if BPF.ksymname("bpf_find_raw_tracepoint") != -1:
+ if BPF.ksymname("bpf_find_raw_tracepoint") != -1 or \
+ BPF.ksymname("bpf_get_raw_tracepoint") != -1:
return True
return False
--
2.20.1

View File

@ -0,0 +1,50 @@
From 3f7b59660037c0d5dea785d115df25d9b95f07dc Mon Sep 17 00:00:00 2001
From: Xiaozhou Liu <liuxiaozhou@bytedance.com>
Date: Mon, 21 Jan 2019 11:23:42 +0800
Subject: [PATCH] print_log2_hist(): check and skip possible paddings (#2155)
Address issue 2154.
When a struct S is used as key to a BPF_HISTOGRAM, it is assumed that the second
member of S holds the slot. But when S is converted to python from bpf C,
a padding may be inserted as a second member. This breaks print_log2_hist().
root@debian:~/bcc/tools# ./softirqs.py -d
Tracing soft irq event time... Hit Ctrl-C to end.
^C
Traceback (most recent call last):
File "./softirqs.py", line 144, in <module>
dist.print_log2_hist(label, "softirq", section_print_fn=vec_to_name)
File "/usr/local/lib/python2.7/dist-packages/bcc/table.py", line 326, in print_log2_hist
vals[slot] = v.value
TypeError: list indices must be integers, not str
Fix it by skipping the possible padding. Future work would be fixing/working
around in the library where the padding is introduced.
---
src/python/bcc/table.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/python/bcc/table.py b/src/python/bcc/table.py
index 6f598353..f6449de7 100644
--- a/src/python/bcc/table.py
+++ b/src/python/bcc/table.py
@@ -317,6 +317,15 @@ linear_index_max = 1025
tmp = {}
f1 = self.Key._fields_[0][0]
f2 = self.Key._fields_[1][0]
+
+ # The above code assumes that self.Key._fields_[1][0] holds the
+ # slot. But a padding member may have been inserted here, which
+ # breaks the assumption and leads to chaos.
+ # TODO: this is a quick fix. Fixing/working around in the BCC
+ # internal library is the right thing to do.
+ if f2 == '__pad_1' and len(self.Key._fields_) == 3:
+ f2 = self.Key._fields_[2][0]
+
for k, v in self.items():
bucket = getattr(k, f1)
if bucket_fn:
--
2.20.1

View File

@ -0,0 +1,37 @@
From bac633a6bb60b6b8542348ea3f61c367eae14f7c Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Wed, 3 Jul 2019 11:12:08 +0200
Subject: [PATCH] tools: fix runqslower warning
The state member of task_struct is volatile and it's use as the last
parameter of bpf_probe_read (const void *) triggers the following
clang warning (LLVM 8):
/virtual/main.c:56:42: warning: passing 'volatile long *' to parameter of type 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
bpf_probe_read(&state, sizeof(long), &prev->state);
^~~~~~~~~~~~
1 warning generated.
Tracing run queue latency higher than 10000 us
TIME COMM PID LAT(us)
An explicit cast fixes the warning.
---
tools/runqslower.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/runqslower.py b/tools/runqslower.py
index 1d48be8a..5f5c3b9b 100755
--- a/tools/runqslower.py
+++ b/tools/runqslower.py
@@ -167,7 +167,7 @@ RAW_TRACEPOINT_PROBE(sched_switch)
long state;
// ivcsw: treat like an enqueue event and store timestamp
- bpf_probe_read(&state, sizeof(long), &prev->state);
+ bpf_probe_read(&state, sizeof(long), (const void *)&prev->state);
if (state == TASK_RUNNING) {
bpf_probe_read(&tgid, sizeof(prev->tgid), &prev->tgid);
bpf_probe_read(&pid, sizeof(prev->pid), &prev->pid);
--
2.20.1

View File

@ -0,0 +1,111 @@
From f03beca4d6e6bc3fa7089416d752387bd26904dc Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Fri, 15 Feb 2019 17:35:37 +0100
Subject: [PATCH] tools: fix some python3 bytes vs strings issues (#2205)
It fixes the following errors:
$ execsnoop.py -q
PCOMM PID PPID RET ARGS
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "/usr/lib/python3.6/site-packages/bcc/table.py", line 572, in raw_cb_
callback(cpu, data, size)
File "tools/execsnoop.py", line 229, in print_event
for arg in argv[event.pid]
File "tools/execsnoop.py", line 229, in <listcomp>
for arg in argv[event.pid]
TypeError: a bytes-like object is required, not 'str'
$ offcputime.py -K -f 5
Traceback (most recent call last):
File "./tools/offcputime.py", line 298, in <module>
print("%s %d" % (";".join(line), v.value))
TypeError: sequence item 1: expected str instance, bytes found
$ offwaketime.py -f 5
Traceback (most recent call last):
File "./tools/offwaketime.py", line 350, in <module>
print("%s %d" % (";".join(line), v.value))
TypeError: sequence item 1: expected str instance, bytes found
---
tools/execsnoop.py | 2 +-
tools/offcputime.py | 6 ++++--
tools/offwaketime.py | 8 ++++----
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/execsnoop.py b/tools/execsnoop.py
index c4021165..1ce83e07 100755
--- a/tools/execsnoop.py
+++ b/tools/execsnoop.py
@@ -210,7 +210,7 @@ argv = defaultdict(list)
skip = True
if args.quote:
argv[event.pid] = [
- "\"" + arg.replace("\"", "\\\"") + "\""
+ b"\"" + arg.replace(b"\"", b"\\\"") + b"\""
for arg in argv[event.pid]
]
diff --git a/tools/offcputime.py b/tools/offcputime.py
index d84ae529..ac3b7281 100755
--- a/tools/offcputime.py
+++ b/tools/offcputime.py
@@ -288,13 +288,15 @@ stack_traces = b.get_table("stack_traces")
if stack_id_err(k.user_stack_id):
line.append("[Missed User Stack]")
else:
- line.extend([b.sym(addr, k.tgid) for addr in reversed(user_stack)])
+ line.extend([b.sym(addr, k.tgid).decode('utf-8', 'replace')
+ for addr in reversed(user_stack)])
if not args.user_stacks_only:
line.extend(["-"] if (need_delimiter and k.kernel_stack_id >= 0 and k.user_stack_id >= 0) else [])
if stack_id_err(k.kernel_stack_id):
line.append("[Missed Kernel Stack]")
else:
- line.extend([b.ksym(addr) for addr in reversed(kernel_stack)])
+ line.extend([b.ksym(addr).decode('utf-8', 'replace')
+ for addr in reversed(kernel_stack)])
print("%s %d" % (";".join(line), v.value))
else:
# print default multi-line stack output
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
index 38a9ff25..4a1cebab 100755
--- a/tools/offwaketime.py
+++ b/tools/offwaketime.py
@@ -323,28 +323,28 @@ need_delimiter = args.delimited and not (args.kernel_stacks_only or
if stack_id_err(k.t_u_stack_id):
line.append("[Missed User Stack]")
else:
- line.extend([b.sym(addr, k.t_tgid)
+ line.extend([b.sym(addr, k.t_tgid).decode('utf-8', 'replace')
for addr in reversed(list(target_user_stack)[1:])])
if not args.user_stacks_only:
line.extend(["-"] if (need_delimiter and k.t_k_stack_id > 0 and k.t_u_stack_id > 0) else [])
if stack_id_err(k.t_k_stack_id):
line.append("[Missed Kernel Stack]")
else:
- line.extend([b.ksym(addr)
+ line.extend([b.ksym(addr).decode('utf-8', 'replace')
for addr in reversed(list(target_kernel_stack)[1:])])
line.append("--")
if not args.user_stacks_only:
if stack_id_err(k.w_k_stack_id):
line.append("[Missed Kernel Stack]")
else:
- line.extend([b.ksym(addr)
+ line.extend([b.ksym(addr).decode('utf-8', 'replace')
for addr in reversed(list(waker_kernel_stack))])
if not args.kernel_stacks_only:
line.extend(["-"] if (need_delimiter and k.w_u_stack_id > 0 and k.w_k_stack_id > 0) else [])
if stack_id_err(k.w_u_stack_id):
line.append("[Missed User Stack]")
else:
- line.extend([b.sym(addr, k.w_tgid)
+ line.extend([b.sym(addr, k.w_tgid).decode('utf-8', 'replace')
for addr in reversed(list(waker_user_stack))])
line.append(k.waker.decode('utf-8', 'replace'))
print("%s %d" % (";".join(line), v.value))
--
2.20.1

View File

@ -0,0 +1,180 @@
From ba41501bb2ca89312061b31c08e570a11c092370 Mon Sep 17 00:00:00 2001
From: mephi42 <mephi42@gmail.com>
Date: Tue, 12 Mar 2019 07:02:56 +0100
Subject: [PATCH] Add basic USDT support for s390x (#2266)
Approach and code shamelessly borrowed from "422db709: Add basic USDT
support for powerpc64".
---
src/cc/usdt.h | 7 +++++
src/cc/usdt/usdt.cc | 2 ++
src/cc/usdt/usdt_args.cc | 53 ++++++++++++++++++++++++++++++++++++++
tests/cc/test_usdt_args.cc | 46 +++++++++++++++++++++++++++++++++
4 files changed, 108 insertions(+)
diff --git a/src/cc/usdt.h b/src/cc/usdt.h
index 6d89fd644..406cfd546 100644
--- a/src/cc/usdt.h
+++ b/src/cc/usdt.h
@@ -81,6 +81,7 @@ class Argument {
friend class ArgumentParser;
friend class ArgumentParser_aarch64;
friend class ArgumentParser_powerpc64;
+ friend class ArgumentParser_s390x;
friend class ArgumentParser_x64;
};
@@ -130,6 +131,12 @@ class ArgumentParser_powerpc64 : public ArgumentParser {
ArgumentParser_powerpc64(const char *arg) : ArgumentParser(arg) {}
};
+class ArgumentParser_s390x : public ArgumentParser {
+public:
+ bool parse(Argument *dest);
+ ArgumentParser_s390x(const char *arg) : ArgumentParser(arg) {}
+};
+
class ArgumentParser_x64 : public ArgumentParser {
private:
enum Register {
diff --git a/src/cc/usdt/usdt.cc b/src/cc/usdt/usdt.cc
index 0914fe3a5..c91faa016 100644
--- a/src/cc/usdt/usdt.cc
+++ b/src/cc/usdt/usdt.cc
@@ -40,6 +40,8 @@ Location::Location(uint64_t addr, const std::string &bin_path, const char *arg_f
ArgumentParser_aarch64 parser(arg_fmt);
#elif __powerpc64__
ArgumentParser_powerpc64 parser(arg_fmt);
+#elif __s390x__
+ ArgumentParser_s390x parser(arg_fmt);
#else
ArgumentParser_x64 parser(arg_fmt);
#endif
diff --git a/src/cc/usdt/usdt_args.cc b/src/cc/usdt/usdt_args.cc
index b27e515f4..3e2045575 100644
--- a/src/cc/usdt/usdt_args.cc
+++ b/src/cc/usdt/usdt_args.cc
@@ -285,6 +285,59 @@ bool ArgumentParser_powerpc64::parse(Argument *dest) {
return true;
}
+bool ArgumentParser_s390x::parse(Argument *dest) {
+ if (done())
+ return false;
+
+ bool matched;
+ std::cmatch matches;
+#define S390X_IMM "(-?[0-9]+)"
+ std::regex arg_n_regex("^" S390X_IMM "@");
+ // <imm>
+ std::regex arg_op_regex_imm("^" S390X_IMM "(?: +|$)");
+ // %r<N>
+#define S390X_REG "%r([0-9]|1[0-5])"
+ std::regex arg_op_regex_reg("^" S390X_REG "(?: +|$)");
+ // <disp>(%r<N>,%r<N>)
+ std::regex arg_op_regex_mem("^" S390X_IMM "?\\(" S390X_REG
+ "(?:," S390X_REG ")?\\)(?: +|$)");
+#undef S390X_IMM
+#undef S390X_REG
+
+ matched = std::regex_search(arg_ + cur_pos_, matches, arg_n_regex);
+ if (matched) {
+ dest->arg_size_ = stoi(matches.str(1));
+ cur_pos_ += matches.length(0);
+
+ if (std::regex_search(arg_ + cur_pos_, matches, arg_op_regex_imm)) {
+ dest->constant_ = stoi(matches.str(1));
+ } else if (std::regex_search(arg_ + cur_pos_, matches, arg_op_regex_reg)) {
+ dest->base_register_name_ = "gprs[" + matches.str(1) + "]";
+ } else if (std::regex_search(arg_ + cur_pos_, matches, arg_op_regex_mem)) {
+ if (matches.length(1) > 0) {
+ dest->deref_offset_ = stoi(matches.str(1));
+ }
+ dest->base_register_name_ = "gprs[" + matches.str(2) + "]";
+ if (matches.length(3) > 0) {
+ dest->index_register_name_ = "gprs[" + matches.str(3) + "]";
+ }
+ } else {
+ matched = false;
+ }
+ }
+
+ if (!matched) {
+ print_error(cur_pos_);
+ skip_until_whitespace_from(cur_pos_);
+ skip_whitespace_from(cur_pos_);
+ return false;
+ }
+
+ cur_pos_ += matches.length(0);
+ skip_whitespace_from(cur_pos_);
+ return true;
+}
+
ssize_t ArgumentParser_x64::parse_identifier(ssize_t pos,
optional<std::string> *result) {
if (isalpha(arg_[pos]) || arg_[pos] == '_') {
diff --git a/tests/cc/test_usdt_args.cc b/tests/cc/test_usdt_args.cc
index 3a96c5aac..db1f8c8e6 100644
--- a/tests/cc/test_usdt_args.cc
+++ b/tests/cc/test_usdt_args.cc
@@ -58,6 +58,8 @@ TEST_CASE("test usdt argument parsing", "[usdt]") {
USDT::ArgumentParser_aarch64 parser("4@[x32,200]");
#elif __powerpc64__
USDT::ArgumentParser_powerpc64 parser("4@-12(42)");
+#elif __s390x__
+ USDT::ArgumentParser_s390x parser("4@-12(%r42)");
#elif defined(__x86_64__)
USDT::ArgumentParser_x64 parser("4@i%ra+1r");
#endif
@@ -121,6 +123,50 @@ TEST_CASE("test usdt argument parsing", "[usdt]") {
verify_register(parser, 2, 1097);
verify_register(parser, 4, "gpr[30]", 108);
verify_register(parser, -2, "gpr[31]", -4);
+#elif __s390x__
+ USDT::ArgumentParser_s390x parser(
+ "-4@%r0 8@%r0 8@0 4@0(%r0) -2@0(%r0) "
+ "1@%r0 -2@%r3 -8@9 -1@0(%r4) -4@16(%r6) "
+ "2@%r7 4@%r11 4@-67 8@-16(%r15) 1@-52(%r11) "
+ "-8@%r4 -8@%r14 2@-11 -2@14(%r13) -8@-32(%r12) "
+ "4@%r5 2@%r11 -8@-693 -1@-23(%r10) 4@28(%r9) "
+ "-2@%r3 -4@%r8 2@1097 4@108(%r7) -2@-4(%r6)");
+
+ verify_register(parser, -4, "gprs[0]");
+ verify_register(parser, 8, "gprs[0]");
+ verify_register(parser, 8, 0);
+ verify_register(parser, 4, "gprs[0]", 0);
+ verify_register(parser, -2, "gprs[0]", 0);
+
+ verify_register(parser, 1, "gprs[0]");
+ verify_register(parser, -2, "gprs[3]");
+ verify_register(parser, -8, 9);
+ verify_register(parser, -1, "gprs[4]", 0);
+ verify_register(parser, -4, "gprs[6]", 16);
+
+ verify_register(parser, 2, "gprs[7]");
+ verify_register(parser, 4, "gprs[11]");
+ verify_register(parser, 4, -67);
+ verify_register(parser, 8, "gprs[15]", -16);
+ verify_register(parser, 1, "gprs[11]", -52);
+
+ verify_register(parser, -8, "gprs[4]");
+ verify_register(parser, -8, "gprs[14]");
+ verify_register(parser, 2, -11);
+ verify_register(parser, -2, "gprs[13]", 14);
+ verify_register(parser, -8, "gprs[12]", -32);
+
+ verify_register(parser, 4, "gprs[5]");
+ verify_register(parser, 2, "gprs[11]");
+ verify_register(parser, -8, -693);
+ verify_register(parser, -1, "gprs[10]", -23);
+ verify_register(parser, 4, "gprs[9]", 28);
+
+ verify_register(parser, -2, "gprs[3]");
+ verify_register(parser, -4, "gprs[8]");
+ verify_register(parser, 2, 1097);
+ verify_register(parser, 4, "gprs[7]", 108);
+ verify_register(parser, -2, "gprs[6]", -4);
#elif defined(__x86_64__)
USDT::ArgumentParser_x64 parser(
"-4@$0 8@$1234 %rdi %rax %rsi "

View File

@ -1,48 +0,0 @@
From fc245dfe9dabbd77e3adbf89a45aaab0cb1552fd Mon Sep 17 00:00:00 2001
From: Mark Drayton <mark@markdrayton.info>
Date: Wed, 19 Sep 2018 16:41:49 -0700
Subject: [PATCH] biolatency: Fix --disks bpf_probe_read() (#1980)
bpf_probe_read()'s third argument is no longer rewritten. Instead, use a
temporary variable (like #1973) to avoid a memory access error.
Before:
```
$ sudo biolatency -D 1
bpf: Failed to load program: Permission denied
0: (79) r1 = *(u64 *)(r1 +112)
1: (7b) *(u64 *)(r10 -8) = r1
[..]
R1 invalid mem access 'inv'
HINT: The invalid mem access 'inv' error can happen if you try to
dereference memory without first using bpf_probe_read() to copy it to
the BPF stack. Sometimes the bpf_probe_read is automatic by the bcc
rewriter, other times you'll need to be explicit.
```
After, works as expected.
---
tools/biolatency.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/biolatency.py b/tools/biolatency.py
index 49ee7cf..3879af1 100755
--- a/tools/biolatency.py
+++ b/tools/biolatency.py
@@ -99,8 +99,9 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
'BPF_HISTOGRAM(dist, disk_key_t);')
bpf_text = bpf_text.replace('STORE',
'disk_key_t key = {.slot = bpf_log2l(delta)}; ' +
- 'bpf_probe_read(&key.disk, sizeof(key.disk), ' +
- 'req->rq_disk->disk_name); dist.increment(key);')
+ 'void *__tmp = (void *)req->rq_disk->disk_name; ' +
+ 'bpf_probe_read(&key.disk, sizeof(key.disk), __tmp); ' +
+ 'dist.increment(key);')
else:
bpf_text = bpf_text.replace('STORAGE', 'BPF_HISTOGRAM(dist);')
bpf_text = bpf_text.replace('STORE',
--
2.19.2

View File

@ -1,153 +0,0 @@
From 415bd4e43b2c27e3999923c16f5ff39f9b1adcae Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Thu, 1 Nov 2018 06:18:14 +0100
Subject: [PATCH] covscan: fix miscellaneaous errors (#2003)
* Coverity #def53: COPY_PASTE_ERROR
* Coverity #def18: DC.STREAM_BUFFER. Double-check max length of dev
* Coverity #def44: MISSING_BREAK. This looks like it should be here
* Coverity #def67: STRING_NULL: potential OOB read if 0 bytes read.
* Coverity #def66: FORWARD_NULL: potential null ptr deref
* Coverity #def17: RESOURCE_LEAK: missing free()
* Dont free the result of dirname
dirname() may return pointers to statically allocated memory. Don't
free the pointer it returns.
---
src/cc/bcc_elf.c | 11 +++++++----
src/cc/bcc_proc.c | 4 ++--
src/cc/frontends/b/type_check.cc | 1 +
src/cc/frontends/p4/compiler/ebpfTable.py | 2 +-
src/cc/libbpf.c | 20 +++++++++++---------
5 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/cc/bcc_elf.c b/src/cc/bcc_elf.c
index c425db6..0c696bd 100644
--- a/src/cc/bcc_elf.c
+++ b/src/cc/bcc_elf.c
@@ -398,6 +398,7 @@ static int verify_checksum(const char *file, unsigned int crc) {
static char *find_debug_via_debuglink(Elf *e, const char *binpath,
int check_crc) {
char fullpath[PATH_MAX];
+ char *tmppath;
char *bindir = NULL;
char *res = NULL;
unsigned int crc;
@@ -406,8 +407,8 @@ static char *find_debug_via_debuglink(Elf *e, const char *binpath,
if (!find_debuglink(e, &name, &crc))
return NULL;
- bindir = strdup(binpath);
- bindir = dirname(bindir);
+ tmppath = strdup(binpath);
+ bindir = dirname(tmppath);
// Search for the file in 'binpath', but ignore the file we find if it
// matches the binary itself: the binary will always be probed later on,
@@ -434,9 +435,11 @@ static char *find_debug_via_debuglink(Elf *e, const char *binpath,
}
DONE:
- free(bindir);
- if (res && check_crc && !verify_checksum(res, crc))
+ free(tmppath);
+ if (res && check_crc && !verify_checksum(res, crc)) {
+ free(res);
return NULL;
+ }
return res;
}
diff --git a/src/cc/bcc_proc.c b/src/cc/bcc_proc.c
index d694eb9..f1c30c2 100644
--- a/src/cc/bcc_proc.c
+++ b/src/cc/bcc_proc.c
@@ -92,14 +92,14 @@ int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback,
if (!procmap)
return -1;
- char buf[PATH_MAX + 1], perm[5], dev[8];
+ char buf[PATH_MAX + 1], perm[5], dev[6];
char *name;
uint64_t begin, end, inode;
unsigned long long offset;
while (true) {
buf[0] = '\0';
// From fs/proc/task_mmu.c:show_map_vma
- if (fscanf(procmap, "%lx-%lx %s %llx %s %lu%[^\n]", &begin, &end, perm,
+ if (fscanf(procmap, "%lx-%lx %4s %llx %5s %lu%[^\n]", &begin, &end, perm,
&offset, dev, &inode, buf) != 7)
break;
diff --git a/src/cc/frontends/b/type_check.cc b/src/cc/frontends/b/type_check.cc
index 8d49de9..7c5b7ce 100644
--- a/src/cc/frontends/b/type_check.cc
+++ b/src/cc/frontends/b/type_check.cc
@@ -204,6 +204,7 @@ StatusTuple TypeCheck::visit_binop_expr_node(BinopExprNode *n) {
case Tok::TCGT:
case Tok::TCGE:
n->bit_width_ = 1;
+ break;
default:
n->bit_width_ = std::max(n->lhs_->bit_width_, n->rhs_->bit_width_);
}
diff --git a/src/cc/frontends/p4/compiler/ebpfTable.py b/src/cc/frontends/p4/compiler/ebpfTable.py
index eb1efd9..4b7e023 100644
--- a/src/cc/frontends/p4/compiler/ebpfTable.py
+++ b/src/cc/frontends/p4/compiler/ebpfTable.py
@@ -110,7 +110,7 @@ import ebpfAction
ebpfHeader = program.getInstance(instance.name)
assert isinstance(ebpfHeader, ebpfInstance.SimpleInstance)
basetype = ebpfHeader.type
- eInstance = program.getInstance(instance.base_name)
+ eInstance = program.getInstance(instance.name)
ebpfField = basetype.getField(fieldname)
assert isinstance(ebpfField, ebpfStructType.EbpfField)
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
index 8a7caec..5cf3554 100644
--- a/src/cc/libbpf.c
+++ b/src/cc/libbpf.c
@@ -521,14 +521,16 @@ int bpf_prog_load(enum bpf_prog_type prog_type, const char *name,
}
}
- if (strncmp(name, "kprobe__", 8) == 0)
- name_offset = 8;
- else if (strncmp(name, "tracepoint__", 12) == 0)
- name_offset = 12;
- else if (strncmp(name, "raw_tracepoint__", 16) == 0)
- name_offset = 16;
- memcpy(attr.prog_name, name + name_offset,
- min(name_len - name_offset, BPF_OBJ_NAME_LEN - 1));
+ if (name_len) {
+ if (strncmp(name, "kprobe__", 8) == 0)
+ name_offset = 8;
+ else if (strncmp(name, "tracepoint__", 12) == 0)
+ name_offset = 12;
+ else if (strncmp(name, "raw_tracepoint__", 16) == 0)
+ name_offset = 16;
+ memcpy(attr.prog_name, name + name_offset,
+ min(name_len - name_offset, BPF_OBJ_NAME_LEN - 1));
+ }
ret = syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
// BPF object name is not supported on older Kernels.
@@ -698,7 +700,7 @@ static int bpf_get_retprobe_bit(const char *event_type)
close(fd);
if (ret < 0 || ret >= sizeof(buf))
return -1;
- if (strlen(buf) < strlen("config:"))
+ if (strncmp(buf, "config:", strlen("config:")))
return -1;
errno = 0;
ret = (int)strtol(buf + strlen("config:"), NULL, 10);
--
2.17.2

View File

@ -1,28 +0,0 @@
From 1d2348027404307b6cd51c0c452207be27c64863 Mon Sep 17 00:00:00 2001
From: yonghong-song <ys114321@gmail.com>
Date: Thu, 11 Oct 2018 08:32:04 -0700
Subject: [PATCH] fix killsnoop.py srr/bytes type error (#2007)
Fix issue #2002
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/killsnoop.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/killsnoop.py b/tools/killsnoop.py
index 89ea5cd..d60c72e 100755
--- a/tools/killsnoop.py
+++ b/tools/killsnoop.py
@@ -139,7 +139,7 @@ print("%-9s %-6s %-16s %-4s %-6s %s" % (
if (args.failed and (event.ret >= 0)):
return
- printb(b"%-9s %-6d %-16s %-4d %-6d %d" % (strftime("%H:%M:%S"),
+ printb(b"%-9s %-6d %-16s %-4d %-6d %d" % (strftime("%H:%M:%S").encode('ascii'),
event.pid, event.comm, event.sig, event.tpid, event.ret))
# loop with callback to print_event
--
2.17.2

View File

@ -1,30 +0,0 @@
From b29ede1b052b5706581370ee98d2eccfbf700e77 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Wed, 12 Dec 2018 10:50:08 +0100
Subject: [PATCH] manpage: remove non-existent -p option from the biotop
manpage
The biotop manpage references a -p option that the tools doesn't have,
and AFAICT, never had. It's only referenced in the manpage option, not
in the synopsis, in "biotop -h" output not biotop_example.txt.
---
man/man8/biotop.8 | 3 ---
1 file changed, 3 deletions(-)
diff --git a/man/man8/biotop.8 b/man/man8/biotop.8
index 8b872aa..ed25521 100644
--- a/man/man8/biotop.8
+++ b/man/man8/biotop.8
@@ -30,9 +30,6 @@ Don't clear the screen.
\-r MAXROWS
Maximum number of rows to print. Default is 20.
.TP
-\-p PID
-Trace this PID only.
-.TP
interval
Interval between updates, seconds.
.TP
--
2.19.2

View File

@ -1,60 +0,0 @@
From 74e25edb248a62e437cdc1b4aaa8a0f44c112880 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Mon, 10 Dec 2018 08:54:50 +0100
Subject: [PATCH] tools: prepare block tools for the removing of legacy I/O
path (#2070)
Recent -next kernels don't have blk_start_request() function
anymore. It has been removed in a recent cleanup. bio* tools should be
able to handle the lack of this probe.
---
tools/biolatency.py | 3 ++-
tools/biosnoop.py | 3 ++-
tools/biotop.py | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/biolatency.py b/tools/biolatency.py
index 3879af1..68aa577 100755
--- a/tools/biolatency.py
+++ b/tools/biolatency.py
@@ -116,7 +116,8 @@ b = BPF(text=bpf_text)
if args.queued:
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_req_start")
else:
- b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
+ if BPF.get_kprobe_functions(b'blk_start_request'):
+ b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_account_io_completion",
fn_name="trace_req_completion")
diff --git a/tools/biosnoop.py b/tools/biosnoop.py
index 2b1e77d..d036c0b 100755
--- a/tools/biosnoop.py
+++ b/tools/biosnoop.py
@@ -122,7 +122,8 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
}
""", debug=0)
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
-b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
+if BPF.get_kprobe_functions(b'blk_start_request'):
+ b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_account_io_completion",
fn_name="trace_req_completion")
diff --git a/tools/biotop.py b/tools/biotop.py
index c6e1ca2..b2b5089 100755
--- a/tools/biotop.py
+++ b/tools/biotop.py
@@ -173,7 +173,8 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
b = BPF(text=bpf_text)
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
-b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
+if BPF.get_kprobe_functions(b'blk_start_request'):
+ b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
b.attach_kprobe(event="blk_account_io_completion",
fn_name="trace_req_completion")
--
2.19.2

View File

@ -1,65 +0,0 @@
From 215fc84bac0037ac5b2047940f97ecc97f0860b9 Mon Sep 17 00:00:00 2001
From: Marko Myllynen <myllynen@redhat.com>
Date: Fri, 5 Oct 2018 16:47:29 +0300
Subject: [PATCH 1/2] uflow: convert bytes to str
Python 3 fix, similar to commit 99d1468 and commit 4e4c9e0 for ucalls.
Closes #1996.
---
tools/lib/uflow.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/lib/uflow.py b/tools/lib/uflow.py
index fb306e31d..fdbcfc332 100755
--- a/tools/lib/uflow.py
+++ b/tools/lib/uflow.py
@@ -196,7 +196,9 @@ def print_event(cpu, data, size):
direction = "<- " if event.depth & (1 << 63) else "-> "
print("%-3d %-6d %-6d %-8.3f %-40s" % (cpu, event.pid >> 32,
event.pid & 0xFFFFFFFF, time.time() - start_ts,
- (" " * (depth - 1)) + direction + event.clazz + "." + event.method))
+ (" " * (depth - 1)) + direction + \
+ event.clazz.decode('utf-8', 'replace') + "." + \
+ event.method.decode('utf-8', 'replace')))
bpf["calls"].open_perf_buffer(print_event)
while 1:
From 1c7e2a8f3fb02d4516fccc410272324fff250be9 Mon Sep 17 00:00:00 2001
From: Marko Myllynen <myllynen@redhat.com>
Date: Fri, 5 Oct 2018 17:16:13 +0300
Subject: [PATCH 2/2] uflow: drop unused timestamp field
---
tools/lib/uflow.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tools/lib/uflow.py b/tools/lib/uflow.py
index fdbcfc332..f2a458d7b 100755
--- a/tools/lib/uflow.py
+++ b/tools/lib/uflow.py
@@ -49,7 +49,6 @@
struct call_t {
u64 depth; // first bit is direction (0 entry, 1 return)
u64 pid; // (tgid << 32) + pid from bpf_get_current...
- u64 timestamp; // ns
char clazz[80];
char method[80];
};
@@ -89,7 +88,6 @@
FILTER_METHOD
data.pid = bpf_get_current_pid_tgid();
- data.timestamp = bpf_ktime_get_ns();
depth = entry.lookup_or_init(&data.pid, &zero);
data.depth = DEPTH;
UPDATE
@@ -183,7 +181,6 @@ class CallEvent(ct.Structure):
_fields_ = [
("depth", ct.c_ulonglong),
("pid", ct.c_ulonglong),
- ("timestamp", ct.c_ulonglong),
("clazz", ct.c_char * 80),
("method", ct.c_char * 80)
]

View File

@ -4,22 +4,18 @@
%bcond_without llvm_static %bcond_without llvm_static
Name: bcc Name: bcc
Version: 0.7.0 Version: 0.8.0
Release: 5%{?dist} Release: 4%{?dist}
Summary: BPF Compiler Collection (BCC) Summary: BPF Compiler Collection (BCC)
License: ASL 2.0 License: ASL 2.0
URL: https://github.com/iovisor/bcc URL: https://github.com/iovisor/bcc
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: uflow-str-bytes.patch Patch0: %{name}-%{version}-usdt-s390x.patch
Patch1: fix-killsnoop.py-srr-bytes-type-error-2007.patch Patch1: %{name}-%{version}-print_log2_hist-check-and-skip-possible-paddings-215.patch
Patch2: Tools-fixes-2009.patch Patch2: %{name}-%{version}-tools-fix-some-python3-bytes-vs-strings-issues-2205.patch
Patch3: Bytes-string-encoding-2004.patch Patch3: %{name}-%{version}-fix-b.support_raw_tracepoint-for-5.0-kernel.patch
Patch4: covscan-fix-miscellaneaous-errors-2003.patch Patch4: %{name}-%{version}-tools-fix-runqslower-warning.patch
Patch5: tools-prepare-block-tools-for-the-removing-of-legacy.patch Patch5: %{name}-%{version}-Manpages-remove-unstable-statement.patch
Patch6: biolatency-Fix-disks-bpf_probe_read-1980.patch
Patch7: manpage-remove-non-existent-p-option-from-the-biotop.patch
# tests/cc doesn't compile on s390x, so disable it until we have a better fix
Patch10: Disable-tests-cc.patch
# Arches will be included as upstream support is added and dependencies are # Arches will be included as upstream support is added and dependencies are
# satisfied in the respective arches # satisfied in the respective arches
@ -102,20 +98,7 @@ Requires: kernel-devel
Command line tools for BPF Compiler Collection (BCC) Command line tools for BPF Compiler Collection (BCC)
%prep %prep
%setup %autosetup -p1
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%ifarch s390x
%patch10 -p1
%endif
%build %build
%cmake . \ %cmake . \
@ -192,9 +175,15 @@ done
%exclude %{_datadir}/%{name}/tools/old/ %exclude %{_datadir}/%{name}/tools/old/
# inject relies on BPF_KPROBE_OVERRIDE which is not set on RHEL 8 # inject relies on BPF_KPROBE_OVERRIDE which is not set on RHEL 8
%exclude %{_datadir}/%{name}/tools/inject %exclude %{_datadir}/%{name}/tools/inject
%exclude %{_datadir}/%{name}/tools/doc/inject_example.txt
%exclude %{_mandir}/man8/bcc-inject.8.gz
# Neither btrfs nor zfs are available on RHEL8 # Neither btrfs nor zfs are available on RHEL8
%exclude %{_datadir}/%{name}/tools/btrfs* %exclude %{_datadir}/%{name}/tools/btrfs*
%exclude %{_datadir}/%{name}/tools/doc/btrfs*
%exclude %{_mandir}/man8/bcc-btrfs*
%exclude %{_datadir}/%{name}/tools/zfs* %exclude %{_datadir}/%{name}/tools/zfs*
%exclude %{_datadir}/%{name}/tools/doc/zfs*
%exclude %{_mandir}/man8/bcc-zfs*
%{_mandir}/man8/* %{_mandir}/man8/*
%if %{with lua} %if %{with lua}
@ -204,6 +193,26 @@ done
%changelog %changelog
* Tue Aug 06 2019 Jerome Marchand <jmarchan@redhat.com> - 0.8.0-4
- remove unstable statement from the man pages
* Wed Jul 03 2019 Jerome Marchand <jmarchan@redhat.com> - 0.8.0-3
- fix b.support_raw_tracepoint
- fix runqslower warning
* Wed May 15 2019 Jerome Marchand <jmarchan@redhat.com> - 0.8.0-2
- Rebuild for llvm 8
* Thu Apr 11 2019 Jerome Marchand <jmarchan@redhat.com> - 0.8.0-1
- Rebase on bcc-8.0.0
- Replace the temporary s390x workaround by a proper fix
- Remove the doc of excluded tool from the package
- Fix print_log2_hist
- Fix yet a few other python3 bytes vs strings issues
* Mon Mar 25 2019 Jerome Marchand <jmarchan@redhat.com> - 0.7.0-6
- Add CI gating
* Thu Dec 13 2018 Jerome Marchand <jmarchan@redhat.com> - 0.7.0-5 * Thu Dec 13 2018 Jerome Marchand <jmarchan@redhat.com> - 0.7.0-5
- Fix biolatency -D - Fix biolatency -D
- Fix biotop manpage - Fix biotop manpage