1package { 2 default_applicable_licenses: ["Android-Apache-2.0"], 3} 4 5cc_defaults { 6 name: "debuggerd_defaults", 7 cflags: [ 8 "-Wall", 9 "-Wextra", 10 "-Werror", 11 "-Wno-gcc-compat", 12 "-Wno-unused-argument", 13 "-Wno-unused-function", 14 "-Wno-nullability-completeness", 15 "-Wno-reorder-init-list", 16 "-Os", 17 "-fno-finite-loops", 18 "-DANDROID_DEBUGGABLE=0", 19 ], 20 21 local_include_dirs: ["include"], 22 product_variables: { 23 debuggable: { 24 cflags: [ 25 "-UANDROID_DEBUGGABLE", 26 "-DANDROID_DEBUGGABLE=1", 27 ], 28 }, 29 }, 30} 31 32cc_library_headers { 33 name: "libdebuggerd_common_headers", 34 export_include_dirs: ["common/include"], 35 recovery_available: true, 36 vendor_ramdisk_available: true, 37 apex_available: [ 38 "com.android.runtime", 39 "com.android.virt", 40 "//apex_available:platform", 41 ], 42} 43 44cc_library_shared { 45 name: "libtombstoned_client", 46 defaults: ["debuggerd_defaults"], 47 srcs: [ 48 "tombstoned/tombstoned_client.cpp", 49 "util.cpp", 50 ], 51 52 header_libs: ["libdebuggerd_common_headers"], 53 54 static_libs: [ 55 "libasync_safe", 56 ], 57 58 shared_libs: [ 59 "libbase", 60 "libcutils", 61 ], 62 apex_available: [ 63 "com.android.virt", 64 "//apex_available:platform", 65 ], 66 67 export_header_lib_headers: ["libdebuggerd_common_headers"], 68 export_include_dirs: ["tombstoned/include"], 69} 70 71// Utility library to talk to tombstoned and get an output fd. 72cc_library_static { 73 name: "libtombstoned_client_static", 74 defaults: ["debuggerd_defaults"], 75 recovery_available: true, 76 vendor_ramdisk_available: true, 77 srcs: [ 78 "tombstoned/tombstoned_client.cpp", 79 "util.cpp", 80 ], 81 82 header_libs: ["libdebuggerd_common_headers"], 83 84 whole_static_libs: [ 85 "libasync_safe", 86 "libcutils", 87 "libbase", 88 ], 89 90 export_header_lib_headers: ["libdebuggerd_common_headers"], 91 export_include_dirs: ["tombstoned/include"], 92 apex_available: ["com.android.runtime"], 93} 94 95// Core implementation, linked into libdebuggerd_handler and the dynamic linker. 96cc_library_static { 97 name: "libdebuggerd_handler_core", 98 defaults: ["debuggerd_defaults"], 99 recovery_available: true, 100 vendor_ramdisk_available: true, 101 srcs: ["handler/debuggerd_handler.cpp"], 102 103 header_libs: [ 104 "libbase_headers", 105 "libdebuggerd_common_headers", 106 "bionic_libc_platform_headers", 107 "gwp_asan_headers", 108 ], 109 110 whole_static_libs: [ 111 "libasync_safe", 112 "libcutils", 113 "libdebuggerd", 114 ], 115 116 export_header_lib_headers: ["libdebuggerd_common_headers"], 117 export_include_dirs: ["include"], 118 apex_available: [ 119 "com.android.runtime", 120 ], 121} 122 123// Implementation with a no-op fallback. 124cc_library_static { 125 name: "libdebuggerd_handler", 126 defaults: ["debuggerd_defaults"], 127 srcs: ["handler/debuggerd_fallback_nop.cpp"], 128 129 header_libs: ["bionic_libc_platform_headers"], 130 export_header_lib_headers: ["bionic_libc_platform_headers"], 131 132 whole_static_libs: [ 133 "libdebuggerd_handler_core", 134 ], 135 136 export_include_dirs: ["include"], 137} 138 139// Fallback implementation, for use in the Bionic linker only. 140cc_library_static { 141 name: "libdebuggerd_handler_fallback", 142 visibility: ["//bionic/linker"], 143 apex_available: [ 144 "com.android.runtime", 145 "//apex_available:platform", 146 ], 147 defaults: ["debuggerd_defaults"], 148 recovery_available: true, 149 vendor_ramdisk_available: true, 150 srcs: [ 151 "handler/debuggerd_fallback.cpp", 152 ], 153 154 whole_static_libs: [ 155 "libdebuggerd_handler_core", 156 "libtombstoned_client_static", 157 "libasync_safe", 158 "libbase", 159 "libdebuggerd", 160 "libunwindstack_no_dex", 161 "liblzma", 162 "libcutils", 163 ], 164 165 header_libs: ["bionic_libc_platform_headers"], 166 export_header_lib_headers: ["bionic_libc_platform_headers"], 167 168 export_include_dirs: ["include"], 169} 170 171cc_library { 172 name: "libdebuggerd_client", 173 defaults: ["debuggerd_defaults"], 174 srcs: [ 175 "client/debuggerd_client.cpp", 176 "util.cpp", 177 ], 178 179 shared_libs: [ 180 "libbase", 181 "libcutils", 182 "libprocinfo", 183 ], 184 185 header_libs: [ 186 "libdebuggerd_common_headers", 187 "bionic_libc_platform_headers", 188 ], 189 export_header_lib_headers: [ 190 "libdebuggerd_common_headers", 191 "bionic_libc_platform_headers", 192 ], 193 194 export_include_dirs: ["include"], 195} 196 197cc_library { 198 name: "libdebuggerd_tombstone_proto_to_text", 199 defaults: ["debuggerd_defaults"], 200 ramdisk_available: true, 201 recovery_available: true, 202 vendor_ramdisk_available: true, 203 host_supported: true, 204 205 local_include_dirs: ["libdebuggerd/include"], 206 export_include_dirs: ["libdebuggerd/include"], 207 208 srcs: [ 209 "libdebuggerd/tombstone_proto_to_text.cpp", 210 "libdebuggerd/utility_host.cpp", 211 ], 212 213 static_libs: [ 214 "libbase", 215 ], 216 217 whole_static_libs: [ 218 "libtombstone_proto", 219 "libprotobuf-cpp-lite", 220 ], 221 222 shared_libs: [ 223 "liblog", 224 ], 225 226 apex_available: [ 227 "//apex_available:platform", 228 "com.android.runtime", 229 ], 230} 231 232cc_library_static { 233 name: "libdebuggerd", 234 defaults: ["debuggerd_defaults"], 235 ramdisk_available: true, 236 recovery_available: true, 237 vendor_ramdisk_available: true, 238 239 srcs: [ 240 "libdebuggerd/backtrace.cpp", 241 "libdebuggerd/gwp_asan.cpp", 242 "libdebuggerd/open_files_list.cpp", 243 "libdebuggerd/scudo.cpp", 244 "libdebuggerd/tombstone.cpp", 245 "libdebuggerd/tombstone_proto.cpp", 246 "libdebuggerd/utility.cpp", 247 ], 248 249 cflags: [ 250 "-DUSE_SCUDO", 251 ], 252 253 local_include_dirs: ["libdebuggerd/include"], 254 export_include_dirs: ["libdebuggerd/include"], 255 256 include_dirs: [ 257 // Needed for private/bionic_fdsan.h 258 "bionic/libc", 259 ], 260 header_libs: [ 261 "bionic_libc_platform_headers", 262 "gwp_asan_headers", 263 "liblog_headers", 264 "scudo_headers", 265 ], 266 267 static_libs: [ 268 "libdexfile_support", // libunwindstack dependency 269 "libunwindstack", 270 "liblzma", 271 "libbase", 272 "libcutils", 273 ], 274 275 whole_static_libs: [ 276 "libdebuggerd_tombstone_proto_to_text", 277 "libasync_safe", 278 "gwp_asan_crash_handler", 279 "libtombstone_proto", 280 "libprocinfo", 281 "libprotobuf-cpp-lite", 282 "libscudo", 283 ], 284 285 target: { 286 recovery: { 287 exclude_static_libs: [ 288 "libdexfile_support", 289 ], 290 exclude_runtime_libs: [ 291 "libdexfile", 292 ], 293 }, 294 vendor_ramdisk: { 295 exclude_static_libs: [ 296 "libdexfile_support", 297 ], 298 exclude_runtime_libs: [ 299 "libdexfile", 300 ], 301 }, 302 ramdisk: { 303 exclude_static_libs: [ 304 "libdexfile_support", 305 ], 306 exclude_runtime_libs: [ 307 "libdexfile", 308 ], 309 }, 310 android: { 311 runtime_libs: [ 312 "libdexfile", // libdexfile_support dependency 313 ], 314 }, 315 }, 316 317 product_variables: { 318 debuggable: { 319 cflags: ["-DROOT_POSSIBLE"], 320 }, 321 322 malloc_low_memory: { 323 cflags: ["-UUSE_SCUDO"], 324 exclude_static_libs: ["libscudo"], 325 }, 326 }, 327 apex_available: [ 328 "com.android.runtime", 329 ], 330} 331 332cc_binary { 333 name: "pbtombstone", 334 host_supported: true, 335 defaults: ["debuggerd_defaults"], 336 srcs: [ 337 "pbtombstone.cpp", 338 "tombstone_symbolize.cpp", 339 ], 340 static_libs: [ 341 "libbase", 342 "libdebuggerd_tombstone_proto_to_text", 343 "liblog", 344 "libprotobuf-cpp-lite", 345 "libtombstone_proto", 346 ], 347} 348 349cc_test_library { 350 name: "libcrash_test", 351 defaults: ["debuggerd_defaults"], 352 srcs: ["crash_test.cpp"], 353} 354 355cc_test { 356 name: "debuggerd_test", 357 defaults: ["debuggerd_defaults"], 358 require_root: true, 359 360 cflags: ["-Wno-missing-field-initializers"], 361 srcs: [ 362 "libdebuggerd/test/dump_memory_test.cpp", 363 "libdebuggerd/test/elf_fake.cpp", 364 "libdebuggerd/test/log_fake.cpp", 365 "libdebuggerd/test/mte_stack_record_test.cpp", 366 "libdebuggerd/test/open_files_list_test.cpp", 367 "libdebuggerd/test/tombstone_proto_to_text_test.cpp", 368 ], 369 370 target: { 371 android: { 372 srcs: [ 373 "client/debuggerd_client_test.cpp", 374 "debuggerd_test.cpp", 375 ], 376 static_libs: [ 377 "libasync_safe", 378 "libtombstoned_client_static", 379 ], 380 }, 381 }, 382 383 sanitize: { 384 memtag_heap: true, 385 }, 386 387 shared_libs: [ 388 "libbase", 389 "libcutils", 390 "libdebuggerd_client", 391 "liblog", 392 "libnativehelper", 393 "libunwindstack", 394 ], 395 396 static_libs: [ 397 "libdebuggerd", 398 "libgmock", 399 "libminijail", 400 ], 401 402 header_libs: [ 403 "bionic_libc_platform_headers", 404 "gwp_asan_headers", 405 ], 406 407 local_include_dirs: [ 408 "libdebuggerd", 409 ], 410 411 compile_multilib: "both", 412 multilib: { 413 lib32: { 414 stem: "debuggerd_test32", 415 }, 416 lib64: { 417 stem: "debuggerd_test64", 418 }, 419 }, 420 421 data: [ 422 ":libcrash_test", 423 ], 424 425 test_suites: ["device-tests"], 426} 427 428cc_benchmark { 429 name: "debuggerd_benchmark", 430 defaults: ["debuggerd_defaults"], 431 srcs: ["debuggerd_benchmark.cpp"], 432 shared_libs: [ 433 "libbase", 434 "libdebuggerd_client", 435 ], 436} 437 438cc_binary { 439 name: "crash_dump", 440 srcs: [ 441 "crash_dump.cpp", 442 "tombstone_handler.cpp", 443 "util.cpp", 444 ], 445 defaults: ["debuggerd_defaults"], 446 447 compile_multilib: "both", 448 multilib: { 449 lib32: { 450 suffix: "32", 451 }, 452 lib64: { 453 suffix: "64", 454 }, 455 }, 456 457 header_libs: [ 458 "bionic_libc_platform_headers", 459 "libnative_bridge_support_accessor_headers", 460 ], 461 462 static_libs: [ 463 "libtombstoned_client_static", 464 "libdebuggerd", 465 "libcutils", 466 467 "libtombstone_proto", 468 "libprotobuf-cpp-lite", 469 470 "libnative_bridge_guest_state_accessor", 471 ], 472 473 shared_libs: [ 474 "libbase", 475 "liblog", 476 "libprocinfo", 477 "libunwindstack", 478 ], 479 480 apex_available: [ 481 "com.android.runtime", 482 ], 483 484 // Required for tests. 485 required: ["crash_dump.policy"], 486 487 target: { 488 android: { 489 header_libs: [ 490 "libnative_bridge_support_accessor_headers", // For dlext_namespaces.h 491 ], 492 shared_libs: ["libdl_android"], // For android_get_exported_namespace implementation 493 }, 494 }, 495} 496 497cc_binary { 498 name: "debuggerd", 499 srcs: [ 500 "debuggerd.cpp", 501 ], 502 defaults: ["debuggerd_defaults"], 503 504 shared_libs: [ 505 "libbase", 506 "libdebuggerd_client", 507 "liblog", 508 "libprocessgroup", 509 "libprocinfo", 510 ], 511 512 local_include_dirs: ["include"], 513} 514 515cc_defaults { 516 name: "tombstoned_defaults", 517 srcs: [ 518 "util.cpp", 519 "tombstoned/intercept_manager.cpp", 520 "tombstoned/tombstoned.cpp", 521 ], 522 defaults: ["debuggerd_defaults"], 523 524 header_libs: [ 525 "bionic_libc_platform_headers", 526 "libdebuggerd_common_headers", 527 ], 528 529 static_libs: [ 530 "libbase", 531 "libcutils", 532 "libevent", 533 "liblog", 534 ], 535} 536 537cc_binary { 538 name: "tombstoned", 539 defaults: ["tombstoned_defaults"], 540 init_rc: ["tombstoned/tombstoned.rc"], 541} 542 543cc_binary { 544 name: "tombstoned.microdroid", 545 defaults: ["tombstoned_defaults"], 546 init_rc: ["tombstoned/tombstoned.microdroid.rc"], 547} 548 549prebuilt_etc { 550 name: "crash_dump.policy", 551 sub_dir: "seccomp_policy", 552 filename_from_src: true, 553 arch: { 554 arm: { 555 src: "seccomp_policy/crash_dump.arm.policy", 556 required: [ 557 "crash_dump.policy_other", 558 ], 559 }, 560 arm64: { 561 src: "seccomp_policy/crash_dump.arm64.policy", 562 required: [ 563 "crash_dump.policy_other", 564 ], 565 }, 566 riscv64: { 567 src: "seccomp_policy/crash_dump.riscv64.policy", 568 }, 569 x86: { 570 src: "seccomp_policy/crash_dump.x86.policy", 571 required: [ 572 "crash_dump.policy_other", 573 ], 574 }, 575 x86_64: { 576 src: "seccomp_policy/crash_dump.x86_64.policy", 577 required: [ 578 "crash_dump.policy_other", 579 ], 580 }, 581 }, 582} 583 584// This installs the "other" architecture (so 32-bit on 64-bit device). 585prebuilt_etc { 586 name: "crash_dump.policy_other", 587 sub_dir: "seccomp_policy", 588 filename_from_src: true, 589 arch: { 590 arm: { 591 src: "seccomp_policy/crash_dump.arm64.policy", 592 }, 593 arm64: { 594 src: "seccomp_policy/crash_dump.arm.policy", 595 }, 596 riscv64: { 597 enabled: false, 598 }, 599 x86: { 600 src: "seccomp_policy/crash_dump.x86_64.policy", 601 }, 602 x86_64: { 603 src: "seccomp_policy/crash_dump.x86.policy", 604 }, 605 }, 606} 607