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

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