The Android 8.0 release includes kernel enhancements that help developers create better applications by improving their debugging experience.
The arm64 Android kernels support setting watchpoints on memory addresses that are not 4/8-byte aligned, and reporting all accesses to those addresses.
Implementation
The feature runs on any ARM 64-bit device. Adding the relevant support for 32-bit hardware/kernels is optional. All necessary kernel modifications have already been done.
This feature is included in the 4.4 and higher common kernels. To add it to a kernel that does not already include it, cherry pick the necessary CLs into your kernel build. Choose the patchset according to the version your kernel is based on, as the patches required some adjustments due to the kernel codebase evolving over time:
- https://android.googlesource.com/kernel/common/+/91495bc622e9356dd63a7c77b98a21f0e2f5d2b2
- https://android.googlesource.com/kernel/common/+/7409857a0717fa78dc936ea08099880be893156c
- https://android.googlesource.com/kernel/common/+/b48318f371e8a8b98238deac868bc7af8ed8ba4b
- https://android.googlesource.com/kernel/common/+/edc166a8714b012a3dd207e437c772ae2a264eca
- https://android.googlesource.com/kernel/common/+/85c450ac7ac0a69aca4c6eb845e419ae092d8c86
- https://android.googlesource.com/kernel/common/+/67de4de5628a47fa794920745dc7869c97b558d3
- https://android.googlesource.com/kernel/common/+/32649b0a393303a97fab6003c5757ff7b100331a
- https://android.googlesource.com/kernel/common/+/d32793b6be517dffa29329a92ffcc688e74bc690
This feature implements an extension of the ptrace
API to support
writing a debugger.
Validation
There is a kernel selftest in the upstream repository, a CTS test, and there are CTS tests added exercising the new kernel API:
https://android.googlesource.com/platform/bionic/+/master/tests/sys_ptrace_test.cpp