simpleperf: fix binary_cache_builder.py.
Fix two exceptions caused by empty binary name.
Bug: none
Test: run python3 test.py.
Change-Id: If559a9c71a8af217fa8d127e634b85d9f6383ee4
diff --git a/simpleperf/scripts/binary_cache_builder.py b/simpleperf/scripts/binary_cache_builder.py
index 6151d16..50fcc54 100755
--- a/simpleperf/scripts/binary_cache_builder.py
+++ b/simpleperf/scripts/binary_cache_builder.py
@@ -154,7 +154,7 @@
"""pull binaries needed in perf.data to binary_cache."""
for binary in self.binaries:
build_id = self.binaries[binary]
- if binary[0] != '/' or binary == "//anon" or binary.startswith("/dev/"):
+ if not binary.startswith('/') or binary == "//anon" or binary.startswith("/dev/"):
# [kernel.kallsyms] or unknown, or something we can't find binary.
continue
binary_cache_file = binary[1:].replace('/', os.sep)
diff --git a/simpleperf/scripts/utils.py b/simpleperf/scripts/utils.py
index 20ea5c5..ea708c6 100644
--- a/simpleperf/scripts/utils.py
+++ b/simpleperf/scripts/utils.py
@@ -78,7 +78,9 @@
return str_value.encode('utf-8')
def bytes_to_str(bytes_value):
- if not is_python3() or not bytes_value:
+ if not bytes_value:
+ return ''
+ if not is_python3():
return bytes_value
return bytes_value.decode('utf-8')