debug

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Debug

Debug

Debug a reported issue using a structured reproduction-then-fix approach.
使用结构化的「复现-修复」方法调试已上报的问题。

Phase 1: Reproduction & Root Cause Analysis

第一阶段:复现与根本原因分析

  1. Investigate — Analyze the bug report for key symptoms and error messages
  2. Trace — Search the codebase for error occurrence patterns, trace from symptom to source
  3. Root cause — Identify the root cause through data flow analysis and edge case checking
  4. Reproduce — Create a minimal failing test case that reproduces the exact error
  5. Document — Clearly document the root cause and reproduction steps
  1. 调查 — 分析bug报告中的关键症状和错误信息
  2. 追踪 — 在代码库中搜索错误出现的模式,从症状追溯到根源
  3. 根本原因 — 通过数据流分析和边缘情况检查确定根本原因
  4. 复现 — 创建一个最小化的失败测试用例,精准复现该错误
  5. 记录 — 清晰记录根本原因和复现步骤

Phase 2: Fix Implementation

第二阶段:修复实施

  1. Plan — Analyze the optimal fix approach based on root cause, check for similar fixes in the codebase
  2. Implement — Make the minimal, targeted fix that addresses the root cause
  3. Verify — Run the failing test to confirm it passes, then run the full test suite to check for regressions
  1. 规划 — 根据根本原因分析最优修复方案,检查代码库中是否有类似修复案例
  2. 实施 — 进行最小化、针对性的修复,解决根本问题
  3. 验证 — 运行失败的测试用例确认其通过,然后运行完整测试套件检查是否存在回归问题

Principles

原则

  • Minimal changes — Fix the bug, nothing more
  • Targeted — Only touch affected code paths
  • Tested — The fix must make the failing test pass and not break existing tests
  • No unrelated improvements — Stay focused on the specific bug
  • 最小改动 — 仅修复bug,不做额外修改
  • 针对性 — 仅触及受影响的代码路径
  • 可测试 — 修复必须使失败的测试用例通过,且不破坏现有测试
  • 不做无关改进 — 专注于当前特定bug