원클릭으로
db-core-debugging
使用 gdb-cli 工具调试 Database core dump 文件时触发。当用户提到 core dump、coredump、崩溃分析、server 崩溃、段错误、SIGSEGV、SIGABRT、堆栈分析等关键词时使用。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
使用 gdb-cli 工具调试 Database core dump 文件时触发。当用户提到 core dump、coredump、崩溃分析、server 崩溃、段错误、SIGSEGV、SIGABRT、堆栈分析等关键词时使用。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | db-core-debugging |
| description | 使用 gdb-cli 工具调试 Database core dump 文件时触发。当用户提到 core dump、coredump、崩溃分析、server 崩溃、段错误、SIGSEGV、SIGABRT、堆栈分析等关键词时使用。 |
自动化分析 Database core dump 文件的工作流程。
gdb-cli env-check
gdb-cli 命令不存在 → 安装:pip install git+http://gitlab.internal.example.com/tools/gdb_cli.gitgdb -batch -ex "python print('ok')"大型 DB binary(6.1G+)加载时间不可预测,采用渐进式超时:
第 1 次:gdb-cli load -b <binary> -c <core> --timeout 120 (2分钟)
若超时 → 第 2 次:gdb-cli load -b <binary> -c <core> --timeout 300 (5分钟)
若仍超时 → 第 3 次:gdb-cli load -b <binary> -c <core> --timeout 600 (10分钟)
仍失败 → 报错并提示可能原因
加载失败排查:
gdb-cli load -b server -c core.xxx--sysroot 或 --solib-prefix 参数--gdb-path 指定正确版本gdb-cli status -s <session_id>
确认:模式(core)、binary 路径、线程数、当前帧信息。
gdb-cli threads -s <SID> --limit 50
找到信号线程(通常是 thread 1,收到 SIGSEGV/SIGABRT)。
gdb-cli bt -s <SID> --thread <crash_thread> --limit 30
从崩溃帧(frame 0)向上遍历调用链,识别关键函数。
如果 bt 输出包含源文件信息:
# 崩溃帧的函数参数
gdb-cli args -s <SID> --thread <crash_thread> --frame 0
# 崩溃帧的局部变量
gdb-cli locals-cmd -s <SID> --thread <crash_thread> --frame 0
# 深入查看关键变量(需先切换上下文)
gdb-cli thread-switch -s <SID> <crash_thread>
gdb-cli frame -s <SID> 0
gdb-cli eval-cmd -s <SID> "this->member_name_"
gdb-cli eval-cmd -s <SID> "*ptr"
根据崩溃类型选择诊断手段:
| 崩溃类型 | 诊断命令 |
|---|---|
| 空指针解引用 | eval-cmd 检查指针值,ptype 查看类型 |
| 内存越界 | memory 检查周边内存,registers 查看地址寄存器 |
| 非法指令 | disasm 查看崩溃点汇编,registers 查看 rip |
| 栈溢出 | registers 查看 rsp,memory 检查栈边界 |
| 断言失败 | eval-cmd 查看断言条件中的变量值 |
输出结构化诊断报告:
## Core Dump 诊断报告
- **崩溃信号**: SIGSEGV / SIGABRT / ...
- **崩溃线程**: Thread N
- **崩溃位置**: function() at file:line
- **调用链关键路径**: ...
- **关键变量值**: ...
- **根因推断**: ...
- **建议修复方向**: ...
gdb-cli stop -s <session_id>
gdb-cli exec — 在大型 binary 上 100% SEGFAULT,已废弃gdb-cli thread-apply — 内部用 gdb.execute(),不稳定。用 threads + bt --thread N 组合替代$ 符号用单引号包裹,寄存器查看用 registers 命令(无需转义)gdb-cli stop 清理资源参考 gdb-cli-reference.md 获取完整 22 命令说明。