Skip to content

Commit

Permalink
Use string type for comparison to PATH elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jongiddy authored and yonghong-song committed Mar 2, 2021
1 parent 1be322c commit 75f20a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/python/bcc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __bytes__(self):
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
Expand Down Expand Up @@ -140,8 +140,8 @@ def rewrite_expr(expr, bin_cmp, is_user, probe_user_list, streq_functions,
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
5 changes: 2 additions & 3 deletions tools/funccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from bcc import ArgString, BPF, USDT
from time import sleep, strftime
import argparse
import os
import re
import signal
import sys
Expand Down Expand Up @@ -74,7 +73,7 @@ def __init__(self, pattern, use_regex=False, pid=None, cpu=None):
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
Expand Down Expand Up @@ -147,7 +146,7 @@ def _generate_functions(self, template):
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):
Expand Down

0 comments on commit 75f20a1

Please sign in to comment.