blob: f713ff2dfff620f8d9caed3295dcd1b214c72576 [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",
Peter Collingbournef8622522020-04-07 14:07:32 -0700183 "libdebuggerd/scudo.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700184 "libdebuggerd/tombstone.cpp",
Josh Gao76e1e302021-01-26 15:53:11 -0800185 "libdebuggerd/tombstone_proto.cpp",
186 "libdebuggerd/tombstone_proto_to_text.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700187 "libdebuggerd/utility.cpp",
188 ],
189
Josh Gaocbe70cb2016-10-18 18:17:52 -0700190 local_include_dirs: ["libdebuggerd/include"],
191 export_include_dirs: ["libdebuggerd/include"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700192
Peter Collingbournef8622522020-04-07 14:07:32 -0700193 include_dirs: [
194 // Needed for private/bionic_fdsan.h
195 "bionic/libc",
196
197 // Needed for scudo/interface.h
198 "external/scudo/standalone/include",
199 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800200 header_libs: [
201 "bionic_libc_platform_headers",
202 "gwp_asan_headers",
203 ],
Josh Gaoce841d92018-08-06 18:26:42 -0700204
Josh Gaoe73c9322017-02-08 16:06:26 -0800205 static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100206 "libdexfile_support", // libunwindstack dependency
Christopher Ferris9a8c8552017-08-11 15:29:19 -0700207 "libunwindstack",
Josh Gaoe73c9322017-02-08 16:06:26 -0800208 "liblzma",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700209 "libbase",
210 "libcutils",
211 "liblog",
212 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800213
Peter Collingbournef8622522020-04-07 14:07:32 -0700214 whole_static_libs: [
Josh Gao618cea32021-01-26 17:45:43 -0800215 "libasync_safe",
Peter Collingbournef8622522020-04-07 14:07:32 -0700216 "gwp_asan_crash_handler",
217 "libscudo",
Josh Gao76e1e302021-01-26 15:53:11 -0800218 "libtombstone_proto",
Josh Gaodbb83de2021-03-01 23:13:13 -0800219 "libprocinfo",
Josh Gao76e1e302021-01-26 15:53:11 -0800220 "libprotobuf-cpp-lite",
Peter Collingbournef8622522020-04-07 14:07:32 -0700221 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800222
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000223 target: {
224 recovery: {
225 exclude_static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100226 "libdexfile_support",
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000227 ],
228 },
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700229 vendor_ramdisk: {
230 exclude_static_libs: [
231 "libdexfile_support",
232 ],
233 },
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000234 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700235
236 product_variables: {
237 debuggable: {
238 cflags: ["-DROOT_POSSIBLE"],
239 },
240 },
Josh Gaocbe70cb2016-10-18 18:17:52 -0700241}
242
Josh Gao76e1e302021-01-26 15:53:11 -0800243cc_binary {
244 name: "pbtombstone",
245 defaults: ["debuggerd_defaults"],
246 srcs: ["pbtombstone.cpp"],
247 static_libs: [
248 "libbase",
249 "libdebuggerd",
250 "liblog",
251 "libprotobuf-cpp-lite",
252 "libtombstone_proto",
253 "libunwindstack",
254 ],
255}
256
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700257cc_test_library {
258 name: "libcrash_test",
259 defaults: ["debuggerd_defaults"],
260 srcs: ["crash_test.cpp"],
261}
262
Josh Gaocbe70cb2016-10-18 18:17:52 -0700263cc_test {
264 name: "debuggerd_test",
265 defaults: ["debuggerd_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700266 require_root: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700267
268 cflags: ["-Wno-missing-field-initializers"],
269 srcs: [
270 "libdebuggerd/test/dump_memory_test.cpp",
271 "libdebuggerd/test/elf_fake.cpp",
272 "libdebuggerd/test/log_fake.cpp",
273 "libdebuggerd/test/open_files_list_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700274 "libdebuggerd/test/tombstone_test.cpp",
275 ],
276
277 target: {
278 android: {
279 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700280 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700281 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700282 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800283 static_libs: [
284 "libasync_safe",
285 "libtombstoned_client_static",
286 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700287 },
288 },
289
290 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700291 "libbase",
292 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700293 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100294 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800295 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000296 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700297 ],
298
299 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700300 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800301 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700302 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700303 ],
304
Josh Gaoa48b41b2019-12-13 14:11:04 -0800305 header_libs: [
306 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800307 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800308 ],
309
Peter Collingbournef8622522020-04-07 14:07:32 -0700310 include_dirs: [
311 "external/scudo/standalone/include",
312 ],
313
Josh Gaocbe70cb2016-10-18 18:17:52 -0700314 local_include_dirs: [
315 "libdebuggerd",
316 ],
317
318 compile_multilib: "both",
319 multilib: {
320 lib32: {
321 stem: "debuggerd_test32",
322 },
323 lib64: {
324 stem: "debuggerd_test64",
325 },
326 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700327
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700328 data: [
329 ":libcrash_test",
330 ],
331
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700332 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700333}
334
Josh Gaoa42314e2017-12-19 15:08:19 -0800335cc_benchmark {
336 name: "debuggerd_benchmark",
337 defaults: ["debuggerd_defaults"],
338 srcs: ["debuggerd_benchmark.cpp"],
339 shared_libs: [
340 "libbase",
341 "libdebuggerd_client",
342 ],
343}
344
Josh Gaocbe70cb2016-10-18 18:17:52 -0700345cc_binary {
346 name: "crash_dump",
347 srcs: [
348 "crash_dump.cpp",
349 "util.cpp",
350 ],
351 defaults: ["debuggerd_defaults"],
352
353 compile_multilib: "both",
354 multilib: {
355 lib32: {
356 suffix: "32",
357 },
358 lib64: {
359 suffix: "64",
360 },
361 },
362
Josh Gaoa48b41b2019-12-13 14:11:04 -0800363 header_libs: [
364 "bionic_libc_platform_headers",
365 ],
366
Josh Gaoe73c9322017-02-08 16:06:26 -0800367 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100368 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800369 "libdebuggerd",
370 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800371
372 "libtombstone_proto",
373 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800374 ],
375
Josh Gaocbe70cb2016-10-18 18:17:52 -0700376 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700377 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700378 "liblog",
379 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700380 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700381 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700382
383 apex_available: [
384 "com.android.runtime",
385 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700386}
387
388cc_binary {
389 name: "debuggerd",
390 srcs: [
391 "debuggerd.cpp",
392 ],
393 defaults: ["debuggerd_defaults"],
394
395 shared_libs: [
396 "libbase",
397 "libdebuggerd_client",
398 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700399 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700400 ],
401
402 local_include_dirs: ["include"],
403}
404
405cc_binary {
406 name: "tombstoned",
407 srcs: [
408 "util.cpp",
409 "tombstoned/intercept_manager.cpp",
410 "tombstoned/tombstoned.cpp",
411 ],
412 defaults: ["debuggerd_defaults"],
413
Josh Gaoa48b41b2019-12-13 14:11:04 -0800414 header_libs: [
415 "bionic_libc_platform_headers",
416 "libdebuggerd_common_headers"
417 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100418
Josh Gaocbe70cb2016-10-18 18:17:52 -0700419 static_libs: [
420 "libbase",
421 "libcutils",
422 "libevent",
423 "liblog",
424 ],
425
Elliott Hughesdc699a22018-02-16 17:58:14 -0800426 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700427}
Ray Essickbd3ba782020-01-21 15:21:08 -0800428
429prebuilt_etc {
430 name: "crash_dump.policy",
431 sub_dir: "seccomp_policy",
432 filename_from_src: true,
433 arch: {
434 arm: {
435 src: "seccomp_policy/crash_dump.arm.policy",
436 },
437 arm64: {
438 src: "seccomp_policy/crash_dump.arm64.policy",
439 },
440 x86: {
441 src: "seccomp_policy/crash_dump.x86.policy",
442 },
443 x86_64: {
444 src: "seccomp_policy/crash_dump.x86_64.policy",
445 },
446 },
447 required: [
448 "crash_dump.policy_other",
449 ],
450}
451
452
453// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
454// or at least that is the intention so that we get both of them populated
455prebuilt_etc {
456 name: "crash_dump.policy_other",
457 sub_dir: "seccomp_policy",
458 filename_from_src: true,
459 arch: {
460 arm: {
461 src: "seccomp_policy/crash_dump.arm64.policy",
462 },
463 arm64: {
464 src: "seccomp_policy/crash_dump.arm.policy",
465 },
466 x86: {
467 src: "seccomp_policy/crash_dump.x86_64.policy",
468 },
469 x86_64: {
470 src: "seccomp_policy/crash_dump.x86.policy",
471 },
472 },
473}