1// ==============================================================
2// libc_malloc_debug_backtrace.a
3// ==============================================================
4// Used by libmemunreachable
5cc_library_static {
6    name: "libc_malloc_debug_backtrace",
7    vendor_available: true,
8
9    srcs: [
10        "backtrace.cpp",
11        "MapData.cpp",
12    ],
13
14    stl: "libc++_static",
15
16    whole_static_libs: [
17        "libbase",
18        "libasync_safe",
19    ],
20
21    include_dirs: ["bionic/libc"],
22
23    export_include_dirs: ["."],
24
25    sanitize: {
26        never: true,
27    },
28    native_coverage: false,
29
30    target: {
31        android: {
32            static_libs: ["libc++demangle"],
33        },
34    },
35
36    // -Wno-error=format-zero-length needed for gcc to compile.
37    cflags: [
38        "-Wall",
39        "-Werror",
40        "-Wno-error=format-zero-length",
41    ],
42
43    apex_available: [
44        "//apex_available:platform",
45        "com.android.runtime",
46    ],
47}
48
49// ==============================================================
50// libc_malloc_debug.so
51// ==============================================================
52cc_library {
53    name: "libc_malloc_debug",
54
55    srcs: [
56        "Config.cpp",
57        "DebugData.cpp",
58        "debug_disable.cpp",
59        "GuardData.cpp",
60        "malloc_debug.cpp",
61        "PointerData.cpp",
62        "RecordData.cpp",
63        "UnwindBacktrace.cpp",
64    ],
65
66    stl: "libc++_static",
67
68    static_libs: [
69        "libasync_safe",
70        "libbase",
71        "libc_malloc_debug_backtrace",
72    ],
73
74    shared_libs: [
75        "libunwindstack",
76    ],
77
78    multilib: {
79        lib32: {
80            version_script: "exported32.map",
81        },
82        lib64: {
83            version_script: "exported64.map",
84        },
85    },
86    allow_undefined_symbols: true,
87    include_dirs: ["bionic/libc"],
88
89    sanitize: {
90        never: true,
91    },
92    native_coverage: false,
93
94    // -Wno-error=format-zero-length needed for gcc to compile.
95    cflags: [
96        "-Wall",
97        "-Werror",
98        "-fno-stack-protector",
99        "-Wno-error=format-zero-length",
100        "-Wthread-safety",
101    ],
102
103    apex_available: [
104        "com.android.runtime",
105    ],
106    static: {
107        apex_available: [
108            "//apex_available:platform",
109        ],
110    },
111}
112
113// ==============================================================
114// Unit Tests
115// ==============================================================
116cc_test {
117    name: "malloc_debug_unit_tests",
118
119    srcs: [
120        "tests/backtrace_fake.cpp",
121        "tests/log_fake.cpp",
122        "tests/libc_fake.cpp",
123        "tests/malloc_debug_config_tests.cpp",
124        "tests/malloc_debug_unit_tests.cpp",
125    ],
126
127    local_include_dirs: ["tests"],
128    include_dirs: [
129        "bionic/libc",
130        "bionic/libc/async_safe/include",
131    ],
132
133    header_libs: [
134        "bionic_libc_platform_headers",
135    ],
136
137    static_libs: [
138        "libc_malloc_debug",
139        "libtinyxml2",
140    ],
141
142    shared_libs: [
143        "libbase",
144        "libunwindstack",
145    ],
146
147    cflags: [
148        "-Wall",
149        "-Werror",
150        "-Wno-error=format-zero-length",
151        "-O0",
152    ],
153}
154
155// ==============================================================
156// System Tests
157// ==============================================================
158cc_test {
159    name: "malloc_debug_system_tests",
160    isolated: true,
161
162    include_dirs: [
163        "bionic/libc",
164    ],
165
166    header_libs: [
167        "bionic_libc_platform_headers",
168    ],
169
170    srcs: [
171        "tests/malloc_debug_system_tests.cpp",
172    ],
173
174    shared_libs: [
175        "libbase",
176        "libbacktrace",
177        "liblog",
178        "libunwindstack",
179    ],
180
181    cflags: [
182        "-Wall",
183        "-Werror",
184        "-O0",
185    ],
186    test_suites: ["general-tests"],
187}
188