Programming Interview : How to debug a program?
- by Jake
I was recently asked the following question in an interview :
How do you debug a C++ program ?
I started by explaining that programs may have syntax and semantic errors. Compiler reports the syntax errors which can be corrected. For semantic errors, various debuggers are available. I specifically talked about gdb, which is command line, and Visual Studio IDE's debugger, which has a GUI, and common commands. I also talked about debug and release version of code, how assertions should be used for debug build, how exceptions helps in automatic cleanup & putting the program in valid state, and how logging can be useful (e.g. using std::clog).
I want to know if this answer is complete or not. Also, I want to hear how other people will go about answering this question in a structured manner ?
Thanks.