[英]How to use actions command in GDB tool?
Below is the code which i had used to understand actions command in gdb.下面是我用来理解 gdb 中的操作命令的代码。
#include <stdio.h>
int Use_Action(int CatchedInt, char * CatchedStr)
{
printf("CatchedInt = %d, CatchedStr = %s\n", CatchedInt, CatchedStr);
return 0;
}
int main(void)
{
int PassingInt = 20;
char PassingStr[10] = "Hello";
Use_Action(PassingInt, PassingStr);
}
In GDB Tool I have done the following things with the help of https://sourceware.org/gdb/current/onlinedocs/gdb/Tracepoint-Actions.html在 GDB 工具中,我在https://sourceware.org/gdb/current/onlinedocs/gdb/Tracepoint-Actions.html的帮助下完成了以下操作
(gdb) trace Use_Action
Tracepoint 1 at 0x1169: file action.c, line 5.
(gdb) info tracepoints
Num Type Disp Enb Address What
1 tracepoint keep y 0x0000000000001169 in Use_Action at action.c:5
not installed on target
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect CatchedInt
>end
(gdb) info tracepoints
Num Type Disp Enb Address What
1 tracepoint keep y 0x0000000000001169 in Use_Action at action.c:5
collect CatchedInt
not installed on target
If i had collect the value of "Catchedint" by command collect Catchedint, then how to display the value.如果我通过命令 collect Catchedint 收集了“Catchedint”的值,那么如何显示该值。 Is there something I missed?
有什么我错过了吗? or i understand this actions command in wrong way!!?
或者我以错误的方式理解这个动作命令!?
Is there something I missed?
有什么我错过了吗?
Yes: you need to actually run the program while collecting the trace, using tstart
, run
and tstop
commands.是啊,你需要实际运行的程序,同时收集跟踪,使用
tstart
, run
和tstop
命令。
If you tried that, you would likely get this error:如果您尝试过,您可能会收到此错误:
(gdb) tstart
You can't do that when your target is `exec'
That's because only some targets support tracepoints, and local execution doesn't.那是因为只有一些目标支持跟踪点,而本地执行不支持。 You'll need to use
gdbserver
instead.您需要改用
gdbserver
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.