使用 rr 进行debug
使用 rr 進行debug
- 簡介
- 關鍵詞
- 安裝
- 編譯源文件方法
- Fedora:
- ubuntu
- arch
- 使用
- 開始
- 回放剛才的運行過程
- 反向debug
- 記錄觀察點
簡介
關鍵詞
- 保留某一次的運行錯誤
- 對錯誤可以反復執行
- 可以反向執行(這個猛)
- 操作和gdb沒啥區別
rr aspires to be your primary C/C++ debugging tool for Linux, replacing — well, enhancing — gdb. You record a failure once, then debug the recording, deterministically, as many times as you want. The same execution is replayed every time.
rr also provides efficient reverse execution under gdb. Set breakpoints and data watchpoints and quickly reverse-execute to where they were hit.
rr works on real applications and is used by many developers to fix real bugs. It makes debugging hard bugs much easier, but also speeds up debugging of easy bugs.
rr 渴望成為 Linux 的主要 C/C++ 調試工具,取代——嗯,增強——gdb。您記錄一次失敗,然后確定性地根據需要多次調試記錄。每次都重播相同的執行。
rr 還提供了 gdb 下的高效反向執行。設置斷點和數據觀察點并快速反向執行到它們被擊中的地方。
rr 適用于實際應用程序,許多開發人員使用它來修復實際錯誤。它使調試困難的錯誤變得更加容易,但也加快了對簡單錯誤的調試。
翻譯自官網
安裝
不同系統有不同安裝方式,參見:
編譯源文件方法
github指南
Fedora:
cd /tmp wget https://github.com/rr-debugger/rr/releases/download/5.5.0/rr-5.5.0-Linux-$(uname -m).rpm sudo dnf install rr-5.5.0-Linux-$(uname -m).rpmubuntu
cd /tmp wget https://github.com/rr-debugger/rr/releases/download/5.5.0/rr-5.5.0-Linux-$(uname -m).deb sudo dpkg -i rr-5.5.0-Linux-$(uname -m).debarch
yay 搜索一下安裝即可,這個最簡單。
使用
開始
對于某個程序,只需要輸入
rr record /your/application --args對于rosrun這種運行方式,可以通過
rosrun --prefix 'rr record' your/node來進行。
回放剛才的運行過程
rr replay進入回放。replay后的調試操作和debug一樣。
反向debug
設置斷點后,運行到斷點后的某處,使用rc,即reverse continue,即可反向運行到之前的斷點處。
‘rn’ 即reverse next, 即可逆向gdb的next進行反向回退。
記錄觀察點
watch -l 變量
可以實時觀察這一變量是否發生變化,有變化立刻停止,十分便于觀察各種隱含錯誤。
總結
以上是生活随笔為你收集整理的使用 rr 进行debug的全部內容,希望文章能夠幫你解決所遇到的問題。