自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
调试功能
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Linux 内核提供了许多诊断问题的机制,包括跟踪、BPF 和性能分析。其中的大多数技术在通用内核映像 (GKI) 二进制内核中都有提供。在开发产品时,开发或集成流程中集成了更多的工具,其中一些工具需要用到 GKI 中没有的内核功能。与大多数 GKI 功能一样,我们建议您与上游维护者合作来将这些功能添加到 Linux 中。
供应商模块中的下游调试功能
调试功能的作用范围与其他类型的功能类似,并且必须遵循 Android 专用补丁中所述的相同流程。
下游调试功能带来的干扰
一些有用的调试功能需要一些特殊的配置选项,而这些选项在 GKI 中已停用,因此需要特殊的内核 build。这些选项可能是因为影响性能或不适合在生产环境中使用而被停用,但对于调试特定类型的问题却必不可少。此类工具的示例包括排错程序(KASAN、UBSAN)、debugfs
和其他合作伙伴专用功能和工具。
如何管理影响内核模块接口 (KMI) 的启用调试功能的特殊内核由您自己决定。常见做法是创建一个内部调试 build,并将生成的工件提供给内部客户或下游开发合作伙伴。我们建议继续将此类功能隔离在模块中,因为不能将合作伙伴专用调试功能纳入到 GKI 内核中,这不符合 Android 专用补丁中所述的准则。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Debug features\n\nThe Linux kernel provides many mechanisms to diagnose issues including\n[tracing](https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/Documentation/trace/),\n[BPF](https://lwn.net/Articles/818714/), and\n[profiling](https://perf.wiki.kernel.org/index.php/Tutorial). Most\nof these techniques are available in the Generic Kernel Image (GKI) binary\nkernel. When developing products, there are many more tools that are integrated\ninto the development or integration processes, some of which require kernel\nfeatures that aren't part of GKI. As with most GKI features, we encourage you to\nwork with upstream maintainers to add these features to Linux.\n| **Note:** Kernel debugging tools and techniques are beyond the scope of this document.\n\nDownstream debug features in vendor modules\n-------------------------------------------\n\nDebugging features are similar in scope to other kinds of features and must\nfollow the same processes as described in\n[Android-specific patches](/docs/core/architecture/kernel/kernel-code#android-specific-patches).\n\nIntrusive downstream debug features\n-----------------------------------\n\nSome useful debug features require special configuration options that are\ndisabled in GKI and therefore require a special build of the kernel. These\nfeatures might be disabled due to performance penalties or unsuitability for\nproduction use, but are indispensable for debugging certain\ntypes of issues. Examples of such tools include sanitizers (KASAN, UBSAN),\n`debugfs`, and other partner-specific features and tools.\n\nIt's up to you to determine how you manage special debug-enabled kernels\nthat impact the Kernel Module Interface (KMI). A common practice is to have an\ninternal debug build and deliver the resulting artifacts to internal customers\nor downstream development partners. We recommend continuing to isolate such\nfeatures into modules as partner-specific debug features can't be accepted into\nthe GKI kernel beyond the guidelines described in\n[Android-specific patches](/docs/core/architecture/kernel/kernel-code#android-specific-patches)."]]