blob: 8555b3dae091df3e67b9e41846e96ad108d4ccbc [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",
Josh Gao2b2ae0c2017-08-21 14:31:17 -070011 "-Wno-unused-argument",
12 "-Wno-unused-function",
Josh Gaocbe70cb2016-10-18 18:17:52 -070013 "-Wno-nullability-completeness",
14 "-Os",
15 ],
16
17 local_include_dirs: ["include"],
18}
19
Narayan Kamatha73df602017-05-24 15:07:25 +010020cc_library_headers {
21 name: "libdebuggerd_common_headers",
Elliott Hughesdc699a22018-02-16 17:58:14 -080022 export_include_dirs: ["common/include"],
Jiyong Parka0e75042018-05-24 14:11:00 +090023 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070024 vendor_ramdisk_available: true,
Narayan Kamatha73df602017-05-24 15:07:25 +010025}
26
Narayan Kamath2d377cd2017-05-10 10:58:59 +010027cc_library_shared {
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080028 name: "libtombstoned_client",
29 defaults: ["debuggerd_defaults"],
30 srcs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010031 "tombstoned/tombstoned_client.cpp",
32 "util.cpp",
33 ],
34
Narayan Kamatha73df602017-05-24 15:07:25 +010035 header_libs: ["libdebuggerd_common_headers"],
36
Narayan Kamath2d377cd2017-05-10 10:58:59 +010037 static_libs: [
Narayan Kamatha73df602017-05-24 15:07:25 +010038 "libasync_safe",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010039 ],
40
41 shared_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010042 "libbase",
Narayan Kamatha73df602017-05-24 15:07:25 +010043 "libcutils",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010044 ],
45
Narayan Kamatha73df602017-05-24 15:07:25 +010046 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080047 export_include_dirs: ["tombstoned/include"],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010048}
49
Josh Gao9da1f512018-08-06 15:38:29 -070050// Utility library to talk to tombstoned and get an output fd.
Narayan Kamath2d377cd2017-05-10 10:58:59 +010051cc_library_static {
52 name: "libtombstoned_client_static",
53 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +090054 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070055 vendor_ramdisk_available: true,
Narayan Kamath2d377cd2017-05-10 10:58:59 +010056 srcs: [
57 "tombstoned/tombstoned_client.cpp",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080058 "util.cpp",
59 ],
60
Narayan Kamatha73df602017-05-24 15:07:25 +010061 header_libs: ["libdebuggerd_common_headers"],
62
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080063 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070064 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080065 "libcutils",
66 "libbase",
67 ],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010068
Narayan Kamatha73df602017-05-24 15:07:25 +010069 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080070 export_include_dirs: ["tombstoned/include"],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080071}
72
73// Core implementation, linked into libdebuggerd_handler and the dynamic linker.
Josh Gao9c02dc52016-06-15 17:29:00 -070074cc_library_static {
Josh Gaoe73c9322017-02-08 16:06:26 -080075 name: "libdebuggerd_handler_core",
Josh Gaocbe70cb2016-10-18 18:17:52 -070076 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +090077 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070078 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -070079 srcs: ["handler/debuggerd_handler.cpp"],
Josh Gao9c02dc52016-06-15 17:29:00 -070080
Josh Gaofdf832d2017-08-25 18:00:18 -070081 header_libs: [
82 "libbase_headers",
83 "libdebuggerd_common_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -080084 "bionic_libc_platform_headers",
Josh Gaofdf832d2017-08-25 18:00:18 -070085 ],
Narayan Kamatha73df602017-05-24 15:07:25 +010086
Josh Gaoe73c9322017-02-08 16:06:26 -080087 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070088 "libasync_safe",
Josh Gao2b2ae0c2017-08-21 14:31:17 -070089 "libcutils",
Josh Gaoe73c9322017-02-08 16:06:26 -080090 "libdebuggerd",
91 ],
92
Narayan Kamatha73df602017-05-24 15:07:25 +010093 export_header_lib_headers: ["libdebuggerd_common_headers"],
Josh Gaoe73c9322017-02-08 16:06:26 -080094 export_include_dirs: ["include"],
95}
96
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080097// Implementation with a no-op fallback.
Josh Gaoe73c9322017-02-08 16:06:26 -080098cc_library_static {
99 name: "libdebuggerd_handler",
100 defaults: ["debuggerd_defaults"],
101 srcs: ["handler/debuggerd_fallback_nop.cpp"],
102
Josh Gaoa48b41b2019-12-13 14:11:04 -0800103 header_libs: ["bionic_libc_platform_headers"],
104 export_header_lib_headers: ["bionic_libc_platform_headers"],
105
Josh Gaoe73c9322017-02-08 16:06:26 -0800106 whole_static_libs: [
107 "libdebuggerd_handler_core",
108 ],
109
110 export_include_dirs: ["include"],
111}
112
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100113// Fallback implementation, for use in the Bionic linker only.
Josh Gaoe73c9322017-02-08 16:06:26 -0800114cc_library_static {
115 name: "libdebuggerd_handler_fallback",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100116 visibility: ["//bionic/linker"],
117 apex_available: [
118 "com.android.runtime",
119 "//apex_available:platform",
120 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800121 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +0900122 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700123 vendor_ramdisk_available: true,
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800124 srcs: [
125 "handler/debuggerd_fallback.cpp",
126 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800127
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800128 whole_static_libs: [
129 "libdebuggerd_handler_core",
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100130 "libtombstoned_client_static",
Christopher Ferrisac225782017-04-25 11:23:10 -0700131 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800132 "libbase",
Josh Gaoe73c9322017-02-08 16:06:26 -0800133 "libdebuggerd",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100134 "libunwindstack_no_dex",
Josh Gaoe73c9322017-02-08 16:06:26 -0800135 "liblzma",
136 "libcutils",
137 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800138
139 header_libs: ["bionic_libc_platform_headers"],
140 export_header_lib_headers: ["bionic_libc_platform_headers"],
141
Josh Gaocbe70cb2016-10-18 18:17:52 -0700142 export_include_dirs: ["include"],
143}
144
145cc_library {
146 name: "libdebuggerd_client",
147 defaults: ["debuggerd_defaults"],
148 srcs: [
149 "client/debuggerd_client.cpp",
150 "util.cpp",
151 ],
152
153 shared_libs: [
154 "libbase",
155 "libcutils",
Josh Gao4175cee2019-01-04 13:57:09 -0800156 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700157 ],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800158
Josh Gaoa48b41b2019-12-13 14:11:04 -0800159 header_libs: [
160 "libdebuggerd_common_headers",
161 "bionic_libc_platform_headers",
162 ],
163 export_header_lib_headers: [
164 "libdebuggerd_common_headers",
165 "bionic_libc_platform_headers",
166 ],
167
Josh Gaocbe70cb2016-10-18 18:17:52 -0700168 export_include_dirs: ["include"],
169}
170
Josh Gaoe73c9322017-02-08 16:06:26 -0800171cc_library_static {
Josh Gaocbe70cb2016-10-18 18:17:52 -0700172 name: "libdebuggerd",
173 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900174 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700175 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700176
177 srcs: [
178 "libdebuggerd/backtrace.cpp",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800179 "libdebuggerd/gwp_asan.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700180 "libdebuggerd/open_files_list.cpp",
Peter Collingbournef8622522020-04-07 14:07:32 -0700181 "libdebuggerd/scudo.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700182 "libdebuggerd/tombstone.cpp",
Josh Gao76e1e302021-01-26 15:53:11 -0800183 "libdebuggerd/tombstone_proto.cpp",
184 "libdebuggerd/tombstone_proto_to_text.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700185 "libdebuggerd/utility.cpp",
186 ],
187
Josh Gaocbe70cb2016-10-18 18:17:52 -0700188 local_include_dirs: ["libdebuggerd/include"],
189 export_include_dirs: ["libdebuggerd/include"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700190
Peter Collingbournef8622522020-04-07 14:07:32 -0700191 include_dirs: [
192 // Needed for private/bionic_fdsan.h
193 "bionic/libc",
194
195 // Needed for scudo/interface.h
196 "external/scudo/standalone/include",
197 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800198 header_libs: [
199 "bionic_libc_platform_headers",
200 "gwp_asan_headers",
201 ],
Josh Gaoce841d92018-08-06 18:26:42 -0700202
Josh Gaoe73c9322017-02-08 16:06:26 -0800203 static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100204 "libdexfile_support", // libunwindstack dependency
Christopher Ferris9a8c8552017-08-11 15:29:19 -0700205 "libunwindstack",
Josh Gaoe73c9322017-02-08 16:06:26 -0800206 "liblzma",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700207 "libbase",
208 "libcutils",
209 "liblog",
210 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800211
Peter Collingbournef8622522020-04-07 14:07:32 -0700212 whole_static_libs: [
Josh Gao618cea32021-01-26 17:45:43 -0800213 "libasync_safe",
Peter Collingbournef8622522020-04-07 14:07:32 -0700214 "gwp_asan_crash_handler",
215 "libscudo",
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 ],
226 },
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700227 vendor_ramdisk: {
228 exclude_static_libs: [
229 "libdexfile_support",
230 ],
231 },
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000232 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700233
234 product_variables: {
235 debuggable: {
236 cflags: ["-DROOT_POSSIBLE"],
237 },
238 },
Josh Gaocbe70cb2016-10-18 18:17:52 -0700239}
240
Josh Gao76e1e302021-01-26 15:53:11 -0800241cc_binary {
242 name: "pbtombstone",
243 defaults: ["debuggerd_defaults"],
244 srcs: ["pbtombstone.cpp"],
245 static_libs: [
246 "libbase",
247 "libdebuggerd",
248 "liblog",
249 "libprotobuf-cpp-lite",
250 "libtombstone_proto",
251 "libunwindstack",
252 ],
253}
254
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700255cc_test_library {
256 name: "libcrash_test",
257 defaults: ["debuggerd_defaults"],
258 srcs: ["crash_test.cpp"],
259}
260
Josh Gaocbe70cb2016-10-18 18:17:52 -0700261cc_test {
262 name: "debuggerd_test",
263 defaults: ["debuggerd_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700264 require_root: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700265
266 cflags: ["-Wno-missing-field-initializers"],
267 srcs: [
268 "libdebuggerd/test/dump_memory_test.cpp",
269 "libdebuggerd/test/elf_fake.cpp",
270 "libdebuggerd/test/log_fake.cpp",
271 "libdebuggerd/test/open_files_list_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700272 "libdebuggerd/test/tombstone_test.cpp",
273 ],
274
275 target: {
276 android: {
277 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700278 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700279 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700280 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800281 static_libs: [
282 "libasync_safe",
283 "libtombstoned_client_static",
284 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700285 },
286 },
287
288 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700289 "libbase",
290 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700291 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100292 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800293 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000294 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700295 ],
296
297 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700298 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800299 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700300 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700301 ],
302
Josh Gaoa48b41b2019-12-13 14:11:04 -0800303 header_libs: [
304 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800305 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800306 ],
307
Peter Collingbournef8622522020-04-07 14:07:32 -0700308 include_dirs: [
309 "external/scudo/standalone/include",
310 ],
311
Josh Gaocbe70cb2016-10-18 18:17:52 -0700312 local_include_dirs: [
313 "libdebuggerd",
314 ],
315
316 compile_multilib: "both",
317 multilib: {
318 lib32: {
319 stem: "debuggerd_test32",
320 },
321 lib64: {
322 stem: "debuggerd_test64",
323 },
324 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700325
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700326 data: [
327 ":libcrash_test",
328 ],
329
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700330 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700331}
332
Josh Gaoa42314e2017-12-19 15:08:19 -0800333cc_benchmark {
334 name: "debuggerd_benchmark",
335 defaults: ["debuggerd_defaults"],
336 srcs: ["debuggerd_benchmark.cpp"],
337 shared_libs: [
338 "libbase",
339 "libdebuggerd_client",
340 ],
341}
342
Josh Gaocbe70cb2016-10-18 18:17:52 -0700343cc_binary {
344 name: "crash_dump",
345 srcs: [
346 "crash_dump.cpp",
347 "util.cpp",
348 ],
349 defaults: ["debuggerd_defaults"],
350
351 compile_multilib: "both",
352 multilib: {
353 lib32: {
354 suffix: "32",
355 },
356 lib64: {
357 suffix: "64",
358 },
359 },
360
Josh Gaoa48b41b2019-12-13 14:11:04 -0800361 header_libs: [
362 "bionic_libc_platform_headers",
363 ],
364
Josh Gaoe73c9322017-02-08 16:06:26 -0800365 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100366 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800367 "libdebuggerd",
368 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800369
370 "libtombstone_proto",
371 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800372 ],
373
Josh Gaocbe70cb2016-10-18 18:17:52 -0700374 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700375 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700376 "liblog",
377 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700378 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700379 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700380
381 apex_available: [
382 "com.android.runtime",
383 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700384}
385
386cc_binary {
387 name: "debuggerd",
388 srcs: [
389 "debuggerd.cpp",
390 ],
391 defaults: ["debuggerd_defaults"],
392
393 shared_libs: [
394 "libbase",
395 "libdebuggerd_client",
396 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700397 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700398 ],
399
400 local_include_dirs: ["include"],
401}
402
403cc_binary {
404 name: "tombstoned",
405 srcs: [
406 "util.cpp",
407 "tombstoned/intercept_manager.cpp",
408 "tombstoned/tombstoned.cpp",
409 ],
410 defaults: ["debuggerd_defaults"],
411
Josh Gaoa48b41b2019-12-13 14:11:04 -0800412 header_libs: [
413 "bionic_libc_platform_headers",
414 "libdebuggerd_common_headers"
415 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100416
Josh Gaocbe70cb2016-10-18 18:17:52 -0700417 static_libs: [
418 "libbase",
419 "libcutils",
420 "libevent",
421 "liblog",
422 ],
423
Elliott Hughesdc699a22018-02-16 17:58:14 -0800424 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700425}
Ray Essickbd3ba782020-01-21 15:21:08 -0800426
427prebuilt_etc {
428 name: "crash_dump.policy",
429 sub_dir: "seccomp_policy",
430 filename_from_src: true,
431 arch: {
432 arm: {
433 src: "seccomp_policy/crash_dump.arm.policy",
434 },
435 arm64: {
436 src: "seccomp_policy/crash_dump.arm64.policy",
437 },
438 x86: {
439 src: "seccomp_policy/crash_dump.x86.policy",
440 },
441 x86_64: {
442 src: "seccomp_policy/crash_dump.x86_64.policy",
443 },
444 },
445 required: [
446 "crash_dump.policy_other",
447 ],
448}
449
450
451// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
452// or at least that is the intention so that we get both of them populated
453prebuilt_etc {
454 name: "crash_dump.policy_other",
455 sub_dir: "seccomp_policy",
456 filename_from_src: true,
457 arch: {
458 arm: {
459 src: "seccomp_policy/crash_dump.arm64.policy",
460 },
461 arm64: {
462 src: "seccomp_policy/crash_dump.arm.policy",
463 },
464 x86: {
465 src: "seccomp_policy/crash_dump.x86_64.policy",
466 },
467 x86_64: {
468 src: "seccomp_policy/crash_dump.x86.policy",
469 },
470 },
471}