Skip to content

Commit

Permalink
decode-stacktrace.py: Added python3 compatability. (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaff authored Jul 14, 2017
1 parent 3afb5dd commit 32dcb95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/decode-stacktrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
import re

def usage():
print "Usage: \n\t%s <file.elf> [<error-stack.log>]" % sys.argv[0]
print("Usage: \n\t%s <file.elf> [<error-stack.log>]" % sys.argv[0])

def extractAddresses(data):
m = re.findall("(40[0-2](\d|[a-f]){5})", data)
if len(m) == 0:
return m

addresses = []
addresses = []
for item in m:
addresses.append(item[0])

return addresses

if __name__ == "__main__":
if len(sys.argv) not in range(2,4):
if len(sys.argv) not in list(range(2,4)):
usage()
sys.exit(1)

Expand All @@ -35,15 +35,15 @@ def extractAddresses(data):

if len(sys.argv) > 2:
data = open(sys.argv[2]).read()
pipe.communicate("\n".join(extractAddresses(data)))
pipe.communicate("\n".join(extractAddresses(data)).encode('ascii'))
else:
while True:
data = raw_input()
data = input()
addresses = extractAddresses(data)
if len(addresses) == 0:
continue

# print "[",addresses,"]"
# print ( "[",addresses,"]" )

line = "\r\n".join(addresses)+"\r\n"
# line = line.ljust(125," ")
Expand Down

0 comments on commit 32dcb95

Please sign in to comment.