Commit Graph

4 Commits

Author SHA1 Message Date
Christopher Ferris
bede9f3b3c Handle num fields that aren't one.
The new version of malloc debug supports using a num field that is more
than one. Modify the parser to handle this case.

Bug: 74361929

Test: Ran on a file that contained non-one numbers and verified the output.
Change-Id: I158922e51ce99afff88f20a80df414d653f95e65
2018-05-22 19:02:41 -07:00
Mathieu Chartier
9ae5ff4895 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
2017-06-13 11:00:26 -07:00
Christopher Ferris
f427655e47 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
2017-05-24 17:27:27 -07:00
Richard Uhler
a178732bcf Script to view native allocations prettily.
Usage:
1. Collect a native heap dump from the device. For example:
  $ adb shell stop
  $ adb shell setprop libc.debug.malloc.program app_process
  $ adb shell setprop libc.debug.malloc.options backtrace=64
  $ adb shell start
  (launch and use app)
  $ adb shell am dumpheap -n <pid> /data/local/tmp/native_heap.txt
  $ adb pull /data/local/tmp/native_heap.txt

2. Run the viewer:
$ python native_heapdump_viewer.py [options] native_heap.txt
  [--verbose]: verbose output
  [--html]: html output
  [--symbols SYMBOL_DIR]: SYMBOL_DIR is the directory containing the
  .so files with symbols. Defaults to $ANDROID_PRODUCT_OUT/symbols

This outputs a file with lines of the form:
5831776  29.09% 100.00%    10532     71b07bc0b0 /system/lib64/libandroid_runtime.so Typeface_createFromArray frameworks/base/core/jni/android/graphics/Typeface.cpp:68

5831776 is the total number of bytes allocated at this stack frame, which
is 29.09% of the total number of bytes allocated and 100.00% of the parent
frame's bytes allocated. 10532 is the total number of allocations at this
stack frame. 71b07bc0b0 is the address of the stack frame.

For generating interactive HTML output, use:
python native_heapdump_viewer.py --html [options] native_heap.txt > allocations.html
Then open allocations.html in a browser. Clicking on nodes will
expand the tree.

Test: Try script on an app following usage instructions.

Bug: 36457259
Change-Id: I18dfe9a00fc1d3e82673dbfb4b5be3dc10480cec
2017-05-23 10:23:29 -07:00