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/capable.py b/tools/capable.py
index 3e032e9..efcff4d 100755
--- a/tools/capable.py
+++ b/tools/capable.py
@@ -148,8 +148,8 @@
     else:
         name = "?"
     print("%-9s %-6d %-6d %-16s %-4d %-20s %d" % (strftime("%H:%M:%S"),
-        event.uid, event.pid, event.comm.decode(), event.cap, name,
-        event.audit))
+        event.uid, event.pid, event.comm.decode('utf-8', 'replace'),
+        event.cap, name, event.audit))
 
 # loop with callback to print_event
 b["events"].open_perf_buffer(print_event)