如何在多线程程序上启用反向调试? [英] How do I enable reverse debugging on a multi-threaded program?

查看:233
本文介绍了如何在多线程程序上启用反向调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在多线程项目上使用gdb 7.3.1的反向调试功能(使用libevent),但是我得到以下错误:

 (gdb)反向步骤
目标多线程不支持此命令。

这个问题,我想也许这是一个加载libthread_db的问题,但是当我运行程序时,gdb说:



<$ p $
使用主机libthread_db库/lib/libthread_db.so.1。

如何在多线程项目中使用gdb 7.3.1启用反向调试?是否有可能?

解决方案

您需要通过执行命令来激活指令记录目标

 记录

(记住录音会显着减慢执行速度,特别是如果你有多个线程!)



我刚刚检查过它是正确工作:

 (gdb)信息线程
Id目标Id帧
2线程0x7ffff7860700(LWP 5503 )test2.c中的a.outhello(arg = 0x601030):16
* 1线程0x7ffff7fca700(LWP 5502)test2.c中的a.outmain(argc = 2,argv = 0x7fffffffe2e8) 47

...

 (gdb)next 
49 p [i] .id = i;
(gdb)reverse-next
47 for(i = 0; i


$

  17 printf(Hello from node%d \\\
,p-> ;ID);
(gdb)next
你好从节点1
18 return(NULL);
(gdb)reverse-next
17 printf(Hello from node%d \\\
,p-> id);


I'm trying to use the reverse debugging features of gdb 7.3.1 on a multi-threaded project (using libevent), but I get the following error:

(gdb) reverse-step
Target multi-thread does not support this command.

From this question, I thought perhaps that it was an issue loading libthread_db but, when I run the program, gdb says:

Starting program: /home/robb/slug/slug 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

How can I enable reverse debugging with gdb 7.3.1 on a multi-threaded project? Is it possible?

解决方案

You need to active the instruction-recording target, by executing the command

record

from the point where you want to go forwards and backwards (remember that the recording will significantly slow down the execution, especially if you have several threads!)

I've just checked that it's working correctly:

(gdb) info threads 
  Id   Target Id         Frame 
  2    Thread 0x7ffff7860700 (LWP 5503) "a.out" hello (arg=0x601030) at test2.c:16
* 1    Thread 0x7ffff7fca700 (LWP 5502) "a.out" main (argc=2, argv=0x7fffffffe2e8) at test2.c:47

...

(gdb) next
49          p[i].id=i;
(gdb) reverse-next
47      for (i=0; i<n; i++)

...

17      printf("Hello from node %d\n", p->id);
(gdb) next
Hello from node 1
18      return (NULL);
(gdb) reverse-next
17      printf("Hello from node %d\n", p->id);

这篇关于如何在多线程程序上启用反向调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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