addr2line may abort and "result" may be incomplete. This leads to
"index out of range" exceptions. Enclose this in a try & except block
and on exception, default to function:location = ---:---
Test: "python native_heapdump_viewer_tests.py" (after CL:780974)
passes.
BUG: 117306194
Change-Id: I4fd5c784949f279550aec95b68045df4a671da74
Fixed backward calculation of mapping offset.
Added logic to page align the data offset for uncompressed shared
objects. This fixes symbolization.
Bug: 111268230
Test: inspect native heap dump for the Camera app
Change-Id: If1af41e7265f017c1a691008309c8a002d5f588e
For zip files, try to open the file in the current directory and
insert the files as mappings. This enables the script to pick up
embedded .so files.
Added a check to look in current directory before the symbol dir.
Added --app-symbols option to specify the directory containing the
app APK and so files.
Test: manual
Bug: 111268230
(cherry picked from commit b284c20247)
Merged-In: Id1b1f13bac78911daa6a72c35ebfadfdc9c1700f
Change-Id: Ia8d3dd64f16e1d06d929b4023292cb98a438ea3e
This only includes a few tests to start with.
Bug: 62492960
Test: Ran new unit tests.
Test: Ran with all different options and verified it produces the same
Test: output as the previous script.
Change-Id: Iad29a5f04f49986139c92030a3259cae512859af
In Android P, the version field did not get incremented properly in
all places. So if a file with a v1.0 version is found, do a further check
to verify if the num field is really valid.
Test: Verified that a file with v1.0 gets checked and the valid num field
Test: is set correctly.
Test: Verified that a file with v1.1 automatically gets num field set to
Test: valid.
Change-Id: I7f828294c833e334cad76a866bbaa1d78ac02cfb
Merged-In: I7f828294c833e334cad76a866bbaa1d78ac02cfb
(cherry picked from commit b558fe4d53)
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
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
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
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