Blame SOURCES/bcc-0.14.0-tools-fix-a-python-3-map-issue-in-dbstat-and-dbslowe.patch

94100b
From fc72365ad7a3fb66902b3e2d0b0fb712eb8735d3 Mon Sep 17 00:00:00 2001
94100b
From: Jerome Marchand <jmarchan@redhat.com>
94100b
Date: Wed, 10 Jun 2020 18:29:11 +0200
94100b
Subject: [PATCH 4/4] tools: fix a python 3 map issue in dbstat and dbslower
94100b
94100b
In python 3, map returns an iterator and not a list anymore. This
94100b
patch cast the map into a list. It fixes the following error:
94100b
94100b
$ /usr/share/bcc/tools/dbstat mysql
94100b
Traceback (most recent call last):
94100b
  File "/usr/share/bcc/tools/dbstat", line 95, in <module>
94100b
    bpf = BPF(text=program, usdt_contexts=usdts)
94100b
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 339, in __init__
94100b
    ctx_array = (ct.c_void_p * len(usdt_contexts))()
94100b
TypeError: object of type 'map' has no len()
94100b
---
94100b
 tools/dbslower.py | 2 +-
94100b
 tools/dbstat.py   | 2 +-
94100b
 2 files changed, 2 insertions(+), 2 deletions(-)
94100b
94100b
diff --git a/tools/dbslower.py b/tools/dbslower.py
94100b
index 2f1b6a8b..e2ee7ad0 100755
94100b
--- a/tools/dbslower.py
94100b
+++ b/tools/dbslower.py
94100b
@@ -188,7 +188,7 @@ int query_end(struct pt_regs *ctx) {
94100b
             args.pids = map(int, subprocess.check_output(
94100b
                                             "pidof postgres".split()).split())
94100b
 
94100b
-    usdts = map(lambda pid: USDT(pid=pid), args.pids)
94100b
+    usdts = list(map(lambda pid: USDT(pid=pid), args.pids))
94100b
     for usdt in usdts:
94100b
         usdt.enable_probe("query__start", "query_start")
94100b
         usdt.enable_probe("query__done", "query_end")
94100b
diff --git a/tools/dbstat.py b/tools/dbstat.py
94100b
index a89b0971..a7d301b1 100755
94100b
--- a/tools/dbstat.py
94100b
+++ b/tools/dbstat.py
94100b
@@ -83,7 +83,7 @@ program = program.replace("SCALE", str(1000 if args.microseconds else 1000000))
94100b
 program = program.replace("FILTER", "" if args.threshold == 0 else
94100b
         "if (delta / 1000000 < %d) { return 0; }" % args.threshold)
94100b
 
94100b
-usdts = map(lambda pid: USDT(pid=pid), args.pids)
94100b
+usdts = list(map(lambda pid: USDT(pid=pid), args.pids))
94100b
 for usdt in usdts:
94100b
     usdt.enable_probe("query__start", "probe_start")
94100b
     usdt.enable_probe("query__done", "probe_end")
94100b
-- 
94100b
2.25.4
94100b