Fix potential divide by zero.
If there are no bytes attributable to APP, then you get a divide by zero. Modify the code to avoid doing a divide by zero. This can happen when using logwrapper to enable malloc debug. Test: Ran on a heap that had no APP bytest. Change-Id: I48f0666a92b591e4537c493c56b136e517a36c25
This commit is contained in:
@@ -225,7 +225,13 @@ app = AddrInfo("APP")
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user