Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to learn debugging?

Tags:

debugging

I am upper level CS major, and I have no idea how to do debugging. No where in my courses they are teaching/showing debugging, and all my course works goes like this - here is the project, write a program in C that does XYZ, and by the way use GDB debugger.

Currently, I am taking Assembly language course, and instructor requires use of GDB debugger, hell I don't even know how to do debugging in Visual Studio. And all the projects we are going to do very soon, will require us to "hack" executable using GDB.

Any advice on how to get started/learn debugging, would be highly appreciated.

like image 307
newprint Avatar asked Oct 20 '10 02:10

newprint


1 Answers

There is no substitue for just doing it:

  • Write a very simple program.

  • Open it in a debugger.

  • Run your program and step through each line.

  • Use the debugger's commands to inspect your variables and program state.

  • Write a more complicated program... Repeat...

If you have written projects on your course and not debugging at all, either you are writing loads of unit tests (that's a good thing), or your programs work first time.

The most important shortcuts for debugging in VS2010 (and 2008) are:

  • Start Debugging F5

  • Start without Debugging Ctrl + F5

  • Quit debugging Shift + F5

  • Step Into F11

  • Step Over F10

  • Step Out Shift + F11

  • Toggle Breakpoint F9

like image 147
Mitch Wheat Avatar answered Oct 17 '22 15:10

Mitch Wheat