SuperAPI AI 工具集

debug-crash-dump

测试与质量

查看项目

更新于 10-16 10:33

技能介绍

用途

本技能用于从 CI 工作流失败(尤其是 fault_injection_full)中下载并分析崩溃转储文件,辅助定位崩溃原因。完整的可读指南见 docs/CrashDumpDebugging.md。

适用时机

当出现以下需求时使用本技能:

  • 调试带崩溃转储的 CI 崩溃或测试失败
  • 下载工作流运行产生的崩溃转储产物
  • 搭建 CDB、WinDbg 或 mcp-windbg 环境
  • 分析 .dmp 文件
  • 排查故障注入(fault injection)内存泄漏检测失败

前置条件

Windows 调试工具(CDB/WinDbg)

从 Windows SDK 安装 Debugging Tools 功能:

# Download the SDK online installer
Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2272610" -OutFile winsdksetup.exe
# Install only the debugging tools (elevated)
Start-Process -FilePath .\winsdksetup.exe -ArgumentList "/features","OptionId.WindowsDesktopDebuggers","/quiet","/norestart" -Verb RunAs -Wait

CDB 安装位置:C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe

mcp-windbg(面向 AI 辅助转储分析的 MCP 服务器)

# Install Python 3.12 via NuGet (if not already available)
nuget install python -Version 3.12.8 -OutputDirectory C:\Users\$env:USERNAME\tools
$pyExe = (Get-ChildItem "C:\Users\$env:USERNAME\tools\python.3.12.8" -Recurse -Filter "python.exe" | Select-Object -First 1).FullName
& $pyExe -m ensurepip --upgrade
& $pyExe -m pip install mcp-windbg

下载产物

# Download crash dumps and build artifacts (PDBs) from a CI run
gh run download <run_id> -R <owner>/ebpf-for-windows -n "Crash-Dumps-<test>-x64-<config>" -D crash-dumps
gh run download <run_id> -R <owner>/ebpf-for-windows -n "Build-x64-<config>" -D build
# Extract inner build zip for PDBs (produces build\<config>\<config>\ with PDBs)
Expand-Archive build\build-<config>.zip -DestinationPath build\<config>

使用 CDB 分析转储

$cdbPath = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe"
$symPath = "build\<config>\<config>;SRV*C:\Symbols*https://msdl.microsoft.com/download/symbols"

# Quick triage: exception record + stack trace
& $cdbPath -z crash-dumps\unit_tests.exe.XXXX.dmp -y $symPath -lines -c ".ecxr;kP;q"

# Full automated analysis
& $cdbPath -z crash-dumps\unit_tests.exe.XXXX.dmp -y $symPath -c "!analyze -v;q"

运行 mcp-windbg 服务器

$pyExe = (Get-ChildItem "C:\Users\$env:USERNAME\tools\python.3.12.8" -Recurse -Filter "python.exe" | Select-Object -First 1).FullName
$cdbPath = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe"
$symPath = "build\<config>\<config>;SRV*C:\Symbols*https://msdl.microsoft.com/download/symbols"

& $pyExe -m mcp_windbg --cdb-path $cdbPath --symbols-path $symPath --transport streamable-http --port 8765
# MCP endpoint: http://127.0.0.1:8765/mcp

常见模式

故障注入崩溃

通常对应 leak_detector.cpp 中的 assert _allocations.empty() —— 在拆除(teardown)期间检测到内存泄漏。检查泄漏检测器的 _in_memory_log 以获取分配调用栈:

$$ Get exception context and inspect the stack to find the leak_detector frame:
.ecxr
kP
$$ Identify the frame index where 'this' is the leak_detector instance
.frame <N>
dx this->_in_memory_log

崩溃转储产物

命名格式为 Crash-Dumps-<test_name>-<platform>-<config>(例如 Crash-Dumps-fault_injection_full-x64-Debug)。

含 PDB 的构建产物

命名格式为 <build_artifact>-<config>(对于默认的 build_artifact=Build-x64,即 Build-x64-Debug),内部包含一个 zip 文件 build-<config>.zip。

限制

关于支持平台、具体版本要求、失败模式与边界条件的更多细节,资料中暂未提供。