blob: d7e8f3297f771dfe1bf3a9ad9c130a7c544f9111 [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",
16 ],
17
18 local_include_dirs: ["include"],
19}
20
Narayan Kamatha73df602017-05-24 15:07:25 +010021cc_library_headers {
22 name: "libdebuggerd_common_headers",
Elliott Hughesdc699a22018-02-16 17:58:14 -080023 export_include_dirs: ["common/include"],
Jiyong Parka0e75042018-05-24 14:11:00 +090024 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070025 vendor_ramdisk_available: true,
Narayan Kamatha73df602017-05-24 15:07:25 +010026}
27
Narayan Kamath2d377cd2017-05-10 10:58:59 +010028cc_library_shared {
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080029 name: "libtombstoned_client",
30 defaults: ["debuggerd_defaults"],
31 srcs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010032 "tombstoned/tombstoned_client.cpp",
33 "util.cpp",
34 ],
35
Narayan Kamatha73df602017-05-24 15:07:25 +010036 header_libs: ["libdebuggerd_common_headers"],
37
Narayan Kamath2d377cd2017-05-10 10:58:59 +010038 static_libs: [
Narayan Kamatha73df602017-05-24 15:07:25 +010039 "libasync_safe",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010040 ],
41
42 shared_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +010043 "libbase",
Narayan Kamatha73df602017-05-24 15:07:25 +010044 "libcutils",
Narayan Kamath2d377cd2017-05-10 10:58:59 +010045 ],
46
Narayan Kamatha73df602017-05-24 15:07:25 +010047 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080048 export_include_dirs: ["tombstoned/include"],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010049}
50
Josh Gao9da1f512018-08-06 15:38:29 -070051// Utility library to talk to tombstoned and get an output fd.
Narayan Kamath2d377cd2017-05-10 10:58:59 +010052cc_library_static {
53 name: "libtombstoned_client_static",
54 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +090055 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070056 vendor_ramdisk_available: true,
Narayan Kamath2d377cd2017-05-10 10:58:59 +010057 srcs: [
58 "tombstoned/tombstoned_client.cpp",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080059 "util.cpp",
60 ],
61
Narayan Kamatha73df602017-05-24 15:07:25 +010062 header_libs: ["libdebuggerd_common_headers"],
63
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080064 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070065 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080066 "libcutils",
67 "libbase",
68 ],
Narayan Kamath2d377cd2017-05-10 10:58:59 +010069
Narayan Kamatha73df602017-05-24 15:07:25 +010070 export_header_lib_headers: ["libdebuggerd_common_headers"],
Elliott Hughesdc699a22018-02-16 17:58:14 -080071 export_include_dirs: ["tombstoned/include"],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080072}
73
74// Core implementation, linked into libdebuggerd_handler and the dynamic linker.
Josh Gao9c02dc52016-06-15 17:29:00 -070075cc_library_static {
Josh Gaoe73c9322017-02-08 16:06:26 -080076 name: "libdebuggerd_handler_core",
Josh Gaocbe70cb2016-10-18 18:17:52 -070077 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +090078 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -070079 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -070080 srcs: ["handler/debuggerd_handler.cpp"],
Josh Gao9c02dc52016-06-15 17:29:00 -070081
Josh Gaofdf832d2017-08-25 18:00:18 -070082 header_libs: [
83 "libbase_headers",
84 "libdebuggerd_common_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -080085 "bionic_libc_platform_headers",
Josh Gaofdf832d2017-08-25 18:00:18 -070086 ],
Narayan Kamatha73df602017-05-24 15:07:25 +010087
Josh Gaoe73c9322017-02-08 16:06:26 -080088 whole_static_libs: [
Christopher Ferrisac225782017-04-25 11:23:10 -070089 "libasync_safe",
Josh Gao2b2ae0c2017-08-21 14:31:17 -070090 "libcutils",
Josh Gaoe73c9322017-02-08 16:06:26 -080091 "libdebuggerd",
92 ],
93
Narayan Kamatha73df602017-05-24 15:07:25 +010094 export_header_lib_headers: ["libdebuggerd_common_headers"],
Josh Gaoe73c9322017-02-08 16:06:26 -080095 export_include_dirs: ["include"],
96}
97
Josh Gaoe1aa0ca2017-03-01 17:23:22 -080098// Implementation with a no-op fallback.
Josh Gaoe73c9322017-02-08 16:06:26 -080099cc_library_static {
100 name: "libdebuggerd_handler",
101 defaults: ["debuggerd_defaults"],
102 srcs: ["handler/debuggerd_fallback_nop.cpp"],
103
Josh Gaoa48b41b2019-12-13 14:11:04 -0800104 header_libs: ["bionic_libc_platform_headers"],
105 export_header_lib_headers: ["bionic_libc_platform_headers"],
106
Josh Gaoe73c9322017-02-08 16:06:26 -0800107 whole_static_libs: [
108 "libdebuggerd_handler_core",
109 ],
110
111 export_include_dirs: ["include"],
112}
113
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100114// Fallback implementation, for use in the Bionic linker only.
Josh Gaoe73c9322017-02-08 16:06:26 -0800115cc_library_static {
116 name: "libdebuggerd_handler_fallback",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100117 visibility: ["//bionic/linker"],
118 apex_available: [
119 "com.android.runtime",
120 "//apex_available:platform",
121 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800122 defaults: ["debuggerd_defaults"],
Jiyong Park011ee122018-05-29 16:41:30 +0900123 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700124 vendor_ramdisk_available: true,
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800125 srcs: [
126 "handler/debuggerd_fallback.cpp",
127 ],
Josh Gaoe73c9322017-02-08 16:06:26 -0800128
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800129 whole_static_libs: [
130 "libdebuggerd_handler_core",
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100131 "libtombstoned_client_static",
Christopher Ferrisac225782017-04-25 11:23:10 -0700132 "libasync_safe",
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800133 "libbase",
Josh Gaoe73c9322017-02-08 16:06:26 -0800134 "libdebuggerd",
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100135 "libunwindstack_no_dex",
Josh Gaoe73c9322017-02-08 16:06:26 -0800136 "liblzma",
137 "libcutils",
138 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800139
140 header_libs: ["bionic_libc_platform_headers"],
141 export_header_lib_headers: ["bionic_libc_platform_headers"],
142
Josh Gaocbe70cb2016-10-18 18:17:52 -0700143 export_include_dirs: ["include"],
144}
145
146cc_library {
147 name: "libdebuggerd_client",
148 defaults: ["debuggerd_defaults"],
149 srcs: [
150 "client/debuggerd_client.cpp",
151 "util.cpp",
152 ],
153
154 shared_libs: [
155 "libbase",
156 "libcutils",
Josh Gao4175cee2019-01-04 13:57:09 -0800157 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700158 ],
Josh Gaoe1aa0ca2017-03-01 17:23:22 -0800159
Josh Gaoa48b41b2019-12-13 14:11:04 -0800160 header_libs: [
161 "libdebuggerd_common_headers",
162 "bionic_libc_platform_headers",
163 ],
164 export_header_lib_headers: [
165 "libdebuggerd_common_headers",
166 "bionic_libc_platform_headers",
167 ],
168
Josh Gaocbe70cb2016-10-18 18:17:52 -0700169 export_include_dirs: ["include"],
170}
171
Josh Gaoe73c9322017-02-08 16:06:26 -0800172cc_library_static {
Josh Gaocbe70cb2016-10-18 18:17:52 -0700173 name: "libdebuggerd",
174 defaults: ["debuggerd_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900175 recovery_available: true,
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700176 vendor_ramdisk_available: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700177
178 srcs: [
179 "libdebuggerd/backtrace.cpp",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800180 "libdebuggerd/gwp_asan.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700181 "libdebuggerd/open_files_list.cpp",
Peter Collingbournef8622522020-04-07 14:07:32 -0700182 "libdebuggerd/scudo.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700183 "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",
195
196 // Needed for scudo/interface.h
197 "external/scudo/standalone/include",
198 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800199 header_libs: [
200 "bionic_libc_platform_headers",
201 "gwp_asan_headers",
202 ],
Josh Gaoce841d92018-08-06 18:26:42 -0700203
Josh Gaoe73c9322017-02-08 16:06:26 -0800204 static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100205 "libdexfile_support", // libunwindstack dependency
Christopher Ferris9a8c8552017-08-11 15:29:19 -0700206 "libunwindstack",
Josh Gaoe73c9322017-02-08 16:06:26 -0800207 "liblzma",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700208 "libbase",
209 "libcutils",
210 "liblog",
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",
216 "libscudo",
Josh Gao76e1e302021-01-26 15:53:11 -0800217 "libtombstone_proto",
Josh Gaodbb83de2021-03-01 23:13:13 -0800218 "libprocinfo",
Josh Gao76e1e302021-01-26 15:53:11 -0800219 "libprotobuf-cpp-lite",
Peter Collingbournef8622522020-04-07 14:07:32 -0700220 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800221
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000222 target: {
223 recovery: {
224 exclude_static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100225 "libdexfile_support",
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000226 ],
227 },
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700228 vendor_ramdisk: {
229 exclude_static_libs: [
230 "libdexfile_support",
231 ],
232 },
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000233 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700234
235 product_variables: {
236 debuggable: {
237 cflags: ["-DROOT_POSSIBLE"],
238 },
239 },
Josh Gaocbe70cb2016-10-18 18:17:52 -0700240}
241
Josh Gao76e1e302021-01-26 15:53:11 -0800242cc_binary {
243 name: "pbtombstone",
244 defaults: ["debuggerd_defaults"],
245 srcs: ["pbtombstone.cpp"],
246 static_libs: [
247 "libbase",
248 "libdebuggerd",
249 "liblog",
250 "libprotobuf-cpp-lite",
251 "libtombstone_proto",
252 "libunwindstack",
253 ],
254}
255
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700256cc_test_library {
257 name: "libcrash_test",
258 defaults: ["debuggerd_defaults"],
259 srcs: ["crash_test.cpp"],
260}
261
Josh Gaocbe70cb2016-10-18 18:17:52 -0700262cc_test {
263 name: "debuggerd_test",
264 defaults: ["debuggerd_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700265 require_root: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700266
267 cflags: ["-Wno-missing-field-initializers"],
268 srcs: [
269 "libdebuggerd/test/dump_memory_test.cpp",
270 "libdebuggerd/test/elf_fake.cpp",
271 "libdebuggerd/test/log_fake.cpp",
272 "libdebuggerd/test/open_files_list_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700273 "libdebuggerd/test/tombstone_test.cpp",
274 ],
275
276 target: {
277 android: {
278 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700279 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700280 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700281 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800282 static_libs: [
283 "libasync_safe",
284 "libtombstoned_client_static",
285 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700286 },
287 },
288
289 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700290 "libbase",
291 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700292 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100293 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800294 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000295 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700296 ],
297
298 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700299 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800300 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700301 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700302 ],
303
Josh Gaoa48b41b2019-12-13 14:11:04 -0800304 header_libs: [
305 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800306 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800307 ],
308
Peter Collingbournef8622522020-04-07 14:07:32 -0700309 include_dirs: [
310 "external/scudo/standalone/include",
311 ],
312
Josh Gaocbe70cb2016-10-18 18:17:52 -0700313 local_include_dirs: [
314 "libdebuggerd",
315 ],
316
317 compile_multilib: "both",
318 multilib: {
319 lib32: {
320 stem: "debuggerd_test32",
321 },
322 lib64: {
323 stem: "debuggerd_test64",
324 },
325 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700326
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700327 data: [
328 ":libcrash_test",
329 ],
330
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700331 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700332}
333
Josh Gaoa42314e2017-12-19 15:08:19 -0800334cc_benchmark {
335 name: "debuggerd_benchmark",
336 defaults: ["debuggerd_defaults"],
337 srcs: ["debuggerd_benchmark.cpp"],
338 shared_libs: [
339 "libbase",
340 "libdebuggerd_client",
341 ],
342}
343
Josh Gaocbe70cb2016-10-18 18:17:52 -0700344cc_binary {
345 name: "crash_dump",
346 srcs: [
347 "crash_dump.cpp",
348 "util.cpp",
349 ],
350 defaults: ["debuggerd_defaults"],
351
352 compile_multilib: "both",
353 multilib: {
354 lib32: {
355 suffix: "32",
356 },
357 lib64: {
358 suffix: "64",
359 },
360 },
361
Josh Gaoa48b41b2019-12-13 14:11:04 -0800362 header_libs: [
363 "bionic_libc_platform_headers",
364 ],
365
Josh Gaoe73c9322017-02-08 16:06:26 -0800366 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100367 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800368 "libdebuggerd",
369 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800370
371 "libtombstone_proto",
372 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800373 ],
374
Josh Gaocbe70cb2016-10-18 18:17:52 -0700375 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700376 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700377 "liblog",
378 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700379 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700380 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700381
382 apex_available: [
383 "com.android.runtime",
384 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700385}
386
387cc_binary {
388 name: "debuggerd",
389 srcs: [
390 "debuggerd.cpp",
391 ],
392 defaults: ["debuggerd_defaults"],
393
394 shared_libs: [
395 "libbase",
396 "libdebuggerd_client",
397 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700398 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700399 ],
400
401 local_include_dirs: ["include"],
402}
403
404cc_binary {
405 name: "tombstoned",
406 srcs: [
407 "util.cpp",
408 "tombstoned/intercept_manager.cpp",
409 "tombstoned/tombstoned.cpp",
410 ],
411 defaults: ["debuggerd_defaults"],
412
Josh Gaoa48b41b2019-12-13 14:11:04 -0800413 header_libs: [
414 "bionic_libc_platform_headers",
415 "libdebuggerd_common_headers"
416 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100417
Josh Gaocbe70cb2016-10-18 18:17:52 -0700418 static_libs: [
419 "libbase",
420 "libcutils",
421 "libevent",
422 "liblog",
423 ],
424
Elliott Hughesdc699a22018-02-16 17:58:14 -0800425 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700426}
Ray Essickbd3ba782020-01-21 15:21:08 -0800427
428prebuilt_etc {
429 name: "crash_dump.policy",
430 sub_dir: "seccomp_policy",
431 filename_from_src: true,
432 arch: {
433 arm: {
434 src: "seccomp_policy/crash_dump.arm.policy",
435 },
436 arm64: {
437 src: "seccomp_policy/crash_dump.arm64.policy",
438 },
439 x86: {
440 src: "seccomp_policy/crash_dump.x86.policy",
441 },
442 x86_64: {
443 src: "seccomp_policy/crash_dump.x86_64.policy",
444 },
445 },
446 required: [
447 "crash_dump.policy_other",
448 ],
449}
450
451
452// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
453// or at least that is the intention so that we get both of them populated
454prebuilt_etc {
455 name: "crash_dump.policy_other",
456 sub_dir: "seccomp_policy",
457 filename_from_src: true,
458 arch: {
459 arm: {
460 src: "seccomp_policy/crash_dump.arm64.policy",
461 },
462 arm64: {
463 src: "seccomp_policy/crash_dump.arm.policy",
464 },
465 x86: {
466 src: "seccomp_policy/crash_dump.x86_64.policy",
467 },
468 x86_64: {
469 src: "seccomp_policy/crash_dump.x86.policy",
470 },
471 },
472}