如何转到GDB中的上一行? [英] How to go to the previous line in GDB?

查看:150
本文介绍了如何转到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获得gdb-7.0:/ pub / gnu / gdb

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

如果遇到错误:目标子级不支持此命令。然后尝试在开始 run 之后,在执行开始时添加目标记录

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 目标记录,因此请使用目标记录已满

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆