Bytes/string encoding (#2004)
* tools: uses 'replace' error handler by default in decode()
Tools might encouter characters from non utf-8 charset (e.g. a file
name). When this happen, it's better to replace the unexpected
character by a question mark than crash the tool when all we do is
to print the string.
* tools: fix a bytes/string issue in attach_perf_event()
diff --git a/tools/trace.py b/tools/trace.py
index 16e9b6b..2233305 100755
--- a/tools/trace.py
+++ b/tools/trace.py
@@ -558,7 +558,8 @@
if Probe.print_cpu:
print("%-3s " % event.cpu, end="")
print("%-7d %-7d %-15s %-16s %s" %
- (event.tgid, event.pid, event.comm.decode(),
+ (event.tgid, event.pid,
+ event.comm.decode('utf-8', 'replace'),
self._display_function(), msg))
if self.kernel_stack: