blob: 408a0469639e570bd0433f98204b9a87d230c79d [file] [log] [blame]
Colin Crossbaa48992016-07-13 11:15:21 -07001// ==============================================================
2// libc_malloc_debug_backtrace.a
3// ==============================================================
4// Used by libmemunreachable
Bob Badouraa7d8352021-02-19 13:06:22 -08005package {
Aditya Choudharyd9d37c02024-02-02 13:57:12 +00006 default_team: "trendy_team_native_tools_libraries",
Bob Badouraa7d8352021-02-19 13:06:22 -08007 // See: http://go/android-license-faq
8 // A large-scale-change added 'default_applicable_licenses' to import
9 // all of the 'license_kinds' from "bionic_libc_license"
10 // to get the below license kinds:
11 // SPDX-license-identifier-Apache-2.0
12 // SPDX-license-identifier-BSD
13 default_applicable_licenses: ["bionic_libc_license"],
14}
15
Colin Crossbaa48992016-07-13 11:15:21 -070016cc_library_static {
Colin Crossbaa48992016-07-13 11:15:21 -070017 name: "libc_malloc_debug_backtrace",
Colin Crossb9667b52019-05-17 13:45:18 -070018 vendor_available: true,
Colin Crossbaa48992016-07-13 11:15:21 -070019
20 srcs: [
21 "backtrace.cpp",
22 "MapData.cpp",
23 ],
24
25 stl: "libc++_static",
26
Elliott Hughesd50a1de2018-02-05 17:30:57 -080027 whole_static_libs: [
Christopher Ferris93bdd6a2018-04-05 11:12:38 -070028 "libbase",
Elliott Hughesd50a1de2018-02-05 17:30:57 -080029 "libasync_safe",
Elliott Hughesd50a1de2018-02-05 17:30:57 -080030 ],
Colin Crossbaa48992016-07-13 11:15:21 -070031
32 include_dirs: ["bionic/libc"],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070033
Colin Crossbaa48992016-07-13 11:15:21 -070034 export_include_dirs: ["."],
35
36 sanitize: {
37 never: true,
38 },
39 native_coverage: false,
40
41 // -Wno-error=format-zero-length needed for gcc to compile.
42 cflags: [
43 "-Wall",
44 "-Werror",
45 "-Wno-error=format-zero-length",
46 ],
Jiyong Parke87e0dc2019-10-02 17:09:33 +090047
48 apex_available: [
49 "//apex_available:platform",
50 "com.android.runtime",
51 ],
Colin Crossbaa48992016-07-13 11:15:21 -070052}
53
54// ==============================================================
55// libc_malloc_debug.so
56// ==============================================================
57cc_library {
58 name: "libc_malloc_debug",
59
60 srcs: [
Colin Crossbaa48992016-07-13 11:15:21 -070061 "Config.cpp",
62 "DebugData.cpp",
63 "debug_disable.cpp",
Colin Crossbaa48992016-07-13 11:15:21 -070064 "GuardData.cpp",
Christopher Ferris5610d5a2023-11-14 15:04:50 -080065 "LogAllocatorStats.cpp",
Colin Crossbaa48992016-07-13 11:15:21 -070066 "malloc_debug.cpp",
Christopher Ferris4da25032018-03-07 13:38:48 -080067 "PointerData.cpp",
Colin Crossbaa48992016-07-13 11:15:21 -070068 "RecordData.cpp",
Christopher Ferrisb42e8b42022-05-09 14:00:47 -070069 "Unreachable.cpp",
Christopher Ferris93bdd6a2018-04-05 11:12:38 -070070 "UnwindBacktrace.cpp",
Colin Crossbaa48992016-07-13 11:15:21 -070071 ],
72
73 stl: "libc++_static",
74
Colin Crossbaa48992016-07-13 11:15:21 -070075 static_libs: [
Christopher Ferris7a3681e2017-04-24 17:48:32 -070076 "libasync_safe",
Colin Crossbaa48992016-07-13 11:15:21 -070077 "libbase",
78 "libc_malloc_debug_backtrace",
Christopher Ferrisb42e8b42022-05-09 14:00:47 -070079 "libmemunreachable",
Colin Crossbaa48992016-07-13 11:15:21 -070080 ],
81
Christopher Ferrise39602c2024-11-02 05:02:43 +000082 whole_static_libs: [
83 "libmemory_trace",
84 ],
85
Christopher Ferris93bdd6a2018-04-05 11:12:38 -070086 shared_libs: [
87 "libunwindstack",
88 ],
89
Colin Crossbaa48992016-07-13 11:15:21 -070090 multilib: {
91 lib32: {
92 version_script: "exported32.map",
93 },
94 lib64: {
95 version_script: "exported64.map",
96 },
97 },
98 allow_undefined_symbols: true,
99 include_dirs: ["bionic/libc"],
100
101 sanitize: {
102 never: true,
103 },
104 native_coverage: false,
105
106 // -Wno-error=format-zero-length needed for gcc to compile.
107 cflags: [
108 "-Wall",
109 "-Werror",
110 "-fno-stack-protector",
111 "-Wno-error=format-zero-length",
Christopher Ferris4da25032018-03-07 13:38:48 -0800112 "-Wthread-safety",
Colin Crossbaa48992016-07-13 11:15:21 -0700113 ],
Jiyong Parke87e0dc2019-10-02 17:09:33 +0900114
115 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +0900116 "com.android.runtime",
117 ],
Jiyong Parkf302cfb2019-10-07 15:52:21 +0900118 static: {
119 apex_available: [
120 "//apex_available:platform",
121 ],
122 },
Colin Crossbaa48992016-07-13 11:15:21 -0700123}
124
125// ==============================================================
126// Unit Tests
127// ==============================================================
Sharjeel Khan378db3c2025-03-27 08:14:06 +0000128cc_defaults {
129 name: "malloc_debug_tests",
Colin Crossbaa48992016-07-13 11:15:21 -0700130
131 srcs: [
Colin Crossbaa48992016-07-13 11:15:21 -0700132 "tests/log_fake.cpp",
133 "tests/libc_fake.cpp",
Colin Crossbaa48992016-07-13 11:15:21 -0700134 ],
135
Colin Crossbaa48992016-07-13 11:15:21 -0700136 local_include_dirs: ["tests"],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800137 include_dirs: [
138 "bionic/libc",
139 "bionic/libc/async_safe/include",
140 ],
Colin Crossbaa48992016-07-13 11:15:21 -0700141
Christopher Ferris2b0638e2019-09-11 19:05:29 -0700142 header_libs: [
143 "bionic_libc_platform_headers",
144 ],
145
Christopher Ferris93bdd6a2018-04-05 11:12:38 -0700146 shared_libs: [
147 "libbase",
148 "libunwindstack",
149 ],
Colin Crossbaa48992016-07-13 11:15:21 -0700150
Sharjeel Khan378db3c2025-03-27 08:14:06 +0000151 static_libs: [
152 "libc_malloc_debug",
153 ],
154
Colin Crossbaa48992016-07-13 11:15:21 -0700155 cflags: [
156 "-Wall",
157 "-Werror",
158 "-Wno-error=format-zero-length",
Christopher Ferris2e1a40a2018-06-13 10:46:34 -0700159 "-O0",
Colin Crossbaa48992016-07-13 11:15:21 -0700160 ],
Colin Crossbaa48992016-07-13 11:15:21 -0700161}
Christopher Ferris97b47472018-07-10 14:45:24 -0700162
Sharjeel Khan378db3c2025-03-27 08:14:06 +0000163cc_test {
164 name: "malloc_debug_system_record_unit_tests",
165 defaults: ["malloc_debug_tests"],
166 test_suites: ["device-tests"],
167 isolated: true,
168
169 srcs: [
170 "tests/malloc_debug_config_tests.cpp",
171 "tests/malloc_debug_record_data_tests.cpp",
172 ],
173}
174
175cc_test {
176 name: "malloc_debug_unit_tests",
177 defaults: ["malloc_debug_tests"],
178 test_suites: ["device-tests"],
179 isolated: true,
180
181 srcs: [
182 "tests/backtrace_fake.cpp",
183 "tests/malloc_debug_unit_tests.cpp",
184 ],
185
186 static_libs: [
187 "libtinyxml2",
188 ],
189
190 cflags: [
191 // This code uses malloc_usable_size(),
192 // and thus can't be built with _FORTIFY_SOURCE=3.
193 "-U_FORTIFY_SOURCE",
194 "-D_FORTIFY_SOURCE=2",
195 ],
196}
197
Christopher Ferris97b47472018-07-10 14:45:24 -0700198// ==============================================================
199// System Tests
200// ==============================================================
201cc_test {
202 name: "malloc_debug_system_tests",
Christopher Ferrise4619f72019-11-11 14:17:44 -0800203 isolated: true,
Christopher Ferris97b47472018-07-10 14:45:24 -0700204
Christopher Ferris2b0638e2019-09-11 19:05:29 -0700205 include_dirs: [
206 "bionic/libc",
Florian Mayerdca72292022-04-13 14:39:36 -0700207 "bionic", // For SKIP_WITH_HWASAN.
Christopher Ferris2b0638e2019-09-11 19:05:29 -0700208 ],
209
210 header_libs: [
211 "bionic_libc_platform_headers",
212 ],
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -0800213
Christopher Ferris97b47472018-07-10 14:45:24 -0700214 srcs: [
215 "tests/malloc_debug_system_tests.cpp",
216 ],
217
218 shared_libs: [
219 "libbase",
220 "liblog",
221 "libunwindstack",
222 ],
223
224 cflags: [
225 "-Wall",
226 "-Werror",
227 "-O0",
228 ],
Christopher Ferrise4619f72019-11-11 14:17:44 -0800229 test_suites: ["general-tests"],
Christopher Ferris852f9b02023-06-02 16:34:28 -0700230 test_config: "tests/AndroidTest.xml",
Christopher Ferris97b47472018-07-10 14:45:24 -0700231}