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/stackcount.py b/tools/stackcount.py
index 8781879..5554014 100755
--- a/tools/stackcount.py
+++ b/tools/stackcount.py
@@ -339,7 +339,7 @@
                     # print folded stack output
                     user_stack = list(user_stack)
                     kernel_stack = list(kernel_stack)
-                    line = [k.name.decode()] + \
+                    line = [k.name.decode('utf-8', 'replace')] + \
                         [b.sym(addr, k.tgid) for addr in
                         reversed(user_stack)] + \
                         (self.need_delimiter and ["-"] or []) + \