tags:

views:

65

answers:

3

Hi !

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 !
Thanks !

+3  A: 

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

Mitch Wheat
+1  A: 

Practice makes perfect!

I would start writing some simple programs. Use whatever you're comfortable in. If you like Visual Studio, use Visual Studio. The concepts will be the same. Start setting breakpoints, looking at the watches, and see how values change throughout the run of the program.

Start making the programs more difficult and set goals for what you want to figure out with the debugger. You'll slowly become more proficient and figure out exactly how to step through your application, watch values, and examine the stack trace to figure out your bugs.

Justin Niessner
+1  A: 

I've discovered that gaining at least a rudimentary knowledge of assembly, as well as knowledge about how your system implements function calls, as well as use of the registers, helps a great deal. At the very least, being able to step through your program step by step and examine variables is a good start. For more complicated matters, sometimes it helps to look at the disassembly.

Tristan