aboutsummaryrefslogtreecommitdiff
path: root/libc/malloc_debug/MapData.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix handling of libs with a ro map and a rx map.Christopher Ferris2018-12-181-15/+60
| | | | | | | | | | | | | | When the linker was changed so that it put a read-only map and read-execute map, this code incorrectly computed the relative pc and offset. Modify to look for the actual start map in this case. Also, change the load_base name to load_bias. Bug: 120613266 Test: Dumped logcat while dumping backtraces. Change-Id: I6628694c5222ea34d63217af3d138707d4900004
* Refactor malloc debug.Christopher Ferris2018-04-021-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Changes - Refactor the code so that only guards require creating a special header for every pointer allocated. - Store only a single copy of every backtrace. This saves memory so that turning on the backtrace option doesn't result in 10X memory usage. - Added new option track_allocs that only verifies pointers are valid for free/malloc_usable_size/realloc. - Remove suffix from test names. - Add the TRACK_ALLOCS options to all guard options. - Add new option verify_pointers that is a lightweight way to verify pointers that are passed to allocation routines. - Do auto-formatting of the code. - Updated documentation for all of these changes. Bug: 74361929 Test: Ran unit tests. Test: Ran libmemunreachable unit tests. Test: Ran an app with backtrace enabled. Change-Id: I3246c48ae4f9811f64622d90d0a9b4d9d818702c
* Fix incorrect size of array.Christopher Ferris2016-02-191-1/+1
| | | | | | | | When using sscanf and "%4s", the array passed in must include space for a nul terminator. Bug: 26739265 Change-Id: I0140a6100ca370666ae61689087ba41b4914789d
* malloc_debug: reread /proc/pid/maps when entry is missingColin Cross2016-02-181-23/+27
| | | | | | Reread /proc/pid/maps on demand in case a new library has been loaded. Change-Id: Iac8109b3e6a07bf02c38300b21eecabf4bcd54df
* Add backtrace_string and export to libmemunreachableColin Cross2016-02-181-5/+0
| | | | | | | | Add backtrace_string to convert a malloc_debug backtrace to a string. Also move the backtrace functions to libc_malloc_debug_backtrace so that libmemunreachable can reuse them. Change-Id: I5ad67001c0b4d184903c762863a8588181d4873b
* Malloc debug rewrite.Christopher Ferris2016-01-251-0/+169
The major components of the rewrite: - Completely remove the qemu shared library code. Nobody was using it and it appears to have broken at some point. - Adds the ability to enable/disable different options independently. - Adds a new option that can enable the backtrace on alloc/free when a process gets a specific signal. - Adds a new way to enable malloc debug. If a special property is set, and the process has an environment variable set, then debug malloc will be enabled. This allows something that might be a derivative of app_process to be started with an environment variable being enabled. - get_malloc_leak_info() used to return one element for each pointer that had the exact same backtrace. The new version returns information for every one of the pointers with same backtrace. It turns out ddms already automatically coalesces these, so the old method simply hid the fact that there where multiple pointers with the same amount of backtrace. - Moved all of the malloc debug specific code into the library. Nothing related to the malloc debug data structures remains in libc. - Removed the calls to the debug malloc cleanup routine. Instead, I added an atexit call with the debug malloc cleanup routine. This gets around most problems related to the timing of doing the cleanup. The new properties and environment variables: libc.debug.malloc.options Set by option name (such as "backtrace"). Setting this to a bad value will cause a usage statement to be printed to the log. libc.debug.malloc.program Same as before. If this is set, then only the program named will be launched with malloc debug enabled. This is not a complete match, but if any part of the property is in the program name, malloc debug is enabled. libc.debug.malloc.env_enabled If set, then malloc debug is only enabled if the running process has the environment variable LIBC_DEBUG_MALLOC_ENABLE set. Bug: 19145921 Change-Id: I7b0e58cc85cc6d4118173fe1f8627a391b64c0d7