Skip to content

Commit

Permalink
tools/stack_decode.py: Migrate to Python 3
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
  • Loading branch information
LukeShu committed Aug 27, 2019
1 parent 00ee946 commit 45f0f35
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tools/stack_decode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3

# Call addr2line as needed to resolve addresses in a stack trace. The addresses
# will be replaced if they can be resolved into file and line numbers. The
Expand All @@ -11,7 +11,6 @@
# In each case this script will add file and line information to any backtrace log
# lines found and echo back all non-Backtrace lines untouched.

from __future__ import print_function
import collections
import re
import subprocess
Expand Down Expand Up @@ -57,7 +56,7 @@ def decode_stacktrace_log(object_file, input_source):
#
# Returns list of result lines
def run_addr2line(obj_file, addr_to_resolve):
return subprocess.check_output(["addr2line", "-Cpie", obj_file, addr_to_resolve])
return subprocess.check_output(["addr2line", "-Cpie", obj_file, addr_to_resolve]).decode('utf-8')


# Because of how bazel compiles, addr2line reports file names that begin with
Expand All @@ -73,7 +72,7 @@ def trim_proc_cwd(file_and_line_number):
decode_stacktrace_log(sys.argv[2], sys.stdin)
sys.exit(0)
elif len(sys.argv) > 1:
rununder = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
rununder = subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
decode_stacktrace_log(sys.argv[1], rununder.stdout)
rununder.wait()
sys.exit(rununder.returncode) # Pass back test pass/fail result
Expand Down

0 comments on commit 45f0f35

Please sign in to comment.