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 current 3.10, 3.18, 4.4, and 4.9 kernel branches. 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:

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