本文介绍了如何转到 GDB 中的上一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 gdb 中是否可以转到当前执行行之前的行.例如:

Is it possible in gdb to go to a line before the currently executing line.e.g:


void my_fun( somePtrType** arr,int start,int end)
{
 // arr is an array of pointers to somePtrType
  //line a
 ... some assignments
 swap(&arr[ind1] , &arr[ind2] ) ;
 //line b (current line )
}

我目前在 b 行,可以检查那里的 arr 值,但当时我想回到 a 行并检查 arr 的内容.

I am at line b currently and can examine the arr values there but I want to go back to line a and examine the contents of arr at that time.

我认为这可能是不可能的,因为调试器可以慢动作运行代码,但不能让它向后执行.
更多见解..

I think it might not be possible because a debugger can run a code in slow motion,but can't make it execute backwards.
Any more insights..

推荐答案

是的!使用新版本 7.0 gdb,您完全可以做到这一点!

Yes! With the new version 7.0 gdb, you can do exactly that!

命令将是reverse-step"或reverse-next".

您可以从 ftp.gnu.org:/pub/gnu/gdb 获取 gdb-7.0

You can get gdb-7.0 from ftp.gnu.org:/pub/gnu/gdb

如果遇到错误:Target child does not support this command. 则在开始执行runtarget record/代码>.

If you run into the error: Target child does not support this command. then try adding target record at the beginning of execution, after starting run.

由于 GDB 7.6 target record 已弃用,请改用 target record-full.

Since GDB 7.6 target record is deprecated, use target record-full instead.

这篇关于如何转到 GDB 中的上一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 03:08