blob: 9ca0eba6ece621fa8c098c754187ffd8264ad816 [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 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100213 runtime_libs: [
214 "libdexfile", // libdexfile_support dependency
215 ],
Josh Gaoa48b41b2019-12-13 14:11:04 -0800216
Peter Collingbournef8622522020-04-07 14:07:32 -0700217 whole_static_libs: [
Josh Gao618cea32021-01-26 17:45:43 -0800218 "libasync_safe",
Peter Collingbournef8622522020-04-07 14:07:32 -0700219 "gwp_asan_crash_handler",
220 "libscudo",
Josh Gao76e1e302021-01-26 15:53:11 -0800221 "libtombstone_proto",
Josh Gaodbb83de2021-03-01 23:13:13 -0800222 "libprocinfo",
Josh Gao76e1e302021-01-26 15:53:11 -0800223 "libprotobuf-cpp-lite",
Peter Collingbournef8622522020-04-07 14:07:32 -0700224 ],
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800225
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000226 target: {
227 recovery: {
228 exclude_static_libs: [
Martin Stjernholma2cc8932019-10-23 21:32:43 +0100229 "libdexfile_support",
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000230 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100231 exclude_runtime_libs: [
232 "libdexfile",
233 ],
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000234 },
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700235 vendor_ramdisk: {
236 exclude_static_libs: [
237 "libdexfile_support",
238 ],
Martin Stjernholm3784b9d2021-08-26 21:18:43 +0100239 exclude_runtime_libs: [
240 "libdexfile",
241 ],
Yifan Hong2ec92cf2020-10-27 16:25:45 -0700242 },
Martin Stjernholmbb4f2b42018-12-19 14:28:33 +0000243 },
Christopher Ferris4ae266c2019-04-03 09:27:12 -0700244
245 product_variables: {
246 debuggable: {
247 cflags: ["-DROOT_POSSIBLE"],
248 },
249 },
Josh Gaocbe70cb2016-10-18 18:17:52 -0700250}
251
Josh Gao76e1e302021-01-26 15:53:11 -0800252cc_binary {
253 name: "pbtombstone",
254 defaults: ["debuggerd_defaults"],
255 srcs: ["pbtombstone.cpp"],
256 static_libs: [
257 "libbase",
258 "libdebuggerd",
259 "liblog",
260 "libprotobuf-cpp-lite",
261 "libtombstone_proto",
262 "libunwindstack",
263 ],
264}
265
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700266cc_test_library {
267 name: "libcrash_test",
268 defaults: ["debuggerd_defaults"],
269 srcs: ["crash_test.cpp"],
270}
271
Josh Gaocbe70cb2016-10-18 18:17:52 -0700272cc_test {
273 name: "debuggerd_test",
274 defaults: ["debuggerd_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700275 require_root: true,
Josh Gaocbe70cb2016-10-18 18:17:52 -0700276
277 cflags: ["-Wno-missing-field-initializers"],
278 srcs: [
279 "libdebuggerd/test/dump_memory_test.cpp",
280 "libdebuggerd/test/elf_fake.cpp",
281 "libdebuggerd/test/log_fake.cpp",
282 "libdebuggerd/test/open_files_list_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700283 "libdebuggerd/test/tombstone_test.cpp",
284 ],
285
286 target: {
287 android: {
288 srcs: [
Josh Gaoae9d7672017-03-24 16:26:03 -0700289 "client/debuggerd_client_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700290 "debuggerd_test.cpp",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700291 ],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800292 static_libs: [
293 "libasync_safe",
294 "libtombstoned_client_static",
295 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700296 },
297 },
298
299 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700300 "libbase",
301 "libcutils",
Josh Gaoae9d7672017-03-24 16:26:03 -0700302 "libdebuggerd_client",
Narayan Kamatha73df602017-05-24 15:07:25 +0100303 "liblog",
Elliott Hughesdc699a22018-02-16 17:58:14 -0800304 "libnativehelper",
Martin Stjernholm852b64e2019-02-20 17:01:24 +0000305 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700306 ],
307
308 static_libs: [
Josh Gao352a8452017-03-30 16:46:21 -0700309 "libdebuggerd",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800310 "libgmock",
Peter Collingbourned00a5772020-07-20 23:11:16 -0700311 "libminijail",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700312 ],
313
Josh Gaoa48b41b2019-12-13 14:11:04 -0800314 header_libs: [
315 "bionic_libc_platform_headers",
Mitch Phillipse0b4bb12020-02-14 14:54:31 -0800316 "gwp_asan_headers",
Josh Gaoa48b41b2019-12-13 14:11:04 -0800317 ],
318
Peter Collingbournef8622522020-04-07 14:07:32 -0700319 include_dirs: [
320 "external/scudo/standalone/include",
321 ],
322
Josh Gaocbe70cb2016-10-18 18:17:52 -0700323 local_include_dirs: [
324 "libdebuggerd",
325 ],
326
327 compile_multilib: "both",
328 multilib: {
329 lib32: {
330 stem: "debuggerd_test32",
331 },
332 lib64: {
333 stem: "debuggerd_test64",
334 },
335 },
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700336
Christopher Ferrisfe751c52021-04-16 09:40:40 -0700337 data: [
338 ":libcrash_test",
339 ],
340
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700341 test_suites: ["device-tests"],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700342}
343
Josh Gaoa42314e2017-12-19 15:08:19 -0800344cc_benchmark {
345 name: "debuggerd_benchmark",
346 defaults: ["debuggerd_defaults"],
347 srcs: ["debuggerd_benchmark.cpp"],
348 shared_libs: [
349 "libbase",
350 "libdebuggerd_client",
351 ],
352}
353
Josh Gaocbe70cb2016-10-18 18:17:52 -0700354cc_binary {
355 name: "crash_dump",
356 srcs: [
357 "crash_dump.cpp",
358 "util.cpp",
359 ],
360 defaults: ["debuggerd_defaults"],
361
362 compile_multilib: "both",
363 multilib: {
364 lib32: {
365 suffix: "32",
366 },
367 lib64: {
368 suffix: "64",
369 },
370 },
371
Josh Gaoa48b41b2019-12-13 14:11:04 -0800372 header_libs: [
373 "bionic_libc_platform_headers",
374 ],
375
Josh Gaoe73c9322017-02-08 16:06:26 -0800376 static_libs: [
Narayan Kamath2d377cd2017-05-10 10:58:59 +0100377 "libtombstoned_client_static",
Josh Gaoe73c9322017-02-08 16:06:26 -0800378 "libdebuggerd",
379 "libcutils",
Josh Gao76e1e302021-01-26 15:53:11 -0800380
381 "libtombstone_proto",
382 "libprotobuf-cpp-lite",
Josh Gaoe73c9322017-02-08 16:06:26 -0800383 ],
384
Josh Gaocbe70cb2016-10-18 18:17:52 -0700385 shared_libs: [
Josh Gaocbe70cb2016-10-18 18:17:52 -0700386 "libbase",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700387 "liblog",
388 "libprocinfo",
Josh Gao2b2ae0c2017-08-21 14:31:17 -0700389 "libunwindstack",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700390 ],
Peter Collingbourneb72e7482020-03-16 18:14:13 -0700391
392 apex_available: [
393 "com.android.runtime",
394 ],
Josh Gaocbe70cb2016-10-18 18:17:52 -0700395}
396
397cc_binary {
398 name: "debuggerd",
399 srcs: [
400 "debuggerd.cpp",
401 ],
402 defaults: ["debuggerd_defaults"],
403
404 shared_libs: [
405 "libbase",
406 "libdebuggerd_client",
407 "liblog",
Josh Gao0915f232017-06-27 14:08:05 -0700408 "libprocinfo",
Josh Gaocbe70cb2016-10-18 18:17:52 -0700409 ],
410
411 local_include_dirs: ["include"],
412}
413
414cc_binary {
415 name: "tombstoned",
416 srcs: [
417 "util.cpp",
418 "tombstoned/intercept_manager.cpp",
419 "tombstoned/tombstoned.cpp",
420 ],
421 defaults: ["debuggerd_defaults"],
422
Josh Gaoa48b41b2019-12-13 14:11:04 -0800423 header_libs: [
424 "bionic_libc_platform_headers",
425 "libdebuggerd_common_headers"
426 ],
Narayan Kamatha73df602017-05-24 15:07:25 +0100427
Josh Gaocbe70cb2016-10-18 18:17:52 -0700428 static_libs: [
429 "libbase",
430 "libcutils",
431 "libevent",
432 "liblog",
433 ],
434
Elliott Hughesdc699a22018-02-16 17:58:14 -0800435 init_rc: ["tombstoned/tombstoned.rc"],
Josh Gao9c02dc52016-06-15 17:29:00 -0700436}
Ray Essickbd3ba782020-01-21 15:21:08 -0800437
438prebuilt_etc {
439 name: "crash_dump.policy",
440 sub_dir: "seccomp_policy",
441 filename_from_src: true,
442 arch: {
443 arm: {
444 src: "seccomp_policy/crash_dump.arm.policy",
445 },
446 arm64: {
447 src: "seccomp_policy/crash_dump.arm64.policy",
448 },
449 x86: {
450 src: "seccomp_policy/crash_dump.x86.policy",
451 },
452 x86_64: {
453 src: "seccomp_policy/crash_dump.x86_64.policy",
454 },
455 },
456 required: [
457 "crash_dump.policy_other",
458 ],
459}
460
461
462// NB -- this installs "the other" architecture. (puts 32 bit config in on 64 bit device)
463// or at least that is the intention so that we get both of them populated
464prebuilt_etc {
465 name: "crash_dump.policy_other",
466 sub_dir: "seccomp_policy",
467 filename_from_src: true,
468 arch: {
469 arm: {
470 src: "seccomp_policy/crash_dump.arm64.policy",
471 },
472 arm64: {
473 src: "seccomp_policy/crash_dump.arm.policy",
474 },
475 x86: {
476 src: "seccomp_policy/crash_dump.x86_64.policy",
477 },
478 x86_64: {
479 src: "seccomp_policy/crash_dump.x86.policy",
480 },
481 },
482}