GDB跟踪:没有当前跟踪帧

时间:2013-05-02 19:13:11

标签: gdb tracing

我正在尝试GDB跟踪点,但我无法获取任何数据。我启动gdbserver如下:

$ gdbserver :1234 ./a.out 
Process ./a.out created; pid = 13610
Listening on port 1234

然后我在客户端上使用以下命令:

$ gdb ./a.out
...
Reading symbols from /home/simark/src/test/a.out...done.
(gdb) target remote :1234
Remote debugging using :1234
Reading symbols from /lib64/ld-linux-x86-64.so.2...done.
Reading symbols from /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.15.so...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007ffff7ddb6c0 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) l
1   #include <stdio.h>
2   int foo(int a, int b) {
3       return a + b + b;
4   }
5   
6   int main() {
7       int n = foo(33, 4);
8       printf("%d\n", n);
9       return 0;
10  }
(gdb) trace 3
Tracepoint 1 at 0x400526: file test.c, line 3.
(gdb) b 9
Breakpoint 2 at 0x400563: file test.c, line 9.
(gdb) actions 1
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect $regs,$args
>end
(gdb) tstart
(gdb) c
Continuing.

Breakpoint 2, main () at test.c:9
9       return 0;
(gdb) tstop
(gdb) tdump
warning: No current trace frame.
(gdb)

根据我在网上看到的例子,我应该有一个事件,因为控制权通过了我的跟踪点。任何想法,为什么我没有数据?

1 个答案:

答案 0 :(得分:0)

  

根据我在网上看到的例子,我应该有一个事件,因为控制权越过了我的跟踪点。

在执行tfind start之前,您忘了tdump。来自help tdump

Print everything collected at the current tracepoint.

但是你没有在任何一个跟踪点停下来,你在第二个断点处停下来。

tfind start选择跟踪缓冲区中的第一个跟踪帧。