tree: b51cd646565ca22589d1829c2b26240deb2b79ac [search]
  1. client/
  2. common/
  3. crasher/
  4. handler/
  5. include/
  6. libdebuggerd/
  7. proto/
  8. rust/
  9. seccomp_policy/
  10. test_permissive_mte/
  11. tombstoned/
  12. AGENTS.md
  13. Android.bp
  14. crash_dump.cpp
  15. crash_test.cpp
  16. crash_test.h
  17. debuggerd.cpp
  18. debuggerd_benchmark.cpp
  19. debuggerd_test.cpp
  20. MODULE_LICENSE_APACHE2
  21. OWNERS
  22. pbtombstone.cpp
  23. protocol.h
  24. README.md
  25. TEST_MAPPING
  26. tombstone_handler.cpp
  27. tombstone_handler.h
  28. tombstone_symbolize.cpp
  29. tombstone_symbolize.h
  30. util.cpp
  31. util.h
debuggerd/README.md

debuggerd

debuggerd is the set of tools and daemons responsible for handling crashes and providing diagnostic information (tombstones and backtraces) for native processes.

Command-line Tools

debuggerd

Manually trigger a dump of a running process. Root access is required.

Usage:

debuggerd [-bj] PID

Options:

  • -b, --backtrace: Only output a native backtrace instead of a full tombstone.
  • -j: Collect Java traces (for Android apps/runtime).

pbtombstone

Convert a protobuf-formatted tombstone into human-readable text.

Usage:

pbtombstone [OPTION] TOMBSTONE.PB

Options:

  • -h, --help: Show help message.
  • --display-sp: Print stack pointer in backtraces.
  • --debug-file-directory PATH: Specify a directory containing symbols for more detailed backtraces.

crasher

A testing tool used to deliberately trigger various types of crashes.

Usage:

crasher KIND

Common KINDs:

  • SIGSEGV: Cause a segmentation fault.
  • abort: Call abort().
  • heap-buffer-overflow: Write past the end of a heap allocation.
  • stack-overflow: Recurse until the stack overflows.
  • smash-stack: Corrupt the stack guard.
  • fdsan_file: Trigger a file descriptor sanitizer failure.
  • See crasher/crasher.cpp for the full list of supported crash types.

System Components

tombstoned (Daemon)

A daemon that manages the lifecycle of tombstone files and coordinates with crash_dump to provide output file descriptors. By moving the file management logic to a daemon, the system can safely manage tombstone rotation and interception without granting extra filesystem permissions to every process.

  • Tombstone Location: /data/tombstones/ (usually named tombstone_XX)
  • Sockets: tombstoned_crash, tombstoned_intercept, and tombstoned_java_trace.

crash_dump

An architecture-specific helper binary (e.g., crash_dump32, crash_dump64) spawned during a crash. It is forked from the crashing process to ensure it inherits the same security context (UID, GID, and SELinux domain), which allows it to ptrace the target process without requiring elevated system privileges.

How it works (Crash Lifecycle)

Standard Path (crash_dump)

Debuggerd uses a primary signal handler (debuggerd_signal_handler) linked into Bionic that is registered for all crash-related signals.

  1. Crash Triggered: A native process receives a signal (like SIGSEGV, SIGILL, etc.).
  2. Signal Handler: The debuggerd_handler (linked into Bionic) catches the signal and forks/execs crash_dump. Forking from the crashing process preserves its security properties while moving the heavy dump-generation logic into a specialized, short-lived process.
  3. Connection: crash_dump connects to tombstoned to get an output file descriptor.
  4. Dump Generation: crash_dump attaches to the process via ptrace, reads its state, and writes the tombstone.
  5. Completion: crash_dump detaches and exits.
  6. Resend Signal: The signal handler restores the original signal disposition and resends the signal to allow the process to terminate normally with the correct exit status.

Fallback Path (debuggerd_fallback_handler)

This handler is used as a fallback when debuggerd_handler determines that it cannot spawn crash_dump (e.g., in a process where PR_SET_NO_NEW_PRIVS is set).

  1. Detection: debuggerd_handler detects it cannot spawn crash_dump and invokes the fallback handler.
  2. Connection: The fallback handler connects to tombstoned directly to request an output file descriptor.
  3. In-process Dump: It switches the linker to a specialized fallback allocator and uses libunwindstack to generate a dump within the crashing process.
  4. Completion: It notifies tombstoned that the dump is complete.
  5. Resend Signal: The handler restores the original signal disposition and resends the signal to the process to allow it to terminate normally.