iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

argdist.py: Fix verbose printing `b'bytes'`: decode `bytes` to `str` #5005

Closed bernhardkaindl closed 4 months ago

bernhardkaindl commented 4 months ago

tools/argdist.py: Fix verbose printing b'bytes': decode bytes to str

The uprobe and kprobe keys are bytes not str they need to be decoded on Python3:

print("open uprobes: %s" % list(self.bpf.uprobe_fds.keys()))
print("open kprobes: %s" % list(self.bpf.kprobe_fds.keys()))

This fixes the --verbose output from b['key1', b'key2'] to key1, key2, as the keys would be printed in Python2 originally:


- print("open uprobes: %s" % list(self.bpf.uprobe_fds.keys()))
- print("open kprobes: %s" % list(self.bpf.kprobe_fds.keys()))
+ print("open uprobes: [%s]" % b", ".join(self.bpf.uprobe_fds.keys()).decode())
+ print("open kprobes: [%s]" % b", ".join(self.bpf.kprobe_fds.keys()).decode())                                                            ```