Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

GDB 進階除錯技巧

Watchpoints、條件中斷、自動化、追蹤等進階技巧。

🎯 進階功能

Watchpoints

條件與自動化

完整技巧集

🔍 分析與追蹤

函數追蹤

SO 分析

💡 進階技巧

Watchpoints 使用

監視變量變化:

watch variable_name     # 變量被寫入時中斷
rwatch variable_name    # 變量被讀取時中斷
awatch variable_name    # 變量被訪問時中斷

條件中斷點

break main if argc > 1
condition 1 i == 10

自動化指令

commands 1
  print x
  continue
end

函數追蹤技巧

  • 使用 backtrace 查看調用堆疊
  • 使用 info frame 查看棧幀
  • 結合 Python 腳本自動化分析

最後更新: 2025-12-01