Search code examples
c++eclipsedebuggingeclipse-cdt

Very Strange behavior: My c++ program suddenly exit but it run flawlessly o the end in debug mode in Eclipse CDT


I have my own c++ program in Eclipse CDT in ubuntu 64-bit which use an external encoding detection library. As you might guess, I use gcc to compile my program and GDB for debug. Now the most strange behavior I have seen in my programming life: While I debug my program using "Debug As" in Eclipse, it works perfectly to the end but when I select "Run As" it will terminate in the middle of the program suddenly without showing any error or exception message in console!!!

Does someone have any idea about this strange problem?


Solution

  • Knowing how to debug is very important. If your debugger fails to do so, you can try commenting out certain lines of code until the program works. If that doesn't work, your program might be suffering from a heisenbug in which I would suggest you to print out variables in console while running to analyze them. You should also review your code. Sometimes it can be a really silly error.