4da2503d70
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
125 lines
2.7 KiB
Text
125 lines
2.7 KiB
Text
// ==============================================================
|
|
// libc_malloc_debug_backtrace.a
|
|
// ==============================================================
|
|
// Used by libmemunreachable
|
|
cc_library_static {
|
|
|
|
name: "libc_malloc_debug_backtrace",
|
|
|
|
srcs: [
|
|
"backtrace.cpp",
|
|
"MapData.cpp",
|
|
],
|
|
|
|
stl: "libc++_static",
|
|
|
|
whole_static_libs: [
|
|
"libasync_safe",
|
|
"libdemangle",
|
|
],
|
|
|
|
include_dirs: ["bionic/libc"],
|
|
|
|
export_include_dirs: ["."],
|
|
|
|
sanitize: {
|
|
never: true,
|
|
},
|
|
native_coverage: false,
|
|
|
|
// -Wno-error=format-zero-length needed for gcc to compile.
|
|
cflags: [
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-error=format-zero-length",
|
|
],
|
|
}
|
|
|
|
// ==============================================================
|
|
// libc_malloc_debug.so
|
|
// ==============================================================
|
|
cc_library {
|
|
name: "libc_malloc_debug",
|
|
|
|
srcs: [
|
|
"Config.cpp",
|
|
"DebugData.cpp",
|
|
"debug_disable.cpp",
|
|
"GuardData.cpp",
|
|
"malloc_debug.cpp",
|
|
"PointerData.cpp",
|
|
"RecordData.cpp",
|
|
],
|
|
|
|
stl: "libc++_static",
|
|
|
|
// Only need this for arm since libc++ uses its own unwind code that
|
|
// doesn't mix with the other default unwind code.
|
|
arch: {
|
|
arm: {
|
|
static_libs: ["libunwind_llvm"],
|
|
},
|
|
},
|
|
|
|
static_libs: [
|
|
"libasync_safe",
|
|
"libbase",
|
|
"libc_malloc_debug_backtrace",
|
|
],
|
|
|
|
multilib: {
|
|
lib32: {
|
|
version_script: "exported32.map",
|
|
},
|
|
lib64: {
|
|
version_script: "exported64.map",
|
|
},
|
|
},
|
|
allow_undefined_symbols: true,
|
|
include_dirs: ["bionic/libc"],
|
|
|
|
sanitize: {
|
|
never: true,
|
|
},
|
|
native_coverage: false,
|
|
|
|
// -Wno-error=format-zero-length needed for gcc to compile.
|
|
cflags: [
|
|
"-Wall",
|
|
"-Werror",
|
|
"-fno-stack-protector",
|
|
"-Wno-error=format-zero-length",
|
|
"-Wthread-safety",
|
|
],
|
|
}
|
|
|
|
// ==============================================================
|
|
// Unit Tests
|
|
// ==============================================================
|
|
cc_test {
|
|
name: "malloc_debug_unit_tests",
|
|
|
|
srcs: [
|
|
"tests/backtrace_fake.cpp",
|
|
"tests/log_fake.cpp",
|
|
"tests/libc_fake.cpp",
|
|
"tests/malloc_debug_config_tests.cpp",
|
|
"tests/malloc_debug_unit_tests.cpp",
|
|
],
|
|
|
|
whole_static_libs: ["libc_malloc_debug"],
|
|
|
|
local_include_dirs: ["tests"],
|
|
include_dirs: [
|
|
"bionic/libc",
|
|
"bionic/libc/async_safe/include",
|
|
],
|
|
|
|
shared_libs: ["libbase"],
|
|
|
|
cflags: [
|
|
"-Wall",
|
|
"-Werror",
|
|
"-Wno-error=format-zero-length",
|
|
],
|
|
}
|