自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
偵錯功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Linux 核心提供許多機制來診斷問題,包括追蹤、BPF 和分析。這些技術大多可在通用核心映像檔 (GKI) 二進位核心中使用。開發產品時,有許多工具會整合至開發或整合程序,其中有些工具需要非 GKI 的核心功能。如同大多數 GKI 功能,我們建議您與上游維護人員合作,將這些功能新增至 Linux。
供應商模組中的下游偵錯功能
偵錯功能的範圍與其他類型的功能相似,且必須遵循 Android 專屬修補程式中所述的程序。
侵入式下游偵錯功能
部分實用的偵錯功能需要特殊設定選項,這些選項在 GKI 中已停用,因此需要使用特殊的核心版本。這些功能可能會因效能懲罰或不適合實際使用而停用,但對於偵錯某些類型的問題而言,這些功能不可或缺。這類工具的例子包括清理器 (KASAN、UBSAN)、debugfs
以及其他合作夥伴專屬功能和工具。
您可以自行決定如何管理會影響核心模組介面 (KMI) 的特殊啟用偵錯功能核心。常見做法是進行內部偵錯建構,並將產生的構件交付給內部客戶或後端開發合作夥伴。我們建議您繼續將這類功能隔離到模組中,因為合作夥伴專屬的偵錯功能無法納入 GKI 核心,除非符合 Android 專屬修補程式中所述的規範。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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)."]]