Skip to content

Commit

Permalink
tools: fix minor bugs
Browse files Browse the repository at this point in the history
* decodes bytes to str
* tools/funclatency: fix error at wrong pattern
  • Loading branch information
asd142513 committed Jul 8, 2022
1 parent ea3c885 commit f0dee60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tools/funccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def run(self):
if v.value == 0:
continue
print("%-36s %8d" %
(self.probe.trace_functions[k.value], v.value))
(self.probe.trace_functions[k.value].decode('utf-8', 'replace'), v.value))

if exiting:
print("Detaching...")
Expand Down
6 changes: 3 additions & 3 deletions tools/funclatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def bail(error):
library = libpath
pattern = parts[1]
else:
bail("unrecognized pattern format '%s'" % pattern)
bail("unrecognized pattern format '%s'" % args.pattern)

if not args.regexp:
pattern = pattern.replace('*', '.*')
Expand Down Expand Up @@ -367,9 +367,9 @@ def signal_ignore(signal, frame):
# output
def print_section(key):
if not library:
return BPF.sym(key[0], -1)
return BPF.sym(key[0], -1).decode('utf-8', 'replace')
else:
return "%s [%d]" % (BPF.sym(key[0], key[1]), key[1])
return "%s [%d]" % (BPF.sym(key[0], key[1]).decode('utf-8', 'replace'), key[1])

exiting = 0 if args.interval else 1
seconds = 0
Expand Down
8 changes: 4 additions & 4 deletions tools/offwaketime.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ def signal_ignore(signal, frame):
print(" [Missed User Stack] %d" % k.w_u_stack_id)
else:
for addr in waker_user_stack:
print(" %s" % b.sym(addr, k.w_tgid))
print(" %s" % b.sym(addr, k.w_tgid).decode('utf-8', 'replace'))
if not args.user_stacks_only:
if need_delimiter and k.w_u_stack_id > 0 and k.w_k_stack_id > 0:
print(" -")
if stack_id_err(k.w_k_stack_id):
print(" [Missed Kernel Stack]")
else:
for addr in waker_kernel_stack:
print(" %s" % b.ksym(addr))
print(" %s" % b.ksym(addr).decode('utf-8', 'replace'))

# print waker/wakee delimiter
print(" %-16s %s" % ("--", "--"))
Expand All @@ -406,15 +406,15 @@ def signal_ignore(signal, frame):
print(" [Missed Kernel Stack]")
else:
for addr in target_kernel_stack:
print(" %s" % b.ksym(addr))
print(" %s" % b.ksym(addr).decode('utf-8', 'replace'))
if not args.kernel_stacks_only:
if need_delimiter and k.t_u_stack_id > 0 and k.t_k_stack_id > 0:
print(" -")
if stack_id_err(k.t_u_stack_id):
print(" [Missed User Stack]")
else:
for addr in target_user_stack:
print(" %s" % b.sym(addr, k.t_tgid))
print(" %s" % b.sym(addr, k.t_tgid).decode('utf-8', 'replace'))
print(" %-16s %s %s" % ("target:", k.target.decode('utf-8', 'replace'), k.t_pid))
print(" %d\n" % v.value)

Expand Down

0 comments on commit f0dee60

Please sign in to comment.