How do I enable reverse debugging on a multi-threaded program?

折月煮酒 提交于 2019-11-29 20:48:53
Kevin

To do this, you need to activate the instruction-recording target, by executing the command

record

from the point where you want to go forward and backward (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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!