在C或C ++ code编程在Linux上GDB设置断点 [英] Set breakpoint in C or C++ code programmatically for gdb on Linux
本文介绍了在C或C ++ code编程在Linux上GDB设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置一个断点在C或C ++ code编程,将广发行工作在Linux?
的即:的
int main(int argc, char** argv)
{
/* set breakpoint here! */
int a = 3;
a++; /* In gdb> print a; expect result to be 3 */
return 0;
}
推荐答案
的一种方法是对信号的中断:
One way is to signal an interrupt:
#include <csignal>
// Generate an interrupt
std::raise(SIGINT);
在C:
#include <signal.h>
raise(SIGINT);
更新: MSDN国的那Windows不真正支持 SIGINT
,因此,如果便携性是一个问题,你可能最好使用 SIGABRT
。
UPDATE: MSDN states that Windows doesn't really support SIGINT
, so if portability is a concern, you're probably better off using SIGABRT
.
这篇关于在C或C ++ code编程在Linux上GDB设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文