Implement malloc_usable_size for debug impls.
- Implemented chk_memalign.
- Fixed a few bugs in leak_memalign.
- Implemented {leak,fill,check,qemu}_malloc_usable_size.
- Make malloc_usable_size update at run time.
- Add malloc_test.cpp as a small set of tests for the
malloc debug routines.
- Fix the qemu routines since it's been broken since it moved to C++.
- Add support for the %u format to the out_vformat in libc_logging.cpp.
This is used by the emulator code.
Tested using the bionic-unit-tests with setprop libc.debug.malloc
set to 1, 5, and 10.
I tested as much as possible on the emulator, but tracing doesn't appear
to be working properly.
Bug: 6143477
Merge change from internal master.
(cherry-picked from commit 3d594c2580)
Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb
This commit is contained in:
@@ -45,6 +45,11 @@
|
||||
|
||||
#define MAX_SIZE_T (~(size_t)0)
|
||||
|
||||
// This must match the alignment used by dlmalloc.
|
||||
#ifndef MALLOC_ALIGNMENT
|
||||
#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))
|
||||
#endif
|
||||
|
||||
// =============================================================================
|
||||
// Structures
|
||||
// =============================================================================
|
||||
@@ -71,12 +76,14 @@ typedef void (*MallocDebugFree)(void*);
|
||||
typedef void* (*MallocDebugCalloc)(size_t, size_t);
|
||||
typedef void* (*MallocDebugRealloc)(void*, size_t);
|
||||
typedef void* (*MallocDebugMemalign)(size_t, size_t);
|
||||
typedef size_t (*MallocDebugMallocUsableSize)(const void*);
|
||||
struct MallocDebug {
|
||||
MallocDebugMalloc malloc;
|
||||
MallocDebugFree free;
|
||||
MallocDebugCalloc calloc;
|
||||
MallocDebugRealloc realloc;
|
||||
MallocDebugMemalign memalign;
|
||||
MallocDebugMallocUsableSize malloc_usable_size;
|
||||
};
|
||||
|
||||
/* Malloc debugging initialization and finalization routines.
|
||||
|
||||
Reference in New Issue
Block a user