Set breakpoint in C or C++ code programmatically for gdb on Linux

How can I set a breakpoint in C or C++ code programatically that will work for gdb on 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

In C:

#include <signal.h>

UPDATE: MSDN states that Windows doesn't really support SIGINT, so if portability is a concern, you're probably better off using SIGABRT.

Need Your Help

How can I apply my own theme to my Windows Forms application?

c# .net winforms

On executing a Windows Forms application in C# the view of the form looks the same as the theme of Windows.

Chrome firing onClick when space typed in contenteditable button

javascript html google-chrome

I have a button with contenteditable=true. I can edit the text just fine, but I cannot type spaces in Chrome. When I hit spacebar, Chrome instead fires an onClick event on the button. Safari, howev...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.