gdb reverse debugging

gdb reverse debugging

Note when debugging gcc g++ programs

Must add -g parameter

-g can generate variable tables for executable files and
cancel some optimizations so that the executable files are executed strictly in accordance with the source program

Example

gcc -g debugPrint.c  -o debugPrint

Limit gdb> 7.1.0

First start the file to record settings

gdb
file debugPrint
start

/// **** 进行 状态记录设置
target record-full

之后就可以 使用
reverse-next  简写  rn
reverse-step  简写  rs
reverse-nexti  简写  rni
reverse-stepi  简写  rsi
来进行反向调试了

Several commonly used small commands

i locals  [可选:满足的正则] 查看定义的变量

i funtions  [可选:满足的正则]   查看定义的函数

bt 查看函数调用栈

set env 设置环境变量

//设置动态库的加载目录
set env LD_LIBRARY_PATH=/.../LIB_path


frame n 切断到调用堆栈的 第 n 层
up 1 向上1层
down 1 向下1层

where 显示当前执行到了那里

Guess you like

Origin blog.csdn.net/qq_43373608/article/details/108142621