返回顶部
l

linux-kernel-crash-debugLinux内核崩溃调试

Debug Linux kernel crashes using the crash utility and memory debugging tools. Use when users mention kernel crash, kernel panic, vmcore analysis, kernel dump debugging, crash utility, kernel oops debugging, analyzing kernel crash dump files, using crash commands, locating root causes of kernel issues, KASAN, Kprobes, Kmemleak, memory corruption, out-of-bounds access, use-after-free, memory leak detection.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.4
安全检测
已通过
517
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

linux-kernel-crash-debug

Linux 内核崩溃调试

本技能指导您使用 crash 工具分析 Linux 内核崩溃转储文件。

安装

Claude Code

bash claude skill install linux-kernel-crash-debug.skill

OpenClaw

bash

方法1:通过 ClawHub 安装

clawhub install linux-kernel-crash-debug

方法2:手动安装

mkdir -p ~/.openclaw/workspace/skills/linux-kernel-crash-debug cp SKILL.md ~/.openclaw/workspace/skills/linux-kernel-crash-debug/

快速开始

启动会话

bash

分析转储文件


crash vmlinux vmcore

调试运行中的系统

crash vmlinux

原始 RAM 转储

crash vmlinux ddr.bin --ram_start=0x80000000

核心调试流程

  1. 1. crash> sys # 确认崩溃原因
  2. crash> log # 查看内核日志
  3. crash> bt # 分析调用栈
  4. crash> struct # 检查数据结构
  5. crash> kmem # 内存分析

🤖 代理执行指令

如果您是使用此技能的 AI/Agent,请勿交互式调用 crash,因为它会阻塞您的子 shell。
  1. 1. 使用捆绑的包装脚本 ./scripts/agent-crash.sh,该脚本精确映射到以下工作流程,但安全地截断输出:
- ./scripts/agent-crash.sh -k vmlinux -c vmcore triage - 安全运行初始的 sys、log 和 bt。 - ./scripts/agent-crash.sh -k vmlinux -c vmcore flow-oom - 前15项内存检查。 - ./scripts/agent-crash.sh -k vmlinux -c vmcore flow-deadlock - 提取 UN 状态任务栈。 - ./scripts/agent-crash.sh -k vmlinux -c vmcore dis-regs - 汇编回归分析。 - ./scripts/agent-crash.sh -k vmlinux -c vmcore check-poison - 模式匹配内存毒化。
  1. 2. 回退策略:如果宏无法解决问题,手动回退到基本原语:./scripts/agent-crash.sh -k vmlinux -c vmcore run rd ffff880123456780。
  2. 查看 references/agentic-heuristics.md 获取扩展专家方法论。

前提条件

项目要求
vmlinux必须包含调试符号(CONFIGDEBUGINFO=y)
vmcore
kdump/netdump/diskdump/ELF 格式 | | 版本 | vmlinux 必须与 vmcore 内核版本完全匹配 |

软件包安装

Anolis OS / 阿里云 Linux

bash

安装 crash 工具


sudo dnf install crash

安装内核调试信息(匹配您的内核版本)

sudo dnf install kernel-debuginfo-$(uname -r)

安装额外分析工具

sudo dnf install gdb readelf objdump makedumpfile

可选:安装 kernel-devel 用于源码参考

sudo dnf install kernel-devel-$(uname -r)

RHEL / CentOS / Rocky / AlmaLinux

bash
sudo dnf install crash kernel-debuginfo-$(uname -r)
sudo dnf install gdb binutils makedumpfile

Ubuntu / Debian

bash
sudo apt install crash linux-crashdump gdb binutils makedumpfile
sudo apt install linux-image-$(uname -r)-dbgsym

自编译内核

bash

在内核配置中启用调试符号


make menuconfig # 启用 CONFIGDEBUGINFO,CONFIGDEBUGINFO_REDUCED=n

或直接设置

scripts/config --enable CONFIGDEBUGINFO scripts/config --enable CONFIGDEBUGINFODWARFTOOLCHAIN_DEFAULT

验证安装

bash

检查 crash 版本


crash --version

验证调试信息与内核匹配

crash /usr/lib/debug/lib/modules/$(uname -r)/vmlinux /proc/kcore

核心命令参考

调试分析

命令用途示例
sys系统信息/崩溃原因sys,sys -i
log
内核消息缓冲区 | log,log \| tail | | bt | 栈回溯 | bt,bt -a,bt -f | | struct | 查看结构体 | struct task_struct | | p/px/pd | 打印变量 | p jiffies,px current | | kmem | 内存分析 | kmem -i,kmem -S |

任务和进程

命令用途示例
ps进程列表ps,ps -m \grep UN
set
切换上下文 | set ,set -p | | foreach | 批量任务操作 | foreach bt,foreach UN bt | | task | task_struct 内容 | task | | files | 打开的文件 | files |

内存操作

命令用途示例
rd读取内存rd <addr>,rd -p <phys>
search
搜索内存 | search -k deadbeef | | vtop | 地址转换 | vtop | | list | 遍历链表 | list task_struct.tasks -h |

bt 命令详解

最重要的调试命令:

crash> bt # 当前任务栈
crash> bt -a # 所有 CPU 活动任务
crash> bt -f # 展开栈帧原始数据
crash> bt -F # 符号化栈帧数据
crash> bt -l # 显示源文件和行号
crash> bt -e # 搜索异常帧
crash> bt -v # 检查栈溢出
crash> bt -R # 仅显示引用符号的栈
crash> bt # 特定进程

上下文管理

Crash 会话具有当前上下文,影响 bt、files、vm 命令:

crash> set # 查看当前上下文
crash> set # 切换到指定 PID
crash> set # 切换到任务地址
crash> set -p # 恢复到崩溃任务

会话控制

输出控制

crash> set scroll off # 禁用分页 crash> sf # scroll off 的别名

输出重定向

crash> foreach bt > bt.all

GDB 透传

crash> gdb bt # 单次 gdb 调用 crash> set gdb on # 进入 gdb 模式 (gdb) info registers (gdb) set gdb off

从文件读取命令

crash> < commands.txt

典型调试场景

内核 BUG 定位

crash> sys # 确认崩溃
crash> log | tail -50 # 查看日志
crash> bt # 调用栈
crash> bt -f # 展开帧以获取参数
crash> struct # 检查数据结构

死锁分析

crash> bt -a # 所有 CPU 调用栈
crash> ps -m | grep UN # 不可中断进程
crash> foreach UN bt # 查看等待原因
crash> struct mutex # 检查锁状态

内存问题

crash> kmem -i # 内存统计
crash> kmem -S # 检查 slab
crash> vm # 进程内存映射
crash> search -k # 搜索内存

栈溢出

crash> bt -v # 检查栈溢出
crash> bt -r # 原始栈数据

高级技巧

链式查询

crash> bt -f # 获取指针

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 linux-kernel-crash-debug-1776199486 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 linux-kernel-crash-debug-1776199486 技能

通过命令行安装

skillhub install linux-kernel-crash-debug-1776199486

下载

⬇ 下载 linux-kernel-crash-debug v1.0.4(免费)

文件大小: 28.59 KB | 发布时间: 2026-4-15 13:49

v1.0.4 最新 2026-4-15 13:49
- Added agent/expert workflow support: wrapper script (`scripts/agent-crash.sh`) and heuristic methodology (`references/agentic-heuristics.md`) for safe, batch, or programmatic crash analysis.
- Introduced agent execution directives section for non-interactive usage and recommended best practices for agents.
- Embedded OpenClaw-specific `metadata` and runtime `requires` blocks for better platform integration.
- Added legal and contribution documents: `LICENSE`, `CONTRIBUTING.md`.
- Removed user-facing introductory docs (`README.md`, `README_CN.md`); primary usage guidance now lives in `SKILL.md`.
- Reference file structure expanded for deeper tooling and methodology documentation.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部