blob: 0ff047f9e644e1474f6fdc2a5970d16b9f35184c [file] [log] [blame]
Bob Badourd69ad692021-02-16 19:02:14 -08001package {
Elliott Hughes813fd6d2021-06-25 14:42:51 -07002 default_applicable_licenses: ["Android-Apache-2.0"],
Bob Badourd69ad692021-02-16 19:02:14 -08003}
4
Josh Gaocbe70cb2016-10-18 18:17:52 -07005cc_defaults {
6 name: "debuggerd_defaults",
7 cflags: [
8 "-Wall",
9 "-Wextra",
Josh Gaoc7fe0602017-03-13 14:13:29 -070010 "-Werror",
Kalesh Singha9ea7e52021-06-17 15:49:50 -040011 "-Wno-gcc-compat",
Josh Gao2b2ae0c2017-08-21 14:31:17 -070012 "-Wno-unused-argument",
13 "-Wno-unused-function",
Josh Gaocbe70cb2016-10-18 18:17:52 -070014 "-Wno-nullability-completeness",
15 "-Os",
Yabin Cuie90a9442021-08-11 13:21:11 -070016 "-fno-finite-loops",
Josh Gaocbe70cb2016-10-18 18:17:52 -070017 ],
18
19 local_include_dirs: ["include"],
20}
21
Narayan Kamatha73df602017-05-24 15:07:25 +010022cc_library_headers {
23 name: "libdebuggerd_common_headers",
Elliott Hughesdc699a22018-02-16 17:58:14 -080024 export_include_dirs: ["common/include"],
Jiyong Parka0e75042018-05-24 14:11:00 +090025 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070026 vendor_ramdisk_available: true,
Narayan Kamatha73df602017-05-24 15:07:25 +010027}
28
Narayan Kamath2d377cd2017-05-10 10:58:59 +010029cc_library_shared {
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080030 name: "libtombstoned_client",
31 defaults: ["debuggerd_defaults"],
32 srcs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010033 "tombstoned/tombstoned_client.cpp",
34 "util.cpp",
35 ],
36
Narayan Kamatha73df602017-05-24 15:07:25 +010037 header_libs: ["libdebuggerd_common_headers"],
38
Narayan Kamath2d377cd2017-05-10 10:58:59 +010039 static_libs: [
Narayan Kamatha73df602017-05-24 15:07:25 +010040 "libasync_safe",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010041 ],
42
43 shared_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010044 "libbase",
Narayan Kamatha73df602017-05-24 15:07:25 +010045 "libcutils",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010046 ],
47
Narayan Kamatha73df602017-05-24 15:07:25 +010048 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080049 export_include_dirs: ["tombstoned/include"],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010050}
51
Josh Gao9da1f512018-08-06 15:38:29 -070052// Utility library to talk to tombstoned and get an output fd.
Narayan Kamath2d377cd2017-05-10 10:58:59 +010053cc_library_static {
54 name: "libtombstoned_client_static",
55 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +090056 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070057 vendor_ramdisk_available: true,
Narayan Kamath2d377cd2017-05-10 10:58:59 +010058 srcs: [
59 "tombstoned/tombstoned_client.cpp",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080060 "util.cpp",
61 ],
62
Narayan Kamatha73df602017-05-24 15:07:25 +010063 header_libs: ["libdebuggerd_common_headers"],
64
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080065 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070066 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080067 "libcutils",
68 "libbase",
69 ],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010070
Narayan Kamatha73df602017-05-24 15:07:25 +010071 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080072 export_include_dirs: ["tombstoned/include"],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080073}
74
75// Core implementation, linked into libdebuggerd_handler and the dynamic linker.
Josh Gao9c02dc52016-06-15 17:29:00 -070076cc_library_static {
Josh Gaoe73c9322017-02-08 16:06:26 -080077 name: "libdebuggerd_handler_core",
Josh Gaocbe70cb2016-10-18 18:17:52 -070078 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +090079 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070080 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -070081 srcs: ["handler/debuggerd_handler.cpp"],
Josh Gao9c02dc52016-06-15 17:29:00 -070082
Josh Gaofdf832d2017-08-25 18:00:18 -070083 header_libs: [
84 "libbase_headers",
85 "libdebuggerd_common_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -080086 "bionic_libc_platform_headers",
Josh Gaofdf832d2017-08-25 18:00:18 -070087 ],
Narayan Kamatha73df602017-05-24 15:07:25 +010088
Josh Gaoe73c9322017-02-08 16:06:26 -080089 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070090 "libasync_safe",
Josh Gao2b2ae0c2017-08-21 14:31:17 -070091 "libcutils",
Josh Gaoe73c9322017-02-08 16:06:26 -080092 "libdebuggerd",
93 ],
94
Narayan Kamatha73df602017-05-24 15:07:25 +010095 export_header_lib_headers: ["libdebuggerd_common_headers"],
Josh Gaoe73c9322017-02-08 16:06:26 -080096 export_include_dirs: ["include"],
97}
98
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080099// Implementation with a no-op fallback.
Josh Gaoe73c9322017-02-08 16:06:26 -0800100cc_library_static {
101 name: "libdebuggerd_handler",
102 defaults: ["debuggerd_defaults"],
103 srcs: ["handler/debuggerd_fallback_nop.cpp"],
104
Josh Gaoa48b41b2019-12-13 14:11:04 -0800105 header_libs: ["bionic_libc_platform_headers"],
106 export_header_lib_headers: ["bionic_libc_platform_headers"],
107
Josh Gaoe73c9322017-02-08 16:06:26 -0800108 whole_static_libs: [
109 "libdebuggerd_handler_core",
110 ],
111
112 export_include_dirs: ["include"],
113}
114
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100115// Fallback implementation, for use in the Bionic linker only.
Josh Gaoe73c9322017-02-08 16:06:26 -0800116cc_library_static {
117 name: "libdebuggerd_handler_fallback",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100118 visibility: ["//bionic/linker"],
119 apex_available: [
120 "com.android.runtime",
121 "//apex_available:platform",
122 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800123 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +0900124 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700125 vendor_ramdisk_available: true,
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800126 srcs: [
127 "handler/debuggerd_fallback.cpp",
128 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800129
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800130 whole_static_libs: [
131 "libdebuggerd_handler_core",
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100132 "libtombstoned_client_static",
Christopher Ferrisac225782017-04-25 11:23:10 -0700133 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800134 "libbase",
Josh Gaoe73c9322017-02-08 16:06:26 -0800135 "libdebuggerd",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100136 "libunwindstack_no_dex",
Josh Gaoe73c9322017-02-08 16:06:26 -0800137 "liblzma",
138 "libcutils",
139 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800140
141 header_libs: ["bionic_libc_platform_headers"],
142 export_header_lib_headers: ["bionic_libc_platform_headers"],
143
Josh Gaocbe70cb2016-10-18 18:17:52 -0700144 export_include_dirs: ["include"],
145}
146
147cc_library {
148 name: "libdebuggerd_client",
149 defaults: ["debuggerd_defaults"],
150 srcs: [
151 "client/debuggerd_client.cpp",
152 "util.cpp",
153 ],
154
155 shared_libs: [
156 "libbase",
157 "libcutils",
Josh Gao4175cee2019-01-04 13:57:09 -0800158 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700159 ],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800160
Josh Gaoa48b41b2019-12-13 14:11:04 -0800161 header_libs: [
162 "libdebuggerd_common_headers",
163 "bionic_libc_platform_headers",
164 ],
165 export_header_lib_headers: [
166 "libdebuggerd_common_headers",
167 "bionic_libc_platform_headers",
168 ],
169
Josh Gaocbe70cb2016-10-18 18:17:52 -0700170 export_include_dirs: ["include"],
171}
172
Josh Gaoe73c9322017-02-08 16:06:26 -0800173cc_library_static {
Josh Gaocbe70cb2016-10-18 18:17:52 -0700174 name: "libdebuggerd",
175 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900176 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700177 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700178
179 srcs: [
180 "libdebuggerd/backtrace.cpp",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800181 "libdebuggerd/gwp_asan.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700182 "libdebuggerd/open_files_list.cpp",
183 "libdebuggerd/tombstone.cpp",
Josh Gao76e1e302021-01-26 15:53:11 -0800184 "libdebuggerd/tombstone_proto.cpp",
185 "libdebuggerd/tombstone_proto_to_text.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700186 "libdebuggerd/utility.cpp",
187 ],
188
Josh Gaocbe70cb2016-10-18 18:17:52 -0700189 local_include_dirs: ["libdebuggerd/include"],
190 export_include_dirs: ["libdebuggerd/include"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700191
Peter Collingbournef8622522020-04-07 14:07:32 -0700192 include_dirs: [
193 // Needed for private/bionic_fdsan.h
194 "bionic/libc",
Peter Collingbournef8622522020-04-07 14:07:32 -0700195 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800196 header_libs: [
197 "bionic_libc_platform_headers",
198 "gwp_asan_headers",
199 ],
Josh Gaoce841d92018-08-06 18:26:42 -0700200
Josh Gaoe73c9322017-02-08 16:06:26 -0800201 static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100202 "libdexfile_support", // libunwindstack dependency
Christopher Ferris9a8c8552017-08-11 15:29:19 -0700203 "libunwindstack",
Josh Gaoe73c9322017-02-08 16:06:26 -0800204 "liblzma",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700205 "libbase",
206 "libcutils",
207 "liblog",
208 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100209 runtime_libs: [
210 "libdexfile", // libdexfile_support dependency
211 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800212
Peter Collingbournef8622522020-04-07 14:07:32 -0700213 whole_static_libs: [
Josh Gao618cea32021-01-26 17:45:43 -0800214 "libasync_safe",
Peter Collingbournef8622522020-04-07 14:07:32 -0700215 "gwp_asan_crash_handler",
Josh Gao76e1e302021-01-26 15:53:11 -0800216 "libtombstone_proto",
Josh Gaodbb83de2021-03-01 23:13:13 -0800217 "libprocinfo",
Josh Gao76e1e302021-01-26 15:53:11 -0800218 "libprotobuf-cpp-lite",
Peter Collingbournef8622522020-04-07 14:07:32 -0700219 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800220
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000221 target: {
222 recovery: {
223 exclude_static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100224 "libdexfile_support",
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000225 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100226 exclude_runtime_libs: [
227 "libdexfile",
228 ],
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000229 },
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700230 vendor_ramdisk: {
231 exclude_static_libs: [
232 "libdexfile_support",
233 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100234 exclude_runtime_libs: [
235 "libdexfile",
236 ],
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700237 },
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000238 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700239
240 product_variables: {
241 debuggable: {
242 cflags: ["-DROOT_POSSIBLE"],
243 },
Christopher Ferris7aad2562021-09-24 00:06:38 -0700244
245 malloc_not_svelte: {
246 cflags: ["-DUSE_SCUDO"],
247 whole_static_libs: ["libscudo"],
248 srcs: ["libdebuggerd/scudo.cpp"],
249 header_libs: ["scudo_headers"],
250 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700251 },
Josh Gaocbe70cb2016-10-18 18:17:52 -0700252}
253
Josh Gao76e1e302021-01-26 15:53:11 -0800254cc_binary {
255 name: "pbtombstone",
256 defaults: ["debuggerd_defaults"],
257 srcs: ["pbtombstone.cpp"],
258 static_libs: [
259 "libbase",
260 "libdebuggerd",
261 "liblog",
262 "libprotobuf-cpp-lite",
263 "libtombstone_proto",
264 "libunwindstack",
265 ],
266}
267
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700268cc_test_library {
269 name: "libcrash_test",
270 defaults: ["debuggerd_defaults"],
271 srcs: ["crash_test.cpp"],
272}
273
Josh Gaocbe70cb2016-10-18 18:17:52 -0700274cc_test {
275 name: "debuggerd_test",
276 defaults: ["debuggerd_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700277 require_root: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700278
279 cflags: ["-Wno-missing-field-initializers"],
280 srcs: [
281 "libdebuggerd/test/dump_memory_test.cpp",
282 "libdebuggerd/test/elf_fake.cpp",
283 "libdebuggerd/test/log_fake.cpp",
284 "libdebuggerd/test/open_files_list_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700285 "libdebuggerd/test/tombstone_test.cpp",
286 ],
287
288 target: {
289 android: {
290 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700291 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700292 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700293 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800294 static_libs: [
295 "libasync_safe",
296 "libtombstoned_client_static",
297 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700298 },
299 },
300
301 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700302 "libbase",
303 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700304 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100305 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800306 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000307 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700308 ],
309
310 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700311 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800312 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700313 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700314 ],
315
Josh Gaoa48b41b2019-12-13 14:11:04 -0800316 header_libs: [
317 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800318 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800319 ],
320
Josh Gaocbe70cb2016-10-18 18:17:52 -0700321 local_include_dirs: [
322 "libdebuggerd",
323 ],
324
325 compile_multilib: "both",
326 multilib: {
327 lib32: {
328 stem: "debuggerd_test32",
329 },
330 lib64: {
331 stem: "debuggerd_test64",
332 },
333 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700334
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700335 data: [
336 ":libcrash_test",
337 ],
338
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700339 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700340}
341
Josh Gaoa42314e2017-12-19 15:08:19 -0800342cc_benchmark {
343 name: "debuggerd_benchmark",
344 defaults: ["debuggerd_defaults"],
345 srcs: ["debuggerd_benchmark.cpp"],
346 shared_libs: [
347 "libbase",
348 "libdebuggerd_client",
349 ],
350}
351
Josh Gaocbe70cb2016-10-18 18:17:52 -0700352cc_binary {
353 name: "crash_dump",
354 srcs: [
355 "crash_dump.cpp",
356 "util.cpp",
357 ],
358 defaults: ["debuggerd_defaults"],
359
360 compile_multilib: "both",
361 multilib: {
362 lib32: {
363 suffix: "32",
364 },
365 lib64: {
366 suffix: "64",
367 },
368 },
369
Josh Gaoa48b41b2019-12-13 14:11:04 -0800370 header_libs: [
371 "bionic_libc_platform_headers",
372 ],
373
Josh Gaoe73c9322017-02-08 16:06:26 -0800374 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100375 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800376 "libdebuggerd",
377 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800378
379 "libtombstone_proto",
380 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800381 ],
382
Josh Gaocbe70cb2016-10-18 18:17:52 -0700383 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700384 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700385 "liblog",
386 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700387 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700388 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700389
390 apex_available: [
391 "com.android.runtime",
392 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700393}
394
395cc_binary {
396 name: "debuggerd",
397 srcs: [
398 "debuggerd.cpp",
399 ],
400 defaults: ["debuggerd_defaults"],
401
402 shared_libs: [
403 "libbase",
404 "libdebuggerd_client",
405 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700406 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700407 ],
408
409 local_include_dirs: ["include"],
410}
411
412cc_binary {
413 name: "tombstoned",
414 srcs: [
415 "util.cpp",
416 "tombstoned/intercept_manager.cpp",
417 "tombstoned/tombstoned.cpp",
418 ],
419 defaults: ["debuggerd_defaults"],
420
Josh Gaoa48b41b2019-12-13 14:11:04 -0800421 header_libs: [
422 "bionic_libc_platform_headers",
423 "libdebuggerd_common_headers"
424 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100425
Josh Gaocbe70cb2016-10-18 18:17:52 -0700426 static_libs: [
427 "libbase",
428 "libcutils",
429 "libevent",
430 "liblog",
431 ],
432
Elliott Hughesdc699a22018-02-16 17:58:14 -0800433 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700434}
Ray Essickbd3ba782020-01-21 15:21:08 -0800435
436prebuilt_etc {
437 name: "crash_dump.policy",
438 sub_dir: "seccomp_policy",
439 filename_from_src: true,
440 arch: {
441 arm: {
442 src: "seccomp_policy/crash_dump.arm.policy",
443 },
444 arm64: {
445 src: "seccomp_policy/crash_dump.arm64.policy",
446 },
447 x86: {
448 src: "seccomp_policy/crash_dump.x86.policy",
449 },
450 x86_64: {
451 src: "seccomp_policy/crash_dump.x86_64.policy",
452 },
453 },
454 required: [
455 "crash_dump.policy_other",
456 ],
457}
458
459
460// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
461// or at least that is the intention so that we get both of them populated
462prebuilt_etc {
463 name: "crash_dump.policy_other",
464 sub_dir: "seccomp_policy",
465 filename_from_src: true,
466 arch: {
467 arm: {
468 src: "seccomp_policy/crash_dump.arm64.policy",
469 },
470 arm64: {
471 src: "seccomp_policy/crash_dump.arm.policy",
472 },
473 x86: {
474 src: "seccomp_policy/crash_dump.x86_64.policy",
475 },
476 x86_64: {
477 src: "seccomp_policy/crash_dump.x86.policy",
478 },
479 },
480}