Use string type for comparison to PATH elements
authorJonathan Giddy <jongiddy@gmail.com>
Sun, 28 Feb 2021 16:47:37 +0000 (16:47 +0000)
committeryonghong-song <ys114321@gmail.com>
Tue, 2 Mar 2021 05:27:30 +0000 (21:27 -0800)
src/python/bcc/utils.py
tools/funccount.py

index 45205423383dcfffc2dcd0f0e4301a1234d000ab..782b27bbca396d071e37757eda559f7321b94124 100644 (file)
@@ -77,7 +77,7 @@ class ArgString(object):
         return self.s.encode(FILESYSTEMENCODING)
 
     def __str__(self):
-        return self.__bytes__()
+        return self.s
 
 def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
     log = file if hasattr(file, "write") else sys.stderr
@@ -140,8 +140,8 @@ static inline bool %s(char const *ignored, uintptr_t str) {
             probeid += 1
             expr = expr.replace("STRCMP", fname, 1)
         rdict = {
-            "expr" : expr,
-            "streq_functions" : streq_functions,
-            "probeid" : probeid
+            "expr": expr,
+            "streq_functions": streq_functions,
+            "probeid": probeid
         }
         return rdict
index ef7d9cefd86d23eabe883ddf1917c070cdd8c649..e54ba50a257e5e51f66ca52355121deffe986463 100755 (executable)
@@ -20,7 +20,6 @@ from __future__ import print_function
 from bcc import ArgString, BPF, USDT
 from time import sleep, strftime
 import argparse
-import os
 import re
 import signal
 import sys
@@ -74,7 +73,7 @@ class Probe(object):
             libpath = BPF.find_library(self.library)
             if libpath is None:
                 # This might be an executable (e.g. 'bash')
-                libpath = BPF.find_exe(self.library)
+                libpath = BPF.find_exe(str(self.library))
             if libpath is None or len(libpath) == 0:
                 raise Exception("unable to find library %s" % self.library)
             self.library = libpath
@@ -147,7 +146,7 @@ class Probe(object):
             for tracepoint in tracepoints:
                 text += self._add_function(template, tracepoint)
         elif self.type == b"u":
-            self.usdt = USDT(path=self.library, pid=self.pid)
+            self.usdt = USDT(path=str(self.library), pid=self.pid)
             matches = []
             for probe in self.usdt.enumerate_probes():
                 if not self.pid and (probe.bin_path != self.library):