Implement native dump for "am dumpheap -n".

This adds the ability to generate a trivial heap dump on demand.  If
the appropriate system properties aren't set, the output file will
instead contain instructions for enabling them.

The data returned by get_malloc_leak_info() is processed and written
to the specified file.  The output looks something like:

 Android Native Heap Dump v1.0

 Total memory: 2981301
 Allocation records: 2152

 z 1  sz    65557  num    1  bt 8010dd78 afd12618 ...
 z 1  sz    52008  num    3  bt 8010dd78 afd12618 ...
 z 1  sz    24428  num    1  bt 8010dd78 8010de84 ...
 ...2149 more...
 END

(the "..." is actually the remaining entries in the stack backtrace;
I truncated it here)

"z" indicates whether the allocation was made pre- or post-zygote,
"sz" is the size allocated, and "num" is the number of allocations
made of that size with the specified backtrace.

Change-Id: I2d60f07444fce5f7178b3f51c928c8faa0b051bd
3 files changed