blob: 16cbbb0b43762493d302cac8f4968da6f6098db5 [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",
Peter Collingbourne47d784e2021-11-05 18:40:52 -0700275 "libdebuggerd/test/utility_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700276 ],
277
278 target: {
279 android: {
280 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700281 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700282 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700283 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800284 static_libs: [
285 "libasync_safe",
286 "libtombstoned_client_static",
287 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700288 },
289 },
290
291 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700292 "libbase",
293 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700294 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100295 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800296 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000297 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700298 ],
299
300 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700301 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800302 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700303 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700304 ],
305
Josh Gaoa48b41b2019-12-13 14:11:04 -0800306 header_libs: [
307 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800308 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800309 ],
310
Peter Collingbournef8622522020-04-07 14:07:32 -0700311 include_dirs: [
312 "external/scudo/standalone/include",
313 ],
314
Josh Gaocbe70cb2016-10-18 18:17:52 -0700315 local_include_dirs: [
316 "libdebuggerd",
317 ],
318
319 compile_multilib: "both",
320 multilib: {
321 lib32: {
322 stem: "debuggerd_test32",
323 },
324 lib64: {
325 stem: "debuggerd_test64",
326 },
327 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700328
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700329 data: [
330 ":libcrash_test",
331 ],
332
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700333 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700334}
335
Josh Gaoa42314e2017-12-19 15:08:19 -0800336cc_benchmark {
337 name: "debuggerd_benchmark",
338 defaults: ["debuggerd_defaults"],
339 srcs: ["debuggerd_benchmark.cpp"],
340 shared_libs: [
341 "libbase",
342 "libdebuggerd_client",
343 ],
344}
345
Josh Gaocbe70cb2016-10-18 18:17:52 -0700346cc_binary {
347 name: "crash_dump",
348 srcs: [
349 "crash_dump.cpp",
350 "util.cpp",
351 ],
352 defaults: ["debuggerd_defaults"],
353
354 compile_multilib: "both",
355 multilib: {
356 lib32: {
357 suffix: "32",
358 },
359 lib64: {
360 suffix: "64",
361 },
362 },
363
Josh Gaoa48b41b2019-12-13 14:11:04 -0800364 header_libs: [
365 "bionic_libc_platform_headers",
366 ],
367
Josh Gaoe73c9322017-02-08 16:06:26 -0800368 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100369 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800370 "libdebuggerd",
371 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800372
373 "libtombstone_proto",
374 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800375 ],
376
Josh Gaocbe70cb2016-10-18 18:17:52 -0700377 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700378 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700379 "liblog",
380 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700381 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700382 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700383
384 apex_available: [
385 "com.android.runtime",
386 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700387}
388
389cc_binary {
390 name: "debuggerd",
391 srcs: [
392 "debuggerd.cpp",
393 ],
394 defaults: ["debuggerd_defaults"],
395
396 shared_libs: [
397 "libbase",
398 "libdebuggerd_client",
399 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700400 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700401 ],
402
403 local_include_dirs: ["include"],
404}
405
406cc_binary {
407 name: "tombstoned",
408 srcs: [
409 "util.cpp",
410 "tombstoned/intercept_manager.cpp",
411 "tombstoned/tombstoned.cpp",
412 ],
413 defaults: ["debuggerd_defaults"],
414
Josh Gaoa48b41b2019-12-13 14:11:04 -0800415 header_libs: [
416 "bionic_libc_platform_headers",
417 "libdebuggerd_common_headers"
418 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100419
Josh Gaocbe70cb2016-10-18 18:17:52 -0700420 static_libs: [
421 "libbase",
422 "libcutils",
423 "libevent",
424 "liblog",
425 ],
426
Elliott Hughesdc699a22018-02-16 17:58:14 -0800427 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700428}
Ray Essickbd3ba782020-01-21 15:21:08 -0800429
430prebuilt_etc {
431 name: "crash_dump.policy",
432 sub_dir: "seccomp_policy",
433 filename_from_src: true,
434 arch: {
435 arm: {
436 src: "seccomp_policy/crash_dump.arm.policy",
437 },
438 arm64: {
439 src: "seccomp_policy/crash_dump.arm64.policy",
440 },
441 x86: {
442 src: "seccomp_policy/crash_dump.x86.policy",
443 },
444 x86_64: {
445 src: "seccomp_policy/crash_dump.x86_64.policy",
446 },
447 },
448 required: [
449 "crash_dump.policy_other",
450 ],
451}
452
453
454// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
455// or at least that is the intention so that we get both of them populated
456prebuilt_etc {
457 name: "crash_dump.policy_other",
458 sub_dir: "seccomp_policy",
459 filename_from_src: true,
460 arch: {
461 arm: {
462 src: "seccomp_policy/crash_dump.arm64.policy",
463 },
464 arm64: {
465 src: "seccomp_policy/crash_dump.arm.policy",
466 },
467 x86: {
468 src: "seccomp_policy/crash_dump.x86_64.policy",
469 },
470 x86_64: {
471 src: "seccomp_policy/crash_dump.x86.policy",
472 },
473 },
474}