Skip to content

Commit

Permalink
Merge "Fix potential divide by zero."
Browse files Browse the repository at this point in the history
  • Loading branch information
cferris1000 authored and Gerrit Code Review committed Jun 9, 2017
2 parents 06d5da5 + f427655 commit 8d3f617
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/native_heapdump_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ def addStack(self, size, stack):

def display(indent, total, parent_total, node):
fd = addr2line(node.addr)
print "%9d %6.2f%% %6.2f%% %8d %s%s %s %s %s" % (node.size, 100*node.size/float(total), 100*node.size/float(parent_total), node.number, indent, node.addr, fd.library, fd.function, fd.location)
total_percent = 0
if total != 0:
total_percent = 100 * node.size / float(total)
parent_percent = 0
if parent_total != 0:
parent_percent = 100 * node.size / float(parent_total)
print "%9d %6.2f%% %6.2f%% %8d %s%s %s %s %s" % (node.size, total_percent, parent_percent, node.number, indent, node.addr, fd.library, fd.function, fd.location)
children = sorted(node.children.values(), key=lambda x: x.size, reverse=True)
for child in children:
display(indent + " ", total, node.size, child)
Expand Down

0 comments on commit 8d3f617

Please sign in to comment.