summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2017-06-13 10:55:48 -0700
committerMathieu Chartier <mathieuc@google.com>2017-06-13 11:00:26 -0700
commit9ae5ff48955e182b3a4800897de14af4390b608c (patch)
treee1c0b4b00e278b32aa81f220cc573178f328f22d
parent9a882a68a15df45cc6e6cfeb7a9919c7381865d7 (diff)
downloadandroid_development-9ae5ff48955e182b3a4800897de14af4390b608c.tar.gz
android_development-9ae5ff48955e182b3a4800897de14af4390b608c.tar.bz2
android_development-9ae5ff48955e182b3a4800897de14af4390b608c.zip
Fix potential divide by zero in display_html
When using logwrapper, there is only a zygote heap. This caused a divide by zero for the app heap. Test: native_heapdump_viewer.py --html art/native_heap.txt > test.html Change-Id: I7defd94935d72ee9c4cb6e53d7a1a308a1030eb3
-rwxr-xr-xscripts/native_heapdump_viewer.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/native_heapdump_viewer.py b/scripts/native_heapdump_viewer.py
index d896ca6c1..0689a1d1d 100755
--- a/scripts/native_heapdump_viewer.py
+++ b/scripts/native_heapdump_viewer.py
@@ -244,7 +244,10 @@ def display_html(total, node, extra):
lib = fd.library
else:
lib = os.path.basename(fd.library)
- label = "%d %6.2f%% %6d %s%s %s %s" % (node.size, 100*node.size/float(total), node.number, extra, lib, fd.function, fd.location)
+ total_percent = 0
+ if total != 0:
+ total_percent = 100 * node.size / float(total)
+ label = "%d %6.2f%% %6d %s%s %s %s" % (node.size, total_percent, node.number, extra, lib, fd.function, fd.location)
label = label.replace("&", "&amp;")
label = label.replace("'", "&apos;")
label = label.replace('"', "&quot;")